diff --git a/frontend/src/components/dir-view-mode/dir-others/index.js b/frontend/src/components/dir-view-mode/dir-others/index.js index 4427edca22..a60adfdc8a 100644 --- a/frontend/src/components/dir-view-mode/dir-others/index.js +++ b/frontend/src/components/dir-view-mode/dir-others/index.js @@ -1,6 +1,6 @@ import React, { useState, useEffect, useCallback } from 'react'; import PropTypes from 'prop-types'; -import { gettext, username } from '../../../utils/constants'; +import { gettext, username, isPro } from '../../../utils/constants'; import { Utils } from '../../../utils/utils'; import TreeSection from '../../tree-section'; import TrashDialog from '../../dialog/trash-dialog'; @@ -10,11 +10,12 @@ import { eventBus } from '../../common/event-bus'; import { EVENT_BUS_TYPE } from '../../common/event-bus-type'; import { TAB } from '../../../constants/repo-setting-tabs'; import LibraryMoreOperations from './library-more-operations'; +import WatchUnwatchFileChanges from './watch-unwatch-file-changes'; import './index.css'; const DirOthers = ({ userPerm, repoID, currentRepoInfo, updateRepoInfo }) => { - const { owner_email, is_admin, repo_name: repoName } = currentRepoInfo; + const { owner_email, is_admin, repo_name: repoName, permission } = currentRepoInfo; const showSettings = is_admin; // repo owner, department admin, shared with 'Admin' permission let [isSettingsDialogOpen, setSettingsDialogOpen] = useState(false); @@ -55,8 +56,16 @@ const DirOthers = ({ userPerm, repoID, currentRepoInfo, updateRepoInfo }) => { const isDesktop = Utils.isDesktop(); const isRepoOwner = owner_email == username; + const enableMonitorRepo = isPro && (permission == 'r' || permission == 'rw'); + return ( + {enableMonitorRepo && ( + + )} {showSettings && (
diff --git a/frontend/src/components/dir-view-mode/dir-others/library-more-operations.js b/frontend/src/components/dir-view-mode/dir-others/library-more-operations.js index 5f147ee6c9..99e5f414eb 100644 --- a/frontend/src/components/dir-view-mode/dir-others/library-more-operations.js +++ b/frontend/src/components/dir-view-mode/dir-others/library-more-operations.js @@ -3,6 +3,7 @@ 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'; @@ -15,7 +16,6 @@ import LibSubFolderPermissionDialog from '../../../components/dialog/lib-sub-fol 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 { userAPI } from '../../../utils/user-api'; import MylibRepoMenu from '../../../pages/my-libs/mylib-repo-menu'; const propTypes = { @@ -80,30 +80,6 @@ class LibraryMoreOperations extends React.Component { } }; - watchFileChanges = () => { - const { repo } = this.props; - seafileAPI.monitorRepo(repo.repo_id).then(() => { - this.props.updateRepoInfo({ 'monitored': true }); - const message = gettext('Successfully watched the library.'); - toaster.success(message); - }).catch(error => { - let errMessage = Utils.getErrorMsg(error); - toaster.danger(errMessage); - }); - }; - - unwatchFileChanges = () => { - const { repo } = this.props; - seafileAPI.unMonitorRepo(repo.repo_id).then(() => { - this.props.updateRepoInfo({ 'monitored': false }); - const message = gettext('Successfully unwatched the library.'); - toaster.success(message); - }).catch(error => { - let errMessage = Utils.getErrorMsg(error); - toaster.danger(errMessage); - }); - }; - onRenameToggle = () => { this.setState({ isRenameRepoDialogOpen: !this.state.isRenameRepoDialogOpen }); }; diff --git a/frontend/src/components/dir-view-mode/dir-others/watch-unwatch-file-changes.js b/frontend/src/components/dir-view-mode/dir-others/watch-unwatch-file-changes.js new file mode 100644 index 0000000000..01487540f0 --- /dev/null +++ b/frontend/src/components/dir-view-mode/dir-others/watch-unwatch-file-changes.js @@ -0,0 +1,63 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Utils } from '../../../utils/utils'; +import { seafileAPI } from '../../../utils/seafile-api'; +import { gettext } from '../../../utils/constants'; +import toaster from '../../../components/toast'; + +const propTypes = { + repo: PropTypes.object.isRequired, + updateRepoInfo: PropTypes.func.isRequired +}; + +class WatchUnwatchFileChanges extends React.Component { + + constructor(props) { + super(props); + this.state = { + }; + } + + watchFileChanges = () => { + const { repo } = this.props; + seafileAPI.monitorRepo(repo.repo_id).then(() => { + this.props.updateRepoInfo({ 'monitored': true }); + const message = gettext('Successfully watched the library.'); + toaster.success(message); + }).catch(error => { + let errMessage = Utils.getErrorMsg(error); + toaster.danger(errMessage); + }); + }; + + unwatchFileChanges = () => { + const { repo } = this.props; + seafileAPI.unMonitorRepo(repo.repo_id).then(() => { + this.props.updateRepoInfo({ 'monitored': false }); + const message = gettext('Successfully unwatched the library.'); + toaster.success(message); + }).catch(error => { + let errMessage = Utils.getErrorMsg(error); + toaster.danger(errMessage); + }); + }; + + render() { + const { repo } = this.props; + const { monitored } = repo; + + const monitorText = monitored ? gettext('Unwatch File Changes') : gettext('Watch File Changes'); + const clickHandler = monitored ? this.unwatchFileChanges : this.watchFileChanges; + + return ( +
+ + {monitorText} +
+ ); + } +} + +WatchUnwatchFileChanges.propTypes = propTypes; + +export default WatchUnwatchFileChanges; diff --git a/frontend/src/components/repo-monitored-icon.js b/frontend/src/components/repo-monitored-icon.js deleted file mode 100644 index b3d1689e28..0000000000 --- a/frontend/src/components/repo-monitored-icon.js +++ /dev/null @@ -1,31 +0,0 @@ -import React, { Fragment } from 'react'; -import PropTypes from 'prop-types'; -import { UncontrolledTooltip } from 'reactstrap'; -import { gettext } from '../utils/constants'; - -const propTypes = { - repoID: PropTypes.string.isRequired, - className: PropTypes.string -}; - -class RepoMonitoredIcon extends React.Component { - - render() { - const { repoID, className } = this.props; - return ( - - - - {gettext('You are watching file changes of this library.')} - - - ); - } -} - -RepoMonitoredIcon.propTypes = propTypes; - -export default RepoMonitoredIcon; diff --git a/frontend/src/components/shared-repo-list-view/shared-repo-list-item.js b/frontend/src/components/shared-repo-list-view/shared-repo-list-item.js index 8eefab8a84..90714b5267 100644 --- a/frontend/src/components/shared-repo-list-view/shared-repo-list-item.js +++ b/frontend/src/components/shared-repo-list-view/shared-repo-list-item.js @@ -19,7 +19,6 @@ import { userAPI } from '../../utils/user-api'; import toaster from '../toast'; import RepoAPITokenDialog from '../dialog/repo-api-token-dialog'; import RepoShareAdminDialog from '../dialog/repo-share-admin-dialog'; -import RepoMonitoredIcon from '../../components/repo-monitored-icon'; import { LIST_MODE } from '../dir-view-mode/constants'; import TransferDialog from '../dialog/transfer-dialog'; @@ -36,7 +35,6 @@ const propTypes = { onItemUnshare: PropTypes.func.isRequired, onItemRename: PropTypes.func, onItemDelete: PropTypes.func, - onMonitorRepo: PropTypes.func, onContextMenu: PropTypes.func.isRequired, onTransferRepo: PropTypes.func }; @@ -189,36 +187,10 @@ class SharedRepoListItem extends React.Component { case 'Reset Password': this.onResetPasswordToggle(); break; - case 'Watch File Changes': - this.watchFileChanges(); - break; - case 'Unwatch File Changes': - this.unwatchFileChanges(); - break; // no default } }; - watchFileChanges = () => { - const { repo } = this.props; - seafileAPI.monitorRepo(repo.repo_id).then(() => { - this.props.onMonitorRepo(repo, true); - }).catch(error => { - let errMessage = Utils.getErrorMsg(error); - toaster.danger(errMessage); - }); - }; - - unwatchFileChanges = () => { - const { repo } = this.props; - seafileAPI.unMonitorRepo(repo.repo_id).then(() => { - this.props.onMonitorRepo(repo, false); - }).catch(error => { - let errMessage = Utils.getErrorMsg(error); - toaster.danger(errMessage); - }); - }; - onItemRenameToggle = () => { this.props.onFreezedItem(); this.setState({ @@ -402,14 +374,10 @@ class SharedRepoListItem extends React.Component { if (repo.encrypted && enableResetEncryptedRepoPassword && isEmailConfigured) { operations.push('Reset Password'); } - if (repo.permission == 'r' || repo.permission == 'rw') { - const monitorOp = repo.monitored ? 'Unwatch File Changes' : 'Watch File Changes'; - operations.push(monitorOp); - } if (Utils.isDesktop()) { operations.push('Divider', 'Advanced'); } - return operations; + return operations.filter((op, i, arr) => !(op === 'Divider' && arr[i + 1] === 'Divider')); } else { operations.push('Unshare'); } @@ -422,10 +390,6 @@ class SharedRepoListItem extends React.Component { operations.push('Unshare'); } } - if (repo.permission == 'r' || repo.permission == 'rw') { - const monitorOp = repo.monitored ? 'Unwatch File Changes' : 'Watch File Changes'; - operations.push(monitorOp); - } } else { if (isRepoOwner) { operations.push('Share'); @@ -548,32 +512,6 @@ class SharedRepoListItem extends React.Component { return {shareOperation}; case 'Unshare': return {unshareOperation}; - case 'Watch File Changes': - case 'Unwatch File Changes': - return ( - - - - {[item].map((item, index) => { - return {this.translateMenuItem(item)}; - })} - - - ); - // no default default: return null; } @@ -642,7 +580,6 @@ class SharedRepoListItem extends React.Component { : {repo.repo_name} - {repo.monitored && } } @@ -675,7 +612,6 @@ class SharedRepoListItem extends React.Component { > } - {repo.monitored && } }
@@ -703,10 +639,7 @@ class SharedRepoListItem extends React.Component { {this.state.isRenaming ? : - - {repo.repo_name} - {repo.monitored && } - + {repo.repo_name} }
{repo.owner_name} diff --git a/frontend/src/components/shared-repo-list-view/shared-repo-list-view.js b/frontend/src/components/shared-repo-list-view/shared-repo-list-view.js index 182082ef8c..5af6f5491e 100644 --- a/frontend/src/components/shared-repo-list-view/shared-repo-list-view.js +++ b/frontend/src/components/shared-repo-list-view/shared-repo-list-view.js @@ -24,7 +24,6 @@ const propTypes = { onItemDelete: PropTypes.func, onItemRename: PropTypes.func, hasNextPage: PropTypes.bool, - onMonitorRepo: PropTypes.func, inAllLibs: PropTypes.bool, onTransferRepo: PropTypes.func, }; @@ -136,7 +135,6 @@ class SharedRepoListView extends React.Component { onItemUnshare={this.props.onItemUnshare} onItemDelete={this.props.onItemDelete} onItemRename={this.props.onItemRename} - onMonitorRepo={this.props.onMonitorRepo} currentViewMode={currentViewMode} onContextMenu={this.onContextMenu} /> diff --git a/frontend/src/pages/groups/group-item.js b/frontend/src/pages/groups/group-item.js index f35e3571a1..a22e9f4249 100644 --- a/frontend/src/pages/groups/group-item.js +++ b/frontend/src/pages/groups/group-item.js @@ -12,7 +12,6 @@ const propTypes = { inAllLibs: PropTypes.bool, currentViewMode: PropTypes.string, group: PropTypes.object.isRequired, - onMonitorRepo: PropTypes.func, renameRelatedGroupsRepos: PropTypes.func, deleteRelatedGroupsRepos: PropTypes.func, addRepoToGroup: PropTypes.func, @@ -52,10 +51,6 @@ class GroupItem extends React.Component { }); }; - onMonitorRepo = (repo, monitored) => { - this.props.onMonitorRepo(repo, monitored); - }; - addNewRepo = (newRepo) => { const { group } = this.props; const { id: group_id } = group; @@ -109,7 +104,6 @@ class GroupItem extends React.Component { onItemUnshare={this.onItemUnshare} onItemDelete={this.onItemDelete} onItemRename={this.onItemRename} - onMonitorRepo={this.onMonitorRepo} onTransferRepo={this.props.onTransferRepo} currentViewMode={currentViewMode} /> diff --git a/frontend/src/pages/groups/group-view.js b/frontend/src/pages/groups/group-view.js index 430a3278ff..63d50f1011 100644 --- a/frontend/src/pages/groups/group-view.js +++ b/frontend/src/pages/groups/group-view.js @@ -178,16 +178,6 @@ class GroupView extends React.Component { }); }; - onMonitorRepo = (repo, monitored) => { - let repoList = this.state.repoList.map(item => { - if (item.repo_id === repo.repo_id) { - item.monitored = monitored; - } - return item; - }); - this.setState({ repoList: repoList }); - }; - sortItems = (sortBy, sortOrder) => { cookie.save('seafile-repo-dir-sort-by', sortBy); cookie.save('seafile-repo-dir-sort-order', sortOrder); @@ -335,28 +325,32 @@ class GroupView extends React.Component { className={classnames('cur-view-content', 'd-block', 'repos-container', { 'pt-3': currentViewMode != LIST_MODE })} onScroll={this.handleScroll} > - {isLoading ? : errMessage ? -
- -

{errMessage}

-
- : repoList.length == 0 - ? emptyTip - : - + {isLoading + ? + : errMessage + ? ( +
+ +

{errMessage}

+
+ ) + : repoList.length == 0 + ? emptyTip + : ( + + ) } diff --git a/frontend/src/pages/libraries/index.js b/frontend/src/pages/libraries/index.js index 99b297631a..82201d0e0f 100644 --- a/frontend/src/pages/libraries/index.js +++ b/frontend/src/pages/libraries/index.js @@ -230,25 +230,6 @@ class Libraries extends Component { this.setState({ repoList }); }; - monitorRepo = (repoId, monitored, repoList) => { - if (!Array.isArray(repoList) || repoList.length === 0) { - return repoList; - } - return repoList.map((repo) => { - if (repo.repo_id === repoId) { - return { ...repo, monitored }; - } - return repo; - }); - }; - - onMonitorRepo = (repo, monitored) => { - const targetRepoId = repo.repo_id; - const repoList = this.monitorRepo(targetRepoId, monitored, this.state.repoList); - this.monitorRelatedGroupsRepos(targetRepoId, monitored); - this.setState({ repoList }); - }; - deleteRepo = (repoId, repoList) => { if (!Array.isArray(repoList) || repoList.length === 0) { return repoList; @@ -360,24 +341,6 @@ class Libraries extends Component { this.setState({ groupList: updatedGroups }); }; - monitorRelatedGroupsRepos = (repoId, monitored) => { - const relatedGroups = this.groupsReposManager.getRepoInGroupsIdsById(repoId); - if (relatedGroups.length === 0) { - return; - } - - const { groupList } = this.state; - const updatedGroups = groupList.map((group) => { - const { repos } = group; - if (!relatedGroups.includes(group.id)) { - return group; - } - const updatedRepos = this.monitorRepo(repoId, monitored, repos); - return { ...group, repos: updatedRepos }; - }); - this.setState({ groupList: updatedGroups }); - }; - deleteRelatedGroupsRepos = (repoId) => { const relatedGroups = this.groupsReposManager.getRepoInGroupsIdsById(repoId); if (relatedGroups.length === 0) { @@ -486,7 +449,6 @@ class Libraries extends Component { onRenameRepo={this.onRenameRepo} onDeleteRepo={this.onDeleteRepo} onTransferRepo={this.onTransferRepo} - onMonitorRepo={this.onMonitorRepo} onRepoClick={this.onRepoClick} sortRepoList={this.sortRepoList} inAllLibs={true} @@ -521,7 +483,6 @@ class Libraries extends Component { key={group.id} inAllLibs={true} group={group} - onMonitorRepo={this.onMonitorRepo} renameRelatedGroupsRepos={this.renameRelatedGroupsRepos} deleteRelatedGroupsRepos={this.deleteRelatedGroupsRepos} addRepoToGroup={this.addRepoToGroup} diff --git a/frontend/src/pages/my-libs/my-libs.js b/frontend/src/pages/my-libs/my-libs.js index a0fd829b0a..1bbe231cd2 100644 --- a/frontend/src/pages/my-libs/my-libs.js +++ b/frontend/src/pages/my-libs/my-libs.js @@ -113,16 +113,6 @@ class MyLibraries extends Component { this.setState({ repoList: repoList }); }; - onMonitorRepo = (repo, monitored) => { - let repoList = this.state.repoList.map(item => { - if (item.repo_id === repo.repo_id) { - item.monitored = monitored; - } - return item; - }); - this.setState({ repoList: repoList }); - }; - onDeleteRepo = (repo) => { let repoList = this.state.repoList.filter(item => { return item.repo_id !== repo.repo_id; @@ -203,7 +193,6 @@ class MyLibraries extends Component { onRenameRepo={this.onRenameRepo} onDeleteRepo={this.onDeleteRepo} onTransferRepo={this.onTransferRepo} - onMonitorRepo={this.onMonitorRepo} sortRepoList={this.sortRepoList} currentViewMode={currentViewMode} /> diff --git a/frontend/src/pages/my-libs/mylib-repo-list-item.js b/frontend/src/pages/my-libs/mylib-repo-list-item.js index 37b18c2419..95d3a5f4c6 100644 --- a/frontend/src/pages/my-libs/mylib-repo-list-item.js +++ b/frontend/src/pages/my-libs/mylib-repo-list-item.js @@ -21,7 +21,6 @@ import MylibRepoMenu from './mylib-repo-menu'; 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 RepoMonitoredIcon from '../../components/repo-monitored-icon'; import { LIST_MODE } from '../../components/dir-view-mode/constants'; import { userAPI } from '../../utils/user-api'; @@ -35,7 +34,6 @@ const propTypes = { onRenameRepo: PropTypes.func.isRequired, onDeleteRepo: PropTypes.func.isRequired, onTransferRepo: PropTypes.func.isRequired, - onMonitorRepo: PropTypes.func.isRequired, onContextMenu: PropTypes.func.isRequired, }; @@ -113,12 +111,6 @@ class MylibRepoListItem extends React.Component { case 'Reset Password': this.onResetPasswordToggle(); break; - case 'Watch File Changes': - this.watchFileChanges(); - break; - case 'Unwatch File Changes': - this.unwatchFileChanges(); - break; case 'Folder Permission': this.onFolderPermissionToggle(); break; @@ -170,26 +162,6 @@ class MylibRepoListItem extends React.Component { } }; - watchFileChanges = () => { - const { repo } = this.props; - seafileAPI.monitorRepo(repo.repo_id).then(() => { - this.props.onMonitorRepo(repo, true); - }).catch(error => { - let errMessage = Utils.getErrorMsg(error); - toaster.danger(errMessage); - }); - }; - - unwatchFileChanges = () => { - const { repo } = this.props; - seafileAPI.unMonitorRepo(repo.repo_id).then(() => { - this.props.onMonitorRepo(repo, false); - }).catch(error => { - let errMessage = Utils.getErrorMsg(error); - toaster.danger(errMessage); - }); - }; - onShareToggle = () => { this.setState({ isShareDialogShow: !this.state.isShareDialogShow }); }; @@ -333,7 +305,6 @@ class MylibRepoListItem extends React.Component { {!this.state.isRenaming && repo.repo_name && ( {repo.repo_name} - {repo.monitored && } )} {!this.state.isRenaming && !repo.repo_name && @@ -389,7 +360,6 @@ class MylibRepoListItem extends React.Component { > } - {repo.monitored && } )} {!this.state.isRenaming && !repo.repo_name && @@ -433,7 +403,6 @@ class MylibRepoListItem extends React.Component { {!this.state.isRenaming && repo.repo_name && (
{repo.repo_name} - {repo.monitored && }
)} {!this.state.isRenaming && !repo.repo_name && diff --git a/frontend/src/pages/my-libs/mylib-repo-list-view.js b/frontend/src/pages/my-libs/mylib-repo-list-view.js index 27266de4cc..fd7568ebff 100644 --- a/frontend/src/pages/my-libs/mylib-repo-list-view.js +++ b/frontend/src/pages/my-libs/mylib-repo-list-view.js @@ -18,7 +18,6 @@ const propTypes = { onRenameRepo: PropTypes.func.isRequired, onDeleteRepo: PropTypes.func.isRequired, onTransferRepo: PropTypes.func.isRequired, - onMonitorRepo: PropTypes.func.isRequired, inAllLibs: PropTypes.bool, // for 'My Libraries' in 'Files' page currentViewMode: PropTypes.string, }; @@ -101,7 +100,6 @@ class MylibRepoListView extends React.Component { onRenameRepo={this.props.onRenameRepo} onDeleteRepo={this.props.onDeleteRepo} onTransferRepo={this.props.onTransferRepo} - onMonitorRepo={this.props.onMonitorRepo} currentViewMode={this.props.currentViewMode} onContextMenu={this.onContextMenu} inAllLibs={this.props.inAllLibs} diff --git a/frontend/src/pages/my-libs/mylib-repo-menu.js b/frontend/src/pages/my-libs/mylib-repo-menu.js index 0f3fc7f3f8..742f250efc 100644 --- a/frontend/src/pages/my-libs/mylib-repo-menu.js +++ b/frontend/src/pages/my-libs/mylib-repo-menu.js @@ -105,11 +105,6 @@ class MylibRepoMenu extends React.Component { operations.push('Reset Password'); } - if (isPro) { - const monitorOp = repo.monitored ? 'Unwatch File Changes' : 'Watch File Changes'; - operations.push(monitorOp); - } - operations.push('Divider', 'Advanced'); // Remove adjacent excess 'Divider' for (let i = 0; i < operations.length; i++) { @@ -160,12 +155,6 @@ class MylibRepoMenu extends React.Component { case 'Reset Password': translateResult = gettext('Reset Password'); break; - case 'Watch File Changes': - translateResult = gettext('Watch File Changes'); - break; - case 'Unwatch File Changes': - translateResult = gettext('Unwatch File Changes'); - break; case 'Folder Permission': translateResult = gettext('Folder Permission'); break; diff --git a/frontend/src/pages/shared-libs/content.js b/frontend/src/pages/shared-libs/content.js index fae42b2a16..8637758686 100644 --- a/frontend/src/pages/shared-libs/content.js +++ b/frontend/src/pages/shared-libs/content.js @@ -105,7 +105,6 @@ class Content extends Component { isDesktop={isDesktop} isItemFreezed={this.state.isItemFreezed} freezeItem={this.freezeItem} - onMonitorRepo={this.props.onMonitorRepo} currentViewMode={currentViewMode} onContextMenu={this.onContextMenu} />; @@ -171,7 +170,6 @@ Content.propTypes = { sortBy: PropTypes.string.isRequired, sortOrder: PropTypes.string.isRequired, sortItems: PropTypes.func.isRequired, - onMonitorRepo: PropTypes.func.isRequired }; export default Content; diff --git a/frontend/src/pages/shared-libs/index.js b/frontend/src/pages/shared-libs/index.js index d813ca018a..8aff9caad4 100644 --- a/frontend/src/pages/shared-libs/index.js +++ b/frontend/src/pages/shared-libs/index.js @@ -66,16 +66,6 @@ class SharedLibraries extends Component { }); }; - onMonitorRepo = (repo, monitored) => { - let items = this.state.items.map(item => { - if (item.repo_id === repo.repo_id) { - item.monitored = monitored; - } - return item; - }); - this.setState({ items: items }); - }; - renderContent = (currentViewMode) => { const { inAllLibs = false, repoList } = this.props; // inAllLibs: in 'All Libs'('Files') page const { items } = this.state; @@ -87,7 +77,6 @@ class SharedLibraries extends Component { sortBy={this.state.sortBy} sortOrder={this.state.sortOrder} sortItems={this.sortItems} - onMonitorRepo={this.onMonitorRepo} inAllLibs={inAllLibs} currentViewMode={currentViewMode} /> diff --git a/frontend/src/pages/shared-libs/item.js b/frontend/src/pages/shared-libs/item.js index 8153a450e2..77540f1884 100644 --- a/frontend/src/pages/shared-libs/item.js +++ b/frontend/src/pages/shared-libs/item.js @@ -1,5 +1,5 @@ import React, { Component, Fragment } from 'react'; -import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap'; +import { DropdownItem } from 'reactstrap'; import PropTypes from 'prop-types'; import dayjs from 'dayjs'; import relativeTime from 'dayjs/plugin/relativeTime'; @@ -10,7 +10,6 @@ import { Utils } from '../../utils/utils'; import toaster from '../../components/toast'; import ModalPortal from '../../components/modal-portal'; import ShareDialog from '../../components/dialog/share-dialog'; -import RepoMonitoredIcon from '../../components/repo-monitored-icon'; import MobileItemMenu from '../../components/mobile-item-menu'; import { LIST_MODE } from '../../components/dir-view-mode/constants'; @@ -124,26 +123,6 @@ class Item extends Component { navigate(this.repoURL); }; - watchFileChanges = () => { - const { data: repo } = this.props; - seafileAPI.monitorRepo(repo.repo_id).then(() => { - this.props.onMonitorRepo(repo, true); - }).catch(error => { - let errMessage = Utils.getErrorMsg(error); - toaster.danger(errMessage); - }); - }; - - unwatchFileChanges = () => { - const { data: repo } = this.props; - seafileAPI.unMonitorRepo(repo.repo_id).then(() => { - this.props.onMonitorRepo(repo, false); - }).catch(error => { - let errMessage = Utils.getErrorMsg(error); - toaster.danger(errMessage); - }); - }; - handleContextMenu = (event) => { this.props.onContextMenu(event, this.props.data); }; @@ -156,12 +135,6 @@ class Item extends Component { case 'Unshare': this.leaveShare(event); break; - case 'Watch File Changes': - this.watchFileChanges(); - break; - case 'Unwatch File Changes': - this.unwatchFileChanges(); - break; default: break; } @@ -182,9 +155,6 @@ class Item extends Component { let leaveShareIconClassName = 'op-icon sf2-icon-x3' + iconVisibility; let shareRepoUrl = this.repoURL = `${siteRoot}library/${data.repo_id}/${Utils.encodePath(data.repo_name)}/`; - // at present, only repo shared with 'r', 'rw' can be monitored.(Fri Feb 10 16:24:49 CST 2023) - const enableMonitorRepo = isPro && (data.permission == 'r' || data.permission == 'rw'); - if (this.props.isDesktop) { return ( @@ -204,7 +174,6 @@ class Item extends Component { {data.repo_name} - {data.monitored && } @@ -213,23 +182,6 @@ class Item extends Component { } - {enableMonitorRepo && - - - - {data.monitored ? gettext('Unwatch File Changes') : gettext('Watch File Changes')} - - - } {data.size} @@ -257,7 +209,6 @@ class Item extends Component { > } - {data.monitored && }
@@ -265,23 +216,6 @@ class Item extends Component { } - {enableMonitorRepo && - - - - {data.monitored ? gettext('Unwatch File Changes') : gettext('Watch File Changes')} - - - }
)} @@ -310,7 +244,6 @@ class Item extends Component { {data.icon_title} {data.repo_name} - {data.monitored && }
{data.owner_name} {data.size} @@ -325,14 +258,6 @@ class Item extends Component { {gettext('Share')} } {gettext('Leave Share')} - {enableMonitorRepo && - - {data.monitored ? gettext('Unwatch File Changes') : gettext('Watch File Changes')} - - } @@ -364,7 +289,6 @@ Item.propTypes = { data: PropTypes.object.isRequired, isItemFreezed: PropTypes.bool.isRequired, freezeItem: PropTypes.func.isRequired, - onMonitorRepo: PropTypes.func.isRequired, onContextMenu: PropTypes.func.isRequired, }; diff --git a/frontend/src/utils/text-translation.js b/frontend/src/utils/text-translation.js index 0078272bcb..c02c8286fb 100644 --- a/frontend/src/utils/text-translation.js +++ b/frontend/src/utils/text-translation.js @@ -181,14 +181,6 @@ const TextTranslation = { key: 'Reset Password', value: gettext('Reset Password') }, - UNWATCH_FILE_CHANGES: { - key: 'Unwatch File Changes', - value: gettext('Unwatch File Changes') - }, - WATCH_FILE_CHANGES: { - key: 'Watch File Changes', - value: gettext('Watch File Changes') - }, ADVANCED: { key: 'advanced', value: gettext('Advanced') diff --git a/frontend/src/utils/utils.js b/frontend/src/utils/utils.js index 66f91bc145..71d4b48e57 100644 --- a/frontend/src/utils/utils.js +++ b/frontend/src/utils/utils.js @@ -721,7 +721,7 @@ export const Utils = { const showResetPasswordMenuItem = isPro && repo.encrypted && enableResetEncryptedRepoPassword && isEmailConfigured; const operations = []; const DIVIDER = 'Divider'; - const { SHARE, DELETE, RENAME, TRANSFER, FOLDER_PERMISSION, SHARE_ADMIN, CHANGE_PASSWORD, RESET_PASSWORD, UNWATCH_FILE_CHANGES, WATCH_FILE_CHANGES, ADVANCED } = TextTranslation; + const { SHARE, DELETE, RENAME, TRANSFER, FOLDER_PERMISSION, SHARE_ADMIN, CHANGE_PASSWORD, RESET_PASSWORD, ADVANCED } = TextTranslation; operations.push(SHARE, DELETE, DIVIDER, RENAME, TRANSFER); @@ -738,11 +738,6 @@ export const Utils = { operations.push(RESET_PASSWORD); } - if (isPro) { - const monitorOp = repo.monitored ? UNWATCH_FILE_CHANGES : WATCH_FILE_CHANGES; - operations.push(monitorOp); - } - operations.push(DIVIDER); const subOpList = Utils.getAdvancedOperations(); operations.push({ ...ADVANCED, subOpList }); @@ -765,7 +760,7 @@ export const Utils = { }, getSharedLibsOperationList: function (lib) { - const { SHARE, UNSHARE, WATCH_FILE_CHANGES, UNWATCH_FILE_CHANGES } = TextTranslation; + const { SHARE, UNSHARE } = TextTranslation; const operations = []; if (isPro && lib.is_admin) { @@ -773,9 +768,6 @@ export const Utils = { } operations.push(UNSHARE); - const monitorOp = lib.monitored ? UNWATCH_FILE_CHANGES : WATCH_FILE_CHANGES; - operations.push(monitorOp); - return operations; }, @@ -793,7 +785,7 @@ export const Utils = { getSharedRepoOperationList: function (repo, currentGroup, isPublic) { const operations = []; - const { SHARE, UNSHARE, DELETE, RENAME, FOLDER_PERMISSION, SHARE_ADMIN, UNWATCH_FILE_CHANGES, WATCH_FILE_CHANGES, ADVANCED, CHANGE_PASSWORD, RESET_PASSWORD, API_TOKEN } = TextTranslation; + const { SHARE, UNSHARE, DELETE, RENAME, FOLDER_PERMISSION, SHARE_ADMIN, ADVANCED, CHANGE_PASSWORD, RESET_PASSWORD, API_TOKEN } = TextTranslation; const isStaff = currentGroup && currentGroup.admins && currentGroup.admins.indexOf(username) > -1; const isRepoOwner = repo.owner_email === username; @@ -823,16 +815,12 @@ export const Utils = { if (repo.encrypted && enableResetEncryptedRepoPassword && isEmailConfigured) { operations.push(RESET_PASSWORD); } - if (repo.permission === 'r' || repo.permission === 'rw') { - const monitorOp = repo.monitored ? UNWATCH_FILE_CHANGES : WATCH_FILE_CHANGES; - operations.push(monitorOp); - } if (Utils.isDesktop()) { operations.push(DIVIDER); const subOpList = [API_TOKEN]; operations.push({ ...ADVANCED, subOpList }); } - return operations; + return operations.filter((op, i, arr) => !(op === DIVIDER && arr[i + 1] === DIVIDER)); } else { operations.push(UNSHARE); } @@ -845,10 +833,6 @@ export const Utils = { operations.push(UNSHARE); } } - if (repo.permission === 'r' || repo.permission === 'rw') { - const monitorOp = repo.monitored ? UNWATCH_FILE_CHANGES : WATCH_FILE_CHANGES; - operations.push(monitorOp); - } } else { if (isRepoOwner) { operations.push(SHARE);