diff --git a/web/client/plugins/manager/GroupManager.jsx b/web/client/plugins/manager/GroupManager.jsx
index bb3f52f43c..6f741f302a 100644
--- a/web/client/plugins/manager/GroupManager.jsx
+++ b/web/client/plugins/manager/GroupManager.jsx
@@ -9,26 +9,41 @@ const React = require('react');
const {connect} = require('react-redux');
const {Button, Grid, Glyphicon} = require('react-bootstrap');
const {editGroup} = require('../../actions/usergroups');
-const {setControlProperty} = require('../../actions/controls');
-const SearchBar = require('./users/SearchBar');
+const {getUserGroups, groupSearchTextChanged} = require('../../actions/usergroups');
+const SearchBar = require("../../components/mapcontrols/search/SearchBar");
const GroupsGrid = require('./users/GroupGrid');
const GroupDialog = require('./users/GroupDialog');
const GroupDeleteConfirm = require('./users/GroupDeleteConfirm');
const Message = require('../../components/I18N/Message');
const assign = require('object-assign');
-
+const {trim} = require('lodash');
const GroupManager = React.createClass({
propTypes: {
- selectedTool: React.PropTypes.string,
- selectedGroup: React.PropTypes.string,
onNewGroup: React.PropTypes.func,
- onToggleUsersGroups: React.PropTypes.func
+ className: React.PropTypes.string,
+ hideOnBlur: React.PropTypes.bool,
+ placeholderMsgId: React.PropTypes.string,
+ typeAhead: React.PropTypes.bool,
+ searchText: React.PropTypes.string,
+ onSearch: React.PropTypes.func,
+ onSearchReset: React.PropTypes.func,
+ onSearchTextChange: React.PropTypes.func,
+ start: React.PropTypes.number,
+ limit: React.PropTypes.number
},
getDefaultProps() {
return {
- selectedGroup: "groups",
+ className: "user-search",
+ hideOnBlur: false,
+ placeholderMsgId: "usergroups.searchGroups",
+ typeAhead: false,
+ searchText: "",
+ start: 0,
+ limit: 20,
onNewGroup: () => {},
- onToggleUsersGroups: () => {}
+ onSearch: () => {},
+ onSearchReset: () => {},
+ onSearchTextChange: () => {}
};
},
onNew() {
@@ -36,8 +51,17 @@ const GroupManager = React.createClass({
},
render() {
return (
-
- {this.toogleTools()}
+
);
- },
- toogleTools() {
- this.props.onToggleUsersGroups(this.props.selectedGroup);
}
});
module.exports = {
GroupManagerPlugin: assign(
- connect((state) => ({
- selectedTool: state && state.controls && state.controls.managerchoice && state.controls.managerchoice.selectedTool
- }), {
+ connect((state) => {
+ let searchState = state && state.usergroups;
+ return {
+ start: searchState && searchState.start,
+ limit: searchState && searchState.limit,
+ searchText: (searchState && searchState.searchText && trim(searchState.searchText, '*')) || ""
+ };
+ }, {
onNewGroup: editGroup.bind(null, {}),
- onToggleUsersGroups: setControlProperty.bind(null, "managerchoice", "selectedTool")
+ onSearchTextChange: groupSearchTextChanged,
+ onSearch: getUserGroups
+ }, (stateProps, dispatchProps) => {
+ return {
+ ...stateProps,
+ ...dispatchProps,
+ onSearchReset: (text) => {
+ let limit = stateProps.limit;
+ let searchText = (text && text !== "") ? ("*" + text + "*") : "*";
+ dispatchProps.onSearch(searchText, {params: {start: 0, limit}});
+ },
+ onSearch: (text) => {
+ let limit = stateProps.limit;
+ let searchText = (text && text !== "") ? ("*" + text + "*") : "*";
+ dispatchProps.onSearch(searchText, {params: {start: 0, limit}});
+ }
+ };
})(GroupManager), {
hide: true,
Manager: {
@@ -70,8 +112,6 @@ module.exports = {
glyph: "1-group-mod"
}}),
reducers: {
- users: require('../../reducers/users'),
- usergroups: require('../../reducers/usergroups'),
- controls: require('../../reducers/controls')
+ usergroups: require('../../reducers/usergroups')
}
};
diff --git a/web/client/plugins/manager/UserManager.jsx b/web/client/plugins/manager/UserManager.jsx
index 9d02fdf547..433dcf0c10 100644
--- a/web/client/plugins/manager/UserManager.jsx
+++ b/web/client/plugins/manager/UserManager.jsx
@@ -9,26 +9,41 @@ const React = require('react');
const {connect} = require('react-redux');
const {Button, Grid, Glyphicon} = require('react-bootstrap');
const {editUser} = require('../../actions/users');
-const {setControlProperty} = require('../../actions/controls');
-const SearchBar = require('./users/SearchBar');
+const {getUsers, usersSearchTextChanged} = require('../../actions/users');
+const SearchBar = require("../../components/mapcontrols/search/SearchBar");
const UserGrid = require('./users/UserGrid');
const UserDialog = require('./users/UserDialog');
const UserDeleteConfirm = require('./users/UserDeleteConfirm');
const Message = require('../../components/I18N/Message');
const assign = require('object-assign');
-
+const {trim} = require('lodash');
const UserManager = React.createClass({
propTypes: {
- selectedTool: React.PropTypes.string,
- selectedGroup: React.PropTypes.string,
onNewUser: React.PropTypes.func,
- onToggleUsersGroups: React.PropTypes.func
+ className: React.PropTypes.string,
+ hideOnBlur: React.PropTypes.bool,
+ placeholderMsgId: React.PropTypes.string,
+ typeAhead: React.PropTypes.bool,
+ searchText: React.PropTypes.string,
+ onSearch: React.PropTypes.func,
+ onSearchReset: React.PropTypes.func,
+ onSearchTextChange: React.PropTypes.func,
+ start: React.PropTypes.number,
+ limit: React.PropTypes.number
},
getDefaultProps() {
return {
- selectedGroup: "users",
- onNewUser: () => {},
- onToggleUsersGroups: () => {}
+ className: "user-search",
+ hideOnBlur: false,
+ placeholderMsgId: "users.searchUsers",
+ typeAhead: false,
+ searchText: "",
+ start: 0,
+ limit: 20,
+ onSearch: () => {},
+ onSearchReset: () => {},
+ onSearchTextChange: () => {},
+ onNewUser: () => {}
};
},
onNew() {
@@ -36,8 +51,17 @@ const UserManager = React.createClass({
},
render() {
return (
-
- {this.toogleTools()}
+
@@ -46,18 +70,37 @@ const UserManager = React.createClass({
);
- },
- toogleTools() {
- this.props.onToggleUsersGroups(this.props.selectedGroup);
}
});
module.exports = {
UserManagerPlugin: assign(
- connect((state) => ({
- selectedTool: state && state.controls && state.controls.managerchoice && state.controls.managerchoice.selectedTool
- }), {
+ connect((state) => {
+ let searchState = state && state.users;
+ return {
+ start: searchState && searchState.start,
+ limit: searchState && searchState.limit,
+ searchText: (searchState && searchState.searchText && trim(searchState.searchText, '*')) || ""
+ };
+ },
+ {
onNewUser: editUser.bind(null, {role: "USER", "enabled": true}),
- onToggleUsersGroups: setControlProperty.bind(null, "managerchoice", "selectedTool")
+ onSearchTextChange: usersSearchTextChanged,
+ onSearch: getUsers
+ }, (stateProps, dispatchProps) => {
+ return {
+ ...stateProps,
+ ...dispatchProps,
+ onSearchReset: (text) => {
+ let limit = stateProps.limit;
+ let searchText = (text && text !== "") ? ("*" + text + "*") : "*";
+ dispatchProps.onSearch(searchText, {params: {start: 0, limit}});
+ },
+ onSearch: (text) => {
+ let limit = stateProps.limit;
+ let searchText = (text && text !== "") ? ("*" + text + "*") : "*";
+ dispatchProps.onSearch(searchText, {params: {start: 0, limit}});
+ }
+ };
})(UserManager), {
hide: true,
Manager: {
@@ -68,8 +111,6 @@ module.exports = {
glyph: "1-user-mod"
}}),
reducers: {
- users: require('../../reducers/users'),
- usergroups: require('../../reducers/usergroups'),
- controls: require('../../reducers/controls')
+ users: require('../../reducers/users')
}
};
diff --git a/web/client/plugins/manager/users/SearchBar.jsx b/web/client/plugins/manager/users/SearchBar.jsx
deleted file mode 100644
index d8460474bd..0000000000
--- a/web/client/plugins/manager/users/SearchBar.jsx
+++ /dev/null
@@ -1,69 +0,0 @@
-
-/**
- * Copyright 2016, GeoSolutions Sas.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree.
- */
-const {connect} = require('react-redux');
-
-
-const {getUsers, usersSearchTextChanged} = require('../../../actions/users');
-const {getUserGroups, groupSearchTextChanged} = require('../../../actions/usergroups');
-
-const {trim} = require('lodash');
-const USERS = "users";
-// const GROUPS = "groups";
-const SearchBar = connect((state) => {
- let tool = state && state.controls && state.controls.managerchoice && state.controls.managerchoice.selectedTool;
- let searchState = tool === USERS ? (state && state.users) : (state && state.usergroups);
- return {
- tool,
- className: "user-search",
- hideOnBlur: false,
- placeholderMsgId: tool === USERS ? "users.searchUsers" : "usergroups.searchGroups",
- typeAhead: false,
- start: searchState && searchState.start,
- limit: searchState && searchState.limit,
- searchText: (searchState && searchState.searchText && trim(searchState.searchText, '*')) || ""
- };
-}, {
- usersSearchTextChanged, groupSearchTextChanged,
- onSearchUser: (text, options) => {
- let searchText = (text && text !== "") ? ("*" + text + "*") : "*";
- return getUsers(searchText, options);
- },
- onSearchGroup: (text, options) => {
- let searchText = (text && text !== "") ? ("*" + text + "*") : "*";
- return getUserGroups(searchText, options);
- }
-}, (stateProps, dispatchProps) => {
- return {
- ...stateProps,
- onSearch: (text) => {
- let limit = stateProps.limit;
- if (stateProps.tool === USERS) {
- dispatchProps.onSearchUser(text, {params: {start: 0, limit}});
- } else {
- dispatchProps.onSearchGroup(text, {params: {start: 0, limit}});
- }
- },
- onSearchReset: () => {
- if (stateProps.tool === USERS) {
- dispatchProps.onSearchUser();
- } else {
- dispatchProps.onSearchGroup();
- }
- },
- onSearchTextChange: (text) => {
- if (stateProps.tool === USERS) {
- dispatchProps.usersSearchTextChanged(text);
- } else {
- dispatchProps.groupSearchTextChanged(text);
- }
- }
- };
-})(require("../../../components/mapcontrols/search/SearchBar"));
-
-module.exports = SearchBar;