From 480cbe7031a3cacbb73956e02245ae9a2c496f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Fri, 13 Dec 2024 17:47:03 +0100 Subject: [PATCH] Divide patch page into patch and revision tabs --- src/views/repo/Patch.svelte | 84 ++++++++++++++++++++++++++----------- 1 file changed, 59 insertions(+), 25 deletions(-) diff --git a/src/views/repo/Patch.svelte b/src/views/repo/Patch.svelte index 3843fd9b8..13b3ef504 100644 --- a/src/views/repo/Patch.svelte +++ b/src/views/repo/Patch.svelte @@ -9,26 +9,27 @@ import type { Revision } from "@bindings/cob/patch/Revision"; import * as roles from "@app/lib/roles"; + import { formatOid } from "@app/lib/utils"; import { invoke } from "@app/lib/invoke"; import { nodeRunning } from "@app/lib/events"; import { announce } from "@app/components/AnnounceSwitch.svelte"; + import AssigneeInput from "@app/components/AssigneeInput.svelte"; + import Border from "@app/components/Border.svelte"; + import Changeset from "@app/components/Changeset.svelte"; import CommentComponent from "@app/components/Comment.svelte"; import CopyableId from "@app/components/CopyableId.svelte"; import Icon from "@app/components/Icon.svelte"; - import Id from "@app/components/Id.svelte"; import InlineTitle from "@app/components/InlineTitle.svelte"; + import LabelInput from "@app/components/LabelInput.svelte"; import Layout from "./Layout.svelte"; import Link from "@app/components/Link.svelte"; import NodeId from "@app/components/NodeId.svelte"; + import PatchStateBadge from "@app/components/PatchStateBadge.svelte"; import PatchTeaser from "@app/components/PatchTeaser.svelte"; import Sidebar from "@app/components/Sidebar.svelte"; - import Changeset from "@app/components/Changeset.svelte"; - import Border from "@app/components/Border.svelte"; - import PatchStateBadge from "@app/components/PatchStateBadge.svelte"; - import LabelInput from "@app/components/LabelInput.svelte"; - import AssigneeInput from "@app/components/AssigneeInput.svelte"; + import Button from "@app/components/Button.svelte"; interface Props { repo: RepoInfo; @@ -43,11 +44,12 @@ let { repo, patch, patches, revisions, config, status }: Props = $props(); /* eslint-enable prefer-const */ - let items = $state(patches.content); let cursor = patches.cursor; let more = patches.more; + let items = $state(patches.content); let labelSaveInProgress: boolean = $state(false); let assigneesSaveInProgress: boolean = $state(false); + let tab: "patch" | "revisions" = $state("patch"); $effect(() => { items = patches.content; @@ -55,6 +57,13 @@ more = patches.more; }); + $effect(() => { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + patch.id; + + tab = "patch"; + }); + const project = $derived(repo.payloads["xyz.radicle.project"]!); async function loadHighlightedDiff(rid: string, base: string, head: string) { @@ -316,26 +325,51 @@ -
- 1 - ? revisions[0].description.at(-1) - : undefined} - author={revisions[0].author} - reactions={revisions[0].reactions} - timestamp={revisions[0].description.slice(-1)[0].timestamp} - body={revisions[0].description.slice(-1)[0].body}> - +
+ + +
-
Revisions
- {#each revisions as revision} -
+ + {#if tab === "patch"} +
+ 1 + ? revisions[0].description.at(-1) + : undefined} + author={revisions[0].author} + reactions={revisions[0].reactions} + timestamp={revisions[0].description.slice(-1)[0].timestamp} + body={revisions[0].description.slice(-1)[0].body}> + +
+ {:else} + {@const revision = revisions.slice(-1)[0]} {#await loadHighlightedDiff(repo.rid, revision.base, revision.head) then diff} - +
+ +
{/await} - {/each} + {/if}