@reviewflow/ui 6.25.0 → 6.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ import type { CheckoutBranch, CheckoutStatus } from "@reviewflow/sdk";
2
+
3
+ const trackParts = (ahead: number | null, behind: number | null): string[] => [
4
+ ...(ahead === null || ahead === 0 ? [] : [`${String(ahead)} to push`]),
5
+ ...(behind === null || behind === 0 ? [] : [`${String(behind)} to pull`]),
6
+ ];
7
+
8
+ /**
9
+ * What a checkout holds that its remote does not, and the reverse, as short
10
+ * phrases; empty when it is clean and in sync. Push and pull are as of the
11
+ * last fetch.
12
+ */
13
+ export const checkoutSummaryParts = (status: CheckoutStatus): string[] => {
14
+ const uncommitted = status.modified + status.untracked;
15
+ const upstreamParts = ((): string[] => {
16
+ if (status.branch === null) return [];
17
+ if (status.upstream === null) return ["not published"];
18
+ if (status.ahead === null) return ["upstream gone"];
19
+ return trackParts(status.ahead, status.behind);
20
+ })();
21
+ return [
22
+ ...(uncommitted === 0 ? [] : [`${String(uncommitted)} uncommitted`]),
23
+ ...upstreamParts,
24
+ ];
25
+ };
26
+
27
+ /** Where a branch stands against the remote branch it tracks; gone is a badge of its own. */
28
+ export const branchTrackParts = (branch: CheckoutBranch): string[] => {
29
+ if (branch.upstreamGone) return [];
30
+ if (branch.upstream === null) return ["not published"];
31
+ return trackParts(branch.ahead, branch.behind);
32
+ };
package/src/slots.tsx CHANGED
@@ -1,3 +1,5 @@
1
+ import type { PrStatus } from "@reviewflow/sdk";
2
+ import type { Accent } from "alouette";
1
3
  import type { ReactNode } from "react";
2
4
  import { createContext, use } from "react";
3
5
 
@@ -25,6 +27,12 @@ export interface PullRequestSlots {
25
27
  * checkout is configured. Absent: the message stands alone.
26
28
  */
27
29
  renderRepositoryAction?: (ownerRepo: string) => ReactNode;
30
+ /**
31
+ * The status badge's accent, per status, over `prStatusAccents`: an app with
32
+ * an accent of its own for one (a theme it generates beside alouette's, cast
33
+ * to `Accent`) passes it here.
34
+ */
35
+ prStatusAccents?: Partial<Record<PrStatus, Accent | undefined>>;
28
36
  }
29
37
 
30
38
  const SlotsContext = createContext<PullRequestSlots>({});