mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-01 22:29:44 +08:00
feat: add worksapce type label (#4045)
Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import { useMemo } from 'react';
|
||||
import { useWorkspace } from '../../../hooks/use-workspace';
|
||||
import { DeleteLeaveWorkspace } from './delete-leave-workspace';
|
||||
import { ExportPanel } from './export';
|
||||
import { LabelsPanel } from './labels';
|
||||
import { MembersPanel } from './members';
|
||||
import { ProfilePanel } from './profile';
|
||||
import { PublishPanel } from './publish';
|
||||
@@ -69,6 +70,7 @@ export const WorkspaceSettingDetail = (props: WorkspaceSettingDetailProps) => {
|
||||
spreadCol={false}
|
||||
>
|
||||
<ProfilePanel workspace={workspace} {...props} />
|
||||
<LabelsPanel workspace={workspace} {...props} />
|
||||
</SettingRow>
|
||||
</SettingWrapper>
|
||||
<SettingWrapper title={t['AFFiNE Cloud']()}>
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import type { AffineOfficialWorkspace } from '@affine/env/workspace';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { type WorkspaceSettingDetailProps } from './index';
|
||||
import * as style from './style.css';
|
||||
|
||||
export interface LabelsPanelProps extends WorkspaceSettingDetailProps {
|
||||
workspace: AffineOfficialWorkspace;
|
||||
}
|
||||
|
||||
type WorkspaceStatus =
|
||||
| 'local'
|
||||
| 'syncCloud'
|
||||
| 'syncDocker'
|
||||
| 'selfHosted'
|
||||
| 'joinedWorkspace'
|
||||
| 'availableOffline'
|
||||
| 'publishedToWeb';
|
||||
|
||||
type LabelProps = {
|
||||
value: string;
|
||||
background: string;
|
||||
};
|
||||
|
||||
type LabelMap = {
|
||||
[key in WorkspaceStatus]: LabelProps;
|
||||
};
|
||||
type labelConditionsProps = {
|
||||
condition: boolean;
|
||||
label: WorkspaceStatus;
|
||||
};
|
||||
const Label = ({ value, background }: LabelProps) => {
|
||||
return (
|
||||
<div>
|
||||
<div className={style.workspaceLabel} style={{ background: background }}>
|
||||
{value}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export const LabelsPanel = ({ workspace, isOwner }: LabelsPanelProps) => {
|
||||
const labelMap: LabelMap = useMemo(
|
||||
() => ({
|
||||
local: {
|
||||
value: 'Local',
|
||||
background: 'var(--affine-tag-orange)',
|
||||
},
|
||||
syncCloud: {
|
||||
value: 'Sync with AFFiNE Cloud',
|
||||
background: 'var(--affine-tag-blue)',
|
||||
},
|
||||
syncDocker: {
|
||||
value: 'Sync with AFFiNE Docker',
|
||||
background: 'var(--affine-tag-green)',
|
||||
},
|
||||
selfHosted: {
|
||||
value: 'Self-Hosted Server',
|
||||
background: 'var(--affine-tag-purple)',
|
||||
},
|
||||
joinedWorkspace: {
|
||||
value: 'Joined Workspace',
|
||||
background: 'var(--affine-tag-yellow)',
|
||||
},
|
||||
availableOffline: {
|
||||
value: 'Available Offline',
|
||||
background: 'var(--affine-tag-green)',
|
||||
},
|
||||
publishedToWeb: {
|
||||
value: 'Published to Web',
|
||||
background: 'var(--affine-tag-blue)',
|
||||
},
|
||||
}),
|
||||
[]
|
||||
);
|
||||
const labelConditions: labelConditionsProps[] = [
|
||||
{ condition: !isOwner, label: 'joinedWorkspace' },
|
||||
{ condition: workspace.flavour === 'local', label: 'local' },
|
||||
{ condition: workspace.flavour === 'affine-cloud', label: 'syncCloud' },
|
||||
{
|
||||
condition: workspace.flavour === 'affine-public',
|
||||
label: 'publishedToWeb',
|
||||
},
|
||||
//TODO: add these labels
|
||||
// { status==="synced", label: 'availableOffline' }
|
||||
// { workspace.flavour === 'affine-Docker', label: 'syncDocker' }
|
||||
// { workspace.flavour === 'self-hosted', label: 'selfHosted' }
|
||||
];
|
||||
|
||||
return (
|
||||
<div className={style.labelWrapper}>
|
||||
{labelConditions.map(
|
||||
({ condition, label }) =>
|
||||
condition && (
|
||||
<Label
|
||||
key={label}
|
||||
value={labelMap[label].value}
|
||||
background={labelMap[label].background}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -12,6 +12,15 @@ export const profileHandlerWrapper = style({
|
||||
marginLeft: '20px',
|
||||
});
|
||||
|
||||
export const labelWrapper = style({
|
||||
width: '100%',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
marginTop: '24px',
|
||||
gap: '10px',
|
||||
flexWrap: 'wrap',
|
||||
});
|
||||
|
||||
export const avatarWrapper = style({
|
||||
width: '56px',
|
||||
height: '56px',
|
||||
@@ -146,3 +155,17 @@ export const label = style({
|
||||
color: 'var(--affine-text-secondary-color)',
|
||||
marginBottom: '5px',
|
||||
});
|
||||
export const workspaceLabel = style({
|
||||
width: '100%',
|
||||
display: 'flex',
|
||||
flexWrap: 'wrap',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
borderRadius: '6px',
|
||||
padding: '2px 10px',
|
||||
border: '1px solid var(--affine-white-30)',
|
||||
fontSize: 'var(--affine-font-xs)',
|
||||
color: 'var(--affine-text-primary-color)',
|
||||
lineHeight: '20px',
|
||||
whiteSpace: 'nowrap',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user