diff --git a/packages/react/src/modules/guide/components/Toolbar/V2/GuideHoverCard.tsx b/packages/react/src/modules/guide/components/Toolbar/V2/GuideHoverCard.tsx index 873e57488..e11016bee 100644 --- a/packages/react/src/modules/guide/components/Toolbar/V2/GuideHoverCard.tsx +++ b/packages/react/src/modules/guide/components/Toolbar/V2/GuideHoverCard.tsx @@ -6,19 +6,19 @@ import * as React from "react"; import { AnnotatedGuide, - UnknownGuide, - isUnknownGuide, + UncommittedGuide, + isUncommittedGuide, } from "./useInspectGuideClientStore"; type Props = { - guide: AnnotatedGuide | UnknownGuide; + guide: AnnotatedGuide | UncommittedGuide; }; export const GuideHoverCard = ({ children, guide, }: React.PropsWithChildren) => { - if (isUnknownGuide(guide)) { + if (isUncommittedGuide(guide)) { return {children}; } diff --git a/packages/react/src/modules/guide/components/Toolbar/V2/GuideRow.tsx b/packages/react/src/modules/guide/components/Toolbar/V2/GuideRow.tsx index 6a3fe160e..0e72f2f03 100644 --- a/packages/react/src/modules/guide/components/Toolbar/V2/GuideRow.tsx +++ b/packages/react/src/modules/guide/components/Toolbar/V2/GuideRow.tsx @@ -16,8 +16,8 @@ import { GuideRowDetails } from "./GuideRowDetails"; import { AnnotatedGuide, AnnotatedStatuses, - UnknownGuide, - isUnknownGuide, + UncommittedGuide, + isUncommittedGuide, } from "./useInspectGuideClientStore"; const Pill = ({ @@ -56,9 +56,9 @@ type StatusSummary = { }; const getStatusSummary = ( - guide: AnnotatedGuide | UnknownGuide, + guide: AnnotatedGuide | UncommittedGuide, ): StatusSummary => { - if (isUnknownGuide(guide)) { + if (isUncommittedGuide(guide)) { return { color: "red", label: "Inactive", @@ -135,9 +135,9 @@ type StatusDot = { }; const getStatusDots = ( - guide: AnnotatedGuide | UnknownGuide, + guide: AnnotatedGuide | UncommittedGuide, ): Record => { - if (isUnknownGuide(guide)) { + if (isUncommittedGuide(guide)) { return { active: { color: "gray" }, archived: { color: "gray" }, @@ -193,7 +193,7 @@ const getStatusDots = ( }; type Props = { - guide: UnknownGuide | AnnotatedGuide; + guide: UncommittedGuide | AnnotatedGuide; orderIndex: number; isExpanded: boolean; onClick: (guideKey: string) => void; @@ -311,7 +311,7 @@ export const GuideRow = ({ guide, orderIndex, isExpanded, onClick }: Props) => { { { { variant={isFocused ? "solid" : "outline"} color={isFocused ? "blue" : "gray"} disabled={ - isUnknownGuide(guide) || + isUncommittedGuide(guide) || guide.annotation.selectable.status === undefined } onClick={(e: React.MouseEvent) => { diff --git a/packages/react/src/modules/guide/components/Toolbar/V2/GuideRowDetails.tsx b/packages/react/src/modules/guide/components/Toolbar/V2/GuideRowDetails.tsx index 3efc15ddb..f4ce5efaa 100644 --- a/packages/react/src/modules/guide/components/Toolbar/V2/GuideRowDetails.tsx +++ b/packages/react/src/modules/guide/components/Toolbar/V2/GuideRowDetails.tsx @@ -7,8 +7,8 @@ import { } from "./GuideAnnotatedStatusDot"; import { AnnotatedGuide, - UnknownGuide, - isUnknownGuide, + UncommittedGuide, + isUncommittedGuide, } from "./useInspectGuideClientStore"; const CardContainer = ({ @@ -77,9 +77,9 @@ const getDisplayValue = ( export const GuideRowDetails = ({ guide, }: { - guide: AnnotatedGuide | UnknownGuide; + guide: AnnotatedGuide | UncommittedGuide; }) => { - if (isUnknownGuide(guide)) { + if (isUncommittedGuide(guide)) { return ( diff --git a/packages/react/src/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.ts b/packages/react/src/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.ts index a8006278d..78db9d833 100644 --- a/packages/react/src/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.ts +++ b/packages/react/src/modules/guide/components/Toolbar/V2/useInspectGuideClientStore.ts @@ -101,8 +101,8 @@ export type AnnotatedGuide = KnockGuide & { // Exists and ordered in control but absent in switchboard (therefore not // included in the api response), which implies a newly created guide that has // never been published to switchboard. -export type UnknownGuide = { - __typename: "UnknownGuide"; +export type UncommittedGuide = { + __typename: "UncommittedGuide"; key: KnockGuide["key"]; active: false; bypass_global_group_limit: false; @@ -117,7 +117,7 @@ export type UnknownGuide = { export type InspectionResultOk = { status: "ok"; - guides: (AnnotatedGuide | UnknownGuide)[]; + guides: (AnnotatedGuide | UncommittedGuide)[]; }; type InspectionResultError = { status: "error"; @@ -388,9 +388,9 @@ const annotateGuide = ( }; }; -const newUnknownGuide = (key: KnockGuide["key"]) => +const newUncommittedGuide = (key: KnockGuide["key"]) => ({ - __typename: "UnknownGuide", + __typename: "UncommittedGuide", key, active: false, bypass_global_group_limit: false, @@ -401,7 +401,7 @@ const newUnknownGuide = (key: KnockGuide["key"]) => status: undefined, }, }, - }) as UnknownGuide; + }) as UncommittedGuide; export const useInspectGuideClientStore = ( runConfig: ToolbarV2RunConfig, @@ -456,7 +456,7 @@ export const useInspectGuideClientStore = ( const orderedGuides = defaultGroup.display_sequence.map((guideKey) => { const guide = snapshot.guides[guideKey]; if (!guide) { - return newUnknownGuide(guideKey); + return newUncommittedGuide(guideKey); } return annotateGuide(guide, snapshot, groupStage); @@ -483,8 +483,8 @@ export const useInspectGuideClientStore = ( }; }; -export const isUnknownGuide = (input: unknown): input is UnknownGuide => +export const isUncommittedGuide = (input: unknown): input is UncommittedGuide => typeof input === "object" && input !== null && "__typename" in input && - (input as UnknownGuide).__typename === "UnknownGuide"; + (input as UncommittedGuide).__typename === "UncommittedGuide"; diff --git a/packages/react/test/guide/Toolbar/V2/useInspectGuideClientStore.test.ts b/packages/react/test/guide/Toolbar/V2/useInspectGuideClientStore.test.ts index fd2075198..ac107a0b0 100644 --- a/packages/react/test/guide/Toolbar/V2/useInspectGuideClientStore.test.ts +++ b/packages/react/test/guide/Toolbar/V2/useInspectGuideClientStore.test.ts @@ -3,7 +3,7 @@ import { beforeEach, describe, expect, test, vi } from "vitest"; import { type AnnotatedGuide, - isUnknownGuide, + isUncommittedGuide, resolveIsQualified, useInspectGuideClientStore, } from "../../../../src/modules/guide/components/Toolbar/V2/useInspectGuideClientStore"; @@ -173,9 +173,9 @@ describe("useInspectGuideClientStore", () => { }); }); - // ----- Unknown guide ----- + // ----- Uncommitted guide ----- - test("produces an UnknownGuide when key is in display_sequence but not in guides", () => { + test("produces an UncommittedGuide when key is in display_sequence but not in guides", () => { setSnapshot({ guideGroups: [makeGuideGroup(["missing_key"])], guides: {}, @@ -183,7 +183,7 @@ describe("useInspectGuideClientStore", () => { const result = renderInspect()!; expect(result.guides).toHaveLength(1); - expect(isUnknownGuide(result.guides[0])).toBe(true); + expect(isUncommittedGuide(result.guides[0])).toBe(true); const unknown = result.guides[0]!; expect(unknown.key).toBe("missing_key"); @@ -445,7 +445,7 @@ describe("useInspectGuideClientStore", () => { // ----- Mixed guides: eligible, ineligible, and unknown ----- - test("handles a mix of eligible, ineligible, and unknown guides", () => { + test("handles a mix of eligible, ineligible, and uncommitted guides", () => { const eligible = makeGuide({ key: "eligible", active: true }); const inactive = makeGuide({ key: "inactive", active: false }); const archived = makeGuide({ key: "archived", active: true }); @@ -495,10 +495,10 @@ describe("useInspectGuideClientStore", () => { expect(g2.annotation.isEligible).toBe(false); expect(g2.annotation.archived.status).toBe(true); - // unknown guide + // uncommitted guide const g3 = result.guides[3]!; expect(g3.key).toBe("unknown_key"); - expect(isUnknownGuide(g3)).toBe(true); + expect(isUncommittedGuide(g3)).toBe(true); expect(g3.annotation.isEligible).toBe(false); });