From 8622dba11189b93ad5c242fb19eea97c09d93182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Thu, 9 Jan 2025 16:28:04 -0600 Subject: [PATCH] Implement changing patch states --- src/components/PatchStateButton.svelte | 86 ++++++++++++++++++++++++++ src/views/repo/Patch.svelte | 49 ++++++++++++--- 2 files changed, 127 insertions(+), 8 deletions(-) create mode 100644 src/components/PatchStateButton.svelte diff --git a/src/components/PatchStateButton.svelte b/src/components/PatchStateButton.svelte new file mode 100644 index 000000000..91b64f1bb --- /dev/null +++ b/src/components/PatchStateButton.svelte @@ -0,0 +1,86 @@ + + + + +
+ + + + {#snippet toggle(onclick)} + + {/snippet} + {#snippet popover()} + + !isEqual(a.state, patchState))}> + {#snippet item(action)} + { + selectedAction = action; + closeFocused(); + }}> + {action.caption} + + {/snippet} + + + {/snippet} + +
diff --git a/src/views/repo/Patch.svelte b/src/views/repo/Patch.svelte index fa9293347..591000089 100644 --- a/src/views/repo/Patch.svelte +++ b/src/views/repo/Patch.svelte @@ -34,6 +34,7 @@ import LabelInput from "@app/components/LabelInput.svelte"; import Layout from "./Layout.svelte"; import PatchStateBadge from "@app/components/PatchStateBadge.svelte"; + import PatchStateButton from "@app/components/PatchStateButton.svelte"; import PatchTeaser from "@app/components/PatchTeaser.svelte"; import Sidebar from "@app/components/Sidebar.svelte"; @@ -220,6 +221,24 @@ await reload(); } } + + async function saveState(state: Patch["state"]) { + try { + await invoke("edit_patch", { + rid: repo.rid, + cobId: patch.id, + action: { + type: "lifecycle", + state, + }, + opts: { announce: $nodeRunning && $announce }, + }); + } catch (error) { + console.error("Editing reactions failed", error); + } finally { + await reload(); + } + }