feat(core): add deleted state for sidebar journal template (#9980)
This commit is contained in:
@@ -5,13 +5,35 @@ export const container = style({
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
padding: '8px 16px',
|
padding: '8px 16px',
|
||||||
borderTop: `0.5px solid ${cssVarV2.layer.insideBorder.border}`,
|
borderTop: `0.5px solid ${cssVarV2.layer.insideBorder.border}`,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const trigger = style({
|
export const trigger = style({
|
||||||
padding: '2px 4px',
|
padding: '2px 4px',
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
|
flexShrink: 1,
|
||||||
|
minWidth: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const menu = style({
|
export const menu = style({
|
||||||
width: 280,
|
width: 280,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const deletedText = style({
|
||||||
|
textDecoration: 'line-through',
|
||||||
|
color: cssVarV2.text.placeholder,
|
||||||
|
});
|
||||||
|
export const deletedIcon = style({
|
||||||
|
color: cssVarV2.text.placeholder,
|
||||||
|
});
|
||||||
|
export const deletedTag = style({
|
||||||
|
height: 20,
|
||||||
|
borderRadius: 4,
|
||||||
|
border: `1px solid ${cssVarV2.button.error}`,
|
||||||
|
color: cssVarV2.button.error,
|
||||||
|
fontSize: 12,
|
||||||
|
lineHeight: '20px',
|
||||||
|
padding: '0 8px',
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
import { Button, Menu } from '@affine/component';
|
import { Button, Menu } from '@affine/component';
|
||||||
|
import { DocsService } from '@affine/core/modules/doc';
|
||||||
import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta';
|
import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta';
|
||||||
import { TemplateDocService } from '@affine/core/modules/template-doc';
|
import { TemplateDocService } from '@affine/core/modules/template-doc';
|
||||||
import { TemplateListMenuContentScrollable } from '@affine/core/modules/template-doc/view/template-list-menu';
|
import { TemplateListMenuContentScrollable } from '@affine/core/modules/template-doc/view/template-list-menu';
|
||||||
|
import { useI18n } from '@affine/i18n';
|
||||||
import { TemplateIcon } from '@blocksuite/icons/rc';
|
import { TemplateIcon } from '@blocksuite/icons/rc';
|
||||||
import { useLiveData, useService } from '@toeverything/infra';
|
import { useLiveData, useService } from '@toeverything/infra';
|
||||||
|
import clsx from 'clsx';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import * as styles from './template-setting.css';
|
import * as styles from './template-setting.css';
|
||||||
|
|
||||||
export const JournalTemplateSetting = () => {
|
export const JournalTemplateSetting = () => {
|
||||||
|
const t = useI18n();
|
||||||
const templateDocService = useService(TemplateDocService);
|
const templateDocService = useService(TemplateDocService);
|
||||||
const docDisplayService = useService(DocDisplayMetaService);
|
const docDisplayService = useService(DocDisplayMetaService);
|
||||||
const journalTemplateDocId = useLiveData(
|
const journalTemplateDocId = useLiveData(
|
||||||
templateDocService.setting.journalTemplateDocId$
|
templateDocService.setting.journalTemplateDocId$
|
||||||
);
|
);
|
||||||
|
const docsService = useService(DocsService);
|
||||||
|
|
||||||
const title = useLiveData(
|
const title = useLiveData(
|
||||||
useMemo(() => {
|
useMemo(() => {
|
||||||
@@ -22,6 +27,10 @@ export const JournalTemplateSetting = () => {
|
|||||||
: null;
|
: null;
|
||||||
}, [docDisplayService, journalTemplateDocId])
|
}, [docDisplayService, journalTemplateDocId])
|
||||||
);
|
);
|
||||||
|
const journalTemplateDoc = useLiveData(
|
||||||
|
journalTemplateDocId ? docsService.list.doc$(journalTemplateDocId) : null
|
||||||
|
);
|
||||||
|
const isDeleted = useLiveData(journalTemplateDoc?.trash$);
|
||||||
|
|
||||||
const updateJournalTemplate = useCallback(
|
const updateJournalTemplate = useCallback(
|
||||||
(templateId: string) => {
|
(templateId: string) => {
|
||||||
@@ -40,12 +49,21 @@ export const JournalTemplateSetting = () => {
|
|||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="plain"
|
variant="plain"
|
||||||
prefix={<TemplateIcon />}
|
prefix={
|
||||||
|
<TemplateIcon
|
||||||
|
className={clsx({ [styles.deletedIcon]: isDeleted })}
|
||||||
|
/>
|
||||||
|
}
|
||||||
className={styles.trigger}
|
className={styles.trigger}
|
||||||
>
|
>
|
||||||
{title}
|
{isDeleted ? (
|
||||||
|
<del className={styles.deletedText}>{title}</del>
|
||||||
|
) : (
|
||||||
|
title
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
{isDeleted && <div className={styles.deletedTag}>{t['Deleted']()}</div>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
"DB_FILE_PATH_INVALID": "Database file path invalid",
|
"DB_FILE_PATH_INVALID": "Database file path invalid",
|
||||||
"Date": "Date",
|
"Date": "Date",
|
||||||
"Delete": "Delete",
|
"Delete": "Delete",
|
||||||
|
"Deleted": "Deleted",
|
||||||
"Disable": "Disable",
|
"Disable": "Disable",
|
||||||
"Disable Public Sharing": "Disable public sharing",
|
"Disable Public Sharing": "Disable public sharing",
|
||||||
"Disable Snapshot": "Disable snapshot",
|
"Disable Snapshot": "Disable snapshot",
|
||||||
|
|||||||
Reference in New Issue
Block a user