client: update setting

This commit is contained in:
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 */ /* stylelint-disable */
.statusWrap { .wrap {
padding: 10px 12px; margin-top: 5px;
margin-top: 16px;
border: 1px solid var(--semi-color-border);
border-radius: 4px;
.title {
margin-bottom: 16px;
}
} }
.selectedItem, .selectedItem,

View File

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

View File

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