fix(ui): add a warn alert variant and fit org and model forms on phones
This commit is contained in:
1 parent
951acb8088
commit
ffafc3a989
8 files changed
+22
-29
No files matched your search
@@ -13,14 +13,14 @@ const name=ref("");const email=ref("");const password=ref("");const role=ref("vi
|
||||
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}}
|
||||
</script>
|
||||
<template>
|
||||
<Section title="Create a local account" class="max-w-md">
|
||||
<form class="space-y-3" @submit.prevent="create">
|
||||
<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-sm">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-sm">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-sm">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-sm"><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>
|
||||
<p v-if="error" role="alert" class="text-sm text-danger">{{error}} <a class="underline" href="/?reauth=1">Sign in again</a></p>
|
||||
<Button type="submit" :disabled="busy">Create account</Button>
|
||||
<p v-if="error" role="alert" class="text-sm text-danger sm:col-span-2">{{error}} <a class="underline" href="/?reauth=1">Sign in again</a></p>
|
||||
<Button type="submit" :disabled="busy" class="justify-self-start sm:col-span-2">Create account</Button>
|
||||
</form>
|
||||
</Section>
|
||||
</template>
|
||||
@@ -14,6 +14,7 @@ export const alertVariants = cva(
|
||||
default: "bg-card text-card-foreground",
|
||||
destructive:
|
||||
"text-destructive bg-card *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current",
|
||||
warn: "border-warn/40 bg-warn-soft *:[svg]:text-warn",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
||||
import { useSettingsStore } from "@/stores/settings";
|
||||
import { restartPendingTitles } from "./apply-status";
|
||||
|
||||
@@ -17,14 +18,8 @@ const pending = computed(() =>
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="pending.length"
|
||||
role="status"
|
||||
class="mb-6 rounded-md border border-warn/40 bg-warn-soft px-4 py-3 text-sm"
|
||||
>
|
||||
<p class="font-medium text-warn">Restart pending</p>
|
||||
<p class="mt-0.5 text-fg-muted">
|
||||
{{ pending.join(", ") }}
|
||||
</p>
|
||||
</div>
|
||||
<Alert v-if="pending.length" role="status" variant="warn" class="mb-6">
|
||||
<AlertTitle class="text-warn">Restart pending</AlertTitle>
|
||||
<AlertDescription class="text-fg-muted">{{ pending.join(", ") }}</AlertDescription>
|
||||
</Alert>
|
||||
</template>
|
||||
@@ -162,7 +162,7 @@ function setAllowed(id: string, text: string) {
|
||||
<Section title="Aliases">
|
||||
<p v-if="!aliases.default" class="mb-3 text-sm text-warn" role="alert">Set the default alias.</p>
|
||||
<div v-for="alias in aliasNames" :key="alias" class="flex flex-wrap items-center gap-3 border-b border-border py-2.5 last-of-type:border-b-0">
|
||||
<label :for="`alias-${alias}`" class="w-28 text-sm font-medium">{{ alias }}</label>
|
||||
<label :for="`alias-${alias}`" class="w-28 text-sm font-medium max-sm:w-full">{{ alias }}</label>
|
||||
<template v-if="alias === 'embedding'">
|
||||
<Select :model-value="embeddingProvider" @update:model-value="(v) => setEmbedding(String(v), embeddingModel)">
|
||||
<SelectTrigger class="w-44 font-mono" aria-label="Embedding provider"><SelectValue placeholder="unset" /></SelectTrigger>
|
||||
@@ -173,7 +173,7 @@ function setAllowed(id: string, text: string) {
|
||||
<Input
|
||||
:id="`alias-${alias}`"
|
||||
:model-value="embeddingModel"
|
||||
class="max-w-64 font-mono"
|
||||
class="min-w-0 max-w-64 flex-1 font-mono"
|
||||
placeholder="model"
|
||||
:disabled="!embeddingProvider"
|
||||
@update:model-value="(v) => setEmbedding(embeddingProvider, String(v))"
|
||||
@@ -185,7 +185,7 @@ function setAllowed(id: string, text: string) {
|
||||
:id="`alias-${alias}`"
|
||||
:model-value="aliases[alias] ?? ''"
|
||||
list="alias-models"
|
||||
class="max-w-md flex-1 font-mono"
|
||||
class="min-w-0 max-w-md flex-1 font-mono max-sm:max-w-none max-sm:basis-full"
|
||||
placeholder="unset"
|
||||
:aria-invalid="aliasIssue(alias) ? true : undefined"
|
||||
@update:model-value="(v) => setAlias(alias, String(v))"
|
||||
@@ -211,11 +211,11 @@ function setAllowed(id: string, text: string) {
|
||||
</datalist>
|
||||
<Section title="Org access">
|
||||
<div v-for="o in otherOrgs" :key="o.id" class="flex flex-wrap items-center gap-3 border-b border-border py-2.5 last-of-type:border-b-0">
|
||||
<span class="w-28 truncate text-sm font-medium" :title="o.id">{{ o.name }}</span>
|
||||
<span class="w-28 truncate text-sm font-medium max-sm:w-full" :title="o.id">{{ o.name }}</span>
|
||||
<Input
|
||||
:model-value="allowedText(o.id)"
|
||||
list="org-allowed"
|
||||
class="max-w-md flex-1 font-mono"
|
||||
class="min-w-0 max-w-md flex-1 font-mono max-sm:max-w-none max-sm:basis-full"
|
||||
placeholder="no models"
|
||||
:aria-label="`Models ${o.name} may use`"
|
||||
@update:model-value="(v) => setAllowed(o.id, String(v))"
|
||||
|
||||
@@ -18,7 +18,6 @@ import { api } from "@/lib/api";
|
||||
import { runQuery, type LogState } from "./task-run";
|
||||
import { firstLine } from "./first-line";
|
||||
import { statusKind, statusLabel } from "@/lib/task-meta";
|
||||
import { cn } from "@/lib/utils";
|
||||
import DispatchLinks from "@/bindings/DispatchLinks.vue";
|
||||
import { MetadataList } from "@/components/ui/metadata-list";
|
||||
import { Section } from "@/components/ui/section";
|
||||
@@ -164,8 +163,8 @@ const headerActions = computed(() =>
|
||||
|
||||
<Alert
|
||||
v-if="failure"
|
||||
:variant="failure.parked ? 'default' : 'destructive'"
|
||||
:class="cn('mt-4', failure.parked && 'border-warn/40 bg-warn-soft')"
|
||||
:variant="failure.parked ? 'warn' : 'destructive'"
|
||||
class="mt-4"
|
||||
>
|
||||
<CircleAlert aria-hidden="true" />
|
||||
<AlertTitle class="flex flex-wrap items-center justify-between gap-2">
|
||||
|
||||
@@ -30,9 +30,7 @@ const note = computed(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- warn-soft rather than the Alert's default surface: this is a caution the
|
||||
operator should read past, not a panel to look at. -->
|
||||
<Alert v-if="note" class="mb-4 border-warn bg-warn-soft">
|
||||
<Alert v-if="note" variant="warn" class="mb-4">
|
||||
<AlertTriangle />
|
||||
<AlertDescription>{{ note }}</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
Reference in new issue
Block a user