fix(ui): eleven small dashboard state bugs from the audit (#1756)
Install disables when no installable snapshot; retention hours is empty until loaded instead of showing 0; the audit Action field carries all comma-separated actions; saving a view over an existing name asks first; "Password changed" is a notice, not a destructive alert; "Sign in again" appears only on an expired session (classifyActionError) on account, authentication and create-account; sign-out failure sets the store error instead of an unhandled rejection; the workflow identity select shows the seeded agent without writing it into the YAML; unparseable durations show an inline error instead of snapping back; CardAccordion keys items by id; curator add() explains a no-op.
This commit is contained in:
11 files changed
+49
-29
No files matched your search
@@ -11,14 +11,14 @@ import { passkeysAvailable, useAccountsStore, usePasskey } from "./accounts";
|
||||
const accounts=useAccountsStore();
|
||||
const step=ref(1);const recovery=ref(false);const recoveryCode=ref("");
|
||||
const organisation=ref("");const workspace=ref("Default");const publicURL=ref(window.location.origin);
|
||||
const name=ref("");const email=ref("");const password=ref("");const busy=ref(false);const error=ref("");
|
||||
const name=ref("");const email=ref("");const password=ref("");const busy=ref(false);const error=ref("");const notice=ref("");
|
||||
const setup=computed(()=>accounts.status?.setup_required===true);
|
||||
const passkey=computed(()=>passkeysAvailable(accounts.status?.public_url??""));
|
||||
async function submit(){
|
||||
if(setup.value&&step.value===1&&!recovery.value){step.value=2;return}
|
||||
busy.value=true;error.value="";
|
||||
busy.value=true;error.value="";notice.value="";
|
||||
try{
|
||||
if(recovery.value){await api.recoverAccount(email.value,recoveryCode.value,password.value);recovery.value=false;password.value="";error.value="Password changed. Sign in with your new password.";return}
|
||||
if(recovery.value){await api.recoverAccount(email.value,recoveryCode.value,password.value);recovery.value=false;password.value="";notice.value="Password changed. Sign in with your new password.";return}
|
||||
if(setup.value)await api.setupAccount({organisation_name:organisation.value,workspace_name:workspace.value,public_url:publicURL.value.replace(/\/$/,""),display_name:name.value,email:email.value,password:password.value});
|
||||
else await api.signIn(email.value,password.value);
|
||||
password.value="";
|
||||
@@ -48,6 +48,7 @@ async function signInPasskey(){busy.value=true;error.value="";try{await usePassk
|
||||
<p v-if="setup" class="text-caption text-fg-muted">At least 15 characters.</p>
|
||||
</template>
|
||||
<Alert v-if="error" variant="destructive"><AlertDescription>{{error}}</AlertDescription></Alert>
|
||||
<Alert v-if="notice" class="mt-4"><AlertDescription>{{notice}}</AlertDescription></Alert>
|
||||
<div class="flex gap-2"><Button v-if="setup&&step===2" type="button" variant="outline" :disabled="busy" @click="step=1">Back</Button><Button type="submit" class="flex-1" :disabled="busy">{{busy?'Please wait…':setup?(step===1?'Continue':'Create organisation and admin'):recovery?'Reset password':'Sign in'}}</Button></div>
|
||||
</form>
|
||||
<div v-if="!setup&&!recovery" class="mt-4 flex flex-col gap-2">
|
||||
|
||||
@@ -9,15 +9,15 @@ import { Card } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { SettingRow } from "@/components/ui/setting-row";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { api } from "@/lib/api";
|
||||
import { api, classifyActionError } from "@/lib/api";
|
||||
import { passkeysAvailable,useAccountsStore,usePasskey } from "./accounts";
|
||||
const recovery=ref("");
|
||||
const makeRecovery=()=>run(async()=>{recovery.value=(await api.recoveryCode()).code});
|
||||
const accounts=useAccountsStore();const keys=ref<{id:string;name:string}[]>([]);const error=ref("");const busy=ref(false);const keyName=ref("");const current=ref("");const next=ref("");
|
||||
const accounts=useAccountsStore();const keys=ref<{id:string;name:string}[]>([]);const error=ref("");const sessionExpired=ref(false);const busy=ref(false);const keyName=ref("");const current=ref("");const next=ref("");
|
||||
const eligible=computed(()=>passkeysAvailable(accounts.status?.public_url??""));
|
||||
async function load(){try{keys.value=(await api.passkeys()).passkeys}catch(cause){error.value=String((cause as Error).message||cause)}}
|
||||
async function load(){try{keys.value=(await api.passkeys()).passkeys}catch(cause){error.value=String((cause as Error).message||cause);sessionExpired.value=classifyActionError(cause).kind==="session-expired"}}
|
||||
onMounted(load);
|
||||
async function run(action:()=>Promise<unknown>){busy.value=true;error.value="";try{await action()}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}}
|
||||
async function run(action:()=>Promise<unknown>){busy.value=true;error.value="";try{await action()}catch(cause){error.value=String((cause as Error).message||cause);sessionExpired.value=classifyActionError(cause).kind==="session-expired"}finally{busy.value=false}}
|
||||
const enroll=()=>run(async()=>{await usePasskey(true,keyName.value);keyName.value="";await load()});
|
||||
const remove=(id:string)=>run(async()=>{await api.deletePasskey(id);await load()});
|
||||
const change=()=>run(async()=>{await api.changePassword(current.value,next.value);current.value=next.value="";window.location.assign("/")});
|
||||
@@ -26,7 +26,7 @@ const change=()=>run(async()=>{await api.changePassword(current.value,next.value
|
||||
<div class="mx-auto max-w-[80ch]">
|
||||
<PageHeader title="Your account"><span class="text-label text-fg-muted">{{accounts.status?.user?.display_name}}</span></PageHeader>
|
||||
<Alert v-if="$route.query.welcome" class="mb-4">Your organisation and admin account are ready. Add a passkey below, <RouterLink class="underline" to="/org/members">add members</RouterLink>, or <RouterLink class="underline" to="/settings/authentication">configure OIDC</RouterLink>.</Alert>
|
||||
<Alert v-if="error" variant="destructive" class="mb-4"><AlertDescription>{{error}} <a class="underline" href="/?reauth=1">Sign in again</a></AlertDescription></Alert>
|
||||
<Alert v-if="error" variant="destructive" class="mb-4"><AlertDescription>{{error}}<a v-if="sessionExpired" class="underline" href="/?reauth=1"> Sign in again</a></AlertDescription></Alert>
|
||||
<Section title="Passkeys">
|
||||
<ItemGroup v-if="keys.length" class="mb-3"><Item v-for="key in keys" :key="key.id" as="li" variant="outline" size="xs"><ItemContent class="min-w-0 truncate"><span class="truncate">{{key.name}}</span></ItemContent><ItemActions><Button variant="ghost" size="sm" class="text-danger" :disabled="busy" @click="remove(key.id)">Remove</Button></ItemActions></Item></ItemGroup>
|
||||
<form v-if="eligible" class="flex flex-wrap gap-2" @submit.prevent="enroll"><Input v-model="keyName" aria-label="Passkey name" placeholder="Passkey name (optional)" maxlength="200" class="min-w-40 flex-1"/><Button type="submit" :disabled="busy">Add passkey</Button></form>
|
||||
|
||||
@@ -6,18 +6,18 @@ import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import CodeView from "@/base/CodeView.vue";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { api } from "@/lib/api";
|
||||
import { api, classifyActionError } from "@/lib/api";
|
||||
import { SettingRow } from "@/components/ui/setting-row";
|
||||
import { Section } from "@/components/ui/section";
|
||||
interface Settings {public_url:string;oidc_issuer:string;oidc_audience:string;oidc_client_id:string}
|
||||
const value=ref<Settings>({public_url:"",oidc_issuer:"",oidc_audience:"",oidc_client_id:""});const loaded=ref(false);const error=ref("");const busy=ref(false);const saved=ref(false);
|
||||
const value=ref<Settings>({public_url:"",oidc_issuer:"",oidc_audience:"",oidc_client_id:""});const loaded=ref(false);const error=ref("");const sessionExpired=ref(false);const busy=ref(false);const saved=ref(false);
|
||||
onMounted(async()=>{try{value.value=await api.authentication<Settings>();loaded.value=true}catch(cause){error.value=String((cause as Error).message||cause)}});
|
||||
const redirectURI=computed(()=>`${value.value.public_url.replace(/\/$/,"")}/oauth2/callback`);
|
||||
async function save(){busy.value=true;error.value="";saved.value=false;try{await api.saveAuthentication(value.value);saved.value=true}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}}
|
||||
async function save(){busy.value=true;error.value="";saved.value=false;try{await api.saveAuthentication(value.value);saved.value=true}catch(cause){error.value=String((cause as Error).message||cause);sessionExpired.value=classifyActionError(cause).kind==="session-expired"}finally{busy.value=false}}
|
||||
</script>
|
||||
<template>
|
||||
<div><PageHeader title="Authentication"/>
|
||||
<Alert v-if="error" variant="destructive" class="mb-4"><AlertDescription>{{error}} <a class="underline" href="/?reauth=1">Sign in again</a></AlertDescription></Alert>
|
||||
<Alert v-if="error" variant="destructive" class="mb-4"><AlertDescription>{{error}}<a v-if="sessionExpired" class="underline" href="/?reauth=1"> Sign in again</a></AlertDescription></Alert>
|
||||
<form v-if="loaded" @submit.prevent="save">
|
||||
<Section title="Instance URL">
|
||||
<SettingRow label="Public address" for="instance-url" hint="Passkeys require HTTPS and a domain name, or localhost. Once passkeys are enrolled, their domain is fixed."><Input id="instance-url" v-model="value.public_url" type="url" required /></SettingRow>
|
||||
|
||||
@@ -6,13 +6,13 @@ import { Input } from "@/components/ui/input";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { api } from "@/lib/api";
|
||||
import { api, classifyActionError } from "@/lib/api";
|
||||
import { ROLE_LABELS, ROLES } from "@/org/org";
|
||||
const emit=defineEmits<{created:[]}>();
|
||||
// Owner is granted from the member table, not when creating an account.
|
||||
const assignable = ROLES.filter((role) => role !== "owner");
|
||||
const name=ref("");const email=ref("");const password=ref("");const role=ref("viewer");const busy=ref(false);const error=ref("");
|
||||
async function create(){busy.value=true;error.value="";try{await api.createAccount({display_name:name.value,email:email.value,password:password.value,role:role.value});name.value=email.value=password.value="";emit("created")}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}}
|
||||
const name=ref("");const email=ref("");const password=ref("");const role=ref("viewer");const busy=ref(false);const error=ref("");const sessionExpired=ref(false);
|
||||
async function create(){busy.value=true;error.value="";try{await api.createAccount({display_name:name.value,email:email.value,password:password.value,role:role.value});name.value=email.value=password.value="";emit("created")}catch(cause){error.value=String((cause as Error).message||cause);sessionExpired.value=classifyActionError(cause).kind==="session-expired"}finally{busy.value=false}}
|
||||
</script>
|
||||
<template>
|
||||
<Section title="Create a local account">
|
||||
@@ -21,7 +21,7 @@ async function create(){busy.value=true;error.value="";try{await api.createAccou
|
||||
<Label for="new-account-email" class="block space-y-1 text-label">Email<Input id="new-account-email" v-model="email" type="email" required autocomplete="off" :spellcheck="false" /></Label>
|
||||
<Label for="new-account-password" class="block space-y-1 text-label">Initial password<Input id="new-account-password" v-model="password" type="password" required minlength="15" maxlength="1024" autocomplete="new-password" /></Label>
|
||||
<div class="block space-y-1 text-label"><Label for="new-account-role">Role</Label><Select v-model="role"><SelectTrigger id="new-account-role" class="w-full"><SelectValue /></SelectTrigger><SelectContent><SelectItem v-for="choice in assignable" :key="choice" :value="choice">{{ ROLE_LABELS[choice] }}</SelectItem></SelectContent></Select></div>
|
||||
<Alert v-if="error" variant="destructive" class="sm:col-span-2"><AlertDescription>{{error}} <a class="underline" href="/?reauth=1">Sign in again</a></AlertDescription></Alert>
|
||||
<Alert v-if="error" variant="destructive" class="sm:col-span-2"><AlertDescription>{{error}}<a v-if="sessionExpired" class="underline" href="/?reauth=1"> Sign in again</a></AlertDescription></Alert>
|
||||
<Button type="submit" :disabled="busy" class="justify-self-start sm:col-span-2">Create account</Button>
|
||||
</form>
|
||||
</Section>
|
||||
|
||||
@@ -8,7 +8,7 @@ export const useAccountsStore=defineStore("accounts",()=>{
|
||||
const status=ref<AuthStatus|null>(null);
|
||||
const error=ref("");
|
||||
async function load():Promise<void>{try{status.value=await api.authStatus<AuthStatus>();error.value=""}catch(cause){error.value=String((cause as Error).message||cause)}}
|
||||
async function signOut():Promise<void>{await api.signOut();window.location.assign("/")}
|
||||
async function signOut():Promise<void>{try{await api.signOut()}catch(cause){error.value=String((cause as Error).message||cause);return}window.location.assign("/")}
|
||||
// Empty for the default instance, which needs no label.
|
||||
const instance=computed(()=>{const name=status.value?.instance||"";return name==="archie"?"":name});
|
||||
return {status,error,instance,load,signOut};
|
||||
|
||||
@@ -49,13 +49,13 @@ watch(search, (value) => {
|
||||
onUnmounted(() => clearTimeout(searchTimer));
|
||||
|
||||
const actor = ref(props.query.actor ?? "");
|
||||
const action = ref(props.query.actions[0] ?? "");
|
||||
const action = ref((props.query.actions ?? []).join(", "));
|
||||
const targetId = ref(props.query.target_id ?? "");
|
||||
const from = ref(props.query.from ?? "");
|
||||
const to = ref(props.query.to ?? "");
|
||||
|
||||
watch(() => props.query.actor, (value) => (actor.value = value ?? ""));
|
||||
watch(() => props.query.actions.join(","), () => (action.value = props.query.actions[0] ?? ""));
|
||||
watch(() => props.query.actions.join(","), () => (action.value = props.query.actions.join(", ")));
|
||||
watch(() => props.query.target_id, (value) => (targetId.value = value ?? ""));
|
||||
watch(() => props.query.from, (value) => (from.value = value ?? ""));
|
||||
watch(() => props.query.to, (value) => (to.value = value ?? ""));
|
||||
@@ -86,8 +86,8 @@ function commitActor() {
|
||||
}
|
||||
|
||||
function commitAction() {
|
||||
const value = action.value.trim();
|
||||
emit("change", { actions: value ? [value] : [] });
|
||||
const list = action.value.split(",").map((entry) => entry.trim()).filter(Boolean);
|
||||
emit("change", { actions: list });
|
||||
}
|
||||
|
||||
function commitTargetId() {
|
||||
|
||||
@@ -223,6 +223,7 @@ function openSaveView(): void {
|
||||
function saveView(): void {
|
||||
const name = viewName.value.trim();
|
||||
if (!name || !identityId.value) return;
|
||||
if (views.value.some((view) => view.name === name) && activeView.value?.name !== name && !window.confirm(`Replace the saved view "${name}"?`)) return;
|
||||
views.value = [
|
||||
...views.value.filter((view) => view.name !== name),
|
||||
{ name, query: routeQueryFor(query.value) },
|
||||
@@ -318,7 +319,7 @@ async function confirmRevert(): Promise<void> {
|
||||
// same versioned replace the settings pages use.
|
||||
const RETENTION_KIND = "audit-retention";
|
||||
const retentionOpen = ref(false);
|
||||
const retentionHours = ref("0");
|
||||
const retentionHours = ref("");
|
||||
const retentionError = ref("");
|
||||
const retentionSaving = ref(false);
|
||||
const retentionState = settings.stateFor(RETENTION_KIND);
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Button } from "@/components/ui/button";
|
||||
* opens a new card when it adds one and refuses to add another while unsaved
|
||||
* changes exist.
|
||||
*/
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
items: T[];
|
||||
title: (item: T, index: number) => string;
|
||||
removeLabel: string;
|
||||
@@ -17,13 +17,18 @@ defineProps<{
|
||||
}>();
|
||||
const open = defineModel<string>("open", { default: "" });
|
||||
defineEmits<{ remove: [index: number] }>();
|
||||
// Keyed by the item's own id when it has one, so removing a card does not
|
||||
// move another card's child state onto it.
|
||||
function keyOf(item: T, index: number): string {
|
||||
return typeof item === "object" && item !== null && "id" in item ? String((item as { id: unknown }).id) : props.title(item, index);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Accordion v-model="open" type="single" collapsible class="mb-4 gap-4">
|
||||
<AccordionItem
|
||||
v-for="(item, i) in items"
|
||||
:key="i"
|
||||
:key="keyOf(item, i)"
|
||||
:value="String(i)"
|
||||
class="rounded-xl bg-card px-4 ring-1 ring-foreground/10 not-last:border-b-0"
|
||||
>
|
||||
|
||||
@@ -54,6 +54,18 @@ function durationText(seconds: number | null | undefined): string {
|
||||
return formatGoDuration((seconds ?? 0) * 1000);
|
||||
}
|
||||
// Undefined for text that is not a duration, so the draft keeps its last value.
|
||||
const durationErrors = ref<Record<string, string>>({});
|
||||
function commitDuration(field: { handleChange: (value: number) => void }, id: string, text: string): void {
|
||||
const seconds = durationSeconds(text);
|
||||
if (seconds === undefined) {
|
||||
durationErrors.value = { ...durationErrors.value, [id]: "Enter a duration like 30m or 2h." };
|
||||
return;
|
||||
}
|
||||
const next = { ...durationErrors.value };
|
||||
delete next[id];
|
||||
durationErrors.value = next;
|
||||
field.handleChange(seconds);
|
||||
}
|
||||
function durationSeconds(text: string): number | undefined {
|
||||
const ms = parseGoDuration(text);
|
||||
return ms === null ? undefined : Math.round(ms / 1000);
|
||||
@@ -89,8 +101,9 @@ async function restoreWorkflows(): Promise<void> {
|
||||
id="te-task"
|
||||
:model-value="durationText(field.state.value)"
|
||||
:units="['m', 'h']"
|
||||
@update:model-value="(text: string) => { const s = durationSeconds(text); if (s !== undefined) field.handleChange(s); }"
|
||||
@update:model-value="(text: string) => commitDuration(field, 'te-task', text)"
|
||||
/>
|
||||
<p v-if="durationErrors['te-task']" class="text-caption text-danger" role="alert">{{ durationErrors['te-task'] }}</p>
|
||||
<DraftHint :kind="KIND" path="max_task_runtime_seconds" />
|
||||
</div>
|
||||
</Field>
|
||||
@@ -107,8 +120,9 @@ async function restoreWorkflows(): Promise<void> {
|
||||
id="te-call"
|
||||
:model-value="durationText(field.state.value)"
|
||||
:units="['s', 'm', 'h']"
|
||||
@update:model-value="(text: string) => { const s = durationSeconds(text); if (s !== undefined) field.handleChange(s); }"
|
||||
@update:model-value="(text: string) => commitDuration(field, 'te-call', text)"
|
||||
/>
|
||||
<p v-if="durationErrors['te-call']" class="text-caption text-danger" role="alert">{{ durationErrors['te-call'] }}</p>
|
||||
<DraftHint :kind="KIND" path="max_runtime_seconds" />
|
||||
</div>
|
||||
</Field>
|
||||
|
||||
@@ -196,7 +196,7 @@ useLiveResource("updates", () => void loadOutcome());
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<Button class="mt-4 self-start" :disabled="installing" @click="install">{{ installing ? "Installing…" : `Install ${updateable.map((c) => c.label || c.id).join(", ")}`.trim() }}</Button>
|
||||
<Button class="mt-4 self-start" :disabled="installing || !installableSnapshot()" @click="install">{{ installing ? "Installing…" : `Install ${updateable.map((c) => c.label || c.id).join(", ")}`.trim() }}</Button>
|
||||
|
||||
<CodeView v-if="installProgress.length" :code="installProgress.join('\n')" class="mt-3" />
|
||||
<p v-if="installResult" class="mt-2 text-label text-ok">
|
||||
|
||||
@@ -43,7 +43,6 @@ async function loadAgents(): Promise<void> {
|
||||
await identities.loadOrg();
|
||||
const response = await api.orgAgents<{ agents: Identity[] }>(identities.homeOrg);
|
||||
agents.value = response.agents.filter((agent) => agent.lifecycle === "active");
|
||||
if (!text("identity") && agents.value.some((agent) => agent.id === SEEDED_AGENT_ID)) set("identity", SEEDED_AGENT_ID);
|
||||
} catch (cause) {
|
||||
identitiesError.value = String((cause as Error).message || cause);
|
||||
} finally { identitiesLoading.value = false; }
|
||||
@@ -86,7 +85,7 @@ const needs = computed<{ captures?: boolean; gate_retries?: number }>(() => {
|
||||
<span class="flex-1 text-label">Runs as</span>
|
||||
<OptionSelect
|
||||
:key="String(identitiesLoading)"
|
||||
:model-value="text('identity')"
|
||||
:model-value="text('identity') || (agents.some((agent) => agent.id === SEEDED_AGENT_ID) ? SEEDED_AGENT_ID : '')"
|
||||
:options="identityOptions"
|
||||
aria-label="Execution identity"
|
||||
:placeholder="identitiesLoading ? 'Loading agents…' : 'Choose an agent'"
|
||||
|
||||
Reference in new issue
Block a user