Skip to content

Commit

Permalink
Merge pull request #12027 from Wck-iipi/1173Solution
Browse files Browse the repository at this point in the history
useUser can now get all states and getters
  • Loading branch information
rtibbles authored Mar 29, 2024
2 parents 53fdb7e + 9c6cfa2 commit bd2ccf8
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions kolibri/core/assets/src/composables/useUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { computed } from 'kolibri.lib.vueCompositionApi';
import store from 'kolibri.coreVue.vuex.store';

export default function useUser() {
//getters
const isUserLoggedIn = computed(() => store.getters.isUserLoggedIn);
const currentUserId = computed(() => store.getters.currentUserId);
const isLearnerOnlyImport = computed(() => store.getters.isLearnerOnlyImport);
Expand All @@ -10,6 +11,27 @@ export default function useUser() {
const isSuperuser = computed(() => store.getters.isSuperuser);
const canManageContent = computed(() => store.getters.canManageContent);
const isAppContext = computed(() => store.getters.isAppContext);
const isClassCoach = computed(() => store.getters.isClassCoach);
const isFacilityCoach = computed(() => store.getters.isFacilityCoach);
const isLearner = computed(() => store.getters.isLearner);
const isFacilityAdmin = computed(() => store.getters.isFacilityAdmin);
const userIsMultipleFacility = computed(() => store.getters.userIsMultipleFacility);
const getUserPermissions = computed(() => store.getters.getUserPermissions);
const userFacilityId = computed(() => store.getters.userFacilityId);
const getUserKind = computed(() => store.getters.getUserKind);
const userHasPermissions = computed(() => store.getters.userHasPermissions);
const session = computed(() => store.getters.session);

//state
const app_context = computed(() => store.getters.session.app_context);
const can_manage_content = computed(() => store.getters.session.can_manage_content);
const facility_id = computed(() => store.getters.session.facility_id);
const full_name = computed(() => store.getters.session.full_name);
const id = computed(() => store.getters.session.id);
const kind = computed(() => store.getters.session.kind);
const user_id = computed(() => store.getters.session.user_id);
const full_facility_import = computed(() => store.getters.session.full_facility_import);
const username = computed(() => store.getters.session.username);

return {
isLearnerOnlyImport,
Expand All @@ -20,5 +42,25 @@ export default function useUser() {
isSuperuser,
canManageContent,
isAppContext,
isClassCoach,
isFacilityCoach,
isLearner,
isFacilityAdmin,
userIsMultipleFacility,
getUserPermissions,
userFacilityId,
getUserKind,
userHasPermissions,
session,
//state
app_context,
can_manage_content,
facility_id,
full_name,
id,
kind,
user_id,
username,
full_facility_import,
};
}

0 comments on commit bd2ccf8

Please sign in to comment.