fix(editor): Remove isOwner from IUser interface (#8888)

This commit is contained in:
Csaba Tuncsik
2024-03-18 11:39:15 +01:00
committed by GitHub
parent 024be62693
commit 6955e8991c
24 changed files with 74 additions and 65 deletions

View File

@@ -14,6 +14,7 @@ import {
getNotTrialingUserResponse,
} from './utils/cloudStoreUtils';
import type { IRole } from '@/Interface';
import { ROLE } from '@/constants';
let uiStore: ReturnType<typeof useUIStore>;
let settingsStore: ReturnType<typeof useSettingsStore>;
@@ -33,7 +34,7 @@ function setUser(role: IRole) {
}
function setupOwnerAndCloudDeployment() {
setUser('global:owner');
setUser(ROLE.Owner);
settingsStore.setSettings(
merge({}, SETTINGS_STORE_DEFAULT_STATE.settings, {
n8nMetadata: {
@@ -75,19 +76,19 @@ describe('UI store', () => {
[
'default',
'production',
'global:owner',
ROLE.Owner,
'https://n8n.io/pricing?utm_campaign=utm-test-campaign&source=test_source',
],
[
'default',
'development',
'global:owner',
ROLE.Owner,
'https://n8n.io/pricing?utm_campaign=utm-test-campaign&source=test_source',
],
[
'cloud',
'production',
'global:owner',
ROLE.Owner,
`https://app.n8n.cloud/login?code=123&returnPath=${encodeURIComponent(
'/account/change-plan',
)}&utm_campaign=utm-test-campaign&source=test_source`,
@@ -95,7 +96,7 @@ describe('UI store', () => {
[
'cloud',
'production',
'global:member',
ROLE.Member,
'https://n8n.io/pricing?utm_campaign=utm-test-campaign&source=test_source',
],
])(

View File

@@ -67,11 +67,9 @@ export const useCloudPlanStore = defineStore(STORES.CLOUD_PLAN, () => {
const getUserCloudAccount = async () => {
if (!hasCloudPlan.value) throw new Error('User does not have a cloud plan');
try {
if (hasPermission(['instanceOwner'])) {
await usersStore.fetchUserCloudAccount();
if (!usersStore.currentUserCloudInfo?.confirmed && !userIsTrialing.value) {
useUIStore().pushBannerToStack('EMAIL_CONFIRMATION');
}
await usersStore.fetchUserCloudAccount();
if (!usersStore.currentUserCloudInfo?.confirmed && !userIsTrialing.value) {
useUIStore().pushBannerToStack('EMAIL_CONFIRMATION');
}
} catch (error) {
throw new Error(error.message);

View File

@@ -343,7 +343,6 @@ export const useUIStore = defineStore(STORES.UI, {
let linkUrl = '';
const searchParams = new URLSearchParams();
const { isInstanceOwner } = useUsersStore();
if (deploymentType === 'cloud' && hasPermission(['instanceOwner'])) {
const adminPanelHost = new URL(window.location.href).host.split('.').slice(1).join('.');

View File

@@ -18,7 +18,7 @@ import {
validateSignupToken,
updateGlobalRole,
} from '@/api/users';
import { PERSONALIZATION_MODAL_KEY, STORES } from '@/constants';
import { PERSONALIZATION_MODAL_KEY, STORES, ROLE } from '@/constants';
import type {
Cloud,
ICredentialsResponse,
@@ -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?.role === 'global:owner';
const isInstanceOwner = (user: IUserResponse | null) => user?.role === ROLE.Owner;
const isDefaultUser = (user: IUserResponse | null) => isInstanceOwner(user) && isPendingUser(user);
export const useUsersStore = defineStore(STORES.USERS, {
@@ -139,7 +139,6 @@ export const useUsersStore = defineStore(STORES.USERS, {
: undefined,
isDefaultUser: isDefaultUser(updatedUser),
isPendingUser: isPendingUser(updatedUser),
isOwner: isInstanceOwner(updatedUser),
};
this.users = {