From b27f927ffda09050988e78acd224dc0876d471ca Mon Sep 17 00:00:00 2001 From: davidpmccormick Date: Wed, 20 Nov 2024 12:56:47 +0000 Subject: [PATCH 1/4] Add ability to limit where popupDialog appears with regex --- common/customtypes/popup-dialog/index.json | 11 +++++++++-- common/prismicio-types.d.ts | 11 +++++++++++ common/server-data/prismic.ts | 1 + common/views/components/PageLayout/PageLayout.tsx | 6 +++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/common/customtypes/popup-dialog/index.json b/common/customtypes/popup-dialog/index.json index 79c540e86e..2e0b402cfc 100644 --- a/common/customtypes/popup-dialog/index.json +++ b/common/customtypes/popup-dialog/index.json @@ -3,6 +3,7 @@ "label": "Popup dialog", "repeatable": false, "status": true, + "format": "custom", "json": { "Popup dialog": { "openButtonText": { @@ -44,8 +45,14 @@ "default_value": false, "label": "Is shown?" } + }, + "routeRegex": { + "type": "Text", + "config": { + "label": "Route regex", + "placeholder": "Pipe-separated (|) list of page paths here if you only want this on certain pages" + } } } - }, - "format": "custom" + } } diff --git a/common/prismicio-types.d.ts b/common/prismicio-types.d.ts index 91a6e92c42..500aa6497c 100644 --- a/common/prismicio-types.d.ts +++ b/common/prismicio-types.d.ts @@ -4221,6 +4221,17 @@ interface PopupDialogDocumentData { * - **Documentation**: https://prismic.io/docs/field#boolean */ isShown: prismic.BooleanField; + + /** + * Route regex field in *Popup dialog* + * + * - **Field Type**: Text + * - **Placeholder**: Pipe-separated (|) list of page paths here if you only want this on certain pages + * - **API ID Path**: popup-dialog.routeRegex + * - **Tab**: Popup dialog + * - **Documentation**: https://prismic.io/docs/field#key-text + */ + routeRegex: prismic.KeyTextField; } /** diff --git a/common/server-data/prismic.ts b/common/server-data/prismic.ts index eb550d6bf6..8ba61cc572 100644 --- a/common/server-data/prismic.ts +++ b/common/server-data/prismic.ts @@ -40,6 +40,7 @@ export const defaultValue = { openButtonText: null, text: [] as prismic.RichTextField, title: null, + routeRegex: null, }, }, collectionVenues: { diff --git a/common/views/components/PageLayout/PageLayout.tsx b/common/views/components/PageLayout/PageLayout.tsx index f8639969e2..9eb7433505 100644 --- a/common/views/components/PageLayout/PageLayout.tsx +++ b/common/views/components/PageLayout/PageLayout.tsx @@ -341,7 +341,11 @@ const PageLayoutComponent: FunctionComponent = ({ }} /> )} - {popupDialog.data.isShown && } + {popupDialog.data.isShown && + (!popupDialog.data.routeRegex || + urlString.match(new RegExp(popupDialog.data.routeRegex))) && ( + + )}
Date: Wed, 20 Nov 2024 13:31:03 +0000 Subject: [PATCH 2/4] Add routeRegex to emptyPopupDialog --- common/services/prismic/documents.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/common/services/prismic/documents.ts b/common/services/prismic/documents.ts index 233814db5b..8752fdc6e8 100644 --- a/common/services/prismic/documents.ts +++ b/common/services/prismic/documents.ts @@ -101,5 +101,6 @@ export function emptyPopupDialog(): RawPopupDialogDocument { openButtonText: null, text: [], title: null, + routeRegex: null, }) as RawPopupDialogDocument; } From 21f0b6c31d8c3f5dfabf4930e8014c0e9a684485 Mon Sep 17 00:00:00 2001 From: davidpmccormick Date: Wed, 20 Nov 2024 13:35:24 +0000 Subject: [PATCH 3/4] Add routeRegex to popupDialog stories --- cardigan/stories/components/PopupDialog/PopupDialog.stories.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/cardigan/stories/components/PopupDialog/PopupDialog.stories.tsx b/cardigan/stories/components/PopupDialog/PopupDialog.stories.tsx index c756a1753c..548ae54c85 100644 --- a/cardigan/stories/components/PopupDialog/PopupDialog.stories.tsx +++ b/cardigan/stories/components/PopupDialog/PopupDialog.stories.tsx @@ -26,6 +26,7 @@ const meta: Meta = { }, ], isShown: true, + routeRegex: null, }, }, }, From 0d75f563f78254cfc0bc903a82f1e76a49967503 Mon Sep 17 00:00:00 2001 From: davidpmccormick Date: Wed, 20 Nov 2024 13:46:32 +0000 Subject: [PATCH 4/4] Add routeRegex to prismic-data test fixtures --- common/test/fixtures/prismicData/prismic-data.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/common/test/fixtures/prismicData/prismic-data.ts b/common/test/fixtures/prismicData/prismic-data.ts index 4349c747f6..1671ce2de0 100644 --- a/common/test/fixtures/prismicData/prismic-data.ts +++ b/common/test/fixtures/prismicData/prismic-data.ts @@ -32,6 +32,7 @@ const prismicData: SimplifiedPrismicData = { url: 'https://interviewer.djsresearch.com/scripts/Dubinterviewer.dll/Frames?Quest=7577', }, isShown: false, + routeRegex: null, }, }, collectionVenues: {