diff --git a/__snapshots__/prs-header.test.js.snap b/__snapshots__/prs-header.test.js.snap index 034d688..3c38985 100644 --- a/__snapshots__/prs-header.test.js.snap +++ b/__snapshots__/prs-header.test.js.snap @@ -8,16 +8,21 @@ exports[`PRs/Header Author Loading smoke-test 1`] = ` short title
- + + + + + Open +
+
opened 3 months ago
@@ -39,16 +44,21 @@ exports[`PRs/Header Long Details smoke-test 1`] = ` rather long title that goes on and on and on and on and on and on...
- + + + + + Open +
+
opened a minute ago
@@ -69,16 +79,21 @@ exports[`PRs/Header Long and No Spaces smoke-test 1`] = ` LongNameLongNameLongNameLongNameLongNameLongNameLongNameLongNameL...
- + + + + + Open +
+
opened 3 months ago
@@ -99,16 +114,21 @@ exports[`PRs/Header Short Details smoke-test 1`] = ` short title
- + + + + + Open +
+
opened 7 days ago
diff --git a/__snapshots__/prs-status--closed.png b/__snapshots__/prs-status--closed.png new file mode 100644 index 0000000..f01fc4e Binary files /dev/null and b/__snapshots__/prs-status--closed.png differ diff --git a/__snapshots__/prs-status--draft.png b/__snapshots__/prs-status--draft.png new file mode 100644 index 0000000..1c05702 Binary files /dev/null and b/__snapshots__/prs-status--draft.png differ diff --git a/__snapshots__/prs-status--loading.png b/__snapshots__/prs-status--loading.png new file mode 100644 index 0000000..bb56cc4 Binary files /dev/null and b/__snapshots__/prs-status--loading.png differ diff --git a/__snapshots__/prs-status--merged.png b/__snapshots__/prs-status--merged.png new file mode 100644 index 0000000..ae43bc6 Binary files /dev/null and b/__snapshots__/prs-status--merged.png differ diff --git a/__snapshots__/prs-status--open-edit-mode.png b/__snapshots__/prs-status--open-edit-mode.png new file mode 100644 index 0000000..3a70644 Binary files /dev/null and b/__snapshots__/prs-status--open-edit-mode.png differ diff --git a/__snapshots__/prs-status--open.png b/__snapshots__/prs-status--open.png new file mode 100644 index 0000000..0ce1915 Binary files /dev/null and b/__snapshots__/prs-status--open.png differ diff --git a/__snapshots__/prs-status.test.js.snap b/__snapshots__/prs-status.test.js.snap new file mode 100644 index 0000000..8d9d1f0 --- /dev/null +++ b/__snapshots__/prs-status.test.js.snap @@ -0,0 +1,95 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PRs/Status Closed smoke-test 1`] = ` +
+ + + + + Closed +
+`; + +exports[`PRs/Status Draft smoke-test 1`] = ` +
+ + + + + Draft +
+`; + +exports[`PRs/Status Loading smoke-test 1`] = ` +
+
+`; + +exports[`PRs/Status Merged smoke-test 1`] = ` +
+ + + + + Merged +
+`; + +exports[`PRs/Status Open Edit Mode smoke-test 1`] = ` +
+ + + + + Open + + + + +
+`; + +exports[`PRs/Status Open smoke-test 1`] = ` +
+ + + + + Open +
+`; diff --git a/src/lib/components/prs/PRHeader.svelte b/src/lib/components/prs/PRHeader.svelte index cb0fdb9..c71f27c 100644 --- a/src/lib/components/prs/PRHeader.svelte +++ b/src/lib/components/prs/PRHeader.svelte @@ -7,6 +7,7 @@ import { summary_defaults } from "./type"; import { getName } from "../users/type"; import Container from "../Container.svelte"; + import Status from "./Status.svelte"; dayjs.extend(relativeTime); export let { title, id, repo_id, comments, author, created_at, loading } = @@ -49,17 +50,9 @@ {short_title}
- +
+ +
opened {created_at_ago}
diff --git a/src/lib/components/prs/Status.stories.svelte b/src/lib/components/prs/Status.stories.svelte new file mode 100644 index 0000000..f90de63 --- /dev/null +++ b/src/lib/components/prs/Status.stories.svelte @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + diff --git a/src/lib/components/prs/Status.svelte b/src/lib/components/prs/Status.svelte new file mode 100644 index 0000000..50fc062 --- /dev/null +++ b/src/lib/components/prs/Status.svelte @@ -0,0 +1,77 @@ + + +{#if !status} +
+{:else} +
+ {#if status === "Open"} + + + + Open + {:else if status === "Merged"} + + + Merged + {:else if status === "Closed"} + + + Closed + {:else if status === "Draft"} + + + Draft + {:else} + {status} + {/if} + {#if edit_mode} + + {/if} +
+{/if} diff --git a/src/lib/components/prs/StatusSelector.svelte b/src/lib/components/prs/StatusSelector.svelte index d920feb..9042297 100644 --- a/src/lib/components/prs/StatusSelector.svelte +++ b/src/lib/components/prs/StatusSelector.svelte @@ -3,9 +3,10 @@ import { NDKEvent, NDKRelaySet, type NDKTag } from "@nostr-dev-kit/ndk"; import type { PRStatus } from "./type"; import { selected_pr_full } from "$lib/stores/PR"; - import { patch_kind } from "$lib/kinds"; + import { pr_status_kind } from "$lib/kinds"; import { getUserRelays, logged_in_user } from "$lib/stores/users"; import { selected_repo } from "$lib/stores/repo"; + import Status from "$lib/components/prs/Status.svelte"; export let status: PRStatus = "Draft"; export let repo_id: string = ""; @@ -22,7 +23,7 @@ async function changeStatus(new_status: PRStatus) { if (!$logged_in_user) return; let event = new NDKEvent(ndk); - event.kind = patch_kind; + event.kind = pr_status_kind; event.tags.push(["t", new_status]); event.tags.push(["e", pr_id]); event.tags.push(["r", `r-${repo_id}`]); @@ -62,75 +63,10 @@ {#if loading} -
+ {:else}