fix: workspace dropdown fix (#3808)
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { Menu, MenuItem, Tooltip } from '@affine/component';
|
import { Menu, MenuItem, Tooltip } from '@affine/component';
|
||||||
import { ScrollableContainer } from '@affine/component';
|
|
||||||
import { WorkspaceList } from '@affine/component/workspace-list';
|
import { WorkspaceList } from '@affine/component/workspace-list';
|
||||||
import type {
|
import type {
|
||||||
AffineCloudWorkspace,
|
AffineCloudWorkspace,
|
||||||
@@ -32,7 +31,9 @@ import {
|
|||||||
StyledImportWorkspaceCardPill,
|
StyledImportWorkspaceCardPill,
|
||||||
StyledModalBody,
|
StyledModalBody,
|
||||||
StyledModalContent,
|
StyledModalContent,
|
||||||
|
StyledModalFooterContent,
|
||||||
StyledModalHeader,
|
StyledModalHeader,
|
||||||
|
StyledModalHeaderContent,
|
||||||
StyledModalHeaderLeft,
|
StyledModalHeaderLeft,
|
||||||
StyledModalTitle,
|
StyledModalTitle,
|
||||||
StyledOperationWrapper,
|
StyledOperationWrapper,
|
||||||
@@ -170,141 +171,140 @@ export const WorkspaceListModal = ({
|
|||||||
zIndex: 999,
|
zIndex: 999,
|
||||||
'& .MuiPopover-paper': {
|
'& .MuiPopover-paper': {
|
||||||
borderRadius: '8px',
|
borderRadius: '8px',
|
||||||
boxShadow: 'var(--affine-shadow-1)',
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
boxShadow: 'var(--affine-shadow-2)',
|
||||||
|
backgroundColor: 'var(--affine-background-overlay-panel-color)',
|
||||||
},
|
},
|
||||||
|
maxHeight: '90vh',
|
||||||
}}
|
}}
|
||||||
open={open}
|
open={open}
|
||||||
anchorEl={anchorEl}
|
anchorEl={anchorEl}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
>
|
>
|
||||||
<StyledModalBody>
|
<StyledModalHeaderContent>
|
||||||
<ScrollableContainer>
|
<StyledSignInCardPill>
|
||||||
{isLoggedIn ? (
|
<MenuItem
|
||||||
<CloudWorkSpaceList
|
style={{
|
||||||
disabled={disabled}
|
height: 'auto',
|
||||||
open={open}
|
padding: '8px 12px',
|
||||||
onClose={onClose}
|
}}
|
||||||
workspaces={workspaces}
|
onClick={async () => {
|
||||||
onClickWorkspace={onClickWorkspace}
|
if (!runtimeConfig.enableCloud) {
|
||||||
onClickWorkspaceSetting={onClickWorkspaceSetting}
|
setOpen(true);
|
||||||
onNewWorkspace={onNewWorkspace}
|
|
||||||
onAddWorkspace={onAddWorkspace}
|
|
||||||
currentWorkspaceId={currentWorkspaceId}
|
|
||||||
onMoveWorkspace={onMoveWorkspace}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<StyledModalContent>
|
|
||||||
<StyledSignInCardPill>
|
|
||||||
<MenuItem
|
|
||||||
style={{
|
|
||||||
height: 'auto',
|
|
||||||
padding: '8px 12px',
|
|
||||||
}}
|
|
||||||
onClick={async () => {
|
|
||||||
if (!runtimeConfig.enableCloud) {
|
|
||||||
setOpen(true);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
data-testid="cloud-signin-button"
|
|
||||||
>
|
|
||||||
<StyledCreateWorkspaceCardPillContent>
|
|
||||||
<StyledCreateWorkspaceCardPillIcon>
|
|
||||||
<CloudWorkspaceIcon />
|
|
||||||
</StyledCreateWorkspaceCardPillIcon>
|
|
||||||
<StyledSignInCardPillTextCotainer>
|
|
||||||
<StyledSignInCardPillTextPrimary>
|
|
||||||
{t['com.affine.workspace.cloud.auth']()}
|
|
||||||
</StyledSignInCardPillTextPrimary>
|
|
||||||
<StyledSignInCardPillTextSecondary>
|
|
||||||
Sync with AFFiNE Cloud
|
|
||||||
</StyledSignInCardPillTextSecondary>
|
|
||||||
</StyledSignInCardPillTextCotainer>
|
|
||||||
</StyledCreateWorkspaceCardPillContent>
|
|
||||||
</MenuItem>
|
|
||||||
</StyledSignInCardPill>
|
|
||||||
<Divider />
|
|
||||||
</StyledModalContent>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<StyledModalHeader>
|
|
||||||
<StyledModalTitle>{t['Local Workspace']()}</StyledModalTitle>
|
|
||||||
<Tooltip
|
|
||||||
content={t['Workspace description']()}
|
|
||||||
placement="top-start"
|
|
||||||
disablePortal={true}
|
|
||||||
>
|
|
||||||
<StyledHelperContainer>
|
|
||||||
<HelpIcon />
|
|
||||||
</StyledHelperContainer>
|
|
||||||
</Tooltip>
|
|
||||||
</StyledModalHeader>
|
|
||||||
<StyledModalContent>
|
|
||||||
<WorkspaceList
|
|
||||||
disabled={disabled}
|
|
||||||
items={
|
|
||||||
workspaces.filter(
|
|
||||||
({ flavour }) => flavour !== WorkspaceFlavour.PUBLIC
|
|
||||||
) as (AffineCloudWorkspace | LocalWorkspace)[]
|
|
||||||
}
|
}
|
||||||
currentWorkspaceId={currentWorkspaceId}
|
}}
|
||||||
onClick={onClickWorkspace}
|
data-testid="cloud-signin-button"
|
||||||
onSettingClick={onClickWorkspaceSetting}
|
>
|
||||||
onDragEnd={useCallback(
|
<StyledCreateWorkspaceCardPillContent>
|
||||||
(event: DragEndEvent) => {
|
<StyledCreateWorkspaceCardPillIcon>
|
||||||
const { active, over } = event;
|
<CloudWorkspaceIcon />
|
||||||
if (active.id !== over?.id) {
|
</StyledCreateWorkspaceCardPillIcon>
|
||||||
onMoveWorkspace(active.id as string, over?.id as string);
|
<StyledSignInCardPillTextCotainer>
|
||||||
}
|
<StyledSignInCardPillTextPrimary>
|
||||||
},
|
{t['com.affine.workspace.cloud.auth']()}
|
||||||
[onMoveWorkspace]
|
</StyledSignInCardPillTextPrimary>
|
||||||
)}
|
<StyledSignInCardPillTextSecondary>
|
||||||
/>
|
Sync with AFFiNE Cloud
|
||||||
</StyledModalContent>
|
</StyledSignInCardPillTextSecondary>
|
||||||
<StyledModalContent>
|
</StyledSignInCardPillTextCotainer>
|
||||||
{runtimeConfig.enableSQLiteProvider && environment.isDesktop ? (
|
</StyledCreateWorkspaceCardPillContent>
|
||||||
<StyledImportWorkspaceCardPill>
|
</MenuItem>
|
||||||
<MenuItem
|
</StyledSignInCardPill>
|
||||||
onClick={onAddWorkspace}
|
<Divider />
|
||||||
data-testid="add-workspace"
|
</StyledModalHeaderContent>
|
||||||
style={{
|
<StyledModalBody>
|
||||||
height: 'auto',
|
{isLoggedIn ? (
|
||||||
padding: '8px 12px',
|
<CloudWorkSpaceList
|
||||||
}}
|
disabled={disabled}
|
||||||
>
|
open={open}
|
||||||
<StyledCreateWorkspaceCardPillContent>
|
onClose={onClose}
|
||||||
<StyledCreateWorkspaceCardPillIcon>
|
workspaces={workspaces}
|
||||||
<ImportIcon />
|
onClickWorkspace={onClickWorkspace}
|
||||||
</StyledCreateWorkspaceCardPillIcon>
|
onClickWorkspaceSetting={onClickWorkspaceSetting}
|
||||||
<div>
|
onNewWorkspace={onNewWorkspace}
|
||||||
<p>{t['com.affine.workspace.local.import']()}</p>
|
onAddWorkspace={onAddWorkspace}
|
||||||
</div>
|
currentWorkspaceId={currentWorkspaceId}
|
||||||
</StyledCreateWorkspaceCardPillContent>
|
onMoveWorkspace={onMoveWorkspace}
|
||||||
</MenuItem>
|
/>
|
||||||
</StyledImportWorkspaceCardPill>
|
) : null}
|
||||||
) : null}
|
<StyledModalHeader>
|
||||||
<StyledCreateWorkspaceCardPill>
|
<StyledModalTitle>{t['Local Workspace']()}</StyledModalTitle>
|
||||||
<MenuItem
|
<Tooltip
|
||||||
style={{
|
content={t['Workspace description']()}
|
||||||
height: 'auto',
|
placement="top-start"
|
||||||
padding: '8px 12px',
|
disablePortal={true}
|
||||||
}}
|
>
|
||||||
onClick={onNewWorkspace}
|
<StyledHelperContainer>
|
||||||
data-testid="new-workspace"
|
<HelpIcon />
|
||||||
>
|
</StyledHelperContainer>
|
||||||
<StyledCreateWorkspaceCardPillContent>
|
</Tooltip>
|
||||||
<StyledCreateWorkspaceCardPillIcon>
|
</StyledModalHeader>
|
||||||
<PlusIcon />
|
<StyledModalContent>
|
||||||
</StyledCreateWorkspaceCardPillIcon>
|
<WorkspaceList
|
||||||
<div>
|
disabled={disabled}
|
||||||
<p>{t['New Workspace']()}</p>
|
items={
|
||||||
</div>
|
workspaces.filter(
|
||||||
</StyledCreateWorkspaceCardPillContent>
|
({ flavour }) => flavour !== WorkspaceFlavour.PUBLIC
|
||||||
</MenuItem>
|
) as (AffineCloudWorkspace | LocalWorkspace)[]
|
||||||
</StyledCreateWorkspaceCardPill>
|
}
|
||||||
</StyledModalContent>
|
currentWorkspaceId={currentWorkspaceId}
|
||||||
</ScrollableContainer>
|
onClick={onClickWorkspace}
|
||||||
|
onSettingClick={onClickWorkspaceSetting}
|
||||||
|
onDragEnd={useCallback(
|
||||||
|
(event: DragEndEvent) => {
|
||||||
|
const { active, over } = event;
|
||||||
|
if (active.id !== over?.id) {
|
||||||
|
onMoveWorkspace(active.id as string, over?.id as string);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[onMoveWorkspace]
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</StyledModalContent>
|
||||||
|
{runtimeConfig.enableSQLiteProvider && environment.isDesktop ? (
|
||||||
|
<StyledImportWorkspaceCardPill>
|
||||||
|
<MenuItem
|
||||||
|
onClick={onAddWorkspace}
|
||||||
|
data-testid="add-workspace"
|
||||||
|
style={{
|
||||||
|
height: 'auto',
|
||||||
|
padding: '8px 12px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<StyledCreateWorkspaceCardPillContent>
|
||||||
|
<StyledCreateWorkspaceCardPillIcon>
|
||||||
|
<ImportIcon />
|
||||||
|
</StyledCreateWorkspaceCardPillIcon>
|
||||||
|
<div>
|
||||||
|
<p>{t['com.affine.workspace.local.import']()}</p>
|
||||||
|
</div>
|
||||||
|
</StyledCreateWorkspaceCardPillContent>
|
||||||
|
</MenuItem>
|
||||||
|
</StyledImportWorkspaceCardPill>
|
||||||
|
) : null}
|
||||||
</StyledModalBody>
|
</StyledModalBody>
|
||||||
|
<StyledModalFooterContent>
|
||||||
|
<StyledCreateWorkspaceCardPill>
|
||||||
|
<MenuItem
|
||||||
|
style={{
|
||||||
|
height: 'auto',
|
||||||
|
padding: '8px 12px',
|
||||||
|
}}
|
||||||
|
onClick={onNewWorkspace}
|
||||||
|
data-testid="new-workspace"
|
||||||
|
>
|
||||||
|
<StyledCreateWorkspaceCardPillContent>
|
||||||
|
<StyledCreateWorkspaceCardPillIcon>
|
||||||
|
<PlusIcon />
|
||||||
|
</StyledCreateWorkspaceCardPillIcon>
|
||||||
|
<div>
|
||||||
|
<p>{t['New Workspace']()}</p>
|
||||||
|
</div>
|
||||||
|
</StyledCreateWorkspaceCardPillContent>
|
||||||
|
</MenuItem>
|
||||||
|
</StyledCreateWorkspaceCardPill>
|
||||||
|
</StyledModalFooterContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ export const StyledCreateWorkspaceCardPill = styled('div')(() => {
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '58px',
|
height: '58px',
|
||||||
background: 'var(--affine-background-primary-color)',
|
|
||||||
border: `1px solid var(--affine-border-color)`,
|
border: `1px solid var(--affine-border-color)`,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -97,8 +96,6 @@ export const StyledSignInCardPill = styled('div')(() => {
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '58px',
|
height: '58px',
|
||||||
marginBottom: '6px',
|
|
||||||
background: 'var(--affine-background-primary-color)',
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -107,7 +104,6 @@ export const StyledImportWorkspaceCardPill = styled('div')(() => {
|
|||||||
borderRadius: '5px',
|
borderRadius: '5px',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
marginBottom: '12px',
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -176,7 +172,27 @@ export const StyledModalContent = styled('div')({
|
|||||||
...displayFlex('space-between', 'flex-start', 'flex-start'),
|
...displayFlex('space-between', 'flex-start', 'flex-start'),
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
|
width: '100%',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const StyledModalFooterContent = styled('div')({
|
||||||
|
...displayFlex('space-between', 'flex-start', 'flex-start'),
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
flexDirection: 'column',
|
||||||
|
width: '100%',
|
||||||
|
padding: '12px',
|
||||||
|
backgroundColor: 'var(--affine-background-overlay-panel-color)',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const StyledModalHeaderContent = styled('div')({
|
||||||
|
...displayFlex('space-between', 'flex-start', 'flex-start'),
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
flexDirection: 'column',
|
||||||
|
width: '100%',
|
||||||
|
padding: '12px 12px 0px 12px',
|
||||||
|
backgroundColor: 'var(--affine-background-overlay-panel-color)',
|
||||||
|
});
|
||||||
|
|
||||||
export const StyledOperationWrapper = styled('div')(() => {
|
export const StyledOperationWrapper = styled('div')(() => {
|
||||||
return {
|
return {
|
||||||
...displayFlex('flex-end', 'center'),
|
...displayFlex('flex-end', 'center'),
|
||||||
@@ -188,13 +204,13 @@ export const StyleWorkspaceAdd = styled('div')(() => {
|
|||||||
width: '58px',
|
width: '58px',
|
||||||
height: '58px',
|
height: '58px',
|
||||||
borderRadius: '100%',
|
borderRadius: '100%',
|
||||||
background: 'var(--affine-white-80)',
|
background: 'var(--affine-background-overlay-panel-color)',
|
||||||
border: '1.5px dashed #f4f5fa',
|
border: '1.5px dashed #f4f5fa',
|
||||||
transition: 'background .2s',
|
transition: 'background .2s',
|
||||||
fontSize: '24px',
|
fontSize: '24px',
|
||||||
...displayFlex('center', 'center'),
|
...displayFlex('center', 'center'),
|
||||||
borderColor: 'var(--affine-white)',
|
borderColor: 'var(--affine-white)',
|
||||||
color: 'var(--affine-primary-color)',
|
color: 'var(--affine-background-overlay-panel-color)',
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
export const StyledModalHeader = styled('div')(() => {
|
export const StyledModalHeader = styled('div')(() => {
|
||||||
@@ -210,12 +226,12 @@ export const StyledModalHeader = styled('div')(() => {
|
|||||||
|
|
||||||
export const StyledModalBody = styled('div')(() => {
|
export const StyledModalBody = styled('div')(() => {
|
||||||
return {
|
return {
|
||||||
borderRadius: '8px',
|
padding: '0px 12px',
|
||||||
padding: '12px',
|
|
||||||
display: 'inline-flex',
|
display: 'inline-flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
alignItems: 'flex-start',
|
alignItems: 'flex-start',
|
||||||
gap: '12px',
|
gap: '12px',
|
||||||
background: 'var(--affine-white)',
|
flex: 1,
|
||||||
|
overflowY: 'auto',
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,11 +2,6 @@ import { WorkspaceFlavour } from '@affine/env/workspace';
|
|||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
import type { RootWorkspaceMetadata } from '@affine/workspace/atom';
|
import type { RootWorkspaceMetadata } from '@affine/workspace/atom';
|
||||||
import { SettingsIcon } from '@blocksuite/icons';
|
import { SettingsIcon } from '@blocksuite/icons';
|
||||||
import {
|
|
||||||
CloudWorkspaceIcon as DefaultCloudWorkspaceIcon,
|
|
||||||
CollaborationIcon as DefaultJoinedWorkspaceIcon,
|
|
||||||
LocalWorkspaceIcon as DefaultLocalWorkspaceIcon,
|
|
||||||
} from '@blocksuite/icons';
|
|
||||||
import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name';
|
import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name';
|
||||||
import { useStaticBlockSuiteWorkspace } from '@toeverything/infra/__internal__/react';
|
import { useStaticBlockSuiteWorkspace } from '@toeverything/infra/__internal__/react';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
@@ -19,21 +14,6 @@ import {
|
|||||||
StyledWorkspaceTitle,
|
StyledWorkspaceTitle,
|
||||||
} from './styles';
|
} from './styles';
|
||||||
|
|
||||||
const JoinedWorkspaceIcon = () => {
|
|
||||||
return <DefaultJoinedWorkspaceIcon style={{ color: '#FF646B' }} />;
|
|
||||||
};
|
|
||||||
const LocalWorkspaceIcon = () => {
|
|
||||||
return <DefaultLocalWorkspaceIcon style={{ color: '#FDBD32' }} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
const CloudWorkspaceIcon = () => {
|
|
||||||
return <DefaultCloudWorkspaceIcon style={{ color: '#60A5FA' }} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
// const LocalDataIcon = () => {
|
|
||||||
// return <DefaultLocalDataIcon style={{ color: '#62CD80' }} />;
|
|
||||||
// };
|
|
||||||
|
|
||||||
export interface WorkspaceTypeProps {
|
export interface WorkspaceTypeProps {
|
||||||
flavour: WorkspaceFlavour;
|
flavour: WorkspaceFlavour;
|
||||||
}
|
}
|
||||||
@@ -46,7 +26,6 @@ const WorkspaceType = ({ flavour }: WorkspaceTypeProps) => {
|
|||||||
if (flavour === WorkspaceFlavour.LOCAL) {
|
if (flavour === WorkspaceFlavour.LOCAL) {
|
||||||
return (
|
return (
|
||||||
<p style={{ fontSize: '10px' }} title={t['Local Workspace']()}>
|
<p style={{ fontSize: '10px' }} title={t['Local Workspace']()}>
|
||||||
<LocalWorkspaceIcon />
|
|
||||||
<span>{t['Local Workspace']()}</span>
|
<span>{t['Local Workspace']()}</span>
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
@@ -54,12 +33,10 @@ const WorkspaceType = ({ flavour }: WorkspaceTypeProps) => {
|
|||||||
|
|
||||||
return isOwner ? (
|
return isOwner ? (
|
||||||
<p style={{ fontSize: '10px' }} title={t['Cloud Workspace']()}>
|
<p style={{ fontSize: '10px' }} title={t['Cloud Workspace']()}>
|
||||||
<CloudWorkspaceIcon />
|
|
||||||
<span>{t['Cloud Workspace']()}</span>
|
<span>{t['Cloud Workspace']()}</span>
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<p style={{ fontSize: '10px' }} title={t['Joined Workspace']()}>
|
<p style={{ fontSize: '10px' }} title={t['Joined Workspace']()}>
|
||||||
<JoinedWorkspaceIcon />
|
|
||||||
<span>{t['Joined Workspace']()}</span>
|
<span>{t['Joined Workspace']()}</span>
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import StyledPopperContainer from '../shared/container';
|
|||||||
const StyledTooltip = styled(StyledPopperContainer)(() => {
|
const StyledTooltip = styled(StyledPopperContainer)(() => {
|
||||||
return {
|
return {
|
||||||
display: 'inline-flex',
|
display: 'inline-flex',
|
||||||
height: '38px',
|
minHeight: '38px',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
|||||||
Reference in New Issue
Block a user