feat(ui): workflow row actions, throttled live reloads, toolbar and layout fixes (#1833)
This commit is contained in:
24 files changed
+540
-32
No files matched your search
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { ChevronDown, ChevronUp } from "@lucide/vue";
|
||||
import { onMounted, onUnmounted, ref, watch } from "vue";
|
||||
import { nextTick, onMounted, onUnmounted, ref, watch } from "vue";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import ChatBar from "./ChatBar.vue";
|
||||
@@ -50,6 +50,7 @@ watch(expanded, (open) => {
|
||||
else document.removeEventListener("keydown", onKeydown);
|
||||
});
|
||||
onUnmounted(() => document.removeEventListener("keydown", onKeydown));
|
||||
watch(expanded, () => nextTick(reserve));
|
||||
|
||||
// The page reserves the collapsed dock's height, read from the rendered bar so
|
||||
// the last line of any page can scroll clear of it.
|
||||
|
||||
@@ -8,7 +8,7 @@ defineProps<{ hidden: string[] }>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Sidebar collapsible="icon">
|
||||
<Sidebar collapsible="icon" class="h-dvh">
|
||||
<SidebarHeader>
|
||||
<TeamSwitcher />
|
||||
</SidebarHeader>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuRootEmits, ContextMenuRootProps } from 'reka-ui'
|
||||
import { ContextMenuRoot, useForwardPropsEmits } from 'reka-ui'
|
||||
|
||||
const props = defineProps<ContextMenuRootProps>()
|
||||
const emits = defineEmits<ContextMenuRootEmits>()
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuRoot
|
||||
data-slot="context-menu"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot />
|
||||
</ContextMenuRoot>
|
||||
</template>
|
||||
@@ -0,0 +1,40 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuCheckboxItemEmits, ContextMenuCheckboxItemProps } from 'reka-ui'
|
||||
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { CheckIcon } from '@lucide/vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { cn } from 'cn'
|
||||
import {
|
||||
ContextMenuCheckboxItem,
|
||||
ContextMenuItemIndicator,
|
||||
useForwardPropsEmits,
|
||||
} from 'reka-ui'
|
||||
|
||||
const props = defineProps<ContextMenuCheckboxItemProps & { class?: HTMLAttributes['class'] }>()
|
||||
const emits = defineEmits<ContextMenuCheckboxItemEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuCheckboxItem
|
||||
data-slot="context-menu-checkbox-item"
|
||||
v-bind="forwarded"
|
||||
:class="cn(
|
||||
'focus:bg-accent focus:text-accent-foreground gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm data-inset:pl-7 [&_svg:not([class*=size-])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<span class="absolute right-2 pointer-events-none">
|
||||
<ContextMenuItemIndicator>
|
||||
<slot name="indicator-icon">
|
||||
<CheckIcon />
|
||||
</slot>
|
||||
</ContextMenuItemIndicator>
|
||||
</span>
|
||||
<slot />
|
||||
</ContextMenuCheckboxItem>
|
||||
</template>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuContentEmits, ContextMenuContentProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { cn } from 'cn'
|
||||
import {
|
||||
ContextMenuContent,
|
||||
ContextMenuPortal,
|
||||
useForwardPropsEmits,
|
||||
} from 'reka-ui'
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const props = defineProps<ContextMenuContentProps & { class?: HTMLAttributes['class'] }>()
|
||||
const emits = defineEmits<ContextMenuContentEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuPortal>
|
||||
<ContextMenuContent
|
||||
data-slot="context-menu-content"
|
||||
v-bind="{ ...$attrs, ...forwarded }"
|
||||
:class="cn(
|
||||
'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-36 rounded-lg p-1 shadow-md ring-1 duration-100 cn-menu-translucent z-50 max-h-(--reka-context-menu-content-available-height) origin-(--reka-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</ContextMenuContent>
|
||||
</ContextMenuPortal>
|
||||
</template>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuGroupProps } from 'reka-ui'
|
||||
import { ContextMenuGroup } from 'reka-ui'
|
||||
|
||||
const props = defineProps<ContextMenuGroupProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuGroup
|
||||
data-slot="context-menu-group"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</ContextMenuGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,38 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuItemEmits, ContextMenuItemProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { cn } from 'cn'
|
||||
import {
|
||||
ContextMenuItem,
|
||||
useForwardPropsEmits,
|
||||
} from 'reka-ui'
|
||||
|
||||
const props = withDefaults(defineProps<ContextMenuItemProps & {
|
||||
class?: HTMLAttributes['class']
|
||||
inset?: boolean
|
||||
variant?: 'default' | 'destructive'
|
||||
}>(), {
|
||||
variant: 'default',
|
||||
})
|
||||
const emits = defineEmits<ContextMenuItemEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuItem
|
||||
data-slot="context-menu-item"
|
||||
:data-inset="inset ? '' : undefined"
|
||||
:data-variant="variant"
|
||||
v-bind="forwarded"
|
||||
:class="cn(
|
||||
'focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive focus:*:[svg]:text-accent-foreground gap-1.5 rounded-md px-1.5 py-1 text-sm data-inset:pl-7 [&_svg:not([class*=size-])]:size-4 group/context-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
</ContextMenuItem>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuLabelProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { cn } from 'cn'
|
||||
import { ContextMenuLabel } from 'reka-ui'
|
||||
|
||||
const props = defineProps<ContextMenuLabelProps & { class?: HTMLAttributes['class'], inset?: boolean }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuLabel
|
||||
data-slot="context-menu-label"
|
||||
:data-inset="inset ? '' : undefined"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn('text-muted-foreground px-1.5 py-1 text-xs font-medium data-inset:pl-7', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</ContextMenuLabel>
|
||||
</template>
|
||||
@@ -0,0 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuPortalProps } from 'reka-ui'
|
||||
import { ContextMenuPortal } from 'reka-ui'
|
||||
|
||||
const props = defineProps<ContextMenuPortalProps>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuPortal
|
||||
data-slot="context-menu-portal"
|
||||
v-bind="props"
|
||||
>
|
||||
<slot />
|
||||
</ContextMenuPortal>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuRadioGroupEmits, ContextMenuRadioGroupProps } from 'reka-ui'
|
||||
import {
|
||||
ContextMenuRadioGroup,
|
||||
useForwardPropsEmits,
|
||||
} from 'reka-ui'
|
||||
|
||||
const props = defineProps<ContextMenuRadioGroupProps>()
|
||||
const emits = defineEmits<ContextMenuRadioGroupEmits>()
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuRadioGroup
|
||||
data-slot="context-menu-radio-group"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot />
|
||||
</ContextMenuRadioGroup>
|
||||
</template>
|
||||
@@ -0,0 +1,40 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuRadioItemEmits, ContextMenuRadioItemProps } from 'reka-ui'
|
||||
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { CheckIcon } from '@lucide/vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { cn } from 'cn'
|
||||
import {
|
||||
ContextMenuItemIndicator,
|
||||
ContextMenuRadioItem,
|
||||
useForwardPropsEmits,
|
||||
} from 'reka-ui'
|
||||
|
||||
const props = defineProps<ContextMenuRadioItemProps & { class?: HTMLAttributes['class'] }>()
|
||||
const emits = defineEmits<ContextMenuRadioItemEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuRadioItem
|
||||
data-slot="context-menu-radio-item"
|
||||
v-bind="forwarded"
|
||||
:class="cn(
|
||||
'focus:bg-accent focus:text-accent-foreground gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm data-inset:pl-7 [&_svg:not([class*=size-])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<span class="absolute right-2 pointer-events-none">
|
||||
<ContextMenuItemIndicator>
|
||||
<slot name="indicator-icon">
|
||||
<CheckIcon />
|
||||
</slot>
|
||||
</ContextMenuItemIndicator>
|
||||
</span>
|
||||
<slot />
|
||||
</ContextMenuRadioItem>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuSeparatorProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { cn } from 'cn'
|
||||
import {
|
||||
ContextMenuSeparator,
|
||||
} from 'reka-ui'
|
||||
|
||||
const props = defineProps<ContextMenuSeparatorProps & { class?: HTMLAttributes['class'] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuSeparator
|
||||
data-slot="context-menu-separator"
|
||||
v-bind="delegatedProps"
|
||||
:class="cn('bg-border -mx-1 my-1 h-px', props.class)"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { cn } from 'cn'
|
||||
|
||||
const props = defineProps<{
|
||||
class?: HTMLAttributes['class']
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span
|
||||
data-slot="context-menu-shortcut"
|
||||
:class="cn('text-muted-foreground group-focus/context-menu-item:text-accent-foreground ml-auto text-xs tracking-widest', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</span>
|
||||
</template>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuSubEmits, ContextMenuSubProps } from 'reka-ui'
|
||||
import {
|
||||
ContextMenuSub,
|
||||
useForwardPropsEmits,
|
||||
} from 'reka-ui'
|
||||
|
||||
const props = defineProps<ContextMenuSubProps>()
|
||||
const emits = defineEmits<ContextMenuSubEmits>()
|
||||
|
||||
const forwarded = useForwardPropsEmits(props, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuSub
|
||||
data-slot="context-menu-sub"
|
||||
v-bind="forwarded"
|
||||
>
|
||||
<slot />
|
||||
</ContextMenuSub>
|
||||
</template>
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import type { DropdownMenuSubContentEmits, DropdownMenuSubContentProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { cn } from 'cn'
|
||||
import {
|
||||
ContextMenuSubContent,
|
||||
useForwardPropsEmits,
|
||||
} from 'reka-ui'
|
||||
|
||||
const props = defineProps<DropdownMenuSubContentProps & { class?: HTMLAttributes['class'] }>()
|
||||
const emits = defineEmits<DropdownMenuSubContentEmits>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
|
||||
const forwarded = useForwardPropsEmits(delegatedProps, emits)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuSubContent
|
||||
data-slot="context-menu-sub-content"
|
||||
v-bind="forwarded"
|
||||
:class="
|
||||
cn(
|
||||
'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-popover text-popover-foreground min-w-32 rounded-lg border p-1 shadow-lg duration-100 cn-menu-translucent z-50 origin-(--reka-context-menu-content-transform-origin) overflow-hidden',
|
||||
props.class,
|
||||
)
|
||||
"
|
||||
>
|
||||
<slot />
|
||||
</ContextMenuSubContent>
|
||||
</template>
|
||||
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuSubTriggerProps } from 'reka-ui'
|
||||
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { ChevronRightIcon } from '@lucide/vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { cn } from 'cn'
|
||||
import {
|
||||
ContextMenuSubTrigger,
|
||||
useForwardProps,
|
||||
} from 'reka-ui'
|
||||
|
||||
const props = defineProps<ContextMenuSubTriggerProps & { class?: HTMLAttributes['class'], inset?: boolean }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
|
||||
const forwardedProps = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuSubTrigger
|
||||
data-slot="context-menu-sub-trigger"
|
||||
:data-inset="inset ? '' : undefined"
|
||||
v-bind="forwardedProps"
|
||||
:class="cn(
|
||||
'focus:bg-accent focus:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground gap-1.5 rounded-md px-1.5 py-1 text-sm data-inset:pl-7 [&_svg:not([class*=size-])]:size-4 flex cursor-default items-center outline-hidden select-none [&_svg]:pointer-events-none [&_svg]:shrink-0',
|
||||
props.class,
|
||||
)"
|
||||
>
|
||||
<slot />
|
||||
<ChevronRightIcon class="cn-rtl-flip ml-auto" />
|
||||
</ContextMenuSubTrigger>
|
||||
</template>
|
||||
@@ -0,0 +1,22 @@
|
||||
<script setup lang="ts">
|
||||
import type { ContextMenuTriggerProps } from 'reka-ui'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import { reactiveOmit } from '@vueuse/core'
|
||||
import { cn } from 'cn'
|
||||
import { ContextMenuTrigger, useForwardProps } from 'reka-ui'
|
||||
|
||||
const props = defineProps<ContextMenuTriggerProps & { class?: HTMLAttributes['class'] }>()
|
||||
|
||||
const delegatedProps = reactiveOmit(props, 'class')
|
||||
const forwardedProps = useForwardProps(delegatedProps)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenuTrigger
|
||||
data-slot="context-menu-trigger"
|
||||
v-bind="forwardedProps"
|
||||
:class="cn('select-none', props.class)"
|
||||
>
|
||||
<slot />
|
||||
</ContextMenuTrigger>
|
||||
</template>
|
||||
@@ -0,0 +1,14 @@
|
||||
export { default as ContextMenu } from './ContextMenu.vue'
|
||||
export { default as ContextMenuCheckboxItem } from './ContextMenuCheckboxItem.vue'
|
||||
export { default as ContextMenuContent } from './ContextMenuContent.vue'
|
||||
export { default as ContextMenuGroup } from './ContextMenuGroup.vue'
|
||||
export { default as ContextMenuItem } from './ContextMenuItem.vue'
|
||||
export { default as ContextMenuLabel } from './ContextMenuLabel.vue'
|
||||
export { default as ContextMenuRadioGroup } from './ContextMenuRadioGroup.vue'
|
||||
export { default as ContextMenuRadioItem } from './ContextMenuRadioItem.vue'
|
||||
export { default as ContextMenuSeparator } from './ContextMenuSeparator.vue'
|
||||
export { default as ContextMenuShortcut } from './ContextMenuShortcut.vue'
|
||||
export { default as ContextMenuSub } from './ContextMenuSub.vue'
|
||||
export { default as ContextMenuSubContent } from './ContextMenuSubContent.vue'
|
||||
export { default as ContextMenuSubTrigger } from './ContextMenuSubTrigger.vue'
|
||||
export { default as ContextMenuTrigger } from './ContextMenuTrigger.vue'
|
||||
@@ -6,6 +6,6 @@ import { useTasksStore } from "@/stores/tasks";
|
||||
/** Owns the initial fetch and the event stream for the page's lifetime. */
|
||||
export function useDashboard(): void {
|
||||
const store = useTasksStore();
|
||||
useLiveResource("tasks", () => void store.load(), 500);
|
||||
useLiveResource("tasks", () => void store.load(), 5000);
|
||||
onMounted(store.load);
|
||||
}
|
||||
@@ -144,24 +144,48 @@ export const useSessionStore = defineStore("session", () => {
|
||||
};
|
||||
});
|
||||
|
||||
/** Re-read one mounted projection when SSE says its backend resource changed. */
|
||||
/** Re-read one mounted projection when SSE says its backend resource changed.
|
||||
* The first change loads at once; a burst then loads at most once per
|
||||
* intervalMs, and a hidden tab waits until it is visible again. */
|
||||
export function useLiveResource(
|
||||
resource: LiveResource | null,
|
||||
load: () => void,
|
||||
debounceMs = 100,
|
||||
intervalMs = 100,
|
||||
): void {
|
||||
const live = useSessionStore();
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
let lastRun = Number.NEGATIVE_INFINITY;
|
||||
let stale = false;
|
||||
const revision = () =>
|
||||
resource === null
|
||||
? live.connectionRevision
|
||||
: [live.revisions[resource], live.connectionRevision];
|
||||
const stop = watch(revision, () => {
|
||||
function run(): void {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(load, debounceMs);
|
||||
});
|
||||
timer = undefined;
|
||||
stale = document.hidden;
|
||||
if (stale) return;
|
||||
lastRun = Date.now();
|
||||
load();
|
||||
}
|
||||
function request(): void {
|
||||
if (document.hidden) {
|
||||
stale = true;
|
||||
return;
|
||||
}
|
||||
if (timer !== undefined) return;
|
||||
const wait = lastRun + intervalMs - Date.now();
|
||||
if (wait <= 0) run();
|
||||
else timer = setTimeout(run, wait);
|
||||
}
|
||||
function visible(): void {
|
||||
if (!document.hidden && stale) request();
|
||||
}
|
||||
const stop = watch(revision, request);
|
||||
document.addEventListener("visibilitychange", visible);
|
||||
onUnmounted(() => {
|
||||
clearTimeout(timer);
|
||||
document.removeEventListener("visibilitychange", visible);
|
||||
stop();
|
||||
});
|
||||
}
|
||||
@@ -150,7 +150,7 @@ async function loadMore() {
|
||||
}
|
||||
}
|
||||
|
||||
useLiveResource("tasks", () => void load(), 500);
|
||||
useLiveResource("tasks", () => void load(), 5000);
|
||||
onMounted(load);
|
||||
watch(status, () => {
|
||||
tasks.value = null;
|
||||
|
||||
@@ -311,7 +311,7 @@ const changes = computed(() => (dirty.value ? workflowChanges(stored.value ?? ""
|
||||
// Disabled buttons swallow hover, so the reason sits on a wrapper's title.
|
||||
const publishBlocked = computed(() =>
|
||||
archieWorking.value ? "Archie is editing" : !parsed.value.ok ? validationLabel(parsed.value) : !changes.value.length ? "No changes" : undefined);
|
||||
const view = ref("canvas");
|
||||
const view = defineModel<string>("view", { default: "canvas" });
|
||||
// What each step lacks, read the way its editor reads it.
|
||||
const problems = computed(() =>
|
||||
Object.fromEntries(
|
||||
@@ -397,11 +397,11 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
||||
<TabsList class="shrink-0 justify-start">
|
||||
<TabsTrigger value="canvas">Canvas</TabsTrigger>
|
||||
<TabsTrigger value="yaml">YAML</TabsTrigger>
|
||||
<TabsTrigger v-if="stored !== undefined" value="history" class="max-xl:hidden">History</TabsTrigger>
|
||||
<TabsTrigger v-if="$slots.performance" value="performance" class="max-xl:hidden">Performance</TabsTrigger>
|
||||
<TabsTrigger v-if="$slots.runs && stored !== undefined" value="runs" class="max-xl:hidden">Runs <span class="ml-1 font-mono text-caption text-fg-subtle">{{ runsCount ?? 0 }}</span></TabsTrigger>
|
||||
<TabsTrigger v-if="stored !== undefined" value="history" class="max-2xl:hidden">History</TabsTrigger>
|
||||
<TabsTrigger v-if="$slots.performance" value="performance" class="max-2xl:hidden">Performance</TabsTrigger>
|
||||
<TabsTrigger v-if="$slots.runs && stored !== undefined" value="runs" class="max-2xl:hidden">Runs <span class="ml-1 font-mono text-caption text-fg-subtle">{{ runsCount ?? 0 }}</span></TabsTrigger>
|
||||
</TabsList>
|
||||
<span v-if="SECTIONS[view]" class="shrink-0 text-caption font-medium text-fg-muted xl:hidden">{{ SECTIONS[view] }}</span>
|
||||
<span v-if="SECTIONS[view]" class="shrink-0 text-caption font-medium text-fg-muted 2xl:hidden">{{ SECTIONS[view] }}</span>
|
||||
<div role="group" aria-label="Runs" class="workflow-run-actions ml-auto flex min-w-0 items-center gap-1 max-sm:col-span-2 max-sm:row-start-2 max-sm:ml-0">
|
||||
<div v-if="stored !== undefined && (view === 'canvas' || view === 'yaml')" class="shrink-0">
|
||||
<RunWorkflowButton
|
||||
@@ -442,16 +442,16 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
||||
<Spinner v-if="state.saving" data-icon="inline-start" />Publish</Button>
|
||||
</span>
|
||||
<MoreMenu>
|
||||
<DropdownMenuItem v-if="stored !== undefined" class="xl:hidden" @select="view = 'history'">History</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="$slots.performance" class="xl:hidden" @select="view = 'performance'">Performance</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="$slots.runs && stored !== undefined" class="xl:hidden" @select="view = 'runs'">Runs <span class="ml-auto font-mono text-caption text-fg-subtle">{{ runsCount ?? 0 }}</span></DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="stored !== undefined" class="2xl:hidden" @select="view = 'history'">History</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="$slots.performance" class="2xl:hidden" @select="view = 'performance'">Performance</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="$slots.runs && stored !== undefined" class="2xl:hidden" @select="view = 'runs'">Runs <span class="ml-auto font-mono text-caption text-fg-subtle">{{ runsCount ?? 0 }}</span></DropdownMenuItem>
|
||||
<!-- The run's page and the version it pinned are menu items, not
|
||||
row controls: the row keeps the width for the picked run. -->
|
||||
<DropdownMenuItem v-if="watchedRun" as-child><RouterLink :to="`/tasks/${watchedRun.id}`">Open run</RouterLink></DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="watchedRevision" @select="openRevision(watchedRevision.version)">Version {{ watchedRevision.version }}</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="changes.length" @select="draftOpen = true">Draft changes <span class="ml-auto font-mono text-caption text-fg-subtle">{{ changes.length }}</span></DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="dirty" :disabled="archieWorking" @select="restorePublished"><RotateCcw />Restore</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="view === 'canvas' || view === 'yaml'" variant="destructive" @select="confirmDelete = true"><Trash2 />Delete workflow</DropdownMenuItem>
|
||||
<DropdownMenuItem variant="destructive" @select="confirmDelete = true"><Trash2 />Delete workflow</DropdownMenuItem>
|
||||
</MoreMenu>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
import { toast } from "vue-sonner";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import { Plus } from "@lucide/vue";
|
||||
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { Copy, ListChecks, Play, Plus, Power } from "@lucide/vue";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -15,6 +14,11 @@ import {
|
||||
} from "@/components/ui/empty";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "@/components/ui/context-menu";
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { MoreMenu } from "@/components/ui/more-menu";
|
||||
import NewTaskForm from "@/tasks/NewTaskForm.vue";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { StatusDot } from "@/components/ui/status-dot";
|
||||
import { Table, TableBody, TableCell, TableRow } from "@/components/ui/table";
|
||||
@@ -25,7 +29,7 @@ import { delivered } from "@/lib/delivered";
|
||||
import { compact } from "@/lib/format";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { statusKind, statusLabel } from "@/lib/task-meta";
|
||||
import { useWorkflowsStore } from "@/stores/workflows";
|
||||
import { upsertWorkflowDefinition, useWorkflowsStore } from "@/stores/workflows";
|
||||
import { useLiveResource } from "@/stores/session";
|
||||
import ApplyStatusRows from "@/settings/ApplyStatusRows.vue";
|
||||
import SlowestStagesCard from "./SlowestStagesCard.vue";
|
||||
@@ -33,6 +37,7 @@ import StageFailuresCard from "./StageFailuresCard.vue";
|
||||
import type { StageStats } from "./stages";
|
||||
import WorkflowEditor from "./WorkflowEditor.vue";
|
||||
import WorkflowPicker from "./WorkflowPicker.vue";
|
||||
import { setWorkflowField } from "./workflow-edit";
|
||||
import { workflowRows, type WorkflowDefinition, type WorkflowStats } from "./workflow-rows";
|
||||
|
||||
interface WorkflowsResponse {
|
||||
@@ -56,21 +61,25 @@ const data = shallowRef<WorkflowsResponse>({});
|
||||
const error = ref<string | null>(null);
|
||||
const loading = ref(true);
|
||||
|
||||
const statsOf = (id: string) => JSON.stringify(data.value.workflows?.find((w) => w.workflow === id) ?? null);
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
// The sidebar's running count and last status come from the per-workflow
|
||||
// statistics: a page of the newest tasks across every workflow would show
|
||||
// nothing for a workflow whose runs are older than that page.
|
||||
const before = statsOf(selected.value);
|
||||
data.value = keepValue(data.value, (await api.workflows<WorkflowsResponse>()) ?? {});
|
||||
error.value = null;
|
||||
void loadWorkflowRuns();
|
||||
// The runs page only changes when the workflow's own statistics do.
|
||||
if (runsFor !== selected.value || statsOf(selected.value) !== before) void loadWorkflowRuns();
|
||||
} catch (err) {
|
||||
error.value = String((err as Error).message || err);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
useLiveResource("tasks", () => void load(), 500);
|
||||
useLiveResource("tasks", () => void load(), 5000);
|
||||
onMounted(() => Promise.all([load(), store.load()]));
|
||||
|
||||
// Stored definitions are the source of truth for the list; statistics join
|
||||
@@ -113,15 +122,65 @@ const provenance = computed(() => {
|
||||
// A workflow the server does not list yet (a new, unsaved one) has no
|
||||
// enabled state to show.
|
||||
const enabled = computed(() => data.value.definitions?.find((d) => d.id === selected.value)?.enabled);
|
||||
async function setEnabled(value: boolean) {
|
||||
async function setEnabled(id: string, value: boolean) {
|
||||
try {
|
||||
await api.workflowEnabled(selected.value, value);
|
||||
toast.success(`${selected.value} ${value ? "enabled" : "disabled"}`);
|
||||
await api.workflowEnabled(id, value);
|
||||
toast.success(`${id} ${value ? "enabled" : "disabled"}`);
|
||||
await load();
|
||||
} catch (err) {
|
||||
toast.error(`${selected.value} not ${value ? "enabled" : "disabled"}: ${(err as Error).message || err}`);
|
||||
toast.error(`${id} not ${value ? "enabled" : "disabled"}: ${(err as Error).message || err}`);
|
||||
}
|
||||
}
|
||||
const enabledOf = (id: string) => data.value.definitions?.find((d) => d.id === id)?.enabled;
|
||||
|
||||
// The editor's tab, so a row can open straight onto its runs.
|
||||
const view = ref("canvas");
|
||||
const router = useRouter();
|
||||
const runTarget = ref("");
|
||||
const runOpen = computed({
|
||||
get: () => runTarget.value !== "",
|
||||
set: (open) => {
|
||||
if (!open) runTarget.value = "";
|
||||
},
|
||||
});
|
||||
|
||||
async function duplicate(id: string) {
|
||||
const source = stored.value.find((d) => d.id === id);
|
||||
if (!source) return;
|
||||
let copy = `${id}-copy`;
|
||||
for (let n = 2; stored.value.some((d) => d.id === copy); n++) copy = `${id}-copy-${n}`;
|
||||
if (await store.save(upsertWorkflowDefinition(store.collection, { id: copy, yaml: setWorkflowField(source.yaml, "id", copy) }))) {
|
||||
selected.value = copy;
|
||||
toast.success(`${copy} created`);
|
||||
} else toast.error(`${id} not duplicated: ${store.error || "save failed"}`);
|
||||
}
|
||||
|
||||
interface RowAction {
|
||||
label: string;
|
||||
icon: typeof Play;
|
||||
run: () => void;
|
||||
}
|
||||
function rowActions(id: string): RowAction[] {
|
||||
const saved = stored.value.some((d) => d.id === id);
|
||||
const enabled = enabledOf(id);
|
||||
const actions: RowAction[] = [];
|
||||
if (enabled !== undefined) actions.push({ label: enabled ? "Disable" : "Enable", icon: Power, run: () => void setEnabled(id, !enabled) });
|
||||
if (saved) {
|
||||
actions.push(
|
||||
{ label: "Run", icon: Play, run: () => (runTarget.value = id) },
|
||||
{
|
||||
label: "Open runs",
|
||||
icon: ListChecks,
|
||||
run: () => {
|
||||
selected.value = id;
|
||||
view.value = "runs";
|
||||
},
|
||||
},
|
||||
{ label: "Duplicate", icon: Copy, run: () => void duplicate(id) },
|
||||
);
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
const stages = computed(() => (data.value.stages ?? []).filter((s) => s.workflow === selected.value));
|
||||
// The selected workflow's runs come from a workflow-filtered page: the global
|
||||
// list above holds only the newest tasks of every workflow.
|
||||
@@ -178,7 +237,9 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
||||
<div class="grid items-start gap-6 lg:grid-cols-[24rem_minmax(0,1fr)] max-md:min-h-0 max-md:flex-1 max-md:grid-rows-[minmax(0,1fr)]">
|
||||
<div class="hidden min-w-0 flex-col gap-1 lg:flex">
|
||||
<ul class="hidden max-h-[calc(100dvh-10rem)] flex-col gap-0.5 overflow-y-auto lg:flex" aria-label="Workflows">
|
||||
<li v-for="row in rows" :key="row.id" class="min-w-0">
|
||||
<li v-for="row in rows" :key="row.id" class="relative min-w-0">
|
||||
<ContextMenu>
|
||||
<ContextMenuTrigger as-child>
|
||||
<button
|
||||
type="button"
|
||||
:aria-current="row.id === selected ? 'true' : undefined"
|
||||
@@ -202,6 +263,14 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
||||
<span v-if="row.runs" class="w-16 shrink-0 text-right font-mono" aria-hidden="true">{{ delivered(row) }}/{{ row.runs }}</span>
|
||||
</span>
|
||||
</button>
|
||||
</ContextMenuTrigger>
|
||||
<ContextMenuContent v-if="rowActions(row.id).length" class="min-w-40">
|
||||
<ContextMenuItem v-for="action in rowActions(row.id)" :key="action.label" @select="action.run"><component :is="action.icon" />{{ action.label }}</ContextMenuItem>
|
||||
</ContextMenuContent>
|
||||
</ContextMenu>
|
||||
<MoreMenu v-if="rowActions(row.id).length" :label="`${row.id} actions`" class="absolute top-1.5 right-1.5">
|
||||
<DropdownMenuItem v-for="action in rowActions(row.id)" :key="action.label" @select="action.run"><component :is="action.icon" />{{ action.label }}</DropdownMenuItem>
|
||||
</MoreMenu>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -220,14 +289,14 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
||||
<Badge v-if="provenance" variant="outline" class="shrink-0">{{ provenance }}</Badge>
|
||||
<ApplyStatusRows kind="workflow-definitions" compact />
|
||||
</header>
|
||||
<WorkflowEditor v-model:selected="selected" :runs-count="workflowRuns.length">
|
||||
<WorkflowEditor v-model:selected="selected" v-model:view="view" :runs-count="workflowRuns.length">
|
||||
<template #title>
|
||||
<h2 class="min-w-0 truncate text-title font-medium">{{ selected }}</h2>
|
||||
<Badge v-if="provenance" variant="outline" class="shrink-0">{{ provenance }}</Badge>
|
||||
<ApplyStatusRows kind="workflow-definitions" compact />
|
||||
</template>
|
||||
<template v-if="enabled !== undefined" #toolbar>
|
||||
<Switch :model-value="enabled" :title="enabled ? 'Published version runs on events' : 'Published version ignores events'" aria-label="Published version enabled" @update:model-value="setEnabled" />
|
||||
<Switch :model-value="enabled" :title="enabled ? 'Published version runs on events' : 'Published version ignores events'" aria-label="Published version enabled" @update:model-value="setEnabled(selected, $event)" />
|
||||
</template>
|
||||
<template #performance>
|
||||
<Empty v-if="!stages.length">
|
||||
@@ -264,5 +333,13 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
||||
</WorkflowEditor>
|
||||
</Card>
|
||||
</div>
|
||||
<Dialog v-model:open="runOpen">
|
||||
<DialogContent class="sm:max-w-[640px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Run {{ runTarget }}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<NewTaskForm v-if="runTarget" :workflow="runTarget" @started="(taskId) => { runTarget = ''; void router.push(`/tasks/${taskId}`); }" @cancel="runTarget = ''" />
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -109,7 +109,7 @@ export function useWorkflowRuns(workflow: Ref<string>) {
|
||||
pinned.value = undefined;
|
||||
void loadStages();
|
||||
});
|
||||
useLiveResource("tasks", () => void refresh(), 300);
|
||||
useLiveResource("tasks", () => void refresh(), 2000);
|
||||
|
||||
const watchedRun = computed(() => {
|
||||
const run = runs.value.find((run) => String(run.id) === watched.value);
|
||||
|
||||
Reference in new issue
Block a user