Make Operation generic, and handle patch operations

So far we only supported issue operations on the `activity_by_id`
command.

With this commit we separate the commands into a `activity_by_issue` and
`activity_by_patch` command that calls a generic `activity_by_id` trait
implementation.

`Operation` now takes as a generic either `cob/issue/Action.ts` or
`cob/patch/Action.ts`.

Also `Operation` now stores the array of all `Action` that happened on
said operation. I'm not entirely sure if this will help us in the
future, but it represents more closely the state of the relation between
an `Operation` and the cob `Actions`.
This commit is contained in:
Sebastian Martinez
2025-01-10 10:33:32 -06:00
committed by Rūdolfs Ošiņš
parent 63d1c87c7f
commit 432db1ce5b
16 changed files with 218 additions and 134 deletions
@@ -1,5 +1,6 @@
<script lang="ts">
import type { Operation } from "@bindings/cob/issue/Operation";
import type { Operation } from "@bindings/cob/Operation";
import type { Action } from "@bindings/cob/issue/Action";
import { authorForNodeId, formatTimestamp } from "@app/lib/utils";
@@ -8,19 +9,20 @@
import NodeId from "@app/components/NodeId.svelte";
interface Props {
operation: Extract<Operation, { type: "lifecycle" }>;
action: Extract<Action, { type: "lifecycle" }>;
op: Operation<Action>;
}
const { operation }: Props = $props();
const { op, action }: Props = $props();
</script>
<Border variant="float" stylePadding="1rem">
<div class="txt-small">
<div class="global-flex txt-small">
<NodeId {...authorForNodeId(operation.author)} />
<NodeId {...authorForNodeId(op.author)} />
changed status to
<IssueStateBadge state={operation.state} />
{formatTimestamp(operation.timestamp)}
<IssueStateBadge state={action.state} />
{formatTimestamp(op.timestamp)}
</div>
</div>
</Border>
@@ -0,0 +1,28 @@
<script lang="ts">
import type { Operation } from "@bindings/cob/Operation";
import type { Action } from "@bindings/cob/patch/Action";
import { authorForNodeId, formatTimestamp } from "@app/lib/utils";
import Border from "@app/components/Border.svelte";
import NodeId from "@app/components/NodeId.svelte";
import PatchStateBadge from "./PatchStateBadge.svelte";
interface Props {
action: Extract<Action, { type: "lifecycle" }>;
op: Operation<Action>;
}
const { op, action }: Props = $props();
</script>
<Border variant="float" stylePadding="1rem">
<div class="txt-small">
<div class="global-flex txt-small">
<NodeId {...authorForNodeId(op.author)} />
changed status to
<PatchStateBadge state={action.state} />
{formatTimestamp(op.timestamp)}
</div>
</div>
</Border>