fix(editor): Remove isOwner from IUser interface (#8888)
This commit is contained in:
@@ -66,8 +66,12 @@ import { mapStores } from 'pinia';
|
||||
import { useToast } from '@/composables/useToast';
|
||||
import Modal from './Modal.vue';
|
||||
import type { IFormInputs, IInviteResponse, IUser } from '@/Interface';
|
||||
import { ROLE } from '@/utils/userUtils';
|
||||
import { EnterpriseEditionFeature, VALID_EMAIL_REGEX, INVITE_USER_MODAL_KEY } from '@/constants';
|
||||
import {
|
||||
EnterpriseEditionFeature,
|
||||
VALID_EMAIL_REGEX,
|
||||
INVITE_USER_MODAL_KEY,
|
||||
ROLE,
|
||||
} from '@/constants';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { useSettingsStore } from '@/stores/settings.store';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { useCollaborationStore } from '@/stores/collaboration.store';
|
||||
import { onBeforeUnmount, onMounted, computed, ref } from 'vue';
|
||||
import { TIME } from '@/constants';
|
||||
import { isUserGlobalOwner } from '@/utils/userUtils';
|
||||
|
||||
const collaborationStore = useCollaborationStore();
|
||||
const usersStore = useUsersStore();
|
||||
@@ -16,7 +17,7 @@ const activeUsersSorted = computed(() => {
|
||||
const currentWorkflowUsers = (collaborationStore.getUsersForCurrentWorkflow ?? []).map(
|
||||
(userInfo) => userInfo.user,
|
||||
);
|
||||
const owner = currentWorkflowUsers.find((user) => user.role === 'global:owner');
|
||||
const owner = currentWorkflowUsers.find(isUserGlobalOwner);
|
||||
return {
|
||||
defaultGroup: owner
|
||||
? [owner, ...currentWorkflowUsers.filter((user) => user.id !== owner.id)]
|
||||
|
||||
@@ -2,7 +2,7 @@ import { merge } from 'lodash-es';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
|
||||
import { STORES } from '@/constants';
|
||||
import { ROLE, STORES } from '@/constants';
|
||||
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import BannerStack from '@/components/banners/BannerStack.vue';
|
||||
@@ -26,11 +26,11 @@ const initialState = {
|
||||
users: {
|
||||
'aaa-bbb': {
|
||||
id: 'aaa-bbb',
|
||||
role: 'global:owner',
|
||||
role: ROLE.Owner,
|
||||
},
|
||||
'bbb-bbb': {
|
||||
id: 'bbb-bbb',
|
||||
role: 'global:member',
|
||||
role: ROLE.Member,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { merge } from 'lodash-es';
|
||||
import { SETTINGS_STORE_DEFAULT_STATE, waitAllPromises } from '@/__tests__/utils';
|
||||
import { STORES } from '@/constants';
|
||||
import { ROLE, STORES } from '@/constants';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
import CollaborationPane from '@/components//MainHeader/CollaborationPane.vue';
|
||||
@@ -13,10 +13,9 @@ const OWNER_USER = {
|
||||
email: 'owner@user.com',
|
||||
firstName: 'Owner',
|
||||
lastName: 'User',
|
||||
role: 'global:owner',
|
||||
role: ROLE.Owner,
|
||||
disabled: false,
|
||||
isPending: false,
|
||||
isOwner: true,
|
||||
fullName: 'Owner User',
|
||||
};
|
||||
|
||||
@@ -26,10 +25,9 @@ const MEMBER_USER = {
|
||||
email: 'member@user.com',
|
||||
firstName: 'Member',
|
||||
lastName: 'User',
|
||||
role: 'global:member',
|
||||
role: ROLE.Member,
|
||||
disabled: false,
|
||||
isPending: false,
|
||||
isOwner: false,
|
||||
fullName: 'Member User',
|
||||
};
|
||||
|
||||
@@ -39,10 +37,9 @@ const MEMBER_USER_2 = {
|
||||
email: 'member2@user.com',
|
||||
firstName: 'Another Member',
|
||||
lastName: 'User',
|
||||
role: 'global:member',
|
||||
role: ROLE.Member,
|
||||
disabled: false,
|
||||
isPending: false,
|
||||
isOwner: false,
|
||||
fullName: 'Another Member User',
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import PersonalizationModal from '@/components/PersonalizationModal.vue';
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { PERSONALIZATION_MODAL_KEY, STORES, VIEWS } from '@/constants';
|
||||
import { PERSONALIZATION_MODAL_KEY, ROLE, STORES, VIEWS } from '@/constants';
|
||||
import { retry } from '@/__tests__/utils';
|
||||
import { createComponentRenderer } from '@/__tests__/render';
|
||||
import { fireEvent } from '@testing-library/vue';
|
||||
@@ -31,7 +31,7 @@ const pinia = createTestingPinia({
|
||||
isDefaultUser: false,
|
||||
isPendingUser: false,
|
||||
hasRecoveryCodesLeft: true,
|
||||
isOwner: true,
|
||||
role: ROLE.Owner,
|
||||
mfaEnabled: false,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -2,6 +2,8 @@ import { render } from '@testing-library/vue';
|
||||
import V1Banner from '../V1Banner.vue';
|
||||
import { createPinia, setActivePinia } from 'pinia';
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { ROLE } from '@/constants';
|
||||
import type { IUser } from '@/Interface';
|
||||
|
||||
describe('V1 Banner', () => {
|
||||
let pinia: ReturnType<typeof createPinia>;
|
||||
@@ -22,8 +24,8 @@ describe('V1 Banner', () => {
|
||||
|
||||
it('should render banner with dismiss call if user is owner', () => {
|
||||
vi.spyOn(usersStore, 'currentUser', 'get').mockReturnValue({
|
||||
role: 'global:owner',
|
||||
});
|
||||
role: ROLE.Owner,
|
||||
} as IUser);
|
||||
|
||||
const { container } = render(V1Banner);
|
||||
expect(container).toMatchSnapshot();
|
||||
|
||||
Reference in New Issue
Block a user