fix(ui): open the workflow canvas at the top and keep the list within the viewport
This commit is contained in:
2 files changed
+4
-14
No files matched your search
@@ -228,24 +228,14 @@ function framing(width: number): { x: number; zoom: number } {
|
||||
}
|
||||
|
||||
// Start at a readable size rather than shrinking a long workflow until
|
||||
// nothing on it can be read, scrolled to the furthest step the watched run has
|
||||
// reached so the step that is moving stays in view.
|
||||
// nothing on it can be read, with the top of the graph at the top.
|
||||
function place(store?: VueFlowStore): void {
|
||||
const animate = !store;
|
||||
flow = store ?? flow;
|
||||
if (!flow) return;
|
||||
const width = container.value?.clientWidth ?? 800;
|
||||
const height = container.value?.clientHeight ?? 560;
|
||||
const { x, zoom } = framing(width);
|
||||
// Scroll only when the furthest step reached would be out of view.
|
||||
const reached = graph.value.nodes.find((node) => props.marks?.[node.id]) ?? graph.value.nodes.filter((node) => node.data.run).at(-1);
|
||||
const below = reached && 24 + (reached.position.y - top.value + 180) * zoom > height;
|
||||
const y = below ? height / 3 - reached.position.y * zoom : 24 - top.value * zoom;
|
||||
void flow.setViewport({ x, y, zoom }, { duration: animate ? 300 : 0 });
|
||||
const { x, zoom } = framing(container.value?.clientWidth ?? 800);
|
||||
void flow.setViewport({ x, y: 24 - top.value * zoom, zoom });
|
||||
}
|
||||
|
||||
watch(() => graph.value.nodes.filter((node) => node.data.run).length, () => place());
|
||||
watch(() => props.marks, () => place());
|
||||
// A card opened low on the canvas scrolls up so its form is in view, and one
|
||||
// opened wider than the canvas allows is framed so its edges stay reachable.
|
||||
watch(anchor, async (node) => {
|
||||
|
||||
@@ -176,7 +176,7 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
|
||||
<div class="grid items-start gap-6 lg:grid-cols-[24rem_minmax(0,1fr)]">
|
||||
<div class="flex min-w-0 flex-col gap-1">
|
||||
<Button size="icon-sm" variant="ghost" class="self-end" aria-label="New workflow" title="New workflow" @click="create"><Plus /></Button>
|
||||
<ul class="hidden flex-col gap-0.5 lg:flex" aria-label="Workflows">
|
||||
<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">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in new issue
Block a user