fix(client): only template creator can edit

This commit is contained in:
fantasticit 2022-02-21 09:05:27 +08:00
parent 41558d6ca8
commit 004236e12f
1 changed files with 14 additions and 10 deletions

View File

@ -14,6 +14,7 @@ import {
import { IconEdit, IconUser, IconPlus } from "@douyinfe/semi-icons"; import { IconEdit, IconUser, IconPlus } from "@douyinfe/semi-icons";
import { IconDocument } from "components/icons/IconDocument"; import { IconDocument } from "components/icons/IconDocument";
import { TemplateReader } from "components/template/reader"; import { TemplateReader } from "components/template/reader";
import { useUser } from "data/user";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import { useToggle } from "hooks/useToggle"; import { useToggle } from "hooks/useToggle";
@ -34,6 +35,7 @@ export const TemplateCard: React.FC<IProps> = ({
onOpenPreview, onOpenPreview,
onClosePreview, onClosePreview,
}) => { }) => {
const { user } = useUser();
const [visible, toggleVisible] = useToggle(false); const [visible, toggleVisible] = useToggle(false);
const gotoEdit = useCallback(() => { const gotoEdit = useCallback(() => {
@ -63,16 +65,18 @@ export const TemplateCard: React.FC<IProps> = ({
<header> <header>
<IconDocument /> <IconDocument />
<div className={styles.rightWrap}> <div className={styles.rightWrap}>
<Space> {template.createUser && user && template.createUser.id === user.id && (
<Tooltip key="edit" content="编辑" position="bottom"> <Space>
<Button <Tooltip key="edit" content="编辑模板" position="bottom">
type="tertiary" <Button
theme="borderless" type="tertiary"
icon={<IconEdit />} theme="borderless"
onClick={gotoEdit} icon={<IconEdit />}
/> onClick={gotoEdit}
</Tooltip> />
</Space> </Tooltip>
</Space>
)}
</div> </div>
</header> </header>
<main> <main>