Add basic subuser listing for servers
This commit is contained in:
parent
de464d35a2
commit
543884876f
14 changed files with 310 additions and 4 deletions
43
resources/scripts/state/server/subusers.ts
Normal file
43
resources/scripts/state/server/subusers.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { action, Action, thunk, Thunk } from 'easy-peasy';
|
||||
import getServerSubusers from '@/api/server/users/getServerSubusers';
|
||||
|
||||
export type SubuserPermission = string;
|
||||
|
||||
export interface Subuser {
|
||||
uuid: string;
|
||||
username: string;
|
||||
email: string;
|
||||
image: string;
|
||||
twoFactorEnabled: boolean;
|
||||
createdAt: Date;
|
||||
permissions: SubuserPermission[];
|
||||
|
||||
can (permission: SubuserPermission): boolean;
|
||||
}
|
||||
|
||||
export interface ServerSubuserStore {
|
||||
data: Subuser[];
|
||||
setSubusers: Action<ServerSubuserStore, Subuser[]>;
|
||||
appendSubuser: Action<ServerSubuserStore, Subuser>;
|
||||
getSubusers: Thunk<ServerSubuserStore, string, any, {}, Promise<void>>;
|
||||
}
|
||||
|
||||
const subusers: ServerSubuserStore = {
|
||||
data: [],
|
||||
|
||||
setSubusers: action((state, payload) => {
|
||||
state.data = payload;
|
||||
}),
|
||||
|
||||
appendSubuser: action((state, payload) => {
|
||||
state.data = [...state.data, payload];
|
||||
}),
|
||||
|
||||
getSubusers: thunk(async (actions, payload) => {
|
||||
const subusers = await getServerSubusers(payload);
|
||||
|
||||
actions.setSubusers(subusers);
|
||||
}),
|
||||
};
|
||||
|
||||
export default subusers;
|
Loading…
Add table
Add a link
Reference in a new issue