mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-19 16:55:02 +02:00
fix(editor): List instance admins when a project has no admin of its own
This commit is contained in:
parent
22fa2c318c
commit
200790fe2f
|
|
@ -140,6 +140,31 @@ describe('ContactAdminModal', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('lists the instance owners and admins when the project has no admin of its own', async () => {
|
||||
setup([owner]);
|
||||
mockPolicyProject({
|
||||
type: 'team',
|
||||
relations: [projectEditor],
|
||||
implicitMembers: [
|
||||
{
|
||||
id: 'global-admin-1',
|
||||
firstName: 'Margaret',
|
||||
lastName: 'Hamilton',
|
||||
email: 'margaret@example.com',
|
||||
globalRole: { slug: 'global:admin', displayName: 'Admin' },
|
||||
},
|
||||
],
|
||||
});
|
||||
const { findByTestId } = renderComponent({
|
||||
props: { open: true, nodeTypeName: 'Slack', audience: 'project' },
|
||||
});
|
||||
|
||||
const list = await findByTestId('contact-admin-list');
|
||||
|
||||
expect(list).toHaveTextContent('Margaret Hamilton');
|
||||
expect(list).not.toHaveTextContent('Alan Turing');
|
||||
});
|
||||
|
||||
it('falls back to a project hint when the project has no admin to list', async () => {
|
||||
setup([owner]);
|
||||
mockPolicyProject({ type: 'team', relations: [projectEditor] });
|
||||
|
|
|
|||
|
|
@ -62,11 +62,13 @@ const instanceAdmins = computed<Admin[]>(() =>
|
|||
.filter(hasEmail),
|
||||
);
|
||||
|
||||
const projectAdmins = computed<Admin[]>(() =>
|
||||
(policiesStore.policyProject?.relations ?? [])
|
||||
const projectAdmins = computed<Admin[]>(() => {
|
||||
const project = policiesStore.policyProject;
|
||||
const explicitAdmins = (project?.relations ?? [])
|
||||
.filter((relation) => relation.role === PROJECT_ADMIN_ROLE_SLUG)
|
||||
.filter(hasEmail),
|
||||
);
|
||||
.filter(hasEmail);
|
||||
return explicitAdmins.length ? explicitAdmins : (project?.implicitMembers ?? []).filter(hasEmail);
|
||||
});
|
||||
|
||||
const admins = computed(() =>
|
||||
audience === 'project' ? projectAdmins.value : instanceAdmins.value,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user