refactor(core): Remove roleId indirection (no-changelog) (#8413)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-01-24 13:38:57 +01:00
committed by GitHub
parent 1affebd85e
commit d6deceacde
139 changed files with 922 additions and 1684 deletions

View File

@@ -25,11 +25,7 @@ function setUser(role: IRole) {
{
id: '1',
isPending: false,
globalRole: {
id: '1',
name: role,
createdAt: new Date(),
},
role,
},
]);
@@ -37,7 +33,7 @@ function setUser(role: IRole) {
}
function setupOwnerAndCloudDeployment() {
setUser('owner');
setUser('global:owner');
settingsStore.setSettings(
merge({}, SETTINGS_STORE_DEFAULT_STATE.settings, {
n8nMetadata: {
@@ -79,19 +75,19 @@ describe('UI store', () => {
[
'default',
'production',
'owner',
'global:owner',
'https://n8n.io/pricing?utm_campaign=utm-test-campaign&source=test_source',
],
[
'default',
'development',
'owner',
'global:owner',
'https://n8n.io/pricing?utm_campaign=utm-test-campaign&source=test_source',
],
[
'cloud',
'production',
'owner',
'global:owner',
`https://app.n8n.cloud/login?code=123&returnPath=${encodeURIComponent(
'/account/change-plan',
)}&utm_campaign=utm-test-campaign&source=test_source`,
@@ -99,7 +95,7 @@ describe('UI store', () => {
[
'cloud',
'production',
'member',
'global:member',
'https://n8n.io/pricing?utm_campaign=utm-test-campaign&source=test_source',
],
])(

View File

@@ -32,7 +32,7 @@ import type {
InvitableRoleName,
} from '@/Interface';
import { getCredentialPermissions } from '@/permissions';
import { getPersonalizedNodeTypes, ROLE } from '@/utils/userUtils';
import { getPersonalizedNodeTypes } from '@/utils/userUtils';
import { defineStore } from 'pinia';
import { useRootStore } from './n8nRoot.store';
import { usePostHog } from './posthog.store';
@@ -46,7 +46,7 @@ import type { Scope } from '@n8n/permissions';
import { inviteUsers, acceptInvitation } from '@/api/invitation';
const isPendingUser = (user: IUserResponse | null) => !!user?.isPending;
const isInstanceOwner = (user: IUserResponse | null) => user?.globalRole?.name === ROLE.Owner;
const isInstanceOwner = (user: IUserResponse | null) => user?.role === 'global:owner';
const isDefaultUser = (user: IUserResponse | null) => isInstanceOwner(user) && isPendingUser(user);
export const useUsersStore = defineStore(STORES.USERS, {
@@ -79,7 +79,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
return (userId: string): IUser | null => state.users[userId];
},
globalRoleName(): IRole {
return this.currentUser?.globalRole?.name ?? 'default';
return this.currentUser?.role ?? 'default';
},
personalizedNodeTypes(): string[] {
const user = this.currentUser;