diff --git a/frontend/src/components/toolbar/dir-operation-toolbar.js b/frontend/src/components/toolbar/dir-operation-toolbar.js index a51ae4f696..a35344cbb4 100644 --- a/frontend/src/components/toolbar/dir-operation-toolbar.js +++ b/frontend/src/components/toolbar/dir-operation-toolbar.js @@ -1,10 +1,11 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; +import copy from 'copy-to-clipboard'; import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap'; import { Utils } from '../../utils/utils'; +import { seafileAPI } from '../../utils/seafile-api'; import { enableExcalidraw, enableSeadoc, enableWhiteboard, gettext } from '../../utils/constants'; import toaster from '../toast'; -import { seafileAPI } from '../../utils/seafile-api'; import TipDialog from '../dialog/tip-dailog'; import { EVENT_BUS_TYPE } from '../common/event-bus-type'; @@ -64,6 +65,15 @@ class DirOperationToolbar extends React.Component { eventBus.dispatch(EVENT_BUS_TYPE.SHARE_FILE, path, { type, name, permission: userPerm }); }; + copyPath = () => { + const { path } = this.props; + copy(path); + const message = gettext('The path has been copied to the clipboard'); + toaster.success((message), { + duration: 2 + }); + }; + onCreateFolder = () => { const { eventBus, path, direntList } = this.props; eventBus.dispatch(EVENT_BUS_TYPE.CREATE_FOLDER, path, direntList); @@ -220,6 +230,12 @@ class DirOperationToolbar extends React.Component { }); } + opList.push({ + 'icon': 'copy1', + 'text': gettext('Copy path'), + 'onClick': this.copyPath + }); + if (enableSeadoc && !repoEncrypted) { opList.push('Divider', { 'icon': 'import-sdoc',