fix(ui): distinguish loading, failed and empty lists, one role label set, en dash for no value
This commit is contained in:
16 files changed
+95
-46
No files matched your search
@@ -181,7 +181,8 @@ const isAgent = (value: Identity) =>
|
||||
<Button variant="ghost" size="sm" class="text-danger" :disabled="!!store.identityBusy" @click="retiring = value">Retire</Button>
|
||||
</div>
|
||||
</li>
|
||||
<li v-if="!store.identities.length">
|
||||
<li v-if="!store.identitiesLoaded" class="px-4 py-3 text-sm text-fg-muted" role="status">Loading agents…</li>
|
||||
<li v-else-if="!store.identities.length && !store.identityError">
|
||||
<Empty class="py-6">
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>No identities yet</EmptyTitle>
|
||||
|
||||
@@ -4,7 +4,7 @@ import CreateAccount from "@/accounts/CreateAccount.vue";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { Plus } from "@lucide/vue";
|
||||
import { Plus, Trash2 } from "@lucide/vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
} from "@/components/ui/table";
|
||||
import { api } from "@/lib/api";
|
||||
import { useOrgStore } from "@/stores/org";
|
||||
import { ROLES, type Member, type Role } from "./org";
|
||||
import { ROLE_LABELS, ROLES, type Member, type Role } from "./org";
|
||||
|
||||
/**
|
||||
* The org's members and the role each holds. A membership is org-wide, or
|
||||
@@ -35,6 +35,7 @@ import { ROLES, type Member, type Role } from "./org";
|
||||
*/
|
||||
const members = ref<Member[]>([]);
|
||||
const error = ref("");
|
||||
const loading = ref(true);
|
||||
const busy = ref("");
|
||||
const identities = useOrgStore();
|
||||
const { org } = storeToRefs(identities);
|
||||
@@ -61,12 +62,13 @@ async function load(): Promise<void> {
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await identities.loadOrg();
|
||||
identities.watchIdentities();
|
||||
await load();
|
||||
} catch (cause) {
|
||||
error.value = String((cause as Error).message || cause);
|
||||
return;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
identities.watchIdentities();
|
||||
await load();
|
||||
});
|
||||
|
||||
// Active identities that hold no org-wide membership yet, so Add cannot pick
|
||||
@@ -159,22 +161,26 @@ const remove = (member: Member) =>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ role }}</SelectItem>
|
||||
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ ROLE_LABELS[role] }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</TableCell>
|
||||
<TableCell class="text-right">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
class="text-danger"
|
||||
size="icon"
|
||||
:aria-label="`Remove ${member.display_name}`"
|
||||
title="Remove"
|
||||
:disabled="busy !== ''"
|
||||
@click="remove(member)"
|
||||
>Remove</Button
|
||||
>
|
||||
><Trash2
|
||||
/></Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
<TableRow v-if="!members.length">
|
||||
<TableRow v-if="loading">
|
||||
<TableCell colspan="5" class="text-sm text-fg-muted" role="status">Loading members…</TableCell>
|
||||
</TableRow>
|
||||
<TableRow v-else-if="!members.length && !error">
|
||||
<TableCell colspan="5">
|
||||
<Empty class="py-6">
|
||||
<EmptyHeader>
|
||||
@@ -208,7 +214,7 @@ const remove = (member: Member) =>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ role }}</SelectItem>
|
||||
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ ROLE_LABELS[role] }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Button type="submit" size="sm" :disabled="!picked || busy !== ''">
|
||||
@@ -230,7 +236,7 @@ const remove = (member: Member) =>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ role }}</SelectItem>
|
||||
<SelectItem v-for="role in ROLES" :key="role" :value="role">{{ ROLE_LABELS[role] }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Button type="submit" size="sm" :disabled="!person.trim() || busy !== ''">
|
||||
|
||||
@@ -30,6 +30,7 @@ const id = ref("");
|
||||
const name = ref("");
|
||||
const environment = ref("");
|
||||
const error = ref("");
|
||||
const loading = ref(true);
|
||||
const busy = ref(false);
|
||||
|
||||
async function load(): Promise<void> {
|
||||
@@ -47,11 +48,12 @@ async function load(): Promise<void> {
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await orgStore.loadOrg();
|
||||
await load();
|
||||
} catch (cause) {
|
||||
error.value = String((cause as Error).message || cause);
|
||||
return;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
await load();
|
||||
});
|
||||
|
||||
async function create(): Promise<void> {
|
||||
@@ -98,7 +100,10 @@ async function create(): Promise<void> {
|
||||
<TableCell class="font-medium">{{ workspace.name }}</TableCell>
|
||||
<TableCell class="text-fg-subtle">{{ workspace.environment || "–" }}</TableCell>
|
||||
</TableRow>
|
||||
<TableRow v-if="!workspaces.length">
|
||||
<TableRow v-if="loading">
|
||||
<TableCell colspan="3" class="text-sm text-fg-muted" role="status">Loading workspaces…</TableCell>
|
||||
</TableRow>
|
||||
<TableRow v-else-if="!workspaces.length && !error">
|
||||
<TableCell colspan="3">
|
||||
<Empty class="py-6">
|
||||
<EmptyHeader>
|
||||
|
||||
@@ -16,6 +16,14 @@ export type Role = "owner" | "admin" | "developer" | "viewer";
|
||||
/** The roles the domain accepts, in descending authority. */
|
||||
export const ROLES: Role[] = ["owner", "admin", "developer", "viewer"];
|
||||
|
||||
/** How a role reads wherever the dashboard offers one. */
|
||||
export const ROLE_LABELS: Record<Role, string> = {
|
||||
owner: "Owner",
|
||||
admin: "Admin",
|
||||
developer: "Developer",
|
||||
viewer: "Viewer",
|
||||
};
|
||||
|
||||
export interface Member {
|
||||
identity_id: string;
|
||||
kind: string;
|
||||
|
||||
Reference in new issue
Block a user