Skip to content

Commit

Permalink
Hide the "View as draft" option when a version is not in DRAFT status
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWittmann committed Jan 14, 2025
1 parent 8a68961 commit 30e7df3
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const VersionsTable: FunctionComponent<VersionsTableProps> = (props: Vers
const actionsFor = (version: SearchedVersion): (VersionAction | VersionActionSeparator)[] => {
const vhash: number = shash(version.version!);
return [
{ label: "View as draft", onClick: () => props.onViewAsDraft(version), testId: `view-as-draft-${vhash}` },
{ label: "View as draft", onClick: () => props.onViewAsDraft(version), testId: `view-as-draft-${vhash}`, isVisible: () => version.state === "DRAFT" },
{ label: "View in Registry", onClick: () => props.onViewInRegistry(version), testId: `view-in-registry-${vhash}`, isVisible: isRegistryUIConfigured },
{ label: "Create new draft", onClick: () => props.onCreateNewDraft(version), testId: `create-new-version-${vhash}` },
];
Expand Down Expand Up @@ -159,6 +159,7 @@ export const VersionsTable: FunctionComponent<VersionsTableProps> = (props: Vers
itemToString={item => item.label}
itemToTestId={item => item.testId}
itemIsDivider={item => item.isSeparator}
itemIsVisible={item => item.isVisible ? item.isVisible() : true}
onSelect={item => item.onClick()}
testId={`version-actions-${shash(row.version!)}`}
popperProps={{
Expand Down

0 comments on commit 30e7df3

Please sign in to comment.