Skip to content

Commit

Permalink
Fix geosolutions-it#1134 user manager group editing issues
Browse files Browse the repository at this point in the history
Fix issues geosolutions-it#1134 with usergroup updates. 
 - Fix issue introduced by changes on the catalog that influenced the delete user modal  
- Keep the search filter when update or delete user
  • Loading branch information
saidaipparla authored and offtherailz committed Oct 14, 2016
1 parent 120fdda commit 61f5eb4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
19 changes: 19 additions & 0 deletions web/client/actions/__tests__/users-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,25 @@ describe('Test correctness of the users actions', () => {
}
});
});
it('saveUser create with groups', (done) => {
GeoStoreDAO.addBaseUrl = (options) => {
return assign(options, {baseURL: 'base/web/client/test-resources/geostore/users/newUser.txt#'});
};
const retFun = saveUser({name: "test", groups: [{groupName: "everyone"}, {groupName: "testers"}], role: "USER", password: "password"});
expect(retFun).toExist();
let count = 0;
retFun((action) => {
expect(action.type).toBe(USERMANAGER_UPDATE_USER);
count++;
if (count === 2) {
expect(action.user).toExist();
expect(action.user.id).toExist();
expect(action.user.groups).toExist();
expect(action.user.groups.length).toBe(2);
done();
}
});
});
it('saveUser error', (done) => {
const retFun = saveUser({id: 3});
expect(retFun).toExist();
Expand Down
14 changes: 11 additions & 3 deletions web/client/actions/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function editUser(user, options ={params: {includeattributes: true}} ) {
};
}
// the service returns groups = "", skip this to avoid overriding
if (userLoaded && userLoaded.groups === "") {
if (userLoaded) {
userLoaded = {...userLoaded, groups: user.groups};
}
dispatch(editUserSuccess(userLoaded));
Expand Down Expand Up @@ -239,20 +239,28 @@ function saveUser(user, options = {}) {
return (dispatch) => {
if (user && user.id) {
dispatch(savingUser(user));
return API.updateUser(user.id, {...user, group: user.groups}, options).then((userDetails) => {
return API.updateUser(user.id, {...user, groups: { group: user.groups}}, options).then((userDetails) => {
dispatch(savedUser(userDetails));
dispatch(getUsers());
}).catch((error) => {
dispatch(saveError(user, error));
});
}
// createUser
dispatch(creatingUser(user));
return API.createUser(user, options).then((id) => {
let userToPost = {...user};
if (user && user.groups) {
userToPost = {...user, groups: { group: user.groups.filter((g) => {
return g.groupName !== "everyone"; // see:https://github.com/geosolutions-it/geostore/issues/149
})}};
}
return API.createUser(userToPost, options).then((id) => {
dispatch(userCreated(id, user));
dispatch(getUsers());
}).catch((error) => {
dispatch(createError(user, error));
});

};
}
function changeUserMetadata(key, newValue) {
Expand Down
4 changes: 3 additions & 1 deletion web/client/components/misc/Dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const Dialog = React.createClass({
backgroundStyle: React.PropTypes.object,
className: React.PropTypes.string,
maskLoading: React.PropTypes.bool,
containerClassName: React.PropTypes.string,
headerClassName: React.PropTypes.string,
bodyClassName: React.PropTypes.string,
footerClassName: React.PropTypes.string,
Expand All @@ -38,6 +39,7 @@ const Dialog = React.createClass({
start: {x: 0, y: 0},
className: "modal-dialog modal-content",
maskLoading: false,
containerClassName: "",
headerClassName: "modal-header",
bodyClassName: "modal-body",
footerClassName: "modal-footer",
Expand Down Expand Up @@ -84,7 +86,7 @@ const Dialog = React.createClass({
</Draggable>);
let containerStyle = assign({}, this.props.style, this.props.backgroundStyle);
return this.props.modal ?
(<div onClick={this.props.onClickOut} style={containerStyle} className="fade in modal catalog_window" role="dialog">
(<div onClick={this.props.onClickOut} style={containerStyle} className={"fade in modal " + this.props.containerClassName} role="dialog">
<div onClick={(evt)=> {evt.preventDefault(); evt.stopPropagation(); }} className="modal-dialog" style={{background: "transparent"}}>
{dialog}
</div></div>) :
Expand Down
2 changes: 1 addition & 1 deletion web/client/plugins/MetadataExplorer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const MetadataExplorerComponent = React.createClass({
{panel}
</Panel>);
}
return (<Dialog modal id="mapstore-catalog-panel" style={assign({}, this.props.style, {display: "block" })}>
return (<Dialog containerClassName="catalog_window" modal id="mapstore-catalog-panel" style={assign({}, this.props.style, {display: "block" })}>
<span role="header"><span className="metadataexplorer-panel-title"><Message msgId="catalog.title"/></span><button onClick={this.props.toggleControl} className="print-panel-close close">{this.props.closeGlyph ? <Glyphicon glyph={this.props.closeGlyph}/> : <span>×</span>}</button></span>
{panel}
</Dialog>);
Expand Down
1 change: 1 addition & 0 deletions web/client/reducers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function users(state = {
switch (action.type) {
case USERMANAGER_GETUSERS:
return assign({}, state, {
searchText: action.searchText,
status: action.status,
users: action.status === "loading" ? state.users : action.users,
start: action.start,
Expand Down

0 comments on commit 61f5eb4

Please sign in to comment.