Merge pull request #28 from toeverything/bugfix/leftlayout220802

Bugfix/leftlayout220802
This commit is contained in:
DarkSky
2022-08-02 11:45:12 +08:00
committed by GitHub
3 changed files with 40 additions and 27 deletions

View File

@@ -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 = () => {
) : (
<WorkspaceNameContainer>
<span onClick={() => setInRename(true)}>
{workspaceName}
{workspaceName || workspaceId}
</span>
</WorkspaceNameContainer>
)}

View File

@@ -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 (
<>
<span
className={styles['TreeItemMoreActions']}
onClick={handleClick}
>
···
</span>
<Cascader
items={menuList}
anchorEl={anchorEl}
placement="right-start"
open={open}
onClose={handleClose}
></Cascader>
<Snackbar
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
open={alert_open}
message={MESSAGES.COPY_LINK_SUCCESS}
key={'bottomcenter'}
autoHideDuration={2000}
onClose={handle_alert_close}
/>
</>
<ClickAwayListener onClickAway={() => handleClose()}>
<div>
<span
className={styles['TreeItemMoreActions']}
onClick={handleClick}
>
···
</span>
<Cascader
items={menuList}
anchorEl={anchorEl}
placement="right-start"
open={open}
onClose={handleClose}
></Cascader>
<Snackbar
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
open={alert_open}
message={MESSAGES.COPY_LINK_SUCCESS}
key={'bottomcenter'}
autoHideDuration={2000}
onClose={handle_alert_close}
/>
</div>
</ClickAwayListener>
);
}

View File

@@ -112,11 +112,15 @@ export class UserConfig extends ServiceBaseClass {
async getWorkspaceName(workspace: string): Promise<string> {
const workspace_db_block = await this.getWorkspaceDbBlock(workspace);
const workspaceName =
workspace_db_block.getDecoration<string>(WORKSPACE_CONFIG) ||
workspace_db_block.id;
workspace_db_block.getDecoration<string>(WORKSPACE_CONFIG) || '';
return workspaceName;
}
async getWorkspaceId(workspace: string): Promise<string> {
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);