Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add enable cloud failed notify #6741

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/frontend/component/src/ui/modal/confirm-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export const ConfirmModalProvider = ({ children }: PropsWithChildren) => {
return Promise.resolve(_onConfirm?.())
.then(() => onSuccess?.())
.catch(console.error)
.finally(() => setLoading(false))
.finally(() => autoClose && closeConfirmModal());
};
setModalProps({ ...otherProps, onConfirm, open: true });
Expand Down
23 changes: 16 additions & 7 deletions packages/frontend/core/src/hooks/affine/use-enable-cloud.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useConfirmModal } from '@affine/component';
import { notify, useConfirmModal } from '@affine/component';
import { authAtom } from '@affine/core/atoms';
import { AuthService } from '@affine/core/modules/cloud';
import { WorkspaceSubPath } from '@affine/core/shared';
Expand Down Expand Up @@ -37,12 +37,19 @@ export const useEnableCloud = () => {

const enableCloud = useCallback(
async (ws: Workspace | null, options?: ConfirmEnableCloudOptions) => {
if (!ws) return;
const { id: newId } = await workspacesService.transformLocalToCloud(ws);
openPage(newId, options?.openPageId || WorkspaceSubPath.ALL);
options?.onSuccess?.();
try {
if (!ws) return;
const { id: newId } = await workspacesService.transformLocalToCloud(ws);
openPage(newId, options?.openPageId || WorkspaceSubPath.ALL);
options?.onSuccess?.();
} catch (e) {
console.error(e);
notify.error({
title: t['com.affine.workspace.enable-cloud.failed'](),
});
}
},
[openPage, workspacesService]
[openPage, t, workspacesService]
);

const openSignIn = useCallback(() => {
Expand Down Expand Up @@ -95,7 +102,9 @@ export const useEnableCloud = () => {
if (!open) onFinished?.();
},
},
{ autoClose: false }
{
autoClose: false,
}
);
},
[closeConfirmModal, loginStatus, openConfirmModal, signInOrEnableCloud, t]
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/i18n/src/resources/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{

Check warning on line 1 in packages/frontend/i18n/src/resources/en.json

View workflow job for this annotation

GitHub Actions / main

Inconsistent keys

com.affine.payment.ai.usage.change-button-label, com.affine.payment.ai.usage.purchase-button-label, com.affine.payment.billing-setting.ai.free-desc, com.affine.storage.change-plan, com.affine.ai-onboarding.general.skip, com.affine.ai-onboarding.general.try-for-free

Check notice on line 1 in packages/frontend/i18n/src/resources/en.json

View workflow job for this annotation

GitHub Actions / main

New keys

Get in touch! Join our communities., It takes up little space on your device., It takes up more space on your device., com.affine.auth.open.affine.download-app, com.affine.auth.open.affine.prompt, com.affine.auth.open.affine.try-again, com.affine.auth.reset.password.message, com.affine.auth.reset.password.page.success, com.affine.auth.sent.change.email.hint, com.affine.auth.sent.reset.password.success.message, com.affine.auth.sent.set.password.hint, com.affine.auth.sent.set.password.success.message, com.affine.auth.set.password.save, com.affine.auth.sign.up.sent.email.subtitle, com.affine.auth.sign.up.success.title, com.affine.editCollection.rules.tips.highlight, com.affine.page-properties.add-property.menu.create, com.affine.page-properties.add-property.menu.header, com.affine.pageMode.all, com.affine.pageMode.edgeless, com.affine.pageMode.page, com.affine.setting.account.delete.message, com.affine.settings.appearance.border-style-description, com.affine.settings.appearance.start-week-description, com.affine.settings.email.action, com.affine.settings.password.action.change, com.affine.settings.password.action.set, com.affine.settings.password.message, com.affine.settings.profile.message, com.affine.settings.profile.placeholder, com.affine.settings.workspace.experimental-features, com.affine.settings.workspace.experimental-features.get-started, com.affine.settings.workspace.experimental-features.header.plugins, com.affine.settings.workspace.experimental-features.prompt-disclaimer, com.affine.settings.workspace.experimental-features.prompt-header, com.affine.settings.workspace.experimental-features.prompt-warning, com.affine.settings.workspace.experimental-features.prompt-warning-title, com.affine.settings.workspace.preferences, com.affine.settings.workspace.properties, com.affine.settings.workspace.properties.add_property, com.affine.settings.workspace.properties.all, com.affine.settings.workspace.properties.delete-property, com.affine.settings.workspace.properties.doc, com.affine.settings.workspace.properties.doc_others, com.affine.settings.workspace.properties.edit-property, com.affine.settings.workspace.properties.header.subtitle, com.affine.settings.workspace.properties.header.title, com.affine.settings.workspace.properties.in-use, com.affine.settings.workspace.properties.set-as-required, com.affine.settings.workspace.properties.unused, com.affine.settings.workspace.storage.tip, com.affine.storage.maximum-tips.pro, com.affine.workspace.cloud.description, com.affine.workspace.enable-cloud.failed
"404 - Page Not Found": "404 - Page Not Found",
"404.back": "Back to My Content",
"404.hint": "Sorry, you do not have access or this content does not exist...",
Expand Down Expand Up @@ -1312,5 +1312,6 @@
"com.affine.ai.login-required.dialog-content": "To use AFFiNE AI, please sign in to your AFFiNE Cloud account.",
"com.affine.ai.login-required.dialog-confirm": "Sign in",
"com.affine.ai.login-required.dialog-cancel": "Cancel",
"com.affine.ai.action.edgeless-only.dialog-title": "Please switch to edgeless mode"
"com.affine.ai.action.edgeless-only.dialog-title": "Please switch to edgeless mode",
"com.affine.workspace.enable-cloud.failed": "Failed to enable Cloud, please try again."
}