Merge pull request #28 from toeverything/bugfix/leftlayout220802
Bugfix/leftlayout220802
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
|||||||
useUserAndSpaces,
|
useUserAndSpaces,
|
||||||
useShowSpaceSidebar,
|
useShowSpaceSidebar,
|
||||||
} from '@toeverything/datasource/state';
|
} from '@toeverything/datasource/state';
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { services } from '@toeverything/datasource/db-service';
|
import { services } from '@toeverything/datasource/db-service';
|
||||||
|
|
||||||
const WorkspaceContainer = styled('div')({
|
const WorkspaceContainer = styled('div')({
|
||||||
@@ -78,6 +78,7 @@ export const WorkspaceName = () => {
|
|||||||
const { fixedDisplay, toggleSpaceSidebar } = useShowSpaceSidebar();
|
const { fixedDisplay, toggleSpaceSidebar } = useShowSpaceSidebar();
|
||||||
const [inRename, setInRename] = useState(false);
|
const [inRename, setInRename] = useState(false);
|
||||||
const [workspaceName, setWorkspaceName] = useState('');
|
const [workspaceName, setWorkspaceName] = useState('');
|
||||||
|
const [workspaceId, setWorkspaceId] = useState('');
|
||||||
|
|
||||||
const fetchWorkspaceName = useCallback(async () => {
|
const fetchWorkspaceName = useCallback(async () => {
|
||||||
if (!currentSpaceId) {
|
if (!currentSpaceId) {
|
||||||
@@ -88,6 +89,11 @@ export const WorkspaceName = () => {
|
|||||||
currentSpaceId
|
currentSpaceId
|
||||||
);
|
);
|
||||||
setWorkspaceName(name);
|
setWorkspaceName(name);
|
||||||
|
|
||||||
|
const workspaceId = await services.api.userConfig.getWorkspaceId(
|
||||||
|
currentSpaceId
|
||||||
|
);
|
||||||
|
setWorkspaceId(workspaceId);
|
||||||
}, [currentSpaceId]);
|
}, [currentSpaceId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -150,7 +156,7 @@ export const WorkspaceName = () => {
|
|||||||
) : (
|
) : (
|
||||||
<WorkspaceNameContainer>
|
<WorkspaceNameContainer>
|
||||||
<span onClick={() => setInRename(true)}>
|
<span onClick={() => setInRename(true)}>
|
||||||
{workspaceName}
|
{workspaceName || workspaceId}
|
||||||
</span>
|
</span>
|
||||||
</WorkspaceNameContainer>
|
</WorkspaceNameContainer>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
Cascader,
|
Cascader,
|
||||||
CascaderItemProps,
|
CascaderItemProps,
|
||||||
MuiDivider as Divider,
|
MuiDivider as Divider,
|
||||||
|
MuiClickAwayListener as ClickAwayListener,
|
||||||
} from '@toeverything/components/ui';
|
} from '@toeverything/components/ui';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { NavLink, useNavigate } from 'react-router-dom';
|
import { NavLink, useNavigate } from 'react-router-dom';
|
||||||
@@ -233,29 +234,31 @@ function DndTreeItemMoreActions(props: ActionsProps) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<ClickAwayListener onClickAway={() => handleClose()}>
|
||||||
<span
|
<div>
|
||||||
className={styles['TreeItemMoreActions']}
|
<span
|
||||||
onClick={handleClick}
|
className={styles['TreeItemMoreActions']}
|
||||||
>
|
onClick={handleClick}
|
||||||
···
|
>
|
||||||
</span>
|
···
|
||||||
<Cascader
|
</span>
|
||||||
items={menuList}
|
<Cascader
|
||||||
anchorEl={anchorEl}
|
items={menuList}
|
||||||
placement="right-start"
|
anchorEl={anchorEl}
|
||||||
open={open}
|
placement="right-start"
|
||||||
onClose={handleClose}
|
open={open}
|
||||||
></Cascader>
|
onClose={handleClose}
|
||||||
<Snackbar
|
></Cascader>
|
||||||
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
|
<Snackbar
|
||||||
open={alert_open}
|
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
|
||||||
message={MESSAGES.COPY_LINK_SUCCESS}
|
open={alert_open}
|
||||||
key={'bottomcenter'}
|
message={MESSAGES.COPY_LINK_SUCCESS}
|
||||||
autoHideDuration={2000}
|
key={'bottomcenter'}
|
||||||
onClose={handle_alert_close}
|
autoHideDuration={2000}
|
||||||
/>
|
onClose={handle_alert_close}
|
||||||
</>
|
/>
|
||||||
|
</div>
|
||||||
|
</ClickAwayListener>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,11 +112,15 @@ export class UserConfig extends ServiceBaseClass {
|
|||||||
async getWorkspaceName(workspace: string): Promise<string> {
|
async getWorkspaceName(workspace: string): Promise<string> {
|
||||||
const workspace_db_block = await this.getWorkspaceDbBlock(workspace);
|
const workspace_db_block = await this.getWorkspaceDbBlock(workspace);
|
||||||
const workspaceName =
|
const workspaceName =
|
||||||
workspace_db_block.getDecoration<string>(WORKSPACE_CONFIG) ||
|
workspace_db_block.getDecoration<string>(WORKSPACE_CONFIG) || '';
|
||||||
workspace_db_block.id;
|
|
||||||
return workspaceName;
|
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) {
|
async setWorkspaceName(workspace: string, workspaceName: string) {
|
||||||
const workspace_db_block = await this.getWorkspaceDbBlock(workspace);
|
const workspace_db_block = await this.getWorkspaceDbBlock(workspace);
|
||||||
workspace_db_block.setDecoration(WORKSPACE_CONFIG, workspaceName);
|
workspace_db_block.setDecoration(WORKSPACE_CONFIG, workspaceName);
|
||||||
|
|||||||
Reference in New Issue
Block a user