From b07f33e07c4199ad9d9a7fb8f10af72b4f64cfce Mon Sep 17 00:00:00 2001 From: Michael An <2331806369@qq.com> Date: Wed, 22 Jan 2025 14:38:40 +0800 Subject: [PATCH] add repo in right tool panel (#7410) --- frontend/src/components/add-repos.js | 61 +++++++++++++++++++++ frontend/src/components/view-modes.js | 4 +- frontend/src/pages/groups/group-view.js | 6 +- frontend/src/pages/libraries/index.js | 6 +- frontend/src/pages/my-libs/my-libs.js | 6 +- frontend/src/pages/shared-libs/index.js | 4 +- frontend/src/pages/shared-with-all/index.js | 4 +- 7 files changed, 75 insertions(+), 16 deletions(-) create mode 100644 frontend/src/components/add-repos.js diff --git a/frontend/src/components/add-repos.js b/frontend/src/components/add-repos.js new file mode 100644 index 0000000000..5002fe3cf9 --- /dev/null +++ b/frontend/src/components/add-repos.js @@ -0,0 +1,61 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Dropdown, DropdownMenu, DropdownToggle, DropdownItem } from 'reactstrap'; +import { gettext } from '../utils/constants'; + +const propTypes = { + className: PropTypes.string, + onAddRepo: PropTypes.func.isRequired, +}; + +class AddRepos extends React.Component { + + constructor(props) { + super(props); + this.state = { + isDropdownMenuOpen: false + }; + } + + toggleDropdownMenu = () => { + this.setState({ + isDropdownMenuOpen: !this.state.isDropdownMenuOpen + }); + }; + + render() { + const { isDropdownMenuOpen } = this.state; + const { className = '' } = this.props; + return ( + + + + + + + + + + + {gettext('New Library')} + + + + ); + } + +} + +AddRepos.propTypes = propTypes; + +export default AddRepos; diff --git a/frontend/src/components/view-modes.js b/frontend/src/components/view-modes.js index 951e67c72d..939579542f 100644 --- a/frontend/src/components/view-modes.js +++ b/frontend/src/components/view-modes.js @@ -8,6 +8,7 @@ import { GRID_MODE, LIST_MODE } from './dir-view-mode/constants'; import '../css/view-modes.css'; const propTypes = { + className: PropTypes.string, currentViewMode: PropTypes.string.isRequired, switchViewMode: PropTypes.func.isRequired }; @@ -47,7 +48,7 @@ class ViewModes extends React.Component { render() { const { isDropdownMenuOpen } = this.state; - const { currentViewMode } = this.props; + const { currentViewMode, className = '' } = this.props; const shortcutMain = Utils.isMac() ? '⇧ ⌘' : 'Ctrl + Shift +'; const options = [ { 'icon': 'list-view', 'text': gettext('List view'), 'value': LIST_MODE, 'shortcut': `${shortcutMain} 1` }, @@ -58,6 +59,7 @@ class ViewModes extends React.Component { isOpen={isDropdownMenuOpen} toggle={this.toggleDropdownMenu} id="cur-view-change-mode-dropdown" + className={className} > -
- -
+ + )} diff --git a/frontend/src/pages/libraries/index.js b/frontend/src/pages/libraries/index.js index 0a4834894e..43469b4076 100644 --- a/frontend/src/pages/libraries/index.js +++ b/frontend/src/pages/libraries/index.js @@ -9,6 +9,7 @@ import toaster from '../../components/toast'; import Loading from '../../components/loading'; import ViewModes from '../../components/view-modes'; import ReposSortMenu from '../../components/sort-menu'; +import AddRepos from '../../components/add-repos'; import SingleDropdownToolbar from '../../components/toolbar/single-dropdown-toolbar'; import SortOptionsDialog from '../../components/dialog/sort-options'; import GuideForNewDialog from '../../components/dialog/guide-for-new-dialog'; @@ -407,9 +408,8 @@ class Libraries extends Component {

{gettext('Files')}

{isDesktop &&
-
- -
+ +
} diff --git a/frontend/src/pages/my-libs/my-libs.js b/frontend/src/pages/my-libs/my-libs.js index 4b74b3e67a..a6ae1cbc43 100644 --- a/frontend/src/pages/my-libs/my-libs.js +++ b/frontend/src/pages/my-libs/my-libs.js @@ -10,6 +10,7 @@ import Loading from '../../components/loading'; import EmptyTip from '../../components/empty-tip'; import ModalPortal from '../../components/modal-portal'; import ViewModes from '../../components/view-modes'; +import AddRepos from '../../components/add-repos'; import ReposSortMenu from '../../components/sort-menu'; import SingleDropdownToolbar from '../../components/toolbar/single-dropdown-toolbar'; import SortOptionsDialog from '../../components/dialog/sort-options'; @@ -174,9 +175,8 @@ class MyLibraries extends Component { {isDesktop ? (
-
- -
+ +
) : ( diff --git a/frontend/src/pages/shared-libs/index.js b/frontend/src/pages/shared-libs/index.js index d813ca018a..f4a568acd9 100644 --- a/frontend/src/pages/shared-libs/index.js +++ b/frontend/src/pages/shared-libs/index.js @@ -142,9 +142,7 @@ class SharedLibraries extends Component {

{gettext('Shared with me')}

{Utils.isDesktop() && (
-
- -
+
)} diff --git a/frontend/src/pages/shared-with-all/index.js b/frontend/src/pages/shared-with-all/index.js index dd00d606f2..5a146f41ab 100644 --- a/frontend/src/pages/shared-with-all/index.js +++ b/frontend/src/pages/shared-with-all/index.js @@ -263,9 +263,7 @@ class SharedWithAll extends React.Component { {Utils.isDesktop() && (
-
- -
+
)}