mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 23:29:49 +00:00
update group in real time (#7141)
This commit is contained in:
@@ -8,6 +8,8 @@ import Loading from '../../../components/loading';
|
||||
import toaster from '../../../components/toast';
|
||||
import EmptyTip from '../../../components/empty-tip';
|
||||
import SharePermissionEditor from '../../../components/select-editor/share-permission-editor';
|
||||
import EventBus from '../../common/event-bus';
|
||||
import { EVENT_BUS_TYPE } from '../../common/event-bus-type';
|
||||
|
||||
const itemPropTypes = {
|
||||
item: PropTypes.object.isRequired,
|
||||
@@ -153,7 +155,9 @@ class RepoShareAdminGroupShares extends Component {
|
||||
}
|
||||
|
||||
deleteItem = (item) => {
|
||||
const eventBus = EventBus.getInstance();
|
||||
seafileAPI.deleteShareToGroupItem(item.repo_id, item.path, 'group', item.share_to).then(res => {
|
||||
eventBus.dispatch(EVENT_BUS_TYPE.UNSHARE_REPO_TO_GROUP, { repo_id: item.repo_id, group_id: item.share_to });
|
||||
let items = this.state.items.filter(shareItem => {
|
||||
return shareItem.path + shareItem.share_to !== item.path + item.share_to;
|
||||
});
|
||||
|
@@ -22,6 +22,7 @@ const propTypes = {
|
||||
itemType: PropTypes.string.isRequired, // there will be three choose: ['library', 'dir', 'file']
|
||||
itemName: PropTypes.string.isRequired,
|
||||
itemPath: PropTypes.string.isRequired,
|
||||
repo: PropTypes.object,
|
||||
toggleDialog: PropTypes.func.isRequired,
|
||||
repoID: PropTypes.string.isRequired,
|
||||
repoEncrypted: PropTypes.bool,
|
||||
@@ -86,7 +87,6 @@ class ShareDialog extends React.Component {
|
||||
};
|
||||
|
||||
renderDirContent = () => {
|
||||
|
||||
if (!this.state.isRepoJudgemented) {
|
||||
return <Loading />;
|
||||
}
|
||||
@@ -223,6 +223,7 @@ class ShareDialog extends React.Component {
|
||||
itemPath={this.props.itemPath}
|
||||
repoID={this.props.repoID}
|
||||
isRepoOwner={this.state.isRepoOwner}
|
||||
repo={this.props.repo}
|
||||
onAddCustomPermissionToggle={this.onAddCustomPermissionToggle}
|
||||
/>
|
||||
</TabPane>
|
||||
|
@@ -7,6 +7,8 @@ import { Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
import SharePermissionEditor from '../select-editor/share-permission-editor';
|
||||
import { SeahubSelect, NoGroupMessage } from '../common/select';
|
||||
import EventBus from '../common/event-bus';
|
||||
import { EVENT_BUS_TYPE } from '../common/event-bus-type';
|
||||
|
||||
class GroupItem extends React.Component {
|
||||
|
||||
@@ -115,6 +117,7 @@ const propTypes = {
|
||||
repoID: PropTypes.string.isRequired,
|
||||
repoType: PropTypes.string,
|
||||
isRepoOwner: PropTypes.bool.isRequired,
|
||||
repo: PropTypes.object,
|
||||
onAddCustomPermissionToggle: PropTypes.func,
|
||||
};
|
||||
|
||||
@@ -200,13 +203,12 @@ class ShareToGroup extends React.Component {
|
||||
};
|
||||
|
||||
shareToGroup = () => {
|
||||
|
||||
let path = this.props.itemPath;
|
||||
let repoID = this.props.repoID;
|
||||
let isGroupOwnedRepo = this.props.isGroupOwnedRepo;
|
||||
|
||||
const eventBus = EventBus.getInstance();
|
||||
const { isGroupOwnedRepo, itemPath: path, repoID } = this.props;
|
||||
const { permission, selectedOption } = this.state;
|
||||
const targetGroupId = selectedOption.id;
|
||||
if (isGroupOwnedRepo) {
|
||||
seafileAPI.shareGroupOwnedRepoToGroup(repoID, this.state.permission, this.state.selectedOption['id'], path).then(res => {
|
||||
seafileAPI.shareGroupOwnedRepoToGroup(repoID, permission, targetGroupId, path).then(res => {
|
||||
let errorMsg = [];
|
||||
if (res.data.failed.length > 0) {
|
||||
for (let i = 0 ; i < res.data.failed.length ; i++) {
|
||||
@@ -224,6 +226,11 @@ class ShareToGroup extends React.Component {
|
||||
return sharedItem;
|
||||
});
|
||||
|
||||
if (this.props.repo && res.data.success.length > 0) {
|
||||
const sharedRepo = { ...this.props.repo, permission: res.data.success[0].permission };
|
||||
eventBus.dispatch(EVENT_BUS_TYPE.ADD_SHARED_REPO_INO_GROUP, { repo: sharedRepo, group_id: targetGroupId });
|
||||
}
|
||||
|
||||
this.setState({
|
||||
errorMsg: errorMsg,
|
||||
sharedItems: this.state.sharedItems.concat(items),
|
||||
@@ -235,7 +242,7 @@ class ShareToGroup extends React.Component {
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
} else {
|
||||
seafileAPI.shareFolder(repoID, path, 'group', this.state.permission, [this.state.selectedOption['id']]).then(res => {
|
||||
seafileAPI.shareFolder(repoID, path, 'group', permission, [targetGroupId]).then(res => {
|
||||
let errorMsg = [];
|
||||
if (res.data.failed.length > 0) {
|
||||
for (let i = 0 ; i < res.data.failed.length ; i++) {
|
||||
@@ -243,6 +250,11 @@ class ShareToGroup extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.props.repo && res.data.success.length > 0) {
|
||||
const sharedRepo = { ...this.props.repo, permission: res.data.success[0].permission };
|
||||
eventBus.dispatch(EVENT_BUS_TYPE.ADD_SHARED_REPO_INO_GROUP, { repo: sharedRepo, group_id: targetGroupId });
|
||||
}
|
||||
|
||||
this.setState({
|
||||
errorMsg: errorMsg,
|
||||
sharedItems: this.state.sharedItems.concat(res.data.success),
|
||||
@@ -257,10 +269,12 @@ class ShareToGroup extends React.Component {
|
||||
};
|
||||
|
||||
deleteShareItem = (groupID) => {
|
||||
let path = this.props.itemPath;
|
||||
let repoID = this.props.repoID;
|
||||
if (this.props.isGroupOwnedRepo) {
|
||||
const eventBus = EventBus.getInstance();
|
||||
const { isGroupOwnedRepo, itemPath: path, repoID } = this.props;
|
||||
if (isGroupOwnedRepo) {
|
||||
seafileAPI.deleteGroupOwnedRepoSharedGroupItem(repoID, groupID, path).then(() => {
|
||||
eventBus.dispatch(EVENT_BUS_TYPE.UNSHARE_REPO_TO_GROUP, { repo_id: repoID, group_id: groupID });
|
||||
|
||||
this.setState({
|
||||
sharedItems: this.state.sharedItems.filter(item => { return item.group_info.id !== groupID; })
|
||||
});
|
||||
@@ -270,6 +284,8 @@ class ShareToGroup extends React.Component {
|
||||
});
|
||||
} else {
|
||||
seafileAPI.deleteShareToGroupItem(repoID, path, 'group', groupID).then(() => {
|
||||
eventBus.dispatch(EVENT_BUS_TYPE.UNSHARE_REPO_TO_GROUP, { repo_id: repoID, group_id: groupID });
|
||||
|
||||
this.setState({
|
||||
sharedItems: this.state.sharedItems.filter(item => { return item.group_info.id !== groupID; })
|
||||
});
|
||||
|
Reference in New Issue
Block a user