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.
29 lines
2.6 KiB
Vue
29 lines
2.6 KiB
Vue
<script setup lang="ts">
|
|
import { Label } from "@/components/ui/label";
|
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
import { ref } from "vue";
|
|
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, 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("");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">
|
|
<form class="grid gap-3 sm:grid-cols-2" @submit.prevent="create">
|
|
<Label for="new-account-name" class="block space-y-1 text-label">Name<Input id="new-account-name" v-model="name" required maxlength="200" autocomplete="off" /></Label>
|
|
<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 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>
|
|
</template>
|