Merge pull request #881 from toeverything/fix-workspace-type

fix: workspace type wrong
This commit is contained in:
DarkSky 2023-02-08 23:21:08 +08:00 committed by GitHub
commit 4d689529b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,33 @@ import { StyleWorkspaceInfo, StyleWorkspaceTitle, StyledCard } from './styles';
import { useTranslation } from '@affine/i18n';
import { FlexWrapper } from '@/ui/layout';
const WorkspaceType = ({ workspaceData }: { workspaceData: WorkspaceUnit }) => {
const { user } = useAppState();
const { t } = useTranslation();
const isOwner = user?.id === workspaceData.owner?.id;
if (workspaceData.provider === 'local') {
return (
<p>
<LocalIcon />
{t('Local Workspace')}
</p>
);
}
return isOwner ? (
<p>
<CloudIcon />
{t('Cloud Workspace')}
</p>
) : (
<p>
<UsersIcon fontSize={20} color={'#FF646B'} />
{t('Joined Workspace')}
</p>
);
};
export const WorkspaceCard = ({
workspaceData,
onClick,
@ -19,7 +46,7 @@ export const WorkspaceCard = ({
workspaceData: WorkspaceUnit;
onClick: (data: WorkspaceUnit) => void;
}) => {
const { currentWorkspace, isOwner } = useAppState();
const { currentWorkspace } = useAppState();
const { t } = useTranslation();
return (
<StyledCard
@ -37,24 +64,7 @@ export const WorkspaceCard = ({
<StyleWorkspaceTitle>
{workspaceData.name || 'AFFiNE'}
</StyleWorkspaceTitle>
{isOwner ? (
workspaceData.provider === 'local' ? (
<p>
<LocalIcon />
{t('Local Workspace')}
</p>
) : (
<p>
<CloudIcon />
{t('Cloud Workspace')}
</p>
)
) : (
<p>
<UsersIcon fontSize={20} color={'#FF646B'} />
{t('Joined Workspace')}
</p>
)}
<WorkspaceType workspaceData={workspaceData} />
{workspaceData.provider === 'local' && (
<p>
<OfflineIcon />