8000 Department repo more menu by llj · Pull Request #7961 · haiwen/seahub · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Department repo more menu #7961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/src/components/dir-view-mode/dir-others/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const DirOthers = ({ userPerm, repoID, currentRepoInfo, updateRepoInfo }) => {

const isDesktop = Utils.isDesktop();
const isRepoOwner = owner_email == username;
const isDepartmentAdmin = owner_email.indexOf('@seafile_group') != -1 && is_admin;

const enableMonitorRepo = isPro && (permission == 'r' || permission == 'rw');

Expand Down Expand Up @@ -84,7 +85,7 @@ const DirOthers = ({ userPerm, repoID, currentRepoInfo, updateRepoInfo }) => {
<span className="dir-others-item-text">{gettext('History')}</span>
</div>
)}
{isDesktop && isRepoOwner && (
{isDesktop && (isRepoOwner || isDepartmentAdmin) && (
<LibraryMoreOperations
repo={currentRepoInfo}
updateRepoInfo={updateRepoInfo}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { navigate } from '@gatsbyjs/reach-router';
import { Utils } from '../../../../utils/utils';
import { seafileAPI } from '../../../../utils/seafile-api';
import { userAPI } from '../../../../utils/user-api';
import { gettext, siteRoot } from '../../../../utils/constants';
import ModalPortal from '../../../../components/modal-portal';
import toaster from '../../../../components/toast';
import RenameRepoDialog from '../../../../components/dialog/rename-repo';
import TransferDialog from '../../../../components/dialog/transfer-dialog';
import ChangeRepoPasswordDialog from '../../../../components/dialog/change-repo-password-dialog';
import ResetEncryptedRepoPasswordDialog from '../../../../components/dialog/reset-encrypted-repo-password-dialog';
import LibSubFolderPermissionDialog from '../../../../components/dialog/lib-sub-folder-permission-dialog';
import RepoAPITokenDialog from '../../../../components/dialog/repo-api-token-dialog';
import RepoShareAdminDialog from '../../../../components/dialog/repo-share-admin-dialog';
import LibraryOpMenu from '../../../../components/library-op-menu';

const propTypes = {
repo: PropTypes.object.isRequired,
updateRepoInfo: PropTypes.func.isRequired
};

class LibraryMoreOperations extends React.Component {

constructor(props) {
super(props);
this.state = {
isRenameRepoDialogOpen: false,
isTransferDialogOpen: false,
isChangePasswordDialogOpen: false,
isResetPasswordDialogOpen: false,
isFolderPermissionDialogOpen: false,
isAPITokenDialogOpen: false,
isRepoShareAdminDialogOpen: false
};
}

=> {
switch (item) {
case 'Rename':
this.onRenameToggle();
break;
case 'Transfer':
this.onTransferToggle();
break;
case 'Folder Permission':
this.onFolderPermissionToggle();
break;
case 'Share Admin':
this.toggleRepoShareAdminDialog();
break;
case 'Change Password':
this.onChangePasswordToggle();
break;
case 'Reset Password':
this.onResetPasswordToggle();
break;
case 'API Token':
this.onAPITokenToggle();
break;
default:
break;
}
};

=> {
this.setState({ isRenameRepoDialogOpen: !this.state.isRenameRepoDialogOpen });
};

=> {
this.setState({ isTransferDialogOpen: !this.state.isTransferDialogOpen });
};

=> {
this.setState({ isChangePasswordDialogOpen: !this.state.isChangePasswordDialogOpen });
};

=> {
this.setState({ isResetPasswordDialogOpen: !this.state.isResetPasswordDialogOpen });
};

=> {
this.setState({ isFolderPermissionDialo 10000 gOpen: !this.state.isFolderPermissionDialogOpen });
};

=> {
this.setState({ isAPITokenDialogOpen: !this.state.isAPITokenDialogOpen });
};

toggleRepoShareAdminDialog = () => {
this.setState({ isRepoShareAdminDialogOpen: !this.state.isRepoShareAdminDialogOpen });
};

renameRepo = (newName) => {
const { repo } = this.props;
const { repo_id: repoID, owner_email } = repo;
const groupID = parseInt(owner_email);
seafileAPI.renameGroupOwnedLibrary(groupID, repoID, newName).then(res => {
this.props.updateRepoInfo({ 'repo_name': newName });
const message = gettext('Successfully renamed the library.');
toaster.success(message);
}).catch(error => {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
};

reshare) => {
const { repo } = this.props;
const { repo_id: repoID, owner_email } = repo;
const groupID = parseInt(owner_email);
userAPI.depAdminTransferRepo(repoID, groupID, email, reshare).then(res => {
const message = gettext('Successfully transferred the library.');
toaster.success(message);
navigate(siteRoot);
}).catch(error => {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
};

render() {
const { repo } = this.props;
const {
isRenameRepoDialogOpen, isTransferDialogOpen
} = this.state;
return (
<Fragment>
<LibraryOpMenu
isPC={true}
isLibView={true}
isDepartmentRepo={true}
repo={repo}
>
>
<>
<span className="sf3-font-more sf3-font"></span>
<span className="dir-others-item-text">{gettext('More')}</span>
</>
</LibraryOpMenu>
{isRenameRepoDialogOpen && (
<ModalPortal>
<RenameRepoDialog
name={repo.repo_name}
renameRepo={this.renameRepo}
toggleDialog={this.onRenameToggle}
/>
</ModalPortal>
)}
{isTransferDialogOpen && (
<ModalPortal>
<TransferDialog
itemName={repo.repo_name}
>
toggleDialog={this.onTransferToggle}
canTransferToDept={true}
isDepAdminTransfer={true}
/>
</ModalPortal>
)}
{this.state.isChangePasswordDialogOpen && (
<ModalPortal>
<ChangeRepoPasswordDialog
repoID={repo.repo_id}
repoName={repo.repo_name}
toggleDialog={this.onChangePasswordToggle}
/>
</ModalPortal>
)}
{this.state.isResetPasswordDialogOpen && (
<ModalPortal>
<ResetEncryptedRepoPasswordDialog
repoID={repo.repo_id}
toggleDialog={this.onResetPasswordToggle}
/>
</ModalPortal>
)}

{this.state.isFolderPermissionDialogOpen && (
<ModalPortal>
<LibSubFolderPermissionDialog
toggleDialog={this.onFolderPermissionToggle}
repoID={repo.repo_id}
repoName={repo.repo_name}
isDepartmentRepo={true}
/>
</ModalPortal>
)}

{this.state.isAPITokenDialogOpen && (
<ModalPortal>
<RepoAPITokenDialog
repo={repo}
>
/>
</ModalPortal>
)}

{this.state.isRepoShareAdminDialogOpen && (
<ModalPortal>
<RepoShareAdminDialog
repo={repo}
toggleDialog={this.toggleRepoShareAdminDialog}
/>
</ModalPortal>
)}

</Fragment>
);
}
}

LibraryMoreOperations.propTypes = propTypes;

export default LibraryMoreOperations;
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import MyLibraryMoreOperations from './my-library-more-operations';
import DepartmentLibraryMoreOperations from './department-library-more-operations';

const propTypes = {
repo: PropTypes.object.isRequired,
updateRepoInfo: PropTypes.func.isRequired
};

class LibraryMoreOperations extends React.Component {

render() {
const { repo } = this.props;
const { owner_email } = repo;
const isDepartmentRepo = owner_email.indexOf('@seafile_group') != -1;
return (
<>
{isDepartmentRepo
? <DepartmentLibraryMoreOperations {...this.props} />
: <MyLibraryMoreOperations {...this.props} />
}
</>
);
}
}

LibraryMoreOperations.propTypes = propTypes;

export default LibraryMoreOperations;
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { navigate } from '@gatsbyjs/reach-router';
import { Utils } from '../../../utils/utils';
import { seafileAPI } from '../../../utils/seafile-api';
import { userAPI } from '../../../utils/user-api';
import { gettext, siteRoot } from '../../../utils/constants';
import ModalPortal from '../../../components/modal-portal';
import toaster from '../../../components/toast';
import RenameRepoDialog from '../../../components/dialog/rename-repo';
import TransferDialog from '../../../components/dialog/transfer-dialog';
import ChangeRepoPasswordDialog from '../../../components/dialog/change-repo-password-dialog';
import ResetEncryptedRepoPasswordDialog from '../../../components/dialog/reset-encrypted-repo-password-dialog';
import LabelRepoStateDialog from '../../../components/dialog/label-repo-state-dialog';
import LibSubFolderPermissionDialog from '../../../components/dialog/lib-sub-folder-permission-dialog';
import RepoAPITokenDialog from '../../../components/dialog/repo-api-token-dialog';
import RepoShareAdminDialog from '../../../components/dialog/repo-share-admin-dialog';
import OfficeSuiteDialog from '../../../components/dialog/repo-office-suite-dialog';
import MylibRepoMenu from '../../../pages/my-libs/mylib-repo-menu';
import { Utils } from '../../../../utils/utils';
import { seafileAPI } from '../../../../utils/seafile-api';
import { userAPI } from '../../../../utils/user-api';
import { gettext, siteRoot } from '../../../../utils/constants';
import ModalPortal from '../../../../components/modal-portal';
import toaster from '../../../../components/toast';
import RenameRepoDialog from '../../../../components/dialog/rename-repo';
import TransferDialog from '../../../../components/dialog/transfer-dialog';
import ChangeRepoPasswordDialog from '../../../../components/dialog/change-repo-password-dialog';
import ResetEncryptedRepoPasswordDialog from '../../../../components/dialog/reset-encrypted-repo-password-dialog';
import LabelRepoStateDialog from '../../../../components/dialog/label-repo-state-dialog';
import LibSubFolderPermissionDialog from '../../../../components/dialog/lib-sub-folder-permission-dialog';
import RepoAPITokenDialog from '../../../../components/dialog/repo-api-token-dialog';
import RepoShareAdminDialog from '../../../../components/dialog/repo-share-admin-dialog';
import OfficeSuiteDialog from '../../../../components/dialog/repo-office-suite-dialog';
import LibraryOpMenu from '../../../../components/library-op-menu';

const propTypes = {
repo: PropTypes.object.isRequired,
Expand Down Expand Up @@ -60,12 +60,6 @@ class LibraryMoreOperations extends React.Component {
case 'Reset Password':
this.onResetPasswordToggle();
break;
case 'Watch File Changes':
this.watchFileChanges();
break;
case 'Unwatch File Changes':
this.unwatchFileChanges();
break;
case 'API Token':
this.onAPITokenToggle();
break;
Expand Down Expand Up @@ -149,7 +143,7 @@ class LibraryMoreOperations extends React.Component {
} = this.state;
return (
<Fragment>
<MylibRepoMenu
<LibraryOpMenu
isPC={true}
isLibView={true}
repo={repo}
Expand All @@ -159,7 +153,7 @@ class LibraryMoreOperations extends React.Component {
<span className="sf3-font-more sf3-font"></span>
<span className="dir-others-item-text">{gettext('More')}</span>
</>
</MylibRepoMenu>
</LibraryOpMenu>
{isRenameRepoDialogOpen && (
<ModalPortal>
<RenameRepoDialog
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Dropdown, DropdownMenu, DropdownToggle, DropdownItem } from 'reactstrap';
import { gettext, isPro, folderPermEnabled, enableRepoSnapshotLabel, enableResetEncryptedRepoPassword, isEmailConfigured, enableMultipleOfficeSuite } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import MobileItemMenu from '../../components/mobile-item-menu';
import { gettext, isPro, folderPermEnabled, enableRepoSnapshotLabel, enableResetEncryptedRepoPassword, isEmailConfigured, enableMultipleOfficeSuite } from '../utils/constants';
import { Utils } from '../utils/utils';
import MobileItemMenu from '../components/mobile-item-menu';

const propTypes = {
isPC: PropTypes.bool,
isLibView: PropTypes.bool,
isDepartmentRepo: PropTypes.bool,
repo: PropTypes.object.isRequired,
isStarred: PropTypes.bool,
onFreezedItem: PropTypes.func,
onUnfreezedItem: PropTypes.func,
onMenuItemClick: PropTypes.func.isRequired,
};

class MylibRepoMenu extends React.Component {
class LibraryOperationMenu extends React.Component {

constructor(props) {
super(props);
Expand Down Expand Up @@ -117,8 +119,13 @@ class MylibRepoMenu extends React.Component {
};

getAdvancedOperations = () => {
const { isDepartmentRepo } = this.props;
const operations = [];
operations.push('API Token');
if (isDepartmentRepo) {
return operations;
}

if (this.props.isPC && enableRepoSnapshotLabel) {
operations.push('Label Current State');
}
Expand Down Expand Up @@ -262,6 +269,6 @@ class MylibRepoMenu extends React.Component {
}
}

MylibRepoMenu.propTypes = propTypes;
LibraryOperationMenu.propTypes = propTypes;

export default MylibRepoMenu;
export default LibraryOperationMenu;
Loading
0