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, }, }, }, 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/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; } 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: { 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))) && ( + + )}