fix(ui): render system identity as System in UserReference
This commit is contained in:
2 files changed
+10
-4
No files matched your search
@@ -39,7 +39,7 @@ module.exports = async ({ page, go, shot }) => {
|
||||
},
|
||||
'/api/approvals': [],
|
||||
'/api/policies/hard-rules': { version, body: '// example', created_at: at, created_by: user.id, versions: [{ version: 2 }, { version: 1 }] },
|
||||
'/api/policies/change-request': { version: 1, body: '', created_at: at },
|
||||
'/api/policies/change-request': { version: 1, body: '', created_at: at, created_by: '00000000-0000-5000-8000-000000000001' },
|
||||
'/api/workflows': [{ id: 'workflow', name: 'Example workflow', version: 1, body: 'steps: []', created_by: user.id, created_at: at, enabled: true }],
|
||||
'/api/workflow-drafts': [],
|
||||
'/api/workflow-stats': [],
|
||||
@@ -89,6 +89,9 @@ module.exports = async ({ page, go, shot }) => {
|
||||
assert.equal(await page.getByRole('link', { name: bot.id, exact: true }).count(), 0);
|
||||
assert.equal(await page.getByRole('link', { name: 'policy-rule', exact: true }).count(), 0);
|
||||
if (path === '/controls') {
|
||||
await page.getByText('System', { exact: true }).waitFor();
|
||||
assert.equal(await page.getByText('00000000-0000-5000-8000-000000000001', { exact: true }).count(), 0);
|
||||
assert.equal(await page.getByRole('link', { name: 'System', exact: true }).count(), 0);
|
||||
await page.getByRole('combobox', { name: 'Hard rules version' }).click();
|
||||
await page.getByRole('option', { name: 'Version 1' }).click();
|
||||
await page.getByRole('textbox', { name: 'Hard rules, version 1' }).waitFor();
|
||||
|
||||
@@ -3,22 +3,25 @@ import { computed, watch } from "vue";
|
||||
import { useAccountsStore } from "@/accounts/accounts";
|
||||
import { useOrgStore } from "@/stores/org";
|
||||
|
||||
const SYSTEM_IDENTITY_ID = "00000000-0000-5000-8000-000000000001";
|
||||
|
||||
const props = defineProps<{ id?: string | null; name?: string; kind?: string; orgId?: string; fallback?: string }>();
|
||||
const org = useOrgStore();
|
||||
const accounts = useAccountsStore();
|
||||
const scope = computed(() => props.orgId || org.homeOrg);
|
||||
const isSystem = computed(() => props.id === SYSTEM_IDENTITY_ID);
|
||||
const recordName = computed(() => props.name === props.id ? undefined : props.name);
|
||||
|
||||
watch(() => [props.id, props.kind, props.orgId] as const, ([id, kind, orgId]) => {
|
||||
if (!id || (kind && kind !== "user")) return;
|
||||
if (!id || id === SYSTEM_IDENTITY_ID || (kind && kind !== "user")) return;
|
||||
void org.loadOrg().then(() => org.readMembers(orgId || org.homeOrg))
|
||||
.catch(() => { /* Without a member list, keep the attribution supplied by the record. */ });
|
||||
}, { immediate: true });
|
||||
|
||||
const member = computed(() => org.membersByOrg.get(scope.value)?.find((entry) => entry.identity_id === props.id));
|
||||
const account = computed(() => accounts.status?.user?.id === props.id ? accounts.status?.user : undefined);
|
||||
const kind = computed(() => props.kind || member.value?.kind || account.value?.kind);
|
||||
const label = computed(() => recordName.value || member.value?.display_name || account.value?.display_name || props.id || props.fallback);
|
||||
const kind = computed(() => props.kind || (isSystem.value ? "system" : undefined) || member.value?.kind || account.value?.kind);
|
||||
const label = computed(() => recordName.value || member.value?.display_name || account.value?.display_name || (isSystem.value ? "System" : undefined) || props.id || props.fallback);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in new issue
Block a user