feat: Add user role select to users list settings page (#7796)

This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
updateOtherUserSettings,
|
||||
validatePasswordToken,
|
||||
validateSignupToken,
|
||||
updateRole,
|
||||
} from '@/api/users';
|
||||
import { PERSONALIZATION_MODAL_KEY, STORES } from '@/constants';
|
||||
import type {
|
||||
@@ -39,16 +40,13 @@ import { useCloudPlanStore } from './cloudPlan.store';
|
||||
import { disableMfa, enableMfa, getMfaQR, verifyMfaToken } from '@/api/mfa';
|
||||
import { confirmEmail, getCloudUserInfo } from '@/api/cloudPlans';
|
||||
import { useRBACStore } from '@/stores/rbac.store';
|
||||
import type { Scope } from '@n8n/permissions';
|
||||
import type { Scope, ScopeLevel } from '@n8n/permissions';
|
||||
import { inviteUsers, acceptInvitation } from '@/api/invitation';
|
||||
|
||||
const isDefaultUser = (user: IUserResponse | null) =>
|
||||
Boolean(user && user.isPending && user.globalRole && user.globalRole.name === ROLE.Owner);
|
||||
|
||||
const isPendingUser = (user: IUserResponse | null) => Boolean(user && user.isPending);
|
||||
|
||||
const isInstanceOwner = (user: IUserResponse | null) =>
|
||||
Boolean(user?.globalRole?.name === ROLE.Owner);
|
||||
user?.isPending && user?.globalRole?.name === ROLE.Owner;
|
||||
const isPendingUser = (user: IUserResponse | null) => !!user?.isPending;
|
||||
const isInstanceOwner = (user: IUserResponse | null) => user?.globalRole?.name === ROLE.Owner;
|
||||
|
||||
export const useUsersStore = defineStore(STORES.USERS, {
|
||||
state: (): IUsersState => ({
|
||||
@@ -375,5 +373,11 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
||||
async confirmEmail() {
|
||||
await confirmEmail(useRootStore().getRestApiContext);
|
||||
},
|
||||
|
||||
async updateRole({ id, role }: { id: string; role: { scope: ScopeLevel; name: IRole } }) {
|
||||
const rootStore = useRootStore();
|
||||
await updateRole(rootStore.getRestApiContext, { id, role });
|
||||
await this.fetchUsers();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user