From 86faaadbe8df5e3a0fed019b13dce1497e67603f Mon Sep 17 00:00:00 2001 From: xiaodong zuo Date: Tue, 2 Aug 2022 11:17:59 +0800 Subject: [PATCH 1/2] fixbug There is a bug in the rename workspace name function in doc mode #15 --- .../src/pages/workspace/docs/workspace-name.tsx | 10 ++++++++-- .../db-service/src/services/workspace/user-config.ts | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/ligo-virgo/src/pages/workspace/docs/workspace-name.tsx b/apps/ligo-virgo/src/pages/workspace/docs/workspace-name.tsx index 6b353cf43d..24d69b659a 100644 --- a/apps/ligo-virgo/src/pages/workspace/docs/workspace-name.tsx +++ b/apps/ligo-virgo/src/pages/workspace/docs/workspace-name.tsx @@ -9,7 +9,7 @@ import { useUserAndSpaces, useShowSpaceSidebar, } from '@toeverything/datasource/state'; -import { useCallback, useEffect, useState } from 'react'; +import { useCallback, useEffect, useRef, useState } from 'react'; import { services } from '@toeverything/datasource/db-service'; const WorkspaceContainer = styled('div')({ @@ -78,6 +78,7 @@ export const WorkspaceName = () => { const { fixedDisplay, toggleSpaceSidebar } = useShowSpaceSidebar(); const [inRename, setInRename] = useState(false); const [workspaceName, setWorkspaceName] = useState(''); + const [workspaceId, setWorkspaceId] = useState(''); const fetchWorkspaceName = useCallback(async () => { if (!currentSpaceId) { @@ -88,6 +89,11 @@ export const WorkspaceName = () => { currentSpaceId ); setWorkspaceName(name); + + const workspaceId = await services.api.userConfig.getWorkspaceId( + currentSpaceId + ); + setWorkspaceId(workspaceId); }, [currentSpaceId]); useEffect(() => { @@ -150,7 +156,7 @@ export const WorkspaceName = () => { ) : ( setInRename(true)}> - {workspaceName} + {workspaceName || workspaceId} )} diff --git a/libs/datasource/db-service/src/services/workspace/user-config.ts b/libs/datasource/db-service/src/services/workspace/user-config.ts index 0977ee9092..0a5dca7eef 100644 --- a/libs/datasource/db-service/src/services/workspace/user-config.ts +++ b/libs/datasource/db-service/src/services/workspace/user-config.ts @@ -112,11 +112,15 @@ export class UserConfig extends ServiceBaseClass { async getWorkspaceName(workspace: string): Promise { const workspace_db_block = await this.getWorkspaceDbBlock(workspace); const workspaceName = - workspace_db_block.getDecoration(WORKSPACE_CONFIG) || - workspace_db_block.id; + workspace_db_block.getDecoration(WORKSPACE_CONFIG) || ''; return workspaceName; } + async getWorkspaceId(workspace: string): Promise { + const workspace_db_block = await this.getWorkspaceDbBlock(workspace); + return workspace_db_block.id; + } + async setWorkspaceName(workspace: string, workspaceName: string) { const workspace_db_block = await this.getWorkspaceDbBlock(workspace); workspace_db_block.setDecoration(WORKSPACE_CONFIG, workspaceName); From d4be73b78bfcefcda3425d15311ac30a01ac9da6 Mon Sep 17 00:00:00 2001 From: xiaodong zuo Date: Tue, 2 Aug 2022 11:20:51 +0800 Subject: [PATCH 2/2] fixbug When opening multiple left sidebar "three-dot" menus in doc mode, the menu boxes will block each other. #16 --- .../page-tree/tree-item/MoreActions.tsx | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/libs/components/layout/src/workspace-sidebar/page-tree/tree-item/MoreActions.tsx b/libs/components/layout/src/workspace-sidebar/page-tree/tree-item/MoreActions.tsx index d2e00bc471..536026052e 100644 --- a/libs/components/layout/src/workspace-sidebar/page-tree/tree-item/MoreActions.tsx +++ b/libs/components/layout/src/workspace-sidebar/page-tree/tree-item/MoreActions.tsx @@ -4,6 +4,7 @@ import { Cascader, CascaderItemProps, MuiDivider as Divider, + MuiClickAwayListener as ClickAwayListener, } from '@toeverything/components/ui'; import React from 'react'; import { NavLink, useNavigate } from 'react-router-dom'; @@ -233,29 +234,31 @@ function DndTreeItemMoreActions(props: ActionsProps) { ]; return ( - <> - - ··· - - - - + handleClose()}> +
+ + ··· + + + +
+
); }