fix(webui): bind task requester to authenticated principal
This commit is contained in:
1 parent
4217a50874
commit
cbc4cf309d
7 files changed
+157
-124
No files matched your search
@@ -1,25 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import { firstLine } from "./first-line";
|
||||
import { computed, onMounted, ref, useId, watchEffect } from "vue";
|
||||
import { ChevronRight } from "@lucide/vue";
|
||||
import { RadioGroupItem, RadioGroupRoot } from "reka-ui";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Kbd } from "@/components/ui/kbd";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { api } from "@/lib/api";
|
||||
import { delivered } from "@/lib/delivered";
|
||||
import { useOrgStore } from "@/stores/org";
|
||||
import type { WorkflowDefinition, WorkflowStats } from "@/workflows/workflow-rows";
|
||||
import {
|
||||
declaredInputs,
|
||||
@@ -55,21 +45,15 @@ onMounted(async () => {
|
||||
}
|
||||
});
|
||||
|
||||
const identities = useOrgStore();
|
||||
identities.watchIdentities();
|
||||
const actors = computed(() => identities.identities.filter((i) => i.kind !== "system" && i.lifecycle === "active"));
|
||||
|
||||
const repository = ref("");
|
||||
const workflow = ref(props.workflow ?? props.initialWorkflow ?? "");
|
||||
const instructions = ref(props.initialInstructions ?? "");
|
||||
const title = ref(firstLine(instructions.value));
|
||||
const identity = ref("");
|
||||
// One text field per declared input, by input name: the chosen workflow's
|
||||
// declaration decides what is rendered and what the request carries.
|
||||
const inputText = ref<Record<string, string>>({});
|
||||
watchEffect(() => {
|
||||
if (!workflow.value && definitions.value[0]) workflow.value = definitions.value[0].id;
|
||||
if (!identity.value && actors.value[0]) identity.value = actors.value[0].id;
|
||||
});
|
||||
|
||||
const selected = computed(() => definitions.value.find((d) => d.id === workflow.value));
|
||||
@@ -82,13 +66,12 @@ const repoMode = computed(() => selected.value?.repository ?? "required");
|
||||
const repoRequired = computed(() => repoMode.value !== "optional" && repoMode.value !== "none");
|
||||
|
||||
const statFor = (id: string) => stats.value.find((s) => s.workflow === id);
|
||||
const identityName = computed(() => actors.value.find((a) => a.id === identity.value)?.display_name ?? "nobody");
|
||||
|
||||
const submitting = ref(false);
|
||||
const error = ref("");
|
||||
const ready = computed(
|
||||
() =>
|
||||
!!((repository.value.trim() || !repoRequired.value) && workflow.value && title.value.trim() && instructions.value.trim() && identity.value) &&
|
||||
!!((repository.value.trim() || !repoRequired.value) && workflow.value && title.value.trim() && instructions.value.trim()) &&
|
||||
missing.value.length === 0,
|
||||
);
|
||||
async function submit() {
|
||||
@@ -97,7 +80,6 @@ async function submit() {
|
||||
error.value = "";
|
||||
try {
|
||||
const result = await api.workRequest<{ task_id: number }>({
|
||||
identity: identity.value,
|
||||
repository: repoMode.value === "none" ? "" : repository.value.trim(),
|
||||
workflow: workflow.value,
|
||||
title: title.value.trim(),
|
||||
@@ -189,21 +171,6 @@ async function submit() {
|
||||
<Textarea :id="`${uid}-instr`" v-model="instructions" :rows="4" required />
|
||||
</div>
|
||||
|
||||
<Collapsible>
|
||||
<CollapsibleTrigger class="group flex items-center gap-1 text-xs text-fg-muted hover:text-foreground">
|
||||
<ChevronRight class="size-3.5 transition-transform group-data-[state=open]:rotate-90" aria-hidden="true" />
|
||||
Advanced · run as <span class="font-mono">{{ identityName }}</span>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent class="pt-2">
|
||||
<Select v-model="identity">
|
||||
<SelectTrigger class="w-64" aria-label="Run as identity"><SelectValue placeholder="Choose an identity" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="a in actors" :key="a.id" :value="a.id">{{ a.display_name }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
|
||||
<p v-if="error" class="text-sm text-danger" role="alert">{{ error }}</p>
|
||||
<div class="flex items-center gap-2 border-t border-border pt-4">
|
||||
<span class="mr-auto text-xs text-fg-subtle"><Kbd>⌘</Kbd> <Kbd>↵</Kbd> to start</span>
|
||||
|
||||
Reference in new issue
Block a user