client: update setting

pull/60/head
fantasticit 2022-05-25 13:37:59 +08:00
parent a534e799c1
commit 414f3a63db
5 changed files with 120 additions and 65 deletions

View File

@ -1,13 +1,6 @@
/* stylelint-disable */
.statusWrap {
padding: 10px 12px;
margin-top: 16px;
border: 1px solid var(--semi-color-border);
border-radius: 4px;
.title {
margin-bottom: 16px;
}
.wrap {
margin-top: 5px;
}
.selectedItem,

View File

@ -1,22 +1,21 @@
import { IconClose } from '@douyinfe/semi-icons';
import { Banner, Button, Checkbox, Radio, RadioGroup, Toast, Transfer, Typography } from '@douyinfe/semi-ui';
import { isPublicDocument, isPublicWiki, WIKI_STATUS_LIST } from '@think/domains';
import { Banner, Button, Checkbox, Toast, Transfer, Typography } from '@douyinfe/semi-ui';
import { isPublicDocument } from '@think/domains';
import { flattenTree2Array } from 'components/wiki/tocs/utils';
import { useWikiDetail, useWikiTocs } from 'data/wiki';
import { buildUrl } from 'helpers/url';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import styles from './index.module.scss';
const { Text, Title } = Typography;
const { Title, Text } = Typography;
interface IProps {
wikiId: string;
}
export const WikiDocumentsShare: React.FC<IProps> = ({ wikiId }) => {
const { data: wiki, loading: wikiLoading, toggleStatus: toggleWorkspaceStatus } = useWikiDetail(wikiId);
const { data: tocs, loading } = useWikiTocs(wikiId);
const { toggleStatus: toggleWorkspaceStatus } = useWikiDetail(wikiId);
const { data: tocs } = useWikiTocs(wikiId);
const documents = useMemo(
() =>
flattenTree2Array(tocs).map((d) => {
@ -26,15 +25,13 @@ export const WikiDocumentsShare: React.FC<IProps> = ({ wikiId }) => {
}),
[tocs]
);
const [nextStatus, setNextStatus] = useState('');
const isPublic = useMemo(() => wiki && isPublicWiki(wiki.status), [wiki]);
const [publicDocumentIds, setPublicDocumentIds] = useState([]); // 公开的
const privateDocumentIds = useMemo(() => {
return documents.filter((doc) => !publicDocumentIds.includes(doc.id)).map((doc) => doc.id);
}, [documents, publicDocumentIds]);
const submit = () => {
const data = { nextStatus, publicDocumentIds, privateDocumentIds };
const data = { publicDocumentIds, privateDocumentIds };
toggleWorkspaceStatus(data).then((res) => {
const ret = res as unknown as any & {
documentOperateMessage?: string;
@ -72,11 +69,6 @@ export const WikiDocumentsShare: React.FC<IProps> = ({ wikiId }) => {
return item.title.includes(sugInput);
}, []);
useEffect(() => {
if (!wiki) return;
setNextStatus(wiki.status);
}, [wiki]);
useEffect(() => {
if (!documents.length) return;
const activeIds = documents.filter((doc) => isPublicDocument(doc.status)).map((doc) => doc.id);
@ -85,48 +77,14 @@ export const WikiDocumentsShare: React.FC<IProps> = ({ wikiId }) => {
return (
<div className={styles.wrap}>
{isPublic && (
<Banner
fullMode={false}
type="info"
bordered
icon={null}
style={{ marginTop: 16 }}
title={<div style={{ fontWeight: 600, fontSize: '14px', lineHeight: '20px' }}></div>}
description={
isPublic && (
<div>
<Text
link={{
href: buildUrl(`/share/wiki/${wikiId}`),
target: '_blank',
}}
copyable={{
content: buildUrl(`/share/wiki/${wikiId}`),
}}
>
</Text>
</div>
)
}
/>
)}
<div className={styles.statusWrap}>
<Title className={styles.title} heading={6}>
</Title>
<RadioGroup direction="vertical" value={nextStatus} onChange={(e) => setNextStatus(e.target.value)}>
{WIKI_STATUS_LIST.map((status) => {
return (
<Radio key={status.value} value={status.value}>
{status.label}
</Radio>
);
})}
</RadioGroup>
</div>
<Banner
fullMode={false}
type="info"
icon={null}
closeIcon={null}
title={<Title heading={5}></Title>}
description={<Text></Text>}
/>
<div className={styles.transferWrap}>
<Transfer
style={{ width: '100%', marginTop: 16 }}

View File

@ -5,6 +5,7 @@ import React from 'react';
import { Base } from './base';
import { More } from './more';
import { Privacy } from './privacy';
import { Users } from './users';
interface IProps {
@ -15,6 +16,7 @@ interface IProps {
const TitleMap = {
base: '基础信息',
privacy: '隐私管理',
users: '成员管理',
more: '更多',
};
@ -32,6 +34,9 @@ export const WikiSetting: React.FC<IProps> = ({ wikiId, tab, onNavigate }) => {
<TabPane tab={TitleMap['users']} itemKey="users">
<Users wikiId={wikiId} />
</TabPane>
<TabPane tab={TitleMap['privacy']} itemKey="privacy">
<Privacy wikiId={wikiId} />
</TabPane>
<TabPane tab={TitleMap['more']} itemKey="more">
<More wikiId={wikiId} />
</TabPane>

View File

@ -0,0 +1,13 @@
/* stylelint-disable */
.wrap {
.statusWrap {
padding: 10px 12px;
margin-top: 16px;
border: 1px solid var(--semi-color-border);
border-radius: 4px;
.title {
margin-bottom: 16px;
}
}
}

View File

@ -0,0 +1,86 @@
import { IconClose } from '@douyinfe/semi-icons';
import { Banner, Button, Checkbox, Radio, RadioGroup, Toast, Transfer, Typography } from '@douyinfe/semi-ui';
import { isPublicDocument, isPublicWiki, WIKI_STATUS_LIST } from '@think/domains';
import { flattenTree2Array } from 'components/wiki/tocs/utils';
import { useWikiDetail, useWikiTocs } from 'data/wiki';
import { buildUrl } from 'helpers/url';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import styles from './index.module.scss';
const { Text, Title } = Typography;
interface IProps {
wikiId: string;
}
export const Privacy: React.FC<IProps> = ({ wikiId }) => {
const { data: wiki, toggleStatus: toggleWorkspaceStatus } = useWikiDetail(wikiId);
const [nextStatus, setNextStatus] = useState('');
const isPublic = useMemo(() => wiki && isPublicWiki(wiki.status), [wiki]);
const submit = () => {
const data = { nextStatus };
toggleWorkspaceStatus(data).then((res) => {
const ret = res as unknown as any & {
documentOperateMessage?: string;
};
Toast.success(ret.documentOperateMessage || '操作成功');
});
};
useEffect(() => {
if (!wiki) return;
setNextStatus(wiki.status);
}, [wiki]);
return (
<div className={styles.wrap}>
{isPublic && (
<Banner
fullMode={false}
type="info"
bordered
icon={null}
style={{ marginTop: 16 }}
title={<div style={{ fontWeight: 600, fontSize: '14px', lineHeight: '20px' }}></div>}
description={
isPublic && (
<div>
<Text
link={{
href: buildUrl(`/share/wiki/${wikiId}`),
target: '_blank',
}}
copyable={{
content: buildUrl(`/share/wiki/${wikiId}`),
}}
>
</Text>
</div>
)
}
/>
)}
<div className={styles.statusWrap}>
<Title className={styles.title} heading={6}>
</Title>
<RadioGroup direction="vertical" value={nextStatus} onChange={(e) => setNextStatus(e.target.value)}>
{WIKI_STATUS_LIST.map((status) => {
return (
<Radio key={status.value} value={status.value}>
{status.label}
</Radio>
);
})}
</RadioGroup>
</div>
<Button style={{ marginTop: 16 }} type="primary" theme="solid" onClick={submit}>
</Button>
</div>
);
};