Skip to content

Commit

Permalink
migrating to the useUser composable (kolibri-tools)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanaelg16 committed Jul 23, 2024
1 parent 7f9a301 commit 775a1f4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
8 changes: 6 additions & 2 deletions packages/kolibri-tools/test/fixtures/TestComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,20 @@
/* eslint-disable */
import { mapGetters, mapState } from 'vuex';
import { mapState } from 'vuex';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import urls from 'kolibri.urls';
import commonCoach from './common';
import useUser from 'kolibri.coreVue.composables.useUser';
export default {
name: 'TestComponent',
mixins: [commonCoach, commonCoreStrings],
setup() {
const { isClassCoach, isFacilityCoach } = useUser();
return { isClassCoach, isFacilityCoach };
},
computed: {
...mapGetters(['isAdmin', 'isClassCoach', 'isFacilityCoach']),
...mapState(['classList']),
// Message that shows up when state.classList is empty
emptyStateDetails() {
Expand Down
8 changes: 6 additions & 2 deletions packages/kolibri-tools/test/fixtures/TestComponentScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@

/* eslint-disable */

import { mapGetters, mapState } from 'vuex';
import { mapState } from 'vuex';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import urls from 'kolibri.urls';
import commonCoach from './common';
import useUser from 'kolibri.coreVue.composables.useUser';

export default {
name: 'TestComponent',
mixins: [commonCoach, commonCoreStrings],
setup() {
const { isClassCoach, isFacilityCoach } = useUser();
return { isClassCoach, isFacilityCoach };
},
computed: {
...mapGetters(['isAdmin', 'isClassCoach', 'isFacilityCoach']),
...mapState(['classList']),
// Message that shows up when state.classList is empty
emptyStateDetails() {
Expand Down
3 changes: 2 additions & 1 deletion packages/kolibri-tools/test/fixtures/TestUserPermissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { DevicePermissionsResource, FacilityUserResource } from 'kolibri.resources';
import samePageCheckGenerator from 'kolibri.utils.samePageCheckGenerator';
import { createTranslator } from 'kolibri.utils.i18n';
import useUser from 'kolibri.coreVue.composables.useUser';

const translator = createTranslator('UserPermissionToolbarTitles', {
loading: 'Loading user permissions…',
Expand Down Expand Up @@ -67,7 +68,7 @@ export function showUserPermissionsPage(store, userId) {
const stopLoading = () => store.commit('CORE_SET_PAGE_LOADING', false);

// Don't request any data if not an Admin
if (!store.getters.isSuperuser) {
if (!useUser().isSuperuser.value) {
setUserPermissionsState({ user: null, permissions: {} });
setAppBarTitle(translator.$tr('goBackTitle'));
stopLoading();
Expand Down

0 comments on commit 775a1f4

Please sign in to comment.