Skip to content

Commit

Permalink
Merge pull request #9535 from rtibbles/user_management_state
Browse files Browse the repository at this point in the history
Clean up state management for user management page
  • Loading branch information
marcellamaki authored Jun 29, 2022
2 parents b4c59f0 + a6bcb0c commit 357becc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { FacilityUserResource } from 'kolibri.resources';
import samePageCheckGenerator from 'kolibri.utils.samePageCheckGenerator';
import { _userState } from '../mappers';
// An action for setting up the initial state of the app by fetching data from the server
export function showUserPage(store, toRoute) {
store.dispatch('preparePage');
export function showUserPage(store, toRoute, fromRoute) {
if (toRoute.name !== fromRoute.name) {
store.dispatch('preparePage');
}
const facilityId = toRoute.params.facility_id || store.getters.activeFacilityId;
return FacilityUserResource.fetchCollection({
getParams: pickBy({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import * as userManagementActions from './actions';
function defaultState() {
return {
facilityUsers: [],
totalPages: 0,
usersCount: 0,
};
}

Expand Down
4 changes: 2 additions & 2 deletions kolibri/plugins/facility/assets/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export default [
name: PageNames.USER_MGMT_PAGE,
component: UserPage,
path: '/:facility_id?/users',
handler: toRoute => {
showUserPage(store, toRoute);
handler: (toRoute, fromRoute) => {
showUserPage(store, toRoute, fromRoute);
},
},
{
Expand Down

0 comments on commit 357becc

Please sign in to comment.