Skip to content

Commit 1d713a3

Browse files
committed
update user
1 parent 4899f87 commit 1d713a3

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

src/components/Apps/AppCard.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ export default {
197197
},
198198
},
199199
computed: {
200+
user() {
201+
return this.$store.state.user;
202+
},
200203
tooltipLabel() {
201204
if (this.isContainerApp) {
202205
return this.$t("Import to CasaOS");
@@ -274,7 +277,7 @@ export default {
274277
},
275278
276279
showActionButton() {
277-
return this.canBeControlled && !this.isUninstalling && !this.isRebuilding;
280+
return this.canBeControlled && !this.isUninstalling && !this.isRebuilding && this.user.is_admin;
278281
},
279282
280283
isSystemApp() {

src/components/Apps/AppSection.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
:label="$t('DragIconsToSort')"
99
:title="$t('Apps')"
1010
></app-section-title-tip>
11-
1211
<b-dropdown
12+
v-if="user.is_admin"
1313
ref="cdro"
1414
animation="fade1"
1515
aria-role="menu"
@@ -38,7 +38,7 @@
3838
<transition name="fade">
3939
<draggable
4040
v-model="appList"
41-
:draggable="draggable"
41+
:draggable="user.is_admin && draggable"
4242
class="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 app-list contextmenu-canvas"
4343
tag="div"
4444
v-bind="dragOptions"
@@ -204,6 +204,9 @@ export default {
204204
showDragTip() {
205205
return this.draggable === ".handle";
206206
},
207+
user() {
208+
return this.$store.state.user;
209+
},
207210
},
208211
async created() {
209212
db = await openDB("casaos", "1", {
@@ -215,7 +218,7 @@ export default {
215218
});
216219
this.getNewAppIdsFromCustomStorage();
217220
this.getTipsStateFromCustomStorage();
218-
221+
this.getUserInfo();
219222
this.isLoading = true;
220223
this.draggable = this.isMobile() ? "" : ".handle";
221224
@@ -324,6 +327,15 @@ export default {
324327
this.gpuAppList = [];
325328
});
326329
},
330+
/**
331+
* @description: Get user info
332+
* @return {*} void
333+
*/
334+
getUserInfo() {
335+
this.$api.users.getUserInfo().then((res) => {
336+
this.$store.commit("SET_USER", res.data.data);
337+
});
338+
},
327339
328340
/**
329341
* @description: Fetch the list of installed apps

src/store/mutations.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ const mutations: MutationTree<State> = {
2323
},
2424

2525
SET_USER(state, user: User) {
26-
state.user = user;
26+
state.user = {
27+
...user,
28+
is_admin: user.role === 'admin' ? true : false,
29+
};
2730
},
2831

2932
SET_INIT_KEY(state, key: string) {

src/store/state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface User {
88
role: string;
99
updated_at: string;
1010
username: string;
11+
is_admin?: boolean;
1112
}
1213

1314
export interface State {

0 commit comments

Comments
 (0)