mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
Merge branch 'feat/datacenter' of https://github.com/toeverything/AFFiNE into feat/datacenter
This commit is contained in:
@@ -22,17 +22,14 @@ const isMac = () => {
|
|||||||
return getUaHelper().isMacOs;
|
return getUaHelper().isMacOs;
|
||||||
};
|
};
|
||||||
export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
||||||
const { currentWorkspaceId, workspaceList } = useAppState();
|
const { currentMetaWorkSpace } = useAppState();
|
||||||
|
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState('');
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [showCreatePage, setShowCreatePage] = useState(true);
|
const [showCreatePage, setShowCreatePage] = useState(true);
|
||||||
const { triggerQuickSearchModal } = useModal();
|
const { triggerQuickSearchModal } = useModal();
|
||||||
|
|
||||||
const currentWorkspace = workspaceList.find(
|
const isPublish = currentMetaWorkSpace?.isPublish;
|
||||||
meta => String(meta.id) === String(currentWorkspaceId)
|
|
||||||
);
|
|
||||||
const isPublish = currentWorkspace?.isPublish;
|
|
||||||
|
|
||||||
// Add ‘⌘+K’ shortcut keys as switches
|
// Add ‘⌘+K’ shortcut keys as switches
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
PublishIcon,
|
PublishIcon,
|
||||||
CloudInsyncIcon,
|
CloudInsyncIcon,
|
||||||
} from '@blocksuite/icons';
|
} from '@blocksuite/icons';
|
||||||
import { ReactElement, useEffect, useState } from 'react';
|
import { ReactElement, ReactNode, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
GeneralPage,
|
GeneralPage,
|
||||||
MembersPage,
|
MembersPage,
|
||||||
@@ -23,132 +23,82 @@ import {
|
|||||||
} from '@/components/workspace-setting';
|
} from '@/components/workspace-setting';
|
||||||
import { useAppState } from '@/providers/app-state-provider';
|
import { useAppState } from '@/providers/app-state-provider';
|
||||||
import WorkspaceLayout from '@/components/workspace-layout';
|
import WorkspaceLayout from '@/components/workspace-layout';
|
||||||
|
import { WorkspaceInfo } from '@affine/datacenter';
|
||||||
|
|
||||||
enum ActiveTab {
|
type TabNames = 'general' | 'members' | 'publish' | 'sync' | 'export';
|
||||||
'general' = 'general',
|
|
||||||
'members' = 'members',
|
|
||||||
'publish' = 'publish',
|
|
||||||
'sync' = 'sync',
|
|
||||||
'export' = 'export',
|
|
||||||
}
|
|
||||||
|
|
||||||
type SettingTabProps = {
|
const tabMap: {
|
||||||
activeTab: ActiveTab;
|
name: TabNames;
|
||||||
onTabChange?: (tab: ActiveTab) => void;
|
icon: ReactNode;
|
||||||
};
|
panelRender: (workspace: WorkspaceInfo) => ReactNode;
|
||||||
|
}[] = [
|
||||||
|
{
|
||||||
|
name: 'general',
|
||||||
|
icon: <EditIcon />,
|
||||||
|
panelRender: workspace => <GeneralPage workspace={workspace} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'members',
|
||||||
|
icon: <CloudInsyncIcon />,
|
||||||
|
panelRender: workspace => <MembersPage workspace={workspace} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'publish',
|
||||||
|
icon: <UsersIcon />,
|
||||||
|
panelRender: workspace => <PublishPage workspace={workspace} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'sync',
|
||||||
|
icon: <PublishIcon />,
|
||||||
|
panelRender: workspace => <SyncPage workspace={workspace} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'export',
|
||||||
|
icon: <PublishIcon />,
|
||||||
|
panelRender: workspace => <ExportPage workspace={workspace} />,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
type WorkspaceSettingProps = {
|
const WorkspaceSetting = () => {
|
||||||
isShow: boolean;
|
const { currentMetaWorkSpace } = useAppState();
|
||||||
onClose?: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
const WorkspaceSettingTab = ({ activeTab, onTabChange }: SettingTabProps) => {
|
const [activeTab, setActiveTab] = useState<TabNames>(tabMap[0].name);
|
||||||
return (
|
const handleTabChange = (tab: TabNames) => {
|
||||||
<StyledSettingTabContainer>
|
|
||||||
<WorkspaceSettingTagItem
|
|
||||||
isActive={activeTab === ActiveTab.general}
|
|
||||||
onClick={() => {
|
|
||||||
onTabChange && onTabChange(ActiveTab.general);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<StyledSettingTagIconContainer>
|
|
||||||
<EditIcon />
|
|
||||||
</StyledSettingTagIconContainer>
|
|
||||||
General
|
|
||||||
</WorkspaceSettingTagItem>
|
|
||||||
|
|
||||||
<WorkspaceSettingTagItem
|
|
||||||
isActive={activeTab === ActiveTab.sync}
|
|
||||||
onClick={() => {
|
|
||||||
onTabChange && onTabChange(ActiveTab.sync);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<StyledSettingTagIconContainer>
|
|
||||||
<CloudInsyncIcon />
|
|
||||||
</StyledSettingTagIconContainer>
|
|
||||||
Sync
|
|
||||||
</WorkspaceSettingTagItem>
|
|
||||||
|
|
||||||
<WorkspaceSettingTagItem
|
|
||||||
isActive={activeTab === ActiveTab.members}
|
|
||||||
onClick={() => {
|
|
||||||
onTabChange && onTabChange(ActiveTab.members);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<StyledSettingTagIconContainer>
|
|
||||||
<UsersIcon />
|
|
||||||
</StyledSettingTagIconContainer>
|
|
||||||
Collaboration
|
|
||||||
</WorkspaceSettingTagItem>
|
|
||||||
<WorkspaceSettingTagItem
|
|
||||||
isActive={activeTab === ActiveTab.publish}
|
|
||||||
onClick={() => {
|
|
||||||
onTabChange && onTabChange(ActiveTab.publish);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<StyledSettingTagIconContainer>
|
|
||||||
<PublishIcon />
|
|
||||||
</StyledSettingTagIconContainer>
|
|
||||||
Publish
|
|
||||||
</WorkspaceSettingTagItem>
|
|
||||||
|
|
||||||
<WorkspaceSettingTagItem
|
|
||||||
isActive={activeTab === ActiveTab.export}
|
|
||||||
onClick={() => {
|
|
||||||
onTabChange && onTabChange(ActiveTab.export);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<StyledSettingTagIconContainer>
|
|
||||||
<PublishIcon />
|
|
||||||
</StyledSettingTagIconContainer>
|
|
||||||
Export
|
|
||||||
</WorkspaceSettingTagItem>
|
|
||||||
</StyledSettingTabContainer>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const WorkspaceSetting = ({ isShow, onClose }: WorkspaceSettingProps) => {
|
|
||||||
// const { workspaces } = useAppState();
|
|
||||||
const [activeTab, setActiveTab] = useState<ActiveTab>(ActiveTab.general);
|
|
||||||
const handleTabChange = (tab: ActiveTab) => {
|
|
||||||
setActiveTab(tab);
|
setActiveTab(tab);
|
||||||
};
|
};
|
||||||
|
|
||||||
const { currentMetaWorkSpace } = useAppState();
|
const activeTabPanelRender = tabMap.find(
|
||||||
useEffect(() => {
|
tab => tab.name === activeTab
|
||||||
// reset tab when modal is closed
|
)?.panelRender;
|
||||||
if (!isShow) {
|
|
||||||
setActiveTab(ActiveTab.general);
|
|
||||||
}
|
|
||||||
}, [isShow]);
|
|
||||||
return (
|
return (
|
||||||
<StyledSettingContainer>
|
<StyledSettingContainer>
|
||||||
<StyledSettingSidebar>
|
<StyledSettingSidebar>
|
||||||
<StyledSettingSidebarHeader>
|
<StyledSettingSidebarHeader>
|
||||||
Workspace Settings
|
Workspace Settings
|
||||||
</StyledSettingSidebarHeader>
|
</StyledSettingSidebarHeader>
|
||||||
<WorkspaceSettingTab
|
<StyledSettingTabContainer>
|
||||||
activeTab={activeTab}
|
{tabMap.map(({ icon, name }) => {
|
||||||
onTabChange={handleTabChange}
|
return (
|
||||||
/>
|
<WorkspaceSettingTagItem
|
||||||
|
key={name}
|
||||||
|
isActive={activeTab === name}
|
||||||
|
onClick={() => {
|
||||||
|
handleTabChange(name);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<StyledSettingTagIconContainer>
|
||||||
|
{icon}
|
||||||
|
</StyledSettingTagIconContainer>
|
||||||
|
{name}
|
||||||
|
</WorkspaceSettingTagItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</StyledSettingTabContainer>
|
||||||
</StyledSettingSidebar>
|
</StyledSettingSidebar>
|
||||||
|
|
||||||
<StyledSettingContent>
|
<StyledSettingContent>
|
||||||
{activeTab === ActiveTab.general && currentMetaWorkSpace && (
|
{currentMetaWorkSpace && activeTabPanelRender?.(currentMetaWorkSpace)}
|
||||||
<GeneralPage workspace={currentMetaWorkSpace} />
|
|
||||||
)}
|
|
||||||
{activeTab === ActiveTab.sync && currentMetaWorkSpace && (
|
|
||||||
<SyncPage workspace={currentMetaWorkSpace} />
|
|
||||||
)}
|
|
||||||
{activeTab === ActiveTab.members && currentMetaWorkSpace && (
|
|
||||||
<MembersPage workspace={currentMetaWorkSpace} />
|
|
||||||
)}
|
|
||||||
{activeTab === ActiveTab.publish && currentMetaWorkSpace && (
|
|
||||||
<PublishPage workspace={currentMetaWorkSpace} />
|
|
||||||
)}
|
|
||||||
{activeTab === ActiveTab.export && currentMetaWorkSpace && (
|
|
||||||
<ExportPage workspace={currentMetaWorkSpace} />
|
|
||||||
)}
|
|
||||||
</StyledSettingContent>
|
</StyledSettingContent>
|
||||||
</StyledSettingContainer>
|
</StyledSettingContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
import type { PropsWithChildren } from 'react';
|
import type { PropsWithChildren } from 'react';
|
||||||
import ShortcutsModal from '@/components/shortcuts-modal';
|
import ShortcutsModal from '@/components/shortcuts-modal';
|
||||||
import ContactModal from '@/components/contact-modal';
|
import ContactModal from '@/components/contact-modal';
|
||||||
// import QuickSearch from '@/components/quick-search';
|
import QuickSearch from '@/components/quick-search';
|
||||||
import { ImportModal } from '@/components/import';
|
import { ImportModal } from '@/components/import';
|
||||||
import { LoginModal } from '@/components/login-modal';
|
import { LoginModal } from '@/components/login-modal';
|
||||||
|
|
||||||
@@ -97,12 +97,12 @@ export const ModalProvider = ({
|
|||||||
triggerHandler('shortcuts', false);
|
triggerHandler('shortcuts', false);
|
||||||
}}
|
}}
|
||||||
></ShortcutsModal>
|
></ShortcutsModal>
|
||||||
{/*<QuickSearch*/}
|
<QuickSearch
|
||||||
{/* open={modalMap.quickSearch}*/}
|
open={modalMap.quickSearch}
|
||||||
{/* onClose={() => {*/}
|
onClose={() => {
|
||||||
{/* triggerHandler('quickSearch', false);*/}
|
triggerHandler('quickSearch', false);
|
||||||
{/* }}*/}
|
}}
|
||||||
{/*></QuickSearch>*/}
|
></QuickSearch>
|
||||||
<ImportModal
|
<ImportModal
|
||||||
open={modalMap.import}
|
open={modalMap.import}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user