diff --git a/src/common/model/matter/Matter.ts b/src/common/model/matter/Matter.ts index 610a93f..5b9cfd8 100644 --- a/src/common/model/matter/Matter.ts +++ b/src/common/model/matter/Matter.ts @@ -378,7 +378,7 @@ export default class Matter extends BaseEntity { let that = this; this.httpPost( Matter.URL_CHANGE_PRIVACY, - { uuid: this.uuid, privacy: privacy }, + { uuid: this.uuid, privacy: privacy, spaceUuid: this.spaceUuid }, function (response: any) { that.privacy = privacy; if (typeof successCallback === 'function') { diff --git a/src/pages/matter/Detail.tsx b/src/pages/matter/Detail.tsx index dbd11e8..4b1f4b9 100644 --- a/src/pages/matter/Detail.tsx +++ b/src/pages/matter/Detail.tsx @@ -17,6 +17,7 @@ import TankContentCard from '../widget/TankContentCard'; import Color from '../../common/model/base/option/Color'; interface RouteParam { + spaceUuid?: string; uuid: string; } @@ -34,13 +35,13 @@ export default class Detail extends TankComponent { } componentDidMount() { - const { uuid } = this.props.match.params; + const { spaceUuid, uuid } = this.props.match.params; this.matter.uuid = uuid; - let that = this; + this.matter.spaceUuid = spaceUuid as string | null; this.matter.httpDetail((response: any) => { - that.updateUI(); + this.updateUI(); if (!response.data.data.dir) { - that.downloadToken.httpFetchDownloadToken(that.matter.uuid!); + this.downloadToken.httpFetchDownloadToken(this.matter.uuid!); } }); } diff --git a/src/pages/matter/List.tsx b/src/pages/matter/List.tsx index 68e7dd1..5acfa48 100644 --- a/src/pages/matter/List.tsx +++ b/src/pages/matter/List.tsx @@ -15,7 +15,6 @@ import { Empty, Input, Menu, - message, Modal, Pagination, Row, @@ -54,7 +53,9 @@ import MatterSortPanel from './widget/MatterSortPanel'; import { UploadRequestOption as RcCustomRequestOptions } from 'rc-upload/lib/interface'; import Capacity from '../layout/widget/Capacity'; import Space from '../../common/model/space/Space'; -import MatterCrawlModal, { ICrawlFormValues } from './widget/MatterCrawlModal'; +import MatterCrawlModal from './widget/MatterCrawlModal'; +import SpaceMember from '../../common/model/space/member/SpaceMember'; +import { SpaceMemberRole } from '../../common/model/space/member/SpaceMemberRole'; interface IProps { spaceUuid?: string; @@ -63,9 +64,11 @@ interface IProps { interface IState {} export default class List extends TankComponent { + isInSpace = !!this.props.spaceUuid; // 是否在空间中 // 当前空间 space = new Space(); - isInSpace = !!this.props.spaceUuid; // 是否在空间中 + // 当前用户在当前空间下的成员信息 + spaceMember = new SpaceMember(); // 当前目录 currentDirectory = new Matter(); //准备新建的文件 @@ -208,6 +211,7 @@ export default class List extends TankComponent { if (this.props.spaceUuid) { this.space.uuid = this.props.spaceUuid; this.space.httpDetail(() => this.updateUI()); + this.spaceMember.httpMine(this.props.spaceUuid, () => this.updateUI()); } } @@ -518,13 +522,22 @@ export default class List extends TankComponent { ImagePreviewer.showMultiPhoto(imageArray, startIndex); } + goDetail(matter: Matter) { + const prefix = this.isInSpace ? `/space/${this.getSpaceUuid()}` : ''; + Sun.navigateTo(`${prefix}/matter/detail/${matter.uuid}`); + } + pagerAndCapacityRefresh() { Capacity.instance?.refresh(); this.refresh(); } + // 如果在空间下,有些操作权限只对管理员和读写成员开放 checkHandlePermission() { - return true; + if (!this.isInSpace) return true; + return [SpaceMemberRole.ADMIN, SpaceMemberRole.READ_WRITE].includes( + this.spaceMember.role! + ); } handleCloseMatterCrawlModal() { @@ -788,6 +801,7 @@ export default class List extends TankComponent { {director.createMode ? ( { {pager.loading || pager.data.length ? ( pager.data.map((matter) => ( this.goToDirectory(id)} onDeleteSuccess={() => this.pagerAndCapacityRefresh()} onCheckMatter={(m) => this.checkMatter(m)} onPreviewImage={(m) => this.previewImage(m)} + onGoDetail={(m) => this.goDetail(m)} /> )) ) : ( diff --git a/src/pages/matter/widget/MatterPanel.tsx b/src/pages/matter/widget/MatterPanel.tsx index 0a306d8..5429467 100644 --- a/src/pages/matter/widget/MatterPanel.tsx +++ b/src/pages/matter/widget/MatterPanel.tsx @@ -3,43 +3,40 @@ import Matter from '../../../common/model/matter/Matter'; import TankComponent from '../../../common/component/TankComponent'; import Director from './Director'; import './MatterPanel.less'; -import Sun from '../../../common/model/global/Sun'; import StringUtil from '../../../common/util/StringUtil'; import DateUtil from '../../../common/util/DateUtil'; import AnimateUtil from '../../../common/util/AnimateUtil'; import MessageBoxUtil from '../../../common/util/MessageBoxUtil'; import Expanding from '../../widget/Expanding'; import { - CloseCircleOutlined, DeleteOutlined, DownloadOutlined, EditOutlined, EllipsisOutlined, - ExclamationCircleFilled, InfoCircleOutlined, LinkOutlined, LockOutlined, - RedoOutlined, UnlockOutlined, } from '@ant-design/icons'; -import { Checkbox, Dropdown, Menu, Modal, Tooltip } from 'antd'; +import { Checkbox, Dropdown, Menu, Tooltip } from 'antd'; import { CheckboxChangeEvent } from 'antd/es/checkbox'; import SafeUtil from '../../../common/util/SafeUtil'; import ClipboardUtil from '../../../common/util/ClipboardUtil'; import Lang from '../../../common/model/global/Lang'; import MatterDeleteModal from './MatterDeleteModal'; +import { SpaceMemberRole } from '../../../common/model/space/member/SpaceMemberRole'; interface IProps { matter: Matter; - recycleMode?: boolean; // 回收站模式,默认false,简化相关操作,不可进入文件夹里 - isSpace?: boolean; // 是否共享空间下 + mode: 'normal' | 'space'; // normal:正常模式,space:空间模式 + spaceMemberRole?: SpaceMemberRole; // 用户在当前空间下的角色,只有在space模式下才有值 director?: Director; onCreateDirectoryCallback?: () => any; onDeleteSuccess?: () => any; - onRecoverySuccess?: () => any; onCheckMatter?: (matter?: Matter) => any; onPreviewImage?: (matter: Matter) => any; onGoToDirectory?: (id: string) => any; + onGoDetail?: (matter: Matter) => any; } interface IState {} @@ -59,6 +56,14 @@ export default class MatterPanel extends TankComponent { this.state = {}; } + // 如果在空间下,有些操作权限只对管理员和读写成员开放 + checkHandlePermission() { + if (this.props.mode !== 'space') return true; + return [SpaceMemberRole.ADMIN, SpaceMemberRole.READ_WRITE].includes( + this.props.spaceMemberRole! + ); + } + prepareRename() { const { matter, director } = this.props; if (director!.isEditing()) { @@ -96,7 +101,7 @@ export default class MatterPanel extends TankComponent { deleteMatter() { MatterDeleteModal.open( - !!this.props.isSpace, + this.props.mode === 'space', () => { this.props.matter.httpSoftDelete(() => { MessageBoxUtil.success(Lang.t('operationSuccess')); @@ -112,32 +117,6 @@ export default class MatterPanel extends TankComponent { ); } - hardDeleteMatter() { - Modal.confirm({ - title: Lang.t('actionCanNotRevertConfirm'), - icon: , - onOk: () => { - this.props.matter.httpDelete(() => { - MessageBoxUtil.success(Lang.t('operationSuccess')); - this.props.onDeleteSuccess!(); - }); - }, - }); - } - - recoveryMatter() { - Modal.confirm({ - title: Lang.t('actionRecoveryConfirm'), - icon: , - onOk: () => { - this.props.matter.httpRecovery(() => { - MessageBoxUtil.success(Lang.t('operationSuccess')); - this.props.onRecoverySuccess!(); - }); - }, - }); - } - changeMatterName(e: any) { this.renameMatterName = e.currentTarget.value; this.updateUI(); @@ -222,20 +201,14 @@ export default class MatterPanel extends TankComponent { } clickRow() { - const { - matter, - recycleMode = false, - director, - onGoToDirectory, - onPreviewImage, - } = this.props; + const { matter, director, onGoToDirectory, onPreviewImage, mode } = + this.props; if (director && director.isEditing()) { console.error('导演正忙着,不予执行'); return; } if (matter.dir) { - if (recycleMode) return; onGoToDirectory!(matter.uuid!); } else { //图片进行预览操作 @@ -253,197 +226,93 @@ export default class MatterPanel extends TankComponent { } renderPcOperation() { - const { matter, recycleMode = false } = this.props; - - // 文件操作在正常模式 or 回收站模式下不同,其中回收站模式只保留查看信息与彻底删除操作 - const handles = recycleMode ? ( - <> - - - SafeUtil.stopPropagationWrap(e)(this.recoveryMatter()) - } - /> - - - - SafeUtil.stopPropagationWrap(e)( - Sun.navigateTo('/matter/detail/' + matter.uuid) - ) - } - /> - - - - SafeUtil.stopPropagationWrap(e)(this.hardDeleteMatter()) - } - /> - - - ) : ( - <> - {!matter.dir && matter.privacy && ( - - - SafeUtil.stopPropagationWrap(e)(this.changePrivacy(false)) - } - /> - - )} - {!matter.dir && !matter.privacy && ( - - - SafeUtil.stopPropagationWrap(e)(this.changePrivacy(true)) - } - /> - - )} - - - SafeUtil.stopPropagationWrap(e)( - Sun.navigateTo('/matter/detail/' + matter.uuid) - ) - } - /> - - - - SafeUtil.stopPropagationWrap(e)(this.prepareRename()) - } - /> - - - SafeUtil.stopPropagationWrap(e)(this.clipboard())} - /> - - - SafeUtil.stopPropagationWrap(e)(matter.download())} - /> - - - - SafeUtil.stopPropagationWrap(e)(this.deleteMatter()) - } - /> - - - ); + const { matter } = this.props; return (
- {handles} + + {!matter.dir && matter.privacy && ( + + + SafeUtil.stopPropagationWrap(e)(this.changePrivacy(false)) + } + /> + + )} + {!matter.dir && !matter.privacy && ( + + + SafeUtil.stopPropagationWrap(e)(this.changePrivacy(true)) + } + /> + + )} + + + SafeUtil.stopPropagationWrap(e)(this.props.onGoDetail?.(matter)) + } + /> + + + + SafeUtil.stopPropagationWrap(e)(this.prepareRename()) + } + /> + + + SafeUtil.stopPropagationWrap(e)(this.clipboard())} + /> + + + + SafeUtil.stopPropagationWrap(e)(matter.download()) + } + /> + + + + SafeUtil.stopPropagationWrap(e)(this.deleteMatter()) + } + /> + + {StringUtil.humanFileSize(matter.size)} - {recycleMode ? ( - - - {DateUtil.simpleDateHourMinute(matter.deleteTime)} - - - ) : ( - - - {DateUtil.simpleDateHourMinute(matter.updateTime)} - - - )} + + + {DateUtil.simpleDateHourMinute(matter.updateTime)} + +
); } - // 文件操作在正常模式 or 回收站模式下不同,其中回收站模式只保留查看信息与彻底删除操作 getHandles() { - const { matter, recycleMode = false } = this.props; - // 回收站模式 - if (recycleMode) - return [ -
- SafeUtil.stopPropagationWrap(e)( - Sun.navigateTo('/matter/detail/' + this.props.matter.uuid) - ) - } - > - - {Lang.t('matter.fileDetail')} -
, -
- SafeUtil.stopPropagationWrap(e)(this.recoveryMatter()) - } - > - - {Lang.t('matter.recovery')} -
, -
- SafeUtil.stopPropagationWrap(e)(this.hardDeleteMatter()) - } - > - - {Lang.t('matter.hardDelete')} -
, - ]; + const { matter } = this.props; // 普通模式 - const handles = []; - if (!matter.dir) { - handles.push( - matter.privacy ? ( -
- SafeUtil.stopPropagationWrap(e)(this.changePrivacy(false)) - } - > - - {Lang.t('matter.setPublic')} -
- ) : ( -
- SafeUtil.stopPropagationWrap(e)(this.changePrivacy(true)) - } - > - - {Lang.t('matter.setPrivate')} -
- ) - ); - } - handles.push( + const handles = [
- SafeUtil.stopPropagationWrap(e)( - Sun.navigateTo('/matter/detail/' + matter.uuid) - ) + SafeUtil.stopPropagationWrap(e)(this.props.onGoDetail?.(matter)) } > @@ -476,22 +345,44 @@ export default class MatterPanel extends TankComponent { > {Lang.t('matter.delete')} -
- ); + , + ]; + if (!matter.dir) { + handles.unshift( + matter.privacy ? ( +
+ SafeUtil.stopPropagationWrap(e)(this.changePrivacy(false)) + } + > + + {Lang.t('matter.setPublic')} +
+ ) : ( +
+ SafeUtil.stopPropagationWrap(e)(this.changePrivacy(true)) + } + > + + {Lang.t('matter.setPrivate')} +
+ ) + ); + } + return handles; } renderMobileOperation() { - const { matter, recycleMode = false } = this.props; + const { matter } = this.props; return (
- - {DateUtil.simpleDateHourMinute( - recycleMode ? matter.deleteTime : matter.updateTime - )} - + {DateUtil.simpleDateHourMinute(matter.updateTime)} {StringUtil.humanFileSize(matter.size)}