mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 14:23:44 +02:00
Add handler to fetch all of the system permissions and load them into the state
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
import { createStore } from 'easy-peasy';
|
||||
import flashes, { FlashStore } from '@/state/flashes';
|
||||
import user, { UserStore } from '@/state/user';
|
||||
import permissions, { GloablPermissionsStore } from '@/state/permissions';
|
||||
|
||||
export interface ApplicationStore {
|
||||
permissions: GloablPermissionsStore;
|
||||
flashes: FlashStore;
|
||||
user: UserStore;
|
||||
}
|
||||
|
||||
const state: ApplicationStore = {
|
||||
permissions,
|
||||
flashes,
|
||||
user,
|
||||
};
|
||||
|
||||
25
resources/scripts/state/permissions.ts
Normal file
25
resources/scripts/state/permissions.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { SubuserPermission } from '@/state/server/subusers';
|
||||
import { action, Action, thunk, Thunk } from 'easy-peasy';
|
||||
import getSystemPermissions from '@/api/getSystemPermissions';
|
||||
|
||||
export interface GloablPermissionsStore {
|
||||
data: SubuserPermission[];
|
||||
setPermissions: Action<GloablPermissionsStore, SubuserPermission[]>;
|
||||
getPermissions: Thunk<GloablPermissionsStore, void, {}, any, Promise<void>>;
|
||||
}
|
||||
|
||||
const permissions: GloablPermissionsStore = {
|
||||
data: [],
|
||||
|
||||
setPermissions: action((state, payload) => {
|
||||
state.data = payload;
|
||||
}),
|
||||
|
||||
getPermissions: thunk(async (actions) => {
|
||||
const permissions = await getSystemPermissions();
|
||||
|
||||
actions.setPermissions(permissions);
|
||||
}),
|
||||
};
|
||||
|
||||
export default permissions;
|
||||
@@ -1,7 +1,16 @@
|
||||
import { action, Action, thunk, Thunk } from 'easy-peasy';
|
||||
import getServerSubusers from '@/api/server/users/getServerSubusers';
|
||||
|
||||
export type SubuserPermission = string;
|
||||
export type SubuserPermission =
|
||||
'websocket.*' |
|
||||
'control.console' | 'control.start' | 'control.stop' | 'control.restart' | 'control.kill' |
|
||||
'user.create' | 'user.read' | 'user.update' | 'user.delete' |
|
||||
'file.create' | 'file.read' | 'file.update' | 'file.delete' | 'file.archive' | 'file.sftp' |
|
||||
'allocation.read' | 'allocation.update' |
|
||||
'startup.read' | 'startup.update' |
|
||||
'database.create' | 'database.read' | 'database.update' | 'database.delete' | 'database.view_password' |
|
||||
'schedule.create' | 'schedule.read' | 'schedule.update' | 'schedule.delete'
|
||||
;
|
||||
|
||||
export interface Subuser {
|
||||
uuid: string;
|
||||
@@ -30,7 +39,7 @@ const subusers: ServerSubuserStore = {
|
||||
}),
|
||||
|
||||
appendSubuser: action((state, payload) => {
|
||||
state.data = [...state.data, payload];
|
||||
state.data = [ ...state.data, payload ];
|
||||
}),
|
||||
|
||||
getSubusers: thunk(async (actions, payload) => {
|
||||
|
||||
Reference in New Issue
Block a user