diff --git a/frontend/src/components/dialog/create-group-dialog.js b/frontend/src/components/dialog/create-group-dialog.js
new file mode 100644
index 0000000000..030bebe2b7
--- /dev/null
+++ b/frontend/src/components/dialog/create-group-dialog.js
@@ -0,0 +1,62 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { gettext } from '../../utils/constants';
+import { seafileAPI } from '../../utils/seafile-api';
+import { Modal, ModalHeader, ModalBody, ModalFooter, Input, Button } from 'reactstrap';
+
+class CreateGroupDialog extends React.Component {
+
+ constructor(props) {
+ super(props);
+ this.state = {
+ groupName: '',
+ };
+ }
+
+ handleGroupChange = (event) => {
+ let name = event.target.value.trim();
+ this.setState({
+ groupName: name
+ });
+ }
+
+ handleSubmitGroup = () => {
+ let name = this.state.groupName.trim();
+ if (name) {
+ let that = this;
+ seafileAPI.createGroup(name).then((res)=> {
+ that.props.listGroups();
+ });
+ }
+ this.setState({
+ groupName: '',
+ });
+ this.props.toggleAddGroupModal();
+ }
+
+ render() {
+ return(
+
+ {gettext('New group')}
+
+
+
+
+
+
+
+
+
+ );
+ }
+}
+
+const CreateGroupDialogPropTypes = {
+ toggleAddGroupModal: PropTypes.func.isRequired,
+ listGroups: PropTypes.func.isRequired,
+ showAddGroupModal: PropTypes.bool.isRequired,
+};
+
+CreateGroupDialog.propTypes = CreateGroupDialogPropTypes;
+
+export default CreateGroupDialog;
\ No newline at end of file
diff --git a/frontend/src/components/toolbar/groups-toolbar.js b/frontend/src/components/toolbar/groups-toolbar.js
new file mode 100644
index 0000000000..f6dbfacd2f
--- /dev/null
+++ b/frontend/src/components/toolbar/groups-toolbar.js
@@ -0,0 +1,43 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import CommonToolbar from './common-toolbar';
+import { Button } from 'reactstrap';
+import { gettext } from '../../utils/constants';
+
+const propTypes = {
+ searchPlaceholder: PropTypes.string,
+ onShowSidePanel: PropTypes.func.isRequired,
+ onSearchedClick: PropTypes.func.isRequired,
+ toggleAddGroupModal: PropTypes.func.isRequired,
+};
+
+class GroupsToolbar extends React.Component {
+
+ constructor(props) {
+ super(props);
+ }
+
+ render() {
+ let { onShowSidePanel, onSearchedClick } = this.props;
+ let placeHolder = this.props.searchPlaceholder || 'Search files in this library';
+ return (
+
+
+
+
+
+
+
+
+
+
+ );
+ }
+}
+
+GroupsToolbar.propTypes = propTypes;
+
+export default GroupsToolbar;
diff --git a/frontend/src/pages/groups/groups-view.js b/frontend/src/pages/groups/groups-view.js
index cd15a23cf4..8eca160b1b 100644
--- a/frontend/src/pages/groups/groups-view.js
+++ b/frontend/src/pages/groups/groups-view.js
@@ -5,8 +5,9 @@ import { seafileAPI } from '../../utils/seafile-api';
import Loading from '../../components/loading';
import Group from '../../models/group';
import RepoInfo from '../../models/repoInfo';
-import GeneralToolbar from '../../components/toolbar/general-toolbar';
+import GroupsToolbar from '../../components/toolbar/groups-toolbar';
import SharedRepoListView from '../../components/shared-repo-list-view/shared-repo-list-view';
+import CreateGroupDialog from '../../components/dialog/create-group-dialog';
import '../../css/groups.css';
@@ -76,10 +77,11 @@ class GroupsView extends React.Component {
isLoading: true,
errorMsg: '',
groupList: [],
+ showAddGroupModal: false,
}
}
- componentDidMount() {
+ listGroups = () => {
seafileAPI.listGroupsV2({'with_repos': 1}).then((res) => { // TODO: api name
// `{'with_repos': 1}`: list repos of every group
// res: {data: [...], status: 200, statusText: "OK", headers: {…}, config: {…}, …}
@@ -114,10 +116,24 @@ class GroupsView extends React.Component {
});
}
+ toggleAddGroupModal = () => {
+ this.setState({
+ showAddGroupModal: !this.state.showAddGroupModal
+ });
+ }
+
+ componentDidMount() {
+ this.listGroups();
+ }
+
render() {
return (
-
+
@@ -135,11 +151,24 @@ class GroupsView extends React.Component {
+ { this.state.showAddGroupModal &&
+
+ }
);
}
}
+const GroupsViewPropTypes = {
+ onShowSidePanel: PropTypes.func.isRequired,
+ onSearchedClick: PropTypes.func.isRequired,
+};
+
+GroupsView.propTypes = GroupsViewPropTypes;
// Groups.propTypes = propTypes;
export default GroupsView;