Skip to content

Commit

Permalink
[Refactor] Refine New user modal (#3529)
Browse files Browse the repository at this point in the history
  • Loading branch information
kravets-levko authored Mar 5, 2019
1 parent 7a4fe50 commit bc22797
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
18 changes: 13 additions & 5 deletions client/app/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ import { isFunction, each, extend } from 'lodash';
export function routesToAngularRoutes(routes, template) {
const result = {};
template = extend({}, template); // convert to object
each(routes, ({ path, title, key }) => {
result[path] = extend({
each(routes, ({ path, title, key, ...resolve }) => {
// Convert to functions
each(resolve, (value, prop) => {
resolve[prop] = () => value;
});

result[path] = {
...template,
title,
// keep `resolve` from `template` (if exists)
resolve: extend({
resolve: {
...template.resolve,
...resolve,
currentPage: () => key,
}, template.resolve),
}, template);
},
};
});
return result;
}
Expand Down
8 changes: 4 additions & 4 deletions client/app/pages/users/UsersList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { currentUser } from '@/services/auth';
import { policy } from '@/services/policy';
import { User } from '@/services/user';
import navigateTo from '@/services/navigateTo';
import { $location, toastr } from '@/services/ng';
import { toastr } from '@/services/ng';
import { absoluteUrl } from '@/services/utils';

function UsersListActions({ user, enableUser, disableUser, deleteUser }) {
Expand Down Expand Up @@ -121,7 +121,7 @@ class UsersList extends React.Component {
];

componentDidMount() {
if ($location.path() === '/users/new') {
if (this.props.controller.params.isNewUserPage) {
this.showCreateUserDialog();
}
}
Expand Down Expand Up @@ -154,12 +154,12 @@ class UsersList extends React.Component {
this.props.controller.update();
}
}).finally(() => {
if ($location.path() === '/users/new') {
if (this.props.controller.params.isNewUserPage) {
navigateTo('users');
}
});
}
}
};

onTableRowClick = (event, item) => navigateTo('users/' + item.id);

Expand Down
1 change: 1 addition & 0 deletions client/app/pages/users/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function init() {
path: '/users/new',
title: 'Users',
key: 'active',
isNewUserPage: true,
},
{
path: '/users/pending',
Expand Down

0 comments on commit bc22797

Please sign in to comment.