refactor(core): move setting dialog to workspace scope (#9706)

This commit is contained in:
pengx17
2025-01-15 13:00:06 +00:00
parent 9df338274d
commit b1896746f9
32 changed files with 248 additions and 277 deletions
@@ -26,7 +26,6 @@ export type GLOBAL_DIALOG_SCHEMA = {
templateMode: DocMode;
snapshotUrl: string;
}) => void;
setting: (props: { activeTab?: SettingTab; scrollAnchor?: string }) => void;
'sign-in': (props: { server?: string; step?: string }) => void;
'change-password': (props: { server?: string }) => void;
'verify-email': (props: { server?: string; changeEmail?: boolean }) => void;
@@ -38,6 +37,7 @@ export type GLOBAL_DIALOG_SCHEMA = {
};
export type WORKSPACE_DIALOG_SCHEMA = {
setting: (props: { activeTab?: SettingTab; scrollAnchor?: string }) => void;
'doc-info': (props: { docId: string }) => void;
'doc-selector': (props: {
init: string[];
@@ -1,4 +1,5 @@
import { Button } from '@affine/component/ui/button';
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
import { appIconMap, appNames } from '@affine/core/utils/channel';
import { Trans, useI18n } from '@affine/i18n';
import { LocalWorkspaceIcon, Logo1Icon } from '@blocksuite/icons/rc';
@@ -6,7 +7,6 @@ import { useService } from '@toeverything/infra';
import type { MouseEvent } from 'react';
import { useCallback } from 'react';
import { GlobalDialogService } from '../../dialogs';
import { getOpenUrlInDesktopAppLink } from '../utils';
import * as styles from './open-in-app-page.css';
@@ -28,7 +28,7 @@ export const OpenInAppPage = ({
}: OpenAppProps) => {
// default to open the current page in desktop app
urlToOpen ??= getOpenUrlInDesktopAppLink(window.location.href, true);
const globalDialogService = useService(GlobalDialogService);
const workspaceDialogService = useService(WorkspaceDialogService);
const t = useI18n();
const openDownloadLink = useCallback(() => {
@@ -41,11 +41,11 @@ export const OpenInAppPage = ({
const goToAppearanceSetting = useCallback(
(e: MouseEvent) => {
openHereClicked?.(e);
globalDialogService.open('setting', {
workspaceDialogService.open('setting', {
activeTab: 'appearance',
});
},
[globalDialogService, openHereClicked]
[workspaceDialogService, openHereClicked]
);
if (urlToOpen && lastOpened !== urlToOpen) {
@@ -1,5 +1,5 @@
import { useConfirmModal } from '@affine/component';
import { GlobalDialogService } from '@affine/core/modules/dialogs';
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
import { type I18nString, useI18n } from '@affine/i18n';
import { InformationFillDuotoneIcon } from '@blocksuite/icons/rc';
import { useLiveData, useService } from '@toeverything/infra';
@@ -36,18 +36,18 @@ export const QuotaCheck = ({
const profile = useLiveData(workspaceProfile.profile$);
const isOwner = profile?.isOwner;
const isTeam = profile?.isTeam;
const globalDialogService = useService(GlobalDialogService);
const workspaceDialogService = useService(WorkspaceDialogService);
const t = useI18n();
const onConfirm = useCallback(() => {
if (!isOwner) {
return;
}
globalDialogService.open('setting', {
workspaceDialogService.open('setting', {
activeTab: 'plans',
scrollAnchor: 'cloudPricingPlan',
});
}, [globalDialogService, isOwner]);
}, [workspaceDialogService, isOwner]);
useEffect(() => {
workspaceQuota?.revalidate();