1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-20 10:58:33 +00:00

add share module (#5582)

This commit is contained in:
杨顺强
2023-08-10 18:05:01 +08:00
committed by GitHub
parent 73a9089884
commit 0f74bb403d
2 changed files with 25 additions and 3 deletions

View File

@@ -5,10 +5,13 @@ import { seafileAPI } from '../../utils/seafile-api';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
import toaster from '../../components/toast'; import toaster from '../../components/toast';
import InternalLinkDialog from '../../components/dialog/internal-link-dialog'; import InternalLinkDialog from '../../components/dialog/internal-link-dialog';
import ShareDialog from '../../components/dialog/share-dialog';
const propTypes = { const propTypes = {
repoID: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired,
docPath: PropTypes.string.isRequired, docPath: PropTypes.string.isRequired,
docName: PropTypes.string.isRequired,
docPerm: PropTypes.string.isRequired,
isStarred: PropTypes.bool.isRequired, isStarred: PropTypes.bool.isRequired,
toggleStar: PropTypes.func.isRequired, toggleStar: PropTypes.func.isRequired,
unmarkDraft: PropTypes.func.isRequired unmarkDraft: PropTypes.func.isRequired
@@ -20,6 +23,7 @@ class ExternalOperations extends React.Component {
super(props); super(props);
this.state = { this.state = {
isShowInternalLinkDialog: false, isShowInternalLinkDialog: false,
isShowShareDialog: false,
}; };
} }
@@ -28,12 +32,14 @@ class ExternalOperations extends React.Component {
this.unsubscribeInternalLinkEvent = eventBus.subscribe(EXTERNAL_EVENT.INTERNAL_LINK_CLICK, this.onInternalLinkToggle); this.unsubscribeInternalLinkEvent = eventBus.subscribe(EXTERNAL_EVENT.INTERNAL_LINK_CLICK, this.onInternalLinkToggle);
this.unsubscribeStar = eventBus.subscribe(EXTERNAL_EVENT.TOGGLE_STAR, this.toggleStar); this.unsubscribeStar = eventBus.subscribe(EXTERNAL_EVENT.TOGGLE_STAR, this.toggleStar);
this.unsubscribeUnmark = eventBus.subscribe(EXTERNAL_EVENT.UNMARK_AS_DRAFT, this.unmark); this.unsubscribeUnmark = eventBus.subscribe(EXTERNAL_EVENT.UNMARK_AS_DRAFT, this.unmark);
this.unsubscribeShare = eventBus.subscribe(EXTERNAL_EVENT.SHARE_SDOC, this.onShareToggle);
} }
componentWillUnmount() { componentWillUnmount() {
this.unsubscribeInternalLinkEvent(); this.unsubscribeInternalLinkEvent();
this.unsubscribeStar(); this.unsubscribeStar();
this.unsubscribeUnmark(); this.unsubscribeUnmark();
this.unsubscribeShare();
} }
onInternalLinkToggle = () => { onInternalLinkToggle = () => {
@@ -69,9 +75,13 @@ class ExternalOperations extends React.Component {
} }
} }
onShareToggle = () => {
this.setState({isShowShareDialog: !this.state.isShowShareDialog});
}
render() { render() {
const { repoID, docPath } = this.props; const { repoID, docPath, docName, docPerm } = this.props;
const { isShowInternalLinkDialog } = this.state; const { isShowInternalLinkDialog, isShowShareDialog } = this.state;
return ( return (
<> <>
{isShowInternalLinkDialog && ( {isShowInternalLinkDialog && (
@@ -81,6 +91,16 @@ class ExternalOperations extends React.Component {
onInternalLinkDialogToggle={this.onInternalLinkToggle} onInternalLinkDialogToggle={this.onInternalLinkToggle}
/> />
)} )}
{isShowShareDialog && (
<ShareDialog
itemType={'file'}
itemPath={docPath}
itemName={docName}
repoID={repoID}
userPerm={docPerm}
toggleDialog={this.onShareToggle}
/>
)}
</> </>
); );
} }

View File

@@ -22,7 +22,7 @@ export default class SdocEditor extends React.Component {
} }
render() { render() {
const { repoID, docPath } = window.seafile; const { repoID, docPath, docName, docPerm } = window.seafile;
const { isStarred, isDraft } = this.state; const { isStarred, isDraft } = this.state;
return ( return (
<Fragment> <Fragment>
@@ -30,6 +30,8 @@ export default class SdocEditor extends React.Component {
<ExternalOperations <ExternalOperations
repoID={repoID} repoID={repoID}
docPath={docPath} docPath={docPath}
docName={docName}
docPrem={docPerm}
isStarred={isStarred} isStarred={isStarred}
toggleStar={this.toggleStar} toggleStar={this.toggleStar}
unmarkDraft={this.unmarkDraft} unmarkDraft={this.unmarkDraft}