feat(core): show server name when delete account (#13175)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Account deletion prompts and confirmation dialogs now display the
specific server name, providing clearer context when deleting your
account.

* **Localization**
* Updated account deletion messages to explicitly mention the server
name.
* Improved translation keys to support server-specific messaging in all
supported languages.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
EYHN
2025-07-11 20:38:05 +08:00
committed by GitHub
parent 847ef00a75
commit 33f6496d79
3 changed files with 39 additions and 16 deletions
@@ -3,7 +3,7 @@ import {
SettingRow, SettingRow,
SettingWrapper, SettingWrapper,
} from '@affine/component/setting-components'; } from '@affine/component/setting-components';
import { AuthService } from '@affine/core/modules/cloud'; import { AuthService, ServerService } from '@affine/core/modules/cloud';
import { WorkspacesService } from '@affine/core/modules/workspace'; import { WorkspacesService } from '@affine/core/modules/workspace';
import { UserFriendlyError } from '@affine/error'; import { UserFriendlyError } from '@affine/error';
import { Trans, useI18n } from '@affine/i18n'; import { Trans, useI18n } from '@affine/i18n';
@@ -18,6 +18,7 @@ import * as styles from './style.css';
export const DeleteAccount = () => { export const DeleteAccount = () => {
const t = useI18n(); const t = useI18n();
const serverService = useService(ServerService);
const workspacesService = useService(WorkspacesService); const workspacesService = useService(WorkspacesService);
const workspaceProfiles = workspacesService.getAllWorkspaceProfile(); const workspaceProfiles = workspacesService.getAllWorkspaceProfile();
const isTeamWorkspaceOwner = workspaceProfiles.some( const isTeamWorkspaceOwner = workspaceProfiles.some(
@@ -33,7 +34,9 @@ export const DeleteAccount = () => {
<SettingRow <SettingRow
name={ name={
<span style={{ color: cssVarV2('status/error') }}> <span style={{ color: cssVarV2('status/error') }}>
{t['com.affine.setting.account.delete']()} {t['com.affine.setting.account.delete-from-server']({
server: serverService.server.config$.value.serverName,
})}
</span> </span>
} }
desc={t['com.affine.setting.account.delete.message']()} desc={t['com.affine.setting.account.delete.message']()}
@@ -96,6 +99,7 @@ const DeleteAccountModal = ({
const authService = useService(AuthService); const authService = useService(AuthService);
const session = authService.session; const session = authService.session;
const account = useLiveData(session.account$); const account = useLiveData(session.account$);
const serverService = useService(ServerService);
const [email, setEmail] = useState(''); const [email, setEmail] = useState('');
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
@@ -128,9 +132,22 @@ const DeleteAccountModal = ({
onConfirm={onDeleteAccountConfirm} onConfirm={onDeleteAccountConfirm}
onOpenChange={onOpenChange} onOpenChange={onOpenChange}
title={t['com.affine.setting.account.delete.confirm-title']()} title={t['com.affine.setting.account.delete.confirm-title']()}
description={t[ description={
'com.affine.setting.account.delete.confirm-description-1' <Trans
]()} i18nKey={
'com.affine.setting.account.delete.confirm-delete-description-1'
}
components={{
1: <strong />,
}}
values={{
server:
serverService.server.id !== 'affine-cloud'
? `${serverService.server.config$.value.serverName} (${serverService.server.baseUrl})`
: serverService.server.config$.value.serverName,
}}
/>
}
confirmText={t['com.affine.setting.account.delete.confirm-button']()} confirmText={t['com.affine.setting.account.delete.confirm-button']()}
confirmButtonOptions={{ confirmButtonOptions={{
variant: 'error', variant: 'error',
@@ -140,7 +157,7 @@ const DeleteAccountModal = ({
childrenContentClassName={styles.confirmContent} childrenContentClassName={styles.confirmContent}
> >
<Trans <Trans
i18nKey="com.affine.setting.account.delete.confirm-description-2" i18nKey="com.affine.setting.account.delete.confirm-delete-description-2"
components={{ components={{
1: <strong />, 1: <strong />,
}} }}
+13 -7
View File
@@ -4838,9 +4838,11 @@ export function useAFFiNEI18N(): {
*/ */
["com.affine.setting.account"](): string; ["com.affine.setting.account"](): string;
/** /**
* `Delete your account` * `Delete your account from {{server}}`
*/ */
["com.affine.setting.account.delete"](): string; ["com.affine.setting.account.delete-from-server"](options: {
readonly server: string;
}): string;
/** /**
* `Once deleted, your account will no longer be accessible, and all data in your personal cloud space will be permanently deleted.` * `Once deleted, your account will no longer be accessible, and all data in your personal cloud space will be permanently deleted.`
*/ */
@@ -4857,10 +4859,6 @@ export function useAFFiNEI18N(): {
* `Delete your account?` * `Delete your account?`
*/ */
["com.affine.setting.account.delete.confirm-title"](): string; ["com.affine.setting.account.delete.confirm-title"](): string;
/**
* `Are you sure you want to delete your account?`
*/
["com.affine.setting.account.delete.confirm-description-1"](): string;
/** /**
* `Please type your email to confirm` * `Please type your email to confirm`
*/ */
@@ -9291,10 +9289,18 @@ export const TypedTrans: {
}, { }, {
["1"]: JSX.Element; ["1"]: JSX.Element;
}>>; }>>;
/**
* `Are you sure you want to delete your account from <1>{{server}}</1>?`
*/
["com.affine.setting.account.delete.confirm-delete-description-1"]: ComponentType<TypedTransProps<{
readonly server: string;
}, {
["1"]: JSX.Element;
}>>;
/** /**
* `Your account will be inaccessible, and your personal cloud space will be permanently deleted. You can remove local data by uninstalling the app or clearing your browser storage. <1>This action is irreversible.</1>` * `Your account will be inaccessible, and your personal cloud space will be permanently deleted. You can remove local data by uninstalling the app or clearing your browser storage. <1>This action is irreversible.</1>`
*/ */
["com.affine.setting.account.delete.confirm-description-2"]: ComponentType<TypedTransProps<Readonly<{}>, { ["com.affine.setting.account.delete.confirm-delete-description-2"]: ComponentType<TypedTransProps<Readonly<{}>, {
["1"]: JSX.Element; ["1"]: JSX.Element;
}>>; }>>;
/** /**
+3 -3
View File
@@ -1202,13 +1202,13 @@
"com.affine.setting.notifications.email.comments.title": "Comments", "com.affine.setting.notifications.email.comments.title": "Comments",
"com.affine.setting.notifications.email.comments.subtitle": "You will be notified through email when other members of the workspace comment on your docs.", "com.affine.setting.notifications.email.comments.subtitle": "You will be notified through email when other members of the workspace comment on your docs.",
"com.affine.setting.account": "Account settings", "com.affine.setting.account": "Account settings",
"com.affine.setting.account.delete": "Delete your account", "com.affine.setting.account.delete-from-server": "Delete your account from {{server}}",
"com.affine.setting.account.delete.message": "Once deleted, your account will no longer be accessible, and all data in your personal cloud space will be permanently deleted.", "com.affine.setting.account.delete.message": "Once deleted, your account will no longer be accessible, and all data in your personal cloud space will be permanently deleted.",
"com.affine.setting.account.delete.team-warning-title": "Cannot delete account", "com.affine.setting.account.delete.team-warning-title": "Cannot delete account",
"com.affine.setting.account.delete.team-warning-description": "Youre the owner of a team workspace. To delete your account, please delete the workspace or transfer ownership first.", "com.affine.setting.account.delete.team-warning-description": "Youre the owner of a team workspace. To delete your account, please delete the workspace or transfer ownership first.",
"com.affine.setting.account.delete.confirm-title": "Delete your account?", "com.affine.setting.account.delete.confirm-title": "Delete your account?",
"com.affine.setting.account.delete.confirm-description-1": "Are you sure you want to delete your account?", "com.affine.setting.account.delete.confirm-delete-description-1": "Are you sure you want to delete your account from <1>{{server}}</1>?",
"com.affine.setting.account.delete.confirm-description-2": "Your account will be inaccessible, and your personal cloud space will be permanently deleted. You can remove local data by uninstalling the app or clearing your browser storage. <1>This action is irreversible.</1>", "com.affine.setting.account.delete.confirm-delete-description-2": "Your account will be inaccessible, and your personal cloud space will be permanently deleted. You can remove local data by uninstalling the app or clearing your browser storage. <1>This action is irreversible.</1>",
"com.affine.setting.account.delete.input-placeholder": "Please type your email to confirm", "com.affine.setting.account.delete.input-placeholder": "Please type your email to confirm",
"com.affine.setting.account.delete.confirm-button": "Delete", "com.affine.setting.account.delete.confirm-button": "Delete",
"com.affine.setting.account.delete.success-title": "Account deleted", "com.affine.setting.account.delete.success-title": "Account deleted",