Skip to content

Commit

Permalink
enable super admins to switch to normal mode
Browse files Browse the repository at this point in the history
  • Loading branch information
khansadaoudi committed Jan 15, 2025
1 parent 4d930cc commit 8b15ffd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/api/backend-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface user_t {
superAdmin: boolean;
createdDate: number;
lastSeen: number;
canToogleSuperAdmin: boolean;
}

//// PROJECT ////
Expand Down
8 changes: 6 additions & 2 deletions src/pages/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<div class="row">
<div :class="'col text-center '+($q.dark.isActive ? '' : 'text-blue-grey-8')">@{{ username }}</div>
</div>
<div v-if="canToggleSuperAdmin" class="row">
<q-toggle label="Switch super admin mode (don't forget to save the modifications)" class="col justify-center text-blue-grey-8" v-model="superAdmin" />
</div>
<div v-show="superAdmin" class="row">
<div :class="'col text-center '+ ($q.dark.isActive ? '' : 'text-blue-grey-8')">Super Admin</div>
</div>
Expand Down Expand Up @@ -310,8 +313,8 @@ export default defineComponent({
}
},
computed: {
...mapWritableState(useUserStore, ['email', 'firstName', 'familyName']),
...mapState(useUserStore, ['avatarKey', 'pictureUrl', 'superAdmin', 'username']),
...mapWritableState(useUserStore, ['email', 'firstName', 'familyName', 'superAdmin']),
...mapState(useUserStore, ['avatarKey', 'pictureUrl', 'username', 'canToggleSuperAdmin']),
filteredListProject(): any[] {
if (this.projectsType === 'Old') {
return this.projects.filter((project: any) => project.isOld)
Expand Down Expand Up @@ -342,6 +345,7 @@ export default defineComponent({
email: this.email || '',
firstName: this.firstName || '',
familyName: this.familyName || '',
superAdmin: this.superAdmin
};
this.updateUserInformation(data);
},
Expand Down
2 changes: 2 additions & 0 deletions src/pinia/modules/user/defaultState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface UserStateInterface {
superAdmin: boolean;
username: string;
reservedUserIds: string[];
canToggleSuperAdmin: boolean;
}

// default user state
Expand All @@ -36,5 +37,6 @@ export default function defaultState(): UserStateInterface {
superAdmin: false,
username: '',
reservedUserIds: ['base_tree', 'validated'],
canToggleSuperAdmin: false,
};
}

0 comments on commit 8b15ffd

Please sign in to comment.