mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-08 01:39:22 +08:00
feat(core): refactor sidebar header (#6251)
- Add user avatar - Move sign-out/user settings link from workspace-modal to user avatar modal - Modify the style of workspace list items - Modify gap of navigation buttons - Animate Syncing/Offline/... 
This commit is contained in:
@@ -1,69 +1,18 @@
|
|||||||
import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant';
|
import { UNTITLED_WORKSPACE_NAME } from '@affine/env/constant';
|
||||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
import type { WorkspaceFlavour } from '@affine/env/workspace';
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
|
||||||
import { CollaborationIcon, SettingsIcon } from '@blocksuite/icons';
|
import { CollaborationIcon, SettingsIcon } from '@blocksuite/icons';
|
||||||
import type { WorkspaceMetadata } from '@toeverything/infra';
|
import type { WorkspaceMetadata } from '@toeverything/infra';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
import { Avatar } from '../../../ui/avatar';
|
import { Avatar, type AvatarProps } from '../../../ui/avatar';
|
||||||
import { Divider } from '../../../ui/divider';
|
|
||||||
import { Skeleton } from '../../../ui/skeleton';
|
import { Skeleton } from '../../../ui/skeleton';
|
||||||
import { Tooltip } from '../../../ui/tooltip';
|
import * as styles from './styles.css';
|
||||||
import {
|
|
||||||
StyledCard,
|
|
||||||
StyledIconContainer,
|
|
||||||
StyledSettingLink,
|
|
||||||
StyledWorkspaceInfo,
|
|
||||||
StyledWorkspaceTitle,
|
|
||||||
StyledWorkspaceTitleArea,
|
|
||||||
StyledWorkspaceType,
|
|
||||||
StyledWorkspaceTypeEllipse,
|
|
||||||
StyledWorkspaceTypeText,
|
|
||||||
} from './styles';
|
|
||||||
|
|
||||||
export interface WorkspaceTypeProps {
|
export interface WorkspaceTypeProps {
|
||||||
flavour: WorkspaceFlavour;
|
flavour: WorkspaceFlavour;
|
||||||
isOwner: boolean;
|
isOwner: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const WorkspaceType = ({ flavour, isOwner }: WorkspaceTypeProps) => {
|
|
||||||
const t = useAFFiNEI18N();
|
|
||||||
if (flavour === WorkspaceFlavour.LOCAL) {
|
|
||||||
return (
|
|
||||||
<StyledWorkspaceType>
|
|
||||||
<StyledWorkspaceTypeEllipse />
|
|
||||||
<StyledWorkspaceTypeText>{t['Local']()}</StyledWorkspaceTypeText>
|
|
||||||
</StyledWorkspaceType>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return isOwner ? (
|
|
||||||
<StyledWorkspaceType>
|
|
||||||
<StyledWorkspaceTypeEllipse cloud={true} />
|
|
||||||
<StyledWorkspaceTypeText>
|
|
||||||
{t['com.affine.brand.affineCloud']()}
|
|
||||||
</StyledWorkspaceTypeText>
|
|
||||||
</StyledWorkspaceType>
|
|
||||||
) : (
|
|
||||||
<StyledWorkspaceType>
|
|
||||||
<StyledWorkspaceTypeEllipse cloud={true} />
|
|
||||||
<StyledWorkspaceTypeText>
|
|
||||||
{t['com.affine.brand.affineCloud']()}
|
|
||||||
</StyledWorkspaceTypeText>
|
|
||||||
<Divider
|
|
||||||
orientation="vertical"
|
|
||||||
size="thinner"
|
|
||||||
style={{ margin: '0px 8px', height: '7px' }}
|
|
||||||
/>
|
|
||||||
<Tooltip content={t['com.affine.workspaceType.joined']()}>
|
|
||||||
<StyledIconContainer>
|
|
||||||
<CollaborationIcon />
|
|
||||||
</StyledIconContainer>
|
|
||||||
</Tooltip>
|
|
||||||
</StyledWorkspaceType>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface WorkspaceCardProps {
|
export interface WorkspaceCardProps {
|
||||||
currentWorkspaceId?: string | null;
|
currentWorkspaceId?: string | null;
|
||||||
meta: WorkspaceMetadata;
|
meta: WorkspaceMetadata;
|
||||||
@@ -77,7 +26,7 @@ export interface WorkspaceCardProps {
|
|||||||
export const WorkspaceCardSkeleton = () => {
|
export const WorkspaceCardSkeleton = () => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<StyledCard data-testid="workspace-card">
|
<div className={styles.card} data-testid="workspace-card">
|
||||||
<Skeleton variant="circular" width={28} height={28} />
|
<Skeleton variant="circular" width={28} height={28} />
|
||||||
<Skeleton
|
<Skeleton
|
||||||
variant="rectangular"
|
variant="rectangular"
|
||||||
@@ -85,11 +34,14 @@ export const WorkspaceCardSkeleton = () => {
|
|||||||
width={220}
|
width={220}
|
||||||
style={{ marginLeft: '12px' }}
|
style={{ marginLeft: '12px' }}
|
||||||
/>
|
/>
|
||||||
</StyledCard>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const avatarImageProps = {
|
||||||
|
style: { borderRadius: 3, overflow: 'hidden' },
|
||||||
|
} satisfies AvatarProps['imageProps'];
|
||||||
export const WorkspaceCard = ({
|
export const WorkspaceCard = ({
|
||||||
onClick,
|
onClick,
|
||||||
onSettingClick,
|
onSettingClick,
|
||||||
@@ -101,32 +53,38 @@ export const WorkspaceCard = ({
|
|||||||
}: WorkspaceCardProps) => {
|
}: WorkspaceCardProps) => {
|
||||||
const displayName = name ?? UNTITLED_WORKSPACE_NAME;
|
const displayName = name ?? UNTITLED_WORKSPACE_NAME;
|
||||||
return (
|
return (
|
||||||
<StyledCard
|
<div
|
||||||
|
className={styles.card}
|
||||||
|
data-active={meta.id === currentWorkspaceId}
|
||||||
data-testid="workspace-card"
|
data-testid="workspace-card"
|
||||||
onClick={useCallback(() => {
|
onClick={useCallback(() => {
|
||||||
onClick(meta);
|
onClick(meta);
|
||||||
}, [onClick, meta])}
|
}, [onClick, meta])}
|
||||||
active={meta.id === currentWorkspaceId}
|
|
||||||
>
|
>
|
||||||
<Avatar size={28} url={avatar} name={name} colorfulFallback />
|
<Avatar
|
||||||
<StyledWorkspaceInfo>
|
imageProps={avatarImageProps}
|
||||||
<StyledWorkspaceTitleArea style={{ display: 'flex' }}>
|
fallbackProps={avatarImageProps}
|
||||||
<StyledWorkspaceTitle>{displayName}</StyledWorkspaceTitle>
|
size={28}
|
||||||
|
url={avatar}
|
||||||
|
name={name}
|
||||||
|
colorfulFallback
|
||||||
|
/>
|
||||||
|
<div className={styles.workspaceInfo}>
|
||||||
|
<div className={styles.workspaceTitle}>{displayName}</div>
|
||||||
|
|
||||||
<StyledSettingLink
|
<div className={styles.actionButtons}>
|
||||||
size="small"
|
{isOwner ? null : <CollaborationIcon />}
|
||||||
className="setting-entry"
|
<div
|
||||||
|
className={styles.settingButton}
|
||||||
onClick={e => {
|
onClick={e => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
onSettingClick(meta);
|
onSettingClick(meta);
|
||||||
}}
|
}}
|
||||||
withoutHoverStyle={true}
|
|
||||||
>
|
>
|
||||||
<SettingsIcon />
|
<SettingsIcon width={16} height={16} />
|
||||||
</StyledSettingLink>
|
</div>
|
||||||
</StyledWorkspaceTitleArea>
|
</div>
|
||||||
<WorkspaceType isOwner={isOwner} flavour={meta.flavour} />
|
</div>
|
||||||
</StyledWorkspaceInfo>
|
</div>
|
||||||
</StyledCard>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import { cssVar } from '@toeverything/theme';
|
||||||
|
import { style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
|
import { displayFlex, textEllipsis } from '../../../styles';
|
||||||
|
|
||||||
|
export const card = style({
|
||||||
|
width: '100%',
|
||||||
|
cursor: 'pointer',
|
||||||
|
padding: '8px 12px',
|
||||||
|
borderRadius: 4,
|
||||||
|
// border: `1px solid ${borderColor}`,
|
||||||
|
boxShadow: 'inset 0 0 0 1px transparent',
|
||||||
|
...displayFlex('flex-start', 'flex-start'),
|
||||||
|
transition: 'background .2s',
|
||||||
|
position: 'relative',
|
||||||
|
color: cssVar('textSecondaryColor'),
|
||||||
|
background: 'transparent',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: 12,
|
||||||
|
|
||||||
|
selectors: {
|
||||||
|
'&:hover': {
|
||||||
|
background: cssVar('hoverColor'),
|
||||||
|
},
|
||||||
|
'&[data-active="true"]': {
|
||||||
|
boxShadow: 'inset 0 0 0 1px ' + cssVar('brandColor'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const workspaceInfo = style({
|
||||||
|
width: 0,
|
||||||
|
flex: 1,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
gap: 2,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const workspaceTitle = style({
|
||||||
|
width: 0,
|
||||||
|
flex: 1,
|
||||||
|
fontSize: cssVar('fontSm'),
|
||||||
|
fontWeight: 500,
|
||||||
|
lineHeight: '22px',
|
||||||
|
maxWidth: '190px',
|
||||||
|
color: cssVar('textPrimaryColor'),
|
||||||
|
...textEllipsis(1),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const actionButtons = style({
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const settingButtonWrapper = style({});
|
||||||
|
|
||||||
|
export const settingButton = style({
|
||||||
|
transition: 'all 0.13s ease',
|
||||||
|
width: 0,
|
||||||
|
height: 20,
|
||||||
|
overflow: 'hidden',
|
||||||
|
marginLeft: 0,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
placeItems: 'center',
|
||||||
|
|
||||||
|
borderRadius: 4,
|
||||||
|
boxShadow: 'none',
|
||||||
|
background: 'transparent',
|
||||||
|
cursor: 'pointer',
|
||||||
|
|
||||||
|
selectors: {
|
||||||
|
[`.${card}:hover &`]: {
|
||||||
|
width: 20,
|
||||||
|
marginLeft: 8,
|
||||||
|
boxShadow: cssVar('shadow1'),
|
||||||
|
background: cssVar('white80'),
|
||||||
|
},
|
||||||
|
// [`.${card}:hover &:hover`]: {
|
||||||
|
// background: cssVar('hoverColor'),
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
import { displayFlex, styled, textEllipsis } from '../../../styles';
|
|
||||||
import { IconButton } from '../../../ui/button';
|
|
||||||
|
|
||||||
export const StyledWorkspaceInfo = styled('div')(() => {
|
|
||||||
return {
|
|
||||||
marginLeft: '12px',
|
|
||||||
width: '100%',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledWorkspaceTitle = styled('div')(() => {
|
|
||||||
return {
|
|
||||||
fontSize: 'var(--affine-font-sm)',
|
|
||||||
fontWeight: 700,
|
|
||||||
lineHeight: '22px',
|
|
||||||
maxWidth: '190px',
|
|
||||||
color: 'var(--affine-text-primary-color)',
|
|
||||||
...textEllipsis(1),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledCard = styled('div')<{
|
|
||||||
active?: boolean;
|
|
||||||
}>(({ active }) => {
|
|
||||||
const borderColor = active ? 'var(--affine-primary-color)' : 'transparent';
|
|
||||||
const backgroundColor = active ? 'var(--affine-white-30)' : 'transparent';
|
|
||||||
return {
|
|
||||||
width: '100%',
|
|
||||||
cursor: 'pointer',
|
|
||||||
padding: '12px',
|
|
||||||
borderRadius: '8px',
|
|
||||||
border: `1px solid ${borderColor}`,
|
|
||||||
...displayFlex('flex-start', 'flex-start'),
|
|
||||||
transition: 'background .2s',
|
|
||||||
alignItems: 'center',
|
|
||||||
position: 'relative',
|
|
||||||
color: 'var(--affine-text-secondary-color)',
|
|
||||||
background: backgroundColor,
|
|
||||||
':hover': {
|
|
||||||
background: 'var(--affine-hover-color)',
|
|
||||||
'.add-icon': {
|
|
||||||
borderColor: 'var(--affine-primary-color)',
|
|
||||||
color: 'var(--affine-primary-color)',
|
|
||||||
},
|
|
||||||
'.setting-entry': {
|
|
||||||
opacity: 1,
|
|
||||||
pointerEvents: 'auto',
|
|
||||||
backgroundColor: 'var(--affine-white-30)',
|
|
||||||
boxShadow: 'var(--affine-shadow-1)',
|
|
||||||
':hover': {
|
|
||||||
background:
|
|
||||||
'linear-gradient(0deg, var(--affine-hover-color) 0%, var(--affine-hover-color) 100%), var(--affine-white-30)',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'@media (max-width: 720px)': {
|
|
||||||
width: '100%',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledModalHeader = styled('div')(() => {
|
|
||||||
return {
|
|
||||||
width: '100%',
|
|
||||||
height: '72px',
|
|
||||||
position: 'absolute',
|
|
||||||
left: 0,
|
|
||||||
top: 0,
|
|
||||||
borderRadius: '24px 24px 0 0',
|
|
||||||
padding: '0 40px',
|
|
||||||
...displayFlex('space-between', 'center'),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledSettingLink = styled(IconButton)(() => {
|
|
||||||
return {
|
|
||||||
position: 'absolute',
|
|
||||||
right: '10px',
|
|
||||||
top: '10px',
|
|
||||||
opacity: 0,
|
|
||||||
borderRadius: '4px',
|
|
||||||
color: 'var(--affine-primary-color)',
|
|
||||||
pointerEvents: 'none',
|
|
||||||
transition: 'all .15s',
|
|
||||||
':hover': {
|
|
||||||
background: 'var(--affine-hover-color)',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledWorkspaceType = styled('div')(() => {
|
|
||||||
return {
|
|
||||||
...displayFlex('flex-start', 'center'),
|
|
||||||
width: '100%',
|
|
||||||
height: '20px',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledWorkspaceTitleArea = styled('div')(() => {
|
|
||||||
return {
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledWorkspaceTypeEllipse = styled('div')<{
|
|
||||||
cloud?: boolean;
|
|
||||||
}>(({ cloud }) => {
|
|
||||||
return {
|
|
||||||
width: '5px',
|
|
||||||
height: '5px',
|
|
||||||
borderRadius: '50%',
|
|
||||||
background: cloud
|
|
||||||
? 'var(--affine-palette-shape-blue)'
|
|
||||||
: 'var(--affine-palette-shape-green)',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledWorkspaceTypeText = styled('div')(() => {
|
|
||||||
return {
|
|
||||||
fontSize: '12px',
|
|
||||||
fontWeight: 500,
|
|
||||||
lineHeight: '20px',
|
|
||||||
marginLeft: '4px',
|
|
||||||
color: 'var(--affine-text-secondary-color)',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const StyledIconContainer = styled('div')(() => {
|
|
||||||
return {
|
|
||||||
...displayFlex('flex-start', 'center'),
|
|
||||||
fontSize: '14px',
|
|
||||||
gap: '8px',
|
|
||||||
color: 'var(--affine-icon-secondary)',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
@@ -79,7 +79,6 @@ export const DefaultAvatarContainerStyle = style({
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
borderRadius: '50%',
|
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
});
|
});
|
||||||
export const DefaultAvatarMiddleItemStyle = style({
|
export const DefaultAvatarMiddleItemStyle = style({
|
||||||
@@ -155,6 +154,7 @@ export const avatarFallback = style({
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
borderRadius: '50%',
|
borderRadius: '50%',
|
||||||
|
overflow: 'hidden',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<g clip-path="url(#clip0_19485_742)">
|
||||||
|
<rect width="20" height="20" rx="10" fill="currentColor" fill-opacity="0.1" />
|
||||||
|
<path
|
||||||
|
d="M10 10.9999C12.0829 10.9999 13.7714 9.29858 13.7714 7.1999C13.7714 5.10122 12.0829 3.3999 10 3.3999C7.91709 3.3999 6.22857 5.10122 6.22857 7.1999C6.22857 9.29858 7.91709 10.9999 10 10.9999Z"
|
||||||
|
fill="currentColor" fill-opacity="0.3" />
|
||||||
|
<path
|
||||||
|
d="M1.5 22.3999C1.33431 22.3999 1.19948 22.2649 1.20496 22.0993C1.36224 17.3416 5.23972 13.5332 10 13.5332C14.7603 13.5332 18.6378 17.3416 18.795 22.0993C18.8005 22.2649 18.6657 22.3999 18.5 22.3999H1.5Z"
|
||||||
|
fill="currentColor" fill-opacity="0.3" />
|
||||||
|
</g>
|
||||||
|
<defs>
|
||||||
|
<clipPath id="clip0_19485_742">
|
||||||
|
<rect width="20" height="20" rx="10" fill="white" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 892 B |
@@ -1,10 +1,9 @@
|
|||||||
import { style } from '@vanilla-extract/css';
|
import { style } from '@vanilla-extract/css';
|
||||||
export const fallbackStyle = style({
|
export const fallbackStyle = style({
|
||||||
margin: '5px 16px',
|
margin: '4px 16px',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
});
|
});
|
||||||
export const fallbackHeaderStyle = style({
|
export const fallbackHeaderStyle = style({
|
||||||
height: '56px',
|
|
||||||
width: '100%',
|
width: '100%',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ import * as styles from './index.css';
|
|||||||
import { UserAccountItem } from './user-account';
|
import { UserAccountItem } from './user-account';
|
||||||
import { AFFiNEWorkspaceList } from './workspace-list';
|
import { AFFiNEWorkspaceList } from './workspace-list';
|
||||||
|
|
||||||
const SignInItem = () => {
|
export const SignInItem = () => {
|
||||||
const setDisableCloudOpen = useSetAtom(openDisableCloudAlertModalAtom);
|
const setDisableCloudOpen = useSetAtom(openDisableCloudAlertModalAtom);
|
||||||
|
|
||||||
const setOpen = useSetAtom(authAtom);
|
const setOpen = useSetAtom(authAtom);
|
||||||
|
|||||||
+1
-79
@@ -1,73 +1,8 @@
|
|||||||
import { IconButton } from '@affine/component/ui/button';
|
|
||||||
import { Divider } from '@affine/component/ui/divider';
|
|
||||||
import { Menu, MenuIcon, MenuItem } from '@affine/component/ui/menu';
|
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
|
||||||
import {
|
|
||||||
AccountIcon,
|
|
||||||
MoreHorizontalIcon,
|
|
||||||
SignOutIcon,
|
|
||||||
} from '@blocksuite/icons';
|
|
||||||
import { useSetAtom } from 'jotai';
|
|
||||||
import { useCallback } from 'react';
|
|
||||||
|
|
||||||
import {
|
|
||||||
openSettingModalAtom,
|
|
||||||
openSignOutModalAtom,
|
|
||||||
} from '../../../../../atoms';
|
|
||||||
import { UserPlanButton } from '../../../../affine/auth/user-plan-button';
|
import { UserPlanButton } from '../../../../affine/auth/user-plan-button';
|
||||||
import * as styles from './index.css';
|
import * as styles from './index.css';
|
||||||
|
|
||||||
const AccountMenu = ({ onEventEnd }: { onEventEnd?: () => void }) => {
|
|
||||||
const setSettingModalAtom = useSetAtom(openSettingModalAtom);
|
|
||||||
const setOpenSignOutModalAtom = useSetAtom(openSignOutModalAtom);
|
|
||||||
|
|
||||||
const onOpenAccountSetting = useCallback(() => {
|
|
||||||
setSettingModalAtom(prev => ({
|
|
||||||
...prev,
|
|
||||||
open: true,
|
|
||||||
activeTab: 'account',
|
|
||||||
}));
|
|
||||||
}, [setSettingModalAtom]);
|
|
||||||
|
|
||||||
const onOpenSignOutModal = useCallback(() => {
|
|
||||||
onEventEnd?.();
|
|
||||||
setOpenSignOutModalAtom(true);
|
|
||||||
}, [onEventEnd, setOpenSignOutModalAtom]);
|
|
||||||
|
|
||||||
const t = useAFFiNEI18N();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<MenuItem
|
|
||||||
preFix={
|
|
||||||
<MenuIcon>
|
|
||||||
<AccountIcon />
|
|
||||||
</MenuIcon>
|
|
||||||
}
|
|
||||||
data-testid="workspace-modal-account-settings-option"
|
|
||||||
onClick={onOpenAccountSetting}
|
|
||||||
>
|
|
||||||
{t['com.affine.workspace.cloud.account.settings']()}
|
|
||||||
</MenuItem>
|
|
||||||
<Divider />
|
|
||||||
<MenuItem
|
|
||||||
preFix={
|
|
||||||
<MenuIcon>
|
|
||||||
<SignOutIcon />
|
|
||||||
</MenuIcon>
|
|
||||||
}
|
|
||||||
data-testid="workspace-modal-sign-out-option"
|
|
||||||
onClick={onOpenSignOutModal}
|
|
||||||
>
|
|
||||||
{t['com.affine.workspace.cloud.account.logout']()}
|
|
||||||
</MenuItem>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const UserAccountItem = ({
|
export const UserAccountItem = ({
|
||||||
email,
|
email,
|
||||||
onEventEnd,
|
|
||||||
}: {
|
}: {
|
||||||
email: string;
|
email: string;
|
||||||
onEventEnd?: () => void;
|
onEventEnd?: () => void;
|
||||||
@@ -76,21 +11,8 @@ export const UserAccountItem = ({
|
|||||||
<div className={styles.userAccountContainer}>
|
<div className={styles.userAccountContainer}>
|
||||||
<div className={styles.leftContainer}>
|
<div className={styles.leftContainer}>
|
||||||
<div className={styles.userEmail}>{email}</div>
|
<div className={styles.userEmail}>{email}</div>
|
||||||
<UserPlanButton />
|
|
||||||
</div>
|
</div>
|
||||||
<Menu
|
<UserPlanButton />
|
||||||
items={<AccountMenu onEventEnd={onEventEnd} />}
|
|
||||||
contentOptions={{
|
|
||||||
side: 'right',
|
|
||||||
sideOffset: 12,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<IconButton
|
|
||||||
data-testid="workspace-modal-account-option"
|
|
||||||
icon={<MoreHorizontalIcon />}
|
|
||||||
type="plain"
|
|
||||||
/>
|
|
||||||
</Menu>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+6
-2
@@ -10,17 +10,21 @@ export const workspaceListWrapper = style({
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
gap: '4px',
|
gap: 2,
|
||||||
});
|
});
|
||||||
export const workspaceType = style({
|
export const workspaceType = style({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'space-between',
|
gap: 4,
|
||||||
padding: '0px 12px',
|
padding: '0px 12px',
|
||||||
|
fontWeight: 500,
|
||||||
fontSize: cssVar('fontXs'),
|
fontSize: cssVar('fontXs'),
|
||||||
lineHeight: '20px',
|
lineHeight: '20px',
|
||||||
color: cssVar('textSecondaryColor'),
|
color: cssVar('textSecondaryColor'),
|
||||||
});
|
});
|
||||||
|
export const workspaceTypeIcon = style({
|
||||||
|
color: cssVar('iconSecondary'),
|
||||||
|
});
|
||||||
export const scrollbar = style({
|
export const scrollbar = style({
|
||||||
transform: 'translateX(8px)',
|
transform: 'translateX(8px)',
|
||||||
width: '4px',
|
width: '4px',
|
||||||
|
|||||||
+11
@@ -8,6 +8,7 @@ import {
|
|||||||
} from '@affine/core/hooks/use-workspace-info';
|
} from '@affine/core/hooks/use-workspace-info';
|
||||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
|
import { CloudWorkspaceIcon, LocalWorkspaceIcon } from '@blocksuite/icons';
|
||||||
import type { DragEndEvent } from '@dnd-kit/core';
|
import type { DragEndEvent } from '@dnd-kit/core';
|
||||||
import type { WorkspaceMetadata } from '@toeverything/infra';
|
import type { WorkspaceMetadata } from '@toeverything/infra';
|
||||||
import { useLiveData, useService, WorkspaceManager } from '@toeverything/infra';
|
import { useLiveData, useService, WorkspaceManager } from '@toeverything/infra';
|
||||||
@@ -49,6 +50,11 @@ const CloudWorkSpaceList = ({
|
|||||||
return (
|
return (
|
||||||
<div className={styles.workspaceListWrapper}>
|
<div className={styles.workspaceListWrapper}>
|
||||||
<div className={styles.workspaceType}>
|
<div className={styles.workspaceType}>
|
||||||
|
<CloudWorkspaceIcon
|
||||||
|
width={14}
|
||||||
|
height={14}
|
||||||
|
className={styles.workspaceTypeIcon}
|
||||||
|
/>
|
||||||
{t['com.affine.workspaceList.workspaceListType.cloud']()}
|
{t['com.affine.workspaceList.workspaceListType.cloud']()}
|
||||||
</div>
|
</div>
|
||||||
<WorkspaceList
|
<WorkspaceList
|
||||||
@@ -81,6 +87,11 @@ const LocalWorkspaces = ({
|
|||||||
return (
|
return (
|
||||||
<div className={styles.workspaceListWrapper}>
|
<div className={styles.workspaceListWrapper}>
|
||||||
<div className={styles.workspaceType}>
|
<div className={styles.workspaceType}>
|
||||||
|
<LocalWorkspaceIcon
|
||||||
|
width={14}
|
||||||
|
height={14}
|
||||||
|
className={styles.workspaceTypeIcon}
|
||||||
|
/>
|
||||||
{t['com.affine.workspaceList.workspaceListType.local']()}
|
{t['com.affine.workspaceList.workspaceListType.local']()}
|
||||||
</div>
|
</div>
|
||||||
<WorkspaceList
|
<WorkspaceList
|
||||||
|
|||||||
+45
-25
@@ -1,7 +1,7 @@
|
|||||||
|
import { Tooltip } from '@affine/component';
|
||||||
import { pushNotificationAtom } from '@affine/component/notification-center';
|
import { pushNotificationAtom } from '@affine/component/notification-center';
|
||||||
import { Avatar } from '@affine/component/ui/avatar';
|
import { Avatar, type AvatarProps } from '@affine/component/ui/avatar';
|
||||||
import { Loading } from '@affine/component/ui/loading';
|
import { Loading } from '@affine/component/ui/loading';
|
||||||
import { Tooltip } from '@affine/component/ui/tooltip';
|
|
||||||
import { openSettingModalAtom } from '@affine/core/atoms';
|
import { openSettingModalAtom } from '@affine/core/atoms';
|
||||||
import { useDocEngineStatus } from '@affine/core/hooks/affine/use-doc-engine-status';
|
import { useDocEngineStatus } from '@affine/core/hooks/affine/use-doc-engine-status';
|
||||||
import { useIsWorkspaceOwner } from '@affine/core/hooks/affine/use-is-workspace-owner';
|
import { useIsWorkspaceOwner } from '@affine/core/hooks/affine/use-is-workspace-owner';
|
||||||
@@ -24,21 +24,15 @@ import type { HTMLAttributes } from 'react';
|
|||||||
import { forwardRef, useCallback, useEffect, useMemo, useState } from 'react';
|
import { forwardRef, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
import { useSystemOnline } from '../../../../hooks/use-system-online';
|
import { useSystemOnline } from '../../../../hooks/use-system-online';
|
||||||
import {
|
import * as styles from './styles.css';
|
||||||
StyledSelectorContainer,
|
|
||||||
StyledSelectorWrapper,
|
|
||||||
StyledWorkspaceName,
|
|
||||||
StyledWorkspaceStatus,
|
|
||||||
} from './styles';
|
|
||||||
|
|
||||||
// FIXME:
|
// FIXME:
|
||||||
// 1. Remove mui style
|
|
||||||
// 2. Refactor the code to improve readability
|
// 2. Refactor the code to improve readability
|
||||||
const CloudWorkspaceStatus = () => {
|
const CloudWorkspaceStatus = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CloudWorkspaceIcon />
|
<CloudWorkspaceIcon />
|
||||||
AFFiNE Cloud
|
Cloud
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -196,21 +190,49 @@ const useSyncEngineSyncProgress = () => {
|
|||||||
) : (
|
) : (
|
||||||
<LocalWorkspaceStatus />
|
<LocalWorkspaceStatus />
|
||||||
),
|
),
|
||||||
|
active:
|
||||||
|
currentWorkspace.flavour === WorkspaceFlavour.AFFINE_CLOUD &&
|
||||||
|
(syncing || retrying || isOverCapacity),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const WorkspaceStatus = () => {
|
const WorkspaceInfo = ({ name }: { name: string }) => {
|
||||||
const { message, icon } = useSyncEngineSyncProgress();
|
const { message, icon, active } = useSyncEngineSyncProgress();
|
||||||
|
const currentWorkspace = useService(Workspace);
|
||||||
|
const isCloud = currentWorkspace.flavour === WorkspaceFlavour.AFFINE_CLOUD;
|
||||||
|
|
||||||
|
// to make sure that animation will play first time
|
||||||
|
const [delayActive, setDelayActive] = useState(false);
|
||||||
|
useEffect(() => {
|
||||||
|
setDelayActive(active);
|
||||||
|
}, [active]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'flex' }}>
|
<div className={styles.workspaceInfoSlider} data-active={delayActive}>
|
||||||
<Tooltip content={message}>
|
<div className={styles.workspaceInfoSlide}>
|
||||||
<StyledWorkspaceStatus>{icon}</StyledWorkspaceStatus>
|
<div className={styles.workspaceInfo} data-type="normal">
|
||||||
</Tooltip>
|
<div className={styles.workspaceName} data-testid="workspace-name">
|
||||||
|
{name}
|
||||||
|
</div>
|
||||||
|
<div className={styles.workspaceStatus}>
|
||||||
|
{isCloud ? <CloudWorkspaceStatus /> : <LocalWorkspaceStatus />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* when syncing/offline/... */}
|
||||||
|
<div className={styles.workspaceInfo} data-type="events">
|
||||||
|
<div className={styles.workspaceActiveStatus}>
|
||||||
|
<Tooltip content={message}>{icon}</Tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const avatarImageProps = {
|
||||||
|
style: { borderRadius: 3 },
|
||||||
|
} satisfies AvatarProps['imageProps'];
|
||||||
export const WorkspaceCard = forwardRef<
|
export const WorkspaceCard = forwardRef<
|
||||||
HTMLDivElement,
|
HTMLDivElement,
|
||||||
HTMLAttributes<HTMLDivElement>
|
HTMLAttributes<HTMLDivElement>
|
||||||
@@ -227,7 +249,8 @@ export const WorkspaceCard = forwardRef<
|
|||||||
const name = information?.name ?? UNTITLED_WORKSPACE_NAME;
|
const name = information?.name ?? UNTITLED_WORKSPACE_NAME;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledSelectorContainer
|
<div
|
||||||
|
className={styles.container}
|
||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
data-testid="current-workspace"
|
data-testid="current-workspace"
|
||||||
@@ -236,19 +259,16 @@ export const WorkspaceCard = forwardRef<
|
|||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
|
imageProps={avatarImageProps}
|
||||||
|
fallbackProps={avatarImageProps}
|
||||||
data-testid="workspace-avatar"
|
data-testid="workspace-avatar"
|
||||||
size={40}
|
size={32}
|
||||||
url={avatarUrl}
|
url={avatarUrl}
|
||||||
name={name}
|
name={name}
|
||||||
colorfulFallback
|
colorfulFallback
|
||||||
/>
|
/>
|
||||||
<StyledSelectorWrapper>
|
<WorkspaceInfo name={name} />
|
||||||
<StyledWorkspaceName data-testid="workspace-name">
|
</div>
|
||||||
{name}
|
|
||||||
</StyledWorkspaceName>
|
|
||||||
<WorkspaceStatus />
|
|
||||||
</StyledSelectorWrapper>
|
|
||||||
</StyledSelectorContainer>
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+99
@@ -0,0 +1,99 @@
|
|||||||
|
import { cssVar } from '@toeverything/theme';
|
||||||
|
import { globalStyle, style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
|
const wsSlideAnim = {
|
||||||
|
ease: 'cubic-bezier(.45,.21,0,1)',
|
||||||
|
duration: '0.5s',
|
||||||
|
delay: '0.23s',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const container = style({
|
||||||
|
height: '50px',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: 8,
|
||||||
|
padding: '0 6px',
|
||||||
|
borderRadius: 4,
|
||||||
|
outline: 'none',
|
||||||
|
width: '100%',
|
||||||
|
maxWidth: 500,
|
||||||
|
color: cssVar('textPrimaryColor'),
|
||||||
|
':hover': {
|
||||||
|
cursor: 'pointer',
|
||||||
|
background: cssVar('hoverColor'),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const workspaceInfoSlider = style({
|
||||||
|
height: 42,
|
||||||
|
overflow: 'hidden',
|
||||||
|
});
|
||||||
|
export const workspaceInfoSlide = style({
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
transform: 'translateY(0)',
|
||||||
|
transition: `transform ${wsSlideAnim.duration} ${wsSlideAnim.ease} ${wsSlideAnim.delay}`,
|
||||||
|
selectors: {
|
||||||
|
[`.${workspaceInfoSlider}[data-active="true"] &`]: {
|
||||||
|
transform: 'translateY(-42px)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
export const workspaceInfo = style({
|
||||||
|
width: '100%',
|
||||||
|
flexGrow: 1,
|
||||||
|
overflow: 'hidden',
|
||||||
|
height: 42,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
justifyContent: 'center',
|
||||||
|
transition: `opacity ${wsSlideAnim.duration} ${wsSlideAnim.ease} ${wsSlideAnim.delay}`,
|
||||||
|
|
||||||
|
selectors: {
|
||||||
|
[`.${workspaceInfoSlider}[data-active="true"] &[data-type="normal"]`]: {
|
||||||
|
opacity: 0,
|
||||||
|
},
|
||||||
|
[`.${workspaceInfoSlider}[data-active="false"] &[data-type="events"]`]: {
|
||||||
|
opacity: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const workspaceName = style({
|
||||||
|
fontSize: cssVar('fontSm'),
|
||||||
|
lineHeight: '22px',
|
||||||
|
fontWeight: 500,
|
||||||
|
userSelect: 'none',
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const workspaceStatus = style({
|
||||||
|
display: 'flex',
|
||||||
|
gap: 2,
|
||||||
|
alignItems: 'center',
|
||||||
|
fontSize: cssVar('fontXs'),
|
||||||
|
lineHeight: '20px',
|
||||||
|
fontWeight: 400,
|
||||||
|
color: cssVar('black50'),
|
||||||
|
});
|
||||||
|
globalStyle(`.${workspaceStatus} svg`, {
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
color: cssVar('iconSecondary'),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const workspaceActiveStatus = style({
|
||||||
|
display: 'flex',
|
||||||
|
gap: 2,
|
||||||
|
alignItems: 'center',
|
||||||
|
fontSize: cssVar('fontSm'),
|
||||||
|
lineHeight: '22px',
|
||||||
|
color: cssVar('textSecondaryColor'),
|
||||||
|
});
|
||||||
|
globalStyle(`.${workspaceActiveStatus} svg`, {
|
||||||
|
width: 16,
|
||||||
|
height: 16,
|
||||||
|
});
|
||||||
+13
-11
@@ -1,16 +1,18 @@
|
|||||||
import { displayFlex, styled, textEllipsis } from '@affine/component';
|
import { displayFlex, styled, textEllipsis } from '@affine/component';
|
||||||
|
import { cssVar } from '@toeverything/theme';
|
||||||
export const StyledSelectorContainer = styled('div')({
|
export const StyledSelectorContainer = styled('div')({
|
||||||
height: '58px',
|
height: '50px',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
padding: '0 6px',
|
padding: '0 6px',
|
||||||
borderRadius: '8px',
|
borderRadius: '8px',
|
||||||
outline: 'none',
|
outline: 'none',
|
||||||
width: '100%',
|
width: 'fit-content',
|
||||||
color: 'var(--affine-text-primary-color)',
|
maxWidth: '100%',
|
||||||
|
color: cssVar('textPrimaryColor'),
|
||||||
':hover': {
|
':hover': {
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
background: 'var(--affine-hover-color)',
|
background: cssVar('hoverColor'),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -23,8 +25,9 @@ export const StyledSelectorWrapper = styled('div')(() => {
|
|||||||
});
|
});
|
||||||
export const StyledWorkspaceName = styled('div')(() => {
|
export const StyledWorkspaceName = styled('div')(() => {
|
||||||
return {
|
return {
|
||||||
lineHeight: '24px',
|
fontSize: cssVar('fontSm'),
|
||||||
fontWeight: 600,
|
lineHeight: '22px',
|
||||||
|
fontWeight: 500,
|
||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
...textEllipsis(1),
|
...textEllipsis(1),
|
||||||
marginLeft: '4px',
|
marginLeft: '4px',
|
||||||
@@ -35,17 +38,16 @@ export const StyledWorkspaceStatus = styled('div')(() => {
|
|||||||
return {
|
return {
|
||||||
height: '22px',
|
height: '22px',
|
||||||
...displayFlex('flex-start', 'center'),
|
...displayFlex('flex-start', 'center'),
|
||||||
fontSize: 'var(--affine-font-sm)',
|
fontSize: cssVar('fontXs'),
|
||||||
color: 'var(--affine-text-secondary-color)',
|
color: cssVar('black50'),
|
||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
padding: '0 4px',
|
padding: '0 4px',
|
||||||
gap: '4px',
|
gap: '4px',
|
||||||
zIndex: '1',
|
zIndex: '1',
|
||||||
svg: {
|
svg: {
|
||||||
color: 'var(--affine-icon-color)',
|
color: cssVar('iconSecondary'),
|
||||||
fontSize: 'var(--affine-font-base)',
|
|
||||||
'&[data-warning-color="true"]': {
|
'&[data-warning-color="true"]': {
|
||||||
color: 'var(--affine-error-color)',
|
color: cssVar('errorColor'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
|
export const workspaceAndUserWrapper = style({
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
gap: 8,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const workspaceWrapper = style({
|
||||||
|
width: 0,
|
||||||
|
flex: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const userInfoWrapper = style({
|
||||||
|
flexShrink: 0,
|
||||||
|
width: 28,
|
||||||
|
height: 28,
|
||||||
|
});
|
||||||
@@ -42,8 +42,10 @@ import { AddFavouriteButton } from '../pure/workspace-slider-bar/favorite/add-fa
|
|||||||
import FavoriteList from '../pure/workspace-slider-bar/favorite/favorite-list';
|
import FavoriteList from '../pure/workspace-slider-bar/favorite/favorite-list';
|
||||||
import { WorkspaceSelector } from '../workspace-selector';
|
import { WorkspaceSelector } from '../workspace-selector';
|
||||||
import ImportPage from './import-page';
|
import ImportPage from './import-page';
|
||||||
|
import { workspaceAndUserWrapper, workspaceWrapper } from './index.css';
|
||||||
import { AppSidebarJournalButton } from './journal-button';
|
import { AppSidebarJournalButton } from './journal-button';
|
||||||
import { UpdaterButton } from './updater-button';
|
import { UpdaterButton } from './updater-button';
|
||||||
|
import { UserInfo } from './user-info';
|
||||||
|
|
||||||
export type RootAppSidebarProps = {
|
export type RootAppSidebarProps = {
|
||||||
isPublicWorkspace: boolean;
|
isPublicWorkspace: boolean;
|
||||||
@@ -179,7 +181,12 @@ export const RootAppSidebar = ({
|
|||||||
titles={deletePageTitles}
|
titles={deletePageTitles}
|
||||||
/>
|
/>
|
||||||
<SidebarContainer>
|
<SidebarContainer>
|
||||||
<WorkspaceSelector />
|
<div className={workspaceAndUserWrapper}>
|
||||||
|
<div className={workspaceWrapper}>
|
||||||
|
<WorkspaceSelector />
|
||||||
|
</div>
|
||||||
|
<UserInfo />
|
||||||
|
</div>
|
||||||
<QuickSearchInput
|
<QuickSearchInput
|
||||||
data-testid="slider-bar-quick-search-button"
|
data-testid="slider-bar-quick-search-button"
|
||||||
onClick={onOpenQuickSearchModal}
|
onClick={onOpenQuickSearchModal}
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
import {
|
||||||
|
Avatar,
|
||||||
|
Button,
|
||||||
|
Divider,
|
||||||
|
Menu,
|
||||||
|
MenuIcon,
|
||||||
|
MenuItem,
|
||||||
|
} from '@affine/component';
|
||||||
|
import {
|
||||||
|
authAtom,
|
||||||
|
openDisableCloudAlertModalAtom,
|
||||||
|
openSettingModalAtom,
|
||||||
|
openSignOutModalAtom,
|
||||||
|
} from '@affine/core/atoms';
|
||||||
|
import {
|
||||||
|
useCurrentUser,
|
||||||
|
useSession,
|
||||||
|
} from '@affine/core/hooks/affine/use-current-user';
|
||||||
|
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||||
|
import { AccountIcon, SignOutIcon } from '@blocksuite/icons';
|
||||||
|
import { cssVar } from '@toeverything/theme';
|
||||||
|
import { useSetAtom } from 'jotai';
|
||||||
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
|
import * as styles from './index.css';
|
||||||
|
|
||||||
|
export const UserInfo = () => {
|
||||||
|
const { status } = useSession();
|
||||||
|
const isAuthenticated = status === 'authenticated';
|
||||||
|
return isAuthenticated ? <AuthorizedUserInfo /> : <UnauthorizedUserInfo />;
|
||||||
|
};
|
||||||
|
|
||||||
|
const AuthorizedUserInfo = () => {
|
||||||
|
const user = useCurrentUser();
|
||||||
|
return (
|
||||||
|
<Menu items={<OperationMenu />}>
|
||||||
|
<Button
|
||||||
|
data-testid="sidebar-user-avatar"
|
||||||
|
type="plain"
|
||||||
|
className={styles.userInfoWrapper}
|
||||||
|
>
|
||||||
|
<Avatar size={20} name={user.name} url={user.avatarUrl} />
|
||||||
|
</Button>
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const UnauthorizedUserInfo = () => {
|
||||||
|
const setDisableCloudOpen = useSetAtom(openDisableCloudAlertModalAtom);
|
||||||
|
const setOpen = useSetAtom(authAtom);
|
||||||
|
|
||||||
|
const openSignInModal = useCallback(() => {
|
||||||
|
if (!runtimeConfig.enableCloud) setDisableCloudOpen(true);
|
||||||
|
else setOpen(state => ({ ...state, openModal: true }));
|
||||||
|
}, [setDisableCloudOpen, setOpen]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
onClick={openSignInModal}
|
||||||
|
data-testid="sidebar-user-avatar"
|
||||||
|
type="plain"
|
||||||
|
className={styles.userInfoWrapper}
|
||||||
|
>
|
||||||
|
<Avatar
|
||||||
|
style={{ color: cssVar('black') }}
|
||||||
|
size={20}
|
||||||
|
url={'/imgs/unknown-user.svg'}
|
||||||
|
/>
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const AccountMenu = () => {
|
||||||
|
const setSettingModalAtom = useSetAtom(openSettingModalAtom);
|
||||||
|
const setOpenSignOutModalAtom = useSetAtom(openSignOutModalAtom);
|
||||||
|
|
||||||
|
const onOpenAccountSetting = useCallback(() => {
|
||||||
|
setSettingModalAtom(prev => ({
|
||||||
|
...prev,
|
||||||
|
open: true,
|
||||||
|
activeTab: 'account',
|
||||||
|
}));
|
||||||
|
}, [setSettingModalAtom]);
|
||||||
|
|
||||||
|
const onOpenSignOutModal = useCallback(() => {
|
||||||
|
setOpenSignOutModalAtom(true);
|
||||||
|
}, [setOpenSignOutModalAtom]);
|
||||||
|
|
||||||
|
const t = useAFFiNEI18N();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<MenuItem
|
||||||
|
preFix={
|
||||||
|
<MenuIcon>
|
||||||
|
<AccountIcon />
|
||||||
|
</MenuIcon>
|
||||||
|
}
|
||||||
|
data-testid="workspace-modal-account-settings-option"
|
||||||
|
onClick={onOpenAccountSetting}
|
||||||
|
>
|
||||||
|
{t['com.affine.workspace.cloud.account.settings']()}
|
||||||
|
</MenuItem>
|
||||||
|
<Divider />
|
||||||
|
<MenuItem
|
||||||
|
preFix={
|
||||||
|
<MenuIcon>
|
||||||
|
<SignOutIcon />
|
||||||
|
</MenuIcon>
|
||||||
|
}
|
||||||
|
data-testid="workspace-modal-sign-out-option"
|
||||||
|
onClick={onOpenSignOutModal}
|
||||||
|
>
|
||||||
|
{t['com.affine.workspace.cloud.account.logout']()}
|
||||||
|
</MenuItem>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const OperationMenu = () => {
|
||||||
|
// TODO: display usage progress bar
|
||||||
|
const StorageUsage = null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{StorageUsage}
|
||||||
|
<AccountMenu />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -3,7 +3,7 @@ import { style } from '@vanilla-extract/css';
|
|||||||
export const container = style({
|
export const container = style({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
columnGap: '32px',
|
columnGap: '8px',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const button = style({
|
export const button = style({
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
clickSideBarAllPageButton,
|
clickSideBarAllPageButton,
|
||||||
clickSideBarCurrentWorkspaceBanner,
|
clickSideBarCurrentWorkspaceBanner,
|
||||||
clickSideBarSettingButton,
|
clickSideBarSettingButton,
|
||||||
|
clickSideBarUseAvatar,
|
||||||
} from '@affine-test/kit/utils/sidebar';
|
} from '@affine-test/kit/utils/sidebar';
|
||||||
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
|
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
@@ -69,14 +70,13 @@ test.describe('login first', () => {
|
|||||||
);
|
);
|
||||||
await clickSideBarAllPageButton(page);
|
await clickSideBarAllPageButton(page);
|
||||||
const currentUrl = page.url();
|
const currentUrl = page.url();
|
||||||
await clickSideBarCurrentWorkspaceBanner(page);
|
await clickSideBarUseAvatar(page);
|
||||||
await page.getByTestId('workspace-modal-account-option').click();
|
|
||||||
await page.getByTestId('workspace-modal-sign-out-option').click();
|
await page.getByTestId('workspace-modal-sign-out-option').click();
|
||||||
await page.getByTestId('confirm-sign-out-button').click();
|
await page.getByTestId('confirm-sign-out-button').click();
|
||||||
await page.reload();
|
await page.reload();
|
||||||
await clickSideBarCurrentWorkspaceBanner(page);
|
await clickSideBarUseAvatar(page);
|
||||||
const signInButton = page.getByTestId('cloud-signin-button');
|
const authModal = page.getByTestId('auth-modal');
|
||||||
await expect(signInButton).toBeVisible();
|
await expect(authModal).toBeVisible();
|
||||||
expect(page.url()).toBe(currentUrl);
|
expect(page.url()).toBe(currentUrl);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ async function importImage(page: Page, url: string) {
|
|||||||
},
|
},
|
||||||
[url]
|
[url]
|
||||||
);
|
);
|
||||||
await page.waitForTimeout(500);
|
// TODO: wait for image to be loaded more reliably
|
||||||
|
await page.waitForTimeout(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function closeImagePreviewModal(page: Page) {
|
async function closeImagePreviewModal(page: Page) {
|
||||||
@@ -53,7 +54,7 @@ test('image preview should be shown', async ({ page }) => {
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
await expect(locator).toBeVisible();
|
await expect(locator).toBeVisible();
|
||||||
await closeImagePreviewModal(page);
|
await closeImagePreviewModal(page);
|
||||||
@@ -70,11 +71,12 @@ test('image go left and right', async ({ page }) => {
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
blobId = (await page
|
blobId = (await page
|
||||||
|
.getByTestId('image-preview-modal')
|
||||||
.locator('img')
|
.locator('img')
|
||||||
.nth(1)
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
await closeImagePreviewModal(page);
|
await closeImagePreviewModal(page);
|
||||||
@@ -87,11 +89,12 @@ test('image go left and right', async ({ page }) => {
|
|||||||
}
|
}
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
await expect(locator).toBeHidden();
|
await expect(locator).toBeHidden();
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
{
|
{
|
||||||
const newBlobId = (await locator
|
const newBlobId = (await page
|
||||||
.locator('img[data-blob-id]')
|
.getByTestId('image-preview-modal')
|
||||||
|
.locator('img')
|
||||||
.first()
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(newBlobId).not.toBe(blobId);
|
expect(newBlobId).not.toBe(blobId);
|
||||||
@@ -99,8 +102,9 @@ test('image go left and right', async ({ page }) => {
|
|||||||
await page.keyboard.press('ArrowRight');
|
await page.keyboard.press('ArrowRight');
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
{
|
{
|
||||||
const newBlobId = (await locator
|
const newBlobId = (await page
|
||||||
.locator('img[data-blob-id]')
|
.getByTestId('image-preview-modal')
|
||||||
|
.locator('img')
|
||||||
.first()
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(newBlobId).toBe(blobId);
|
expect(newBlobId).toBe(blobId);
|
||||||
@@ -117,11 +121,12 @@ test('image able to zoom in and out with mouse scroll', async ({ page }) => {
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
blobId = (await page
|
blobId = (await page
|
||||||
|
.getByTestId('image-preview-modal')
|
||||||
.locator('img')
|
.locator('img')
|
||||||
.nth(1)
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
@@ -170,11 +175,12 @@ test('image able to zoom in and out with button click', async ({ page }) => {
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
blobId = (await page
|
blobId = (await page
|
||||||
|
.getByTestId('image-preview-modal')
|
||||||
.locator('img')
|
.locator('img')
|
||||||
.nth(1)
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
@@ -216,11 +222,12 @@ test('image should able to go left and right by buttons', async ({ page }) => {
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
blobId = (await page
|
blobId = (await page
|
||||||
|
.getByTestId('image-preview-modal')
|
||||||
.locator('img')
|
.locator('img')
|
||||||
.nth(1)
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
await closeImagePreviewModal(page);
|
await closeImagePreviewModal(page);
|
||||||
@@ -232,7 +239,7 @@ test('image should able to go left and right by buttons', async ({ page }) => {
|
|||||||
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
||||||
}
|
}
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await expect(locator).toBeVisible();
|
await expect(locator).toBeVisible();
|
||||||
{
|
{
|
||||||
const newBlobId = (await locator
|
const newBlobId = (await locator
|
||||||
@@ -268,11 +275,12 @@ test('image able to fit to screen by button', async ({ page }) => {
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
blobId = (await page
|
blobId = (await page
|
||||||
|
.getByTestId('image-preview-modal')
|
||||||
.locator('img')
|
.locator('img')
|
||||||
.nth(1)
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
@@ -325,11 +333,12 @@ test('image able to reset zoom to 100%', async ({ page }) => {
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
blobId = (await page
|
blobId = (await page
|
||||||
|
.getByTestId('image-preview-modal')
|
||||||
.locator('img')
|
.locator('img')
|
||||||
.nth(1)
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
@@ -378,11 +387,12 @@ test('image able to copy to clipboard', async ({ page }) => {
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
blobId = (await page
|
blobId = (await page
|
||||||
|
.getByTestId('image-preview-modal')
|
||||||
.locator('img')
|
.locator('img')
|
||||||
.nth(1)
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
@@ -407,11 +417,12 @@ test('image able to download', async ({ page }) => {
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
blobId = (await page
|
blobId = (await page
|
||||||
|
.getByTestId('image-preview-modal')
|
||||||
.locator('img')
|
.locator('img')
|
||||||
.nth(1)
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
@@ -437,11 +448,12 @@ test('image should only able to move when image is larger than viewport', async
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
blobId = (await page
|
blobId = (await page
|
||||||
|
.getByTestId('image-preview-modal')
|
||||||
.locator('img')
|
.locator('img')
|
||||||
.nth(1)
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
@@ -494,11 +506,12 @@ test('image should able to delete and when delete, it will move to previous/next
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
blobId = (await page
|
blobId = (await page
|
||||||
|
.getByTestId('image-preview-modal')
|
||||||
.locator('img')
|
.locator('img')
|
||||||
.nth(1)
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
await closeImagePreviewModal(page);
|
await closeImagePreviewModal(page);
|
||||||
@@ -510,7 +523,7 @@ test('image should able to delete and when delete, it will move to previous/next
|
|||||||
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
||||||
}
|
}
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await expect(locator).toBeVisible();
|
await expect(locator).toBeVisible();
|
||||||
// ensure the new image was imported
|
// ensure the new image was imported
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
@@ -533,7 +546,7 @@ test('image should able to delete and when delete, it will move to previous/next
|
|||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
||||||
}
|
}
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await locator.getByTestId('next-image-button').click();
|
await locator.getByTestId('next-image-button').click();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
{
|
{
|
||||||
@@ -569,11 +582,12 @@ test('tooltips for all buttons should be visible when hovering', async ({
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
blobId = (await page
|
blobId = (await page
|
||||||
|
.getByTestId('image-preview-modal')
|
||||||
.locator('img')
|
.locator('img')
|
||||||
.nth(1)
|
.first()
|
||||||
.getAttribute('data-blob-id')) as string;
|
.getAttribute('data-blob-id')) as string;
|
||||||
expect(blobId).toBeTruthy();
|
expect(blobId).toBeTruthy();
|
||||||
}
|
}
|
||||||
@@ -662,7 +676,7 @@ test('keypress esc should close the modal', async ({ page }) => {
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
await expect(locator).toBeVisible();
|
await expect(locator).toBeVisible();
|
||||||
await page.keyboard.press('Escape');
|
await page.keyboard.press('Escape');
|
||||||
@@ -680,7 +694,7 @@ test('when mouse moves outside, the modal should be closed', async ({
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
await expect(locator).toBeVisible();
|
await expect(locator).toBeVisible();
|
||||||
// animation delay
|
// animation delay
|
||||||
@@ -701,14 +715,14 @@ test('caption should be visible and different styles were applied if image zoome
|
|||||||
await title.click();
|
await title.click();
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||||
await page.locator('img').first().hover();
|
await page.locator('affine-page-image').first().hover();
|
||||||
await page
|
await page
|
||||||
.locator('.embed-editing-state')
|
.locator('.embed-editing-state')
|
||||||
.locator('icon-button')
|
.locator('icon-button')
|
||||||
.nth(1)
|
.nth(1)
|
||||||
.click();
|
.click();
|
||||||
await page.getByPlaceholder('Write a caption').fill(sampleCaption);
|
await page.getByPlaceholder('Write a caption').fill(sampleCaption);
|
||||||
await page.locator('img').first().dblclick();
|
await page.locator('affine-page-image').first().dblclick();
|
||||||
const locator = page.getByTestId('image-preview-modal');
|
const locator = page.getByTestId('image-preview-modal');
|
||||||
await expect(locator).toBeVisible();
|
await expect(locator).toBeVisible();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ export async function clickSideBarCurrentWorkspaceBanner(page: Page) {
|
|||||||
return page.getByTestId('current-workspace').click();
|
return page.getByTestId('current-workspace').click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function clickSideBarUseAvatar(page: Page) {
|
||||||
|
return page.getByTestId('sidebar-user-avatar').click();
|
||||||
|
}
|
||||||
|
|
||||||
export async function clickNewPageButton(page: Page) {
|
export async function clickNewPageButton(page: Page) {
|
||||||
return page.getByTestId('sidebar-new-page-button').click();
|
return page.getByTestId('sidebar-new-page-button').click();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user