Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jaen committed May 22, 2024
1 parent 11e39cb commit 4361437
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const MasterSliceLibraryPreviewModal: React.FC<
MasterSliceLibraryPreviewModalProps
> = ({ isOpen, onClose }) => {
const { masterSliceLibrary } = useMarketingContent();

if (!masterSliceLibrary) return null;

const { exampleLinkUrl, codeLinkUrl, previewVideoUrl } = masterSliceLibrary;
const onGetTheCodeButtonClick = () => {
void telemetry.track({
Expand All @@ -28,6 +31,7 @@ export const MasterSliceLibraryPreviewModal: React.FC<

window.open(codeLinkUrl, "_blank");
};

return (
<Dialog
size="small"
Expand Down
20 changes: 5 additions & 15 deletions packages/slice-machine/src/hooks/useMarketingContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@ type MarketingContent = {
};
};
};
masterSliceLibrary: MasterSliceLibraryMarketingContent;
};

type MasterSliceLibraryMarketingContent = {
showInNavigation: boolean;
exampleLinkUrl: string;
codeLinkUrl: string;
previewVideoUrl: string;
masterSliceLibrary?: {
exampleLinkUrl: string;
codeLinkUrl: string;
previewVideoUrl: string;
};
};

const CONTENT_BY_ADAPTER: Record<string, MarketingContent> = {
Expand All @@ -47,7 +44,6 @@ const CONTENT_BY_ADAPTER: Record<string, MarketingContent> = {
},
},
masterSliceLibrary: {
showInNavigation: true,
exampleLinkUrl: "https://slicify-app.vercel.app/slice-library",
codeLinkUrl:
"https://github.com/prismicio-solution-engineering/slicify-library#readme",
Expand All @@ -69,12 +65,6 @@ const DEFAULT_CONTENT: MarketingContent = {
"Follow our Quick Start guide to learn the basics of Slice Machine",
},
},
masterSliceLibrary: {
showInNavigation: false,
exampleLinkUrl: "",
codeLinkUrl: "",
previewVideoUrl: "",
},
};

export function useMarketingContent(): MarketingContent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Navigation: FC = () => {
useRepositoryInformation();
const gitIntegrationExperiment = useGitIntegrationExperiment();
const [isSliceLibraryDialogOpen, setIsSliceLibraryDialogOpen] =
useState<boolean>(false);
useState(false);
const { masterSliceLibrary } = useMarketingContent();

return (
Expand Down Expand Up @@ -123,7 +123,7 @@ const Navigation: FC = () => {
</ErrorBoundary>

<SideNavList position="bottom">
{masterSliceLibrary.showInNavigation && (
{masterSliceLibrary !== undefined && (
<SideNavListItem>
<MasterSliceLibraryPreviewModal
isOpen={isSliceLibraryDialogOpen}
Expand Down
3 changes: 3 additions & 0 deletions playwright/tests/common/sideNav.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ test('I can access the Academy from the "Learn Prismic" link', async ({
await expect(newTab).toHaveTitle(/Prismic Academy/);
});

// NOTE: This tests doesn't use page objects as the Master Slice Library preview modal
// is meant to be a temporary experiment lasting a few weeks, so it didn't really
// make sense to implement a page object for such a feature.
test('I can open a modal describing Master Slice Libraries by clicking the "Master Slice Library" button', async ({
sliceMachinePage,
procedures,
Expand Down

0 comments on commit 4361437

Please sign in to comment.