diff --git a/packages/app/src/components/workspace-setting/general/General.tsx b/packages/app/src/components/workspace-setting/general/General.tsx index b3f5af88a1..0ced889c68 100644 --- a/packages/app/src/components/workspace-setting/general/General.tsx +++ b/packages/app/src/components/workspace-setting/general/General.tsx @@ -21,9 +21,8 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => { const [showLeave, setShowLeave] = useState(false); const [uploading, setUploading] = useState(false); const [workspaceName, setWorkspaceName] = useState(workspace.name); - const { currentWorkspace } = useAppState(); + const { currentWorkspace, isOwner } = useAppState(); const { updateWorkspace } = useWorkspaceHelper(); - const isOwner = true; const handleChangeWorkSpaceName = (newName: string) => { setWorkspaceName(newName); }; @@ -72,16 +71,19 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceUnit }) => { placeholder="Workspace Name" maxLength={14} minLength={1} + disabled={!isOwner} onChange={handleChangeWorkSpaceName} > - { - handleUpdateWorkspaceName(); - }} - style={{ marginLeft: '0px' }} - > - ✔️ - + {isOwner ? ( + { + handleUpdateWorkspaceName(); + }} + style={{ marginLeft: '0px' }} + > + ✔️ + + ) : null} Workspace Type diff --git a/packages/app/src/pages/new-workspace/index.tsx b/packages/app/src/pages/new-workspace/index.tsx deleted file mode 100644 index 1a1d9e1a44..0000000000 --- a/packages/app/src/pages/new-workspace/index.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { WorkspaceModal } from '@/components/workspace-modal'; -import { getWorkspaces } from '@/hooks/mock-data/mock'; -import { useEffect, useState } from 'react'; -import { styled } from '@/styles'; -import Button from '@/ui/button/Button'; - -const Page = () => { - const [open, setOpen] = useState(false); - - useEffect(() => { - const data = getWorkspaces(); - if (!data.length) { - setOpen(true); - } - }, []); - return ( - -

workspace

-
- -
- { - setOpen(false); - }} - > -
- ); -}; -export default Page; - -const Workspace = styled.div(({ theme }) => { - return { - height: '100vh', - background: theme.colors.pageBackground, - color: '#FFFFFF', - fontSize: '18px', - fontWeight: 500, - }; -}); diff --git a/packages/app/src/pages/workspace/[workspaceId]/setting.tsx b/packages/app/src/pages/workspace/[workspaceId]/setting.tsx index e8c40aacf2..e39a424166 100644 --- a/packages/app/src/pages/workspace/[workspaceId]/setting.tsx +++ b/packages/app/src/pages/workspace/[workspaceId]/setting.tsx @@ -60,7 +60,7 @@ const tabMap: { ]; const WorkspaceSetting = () => { - const { currentWorkspace } = useAppState(); + const { currentWorkspace, isOwner } = useAppState(); const [activeTab, setActiveTab] = useState(tabMap[0].name); const handleTabChange = (tab: TabNames) => { @@ -70,7 +70,20 @@ const WorkspaceSetting = () => { const activeTabPanelRender = tabMap.find( tab => tab.name === activeTab )?.panelRender; - + let tableArr: { + name: TabNames; + icon: ReactNode; + panelRender: (workspace: WorkspaceUnit) => ReactNode; + }[] = tabMap; + if (!isOwner) { + tableArr = [ + { + name: 'general', + icon: , + panelRender: workspace => , + }, + ]; + } return ( @@ -78,7 +91,7 @@ const WorkspaceSetting = () => { Workspace Settings - {tabMap.map(({ icon, name }) => { + {tableArr.map(({ icon, name }) => { return ( (); loadWorkspace.current = async (workspaceId: string) => { - const { dataCenter, workspaceList, currentWorkspace } = appState; + const { dataCenter, workspaceList, currentWorkspace, user } = appState; if (!workspaceList.find(v => v.id.toString() === workspaceId)) { return null; } @@ -99,6 +100,13 @@ export const AppStateProvider = ({ return currentWorkspace; } const workspace = (await dataCenter.loadWorkspace(workspaceId)) ?? null; + let isOwner; + if (workspace.provider === 'local') { + // isOwner is useful only in the cloud + isOwner = true; + } else { + isOwner = workspace?.owner && user?.id === workspace?.owner?.id; + } const pageList = (workspace?.blocksuiteWorkspace?.meta.pageMetas as PageMeta[]) ?? []; setAppState({ @@ -107,6 +115,7 @@ export const AppStateProvider = ({ pageList: pageList, currentPage: null, editor: null, + isOwner, }); return workspace; diff --git a/packages/app/src/providers/app-state-provider/interface.ts b/packages/app/src/providers/app-state-provider/interface.ts index 6cb5f5551c..c76b2993ce 100644 --- a/packages/app/src/providers/app-state-provider/interface.ts +++ b/packages/app/src/providers/app-state-provider/interface.ts @@ -23,6 +23,7 @@ export type AppStateValue = { currentPage: StorePage | null; editor?: EditorContainer | null; synced: boolean; + isOwner?: boolean; }; export type AppStateFunction = {