fix(editor): List instance admins when a project has no admin of its own

This commit is contained in:
Theo Nastos 2026-10-19 14:18:16 +03:00
parent 22fa2c318c
commit 200790fe2f
No known key found for this signature in database
2 changed files with 31 additions and 4 deletions

View File

@ -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] });

View File

@ -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,