feat(core): download template from snapshot url (#8211)

This commit is contained in:
EYHN
2024-09-12 06:21:51 +00:00
parent aad7b90859
commit 3999b04cf1
12 changed files with 87 additions and 94 deletions
@@ -3,20 +3,18 @@ import { useNavigateHelper } from '@affine/core/hooks/use-navigate-helper';
import { useI18n } from '@affine/i18n';
export const ImportTemplateButton = ({
workspaceId,
docId,
name,
snapshotUrl,
}: {
workspaceId: string;
docId: string;
name: string;
snapshotUrl: string;
}) => {
const t = useI18n();
const { jumpToImportTemplate } = useNavigateHelper();
return (
<Button
variant="primary"
onClick={() => jumpToImportTemplate(workspaceId, docId, name)}
onClick={() => jumpToImportTemplate(name, snapshotUrl)}
>
{t['com.affine.share-page.header.import-template']()}
</Button>
@@ -9,19 +9,17 @@ import * as styles from './styles.css';
import { PublishPageUserAvatar } from './user-avatar';
export type ShareHeaderRightItemProps = {
workspaceId: string;
docId: string;
publishMode: DocMode;
isTemplate?: boolean;
templateName?: string;
snapshotUrl?: string;
};
const ShareHeaderRightItem = ({
publishMode,
isTemplate,
templateName,
workspaceId,
docId,
snapshotUrl,
}: ShareHeaderRightItemProps) => {
const loginStatus = useLiveData(useService(AuthService).session.status$);
const authenticated = loginStatus === 'authenticated';
@@ -29,9 +27,8 @@ const ShareHeaderRightItem = ({
<div className={styles.rightItemContainer}>
{isTemplate ? (
<ImportTemplateButton
docId={docId}
workspaceId={workspaceId}
name={templateName ?? ''}
snapshotUrl={snapshotUrl ?? ''}
/>
) : (
<>