From c7813a385b60bb09a936c6d7bd460bdaf98381e8 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Thu, 23 May 2024 19:00:39 -0400 Subject: [PATCH 1/9] feat: new component for rendering Json-LD in Dataset Page --- src/sections/dataset/Dataset.tsx | 2 + .../dataset/dataset-json-ld/DatasetJsonLd.tsx | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/sections/dataset/dataset-json-ld/DatasetJsonLd.tsx diff --git a/src/sections/dataset/Dataset.tsx b/src/sections/dataset/Dataset.tsx index 6cc83be9c..2aa2be672 100644 --- a/src/sections/dataset/Dataset.tsx +++ b/src/sections/dataset/Dataset.tsx @@ -20,6 +20,7 @@ import { SeparationLine } from '../shared/layout/SeparationLine/SeparationLine' import { BreadcrumbsGenerator } from '../shared/hierarchy/BreadcrumbsGenerator' import { useAlertContext } from '../alerts/AlertContext' import { AlertMessageKey } from '../../alert/domain/models/Alert' +import { DatasetJsonLd } from './dataset-json-ld/DatasetJsonLd' interface DatasetProps { fileRepository: FileRepository @@ -46,6 +47,7 @@ export function Dataset({ fileRepository, created }: DatasetProps) { return ( <> + {!dataset ? ( diff --git a/src/sections/dataset/dataset-json-ld/DatasetJsonLd.tsx b/src/sections/dataset/dataset-json-ld/DatasetJsonLd.tsx new file mode 100644 index 000000000..188754ca6 --- /dev/null +++ b/src/sections/dataset/dataset-json-ld/DatasetJsonLd.tsx @@ -0,0 +1,39 @@ +import { useEffect } from 'react' + +interface DatasetJsonLdProps { + persistentId: string | undefined +} + +export function DatasetJsonLd({ persistentId }: DatasetJsonLdProps) { + const addJsonLdScript = (persistentId: string) => { + const jsonLdData = { + '@context': 'http://schema.org', + '@type': 'Dataset', + '@id': persistentId, + identifier: persistentId, + name: 'test', + creator: [ + { + '@type': 'Person', + givenName: 'Guillermo', + familyName: 'Portas', + name: 'Portas, Guillermo' + } + ] + } + //TODO: replace string with data from server + const script = document.createElement('script') + script.type = 'application/ld+json' + script.text = JSON.stringify(jsonLdData) + + const existingScript = document.querySelector('script[type="application/ld+json"]') + if (existingScript) { + existingScript.remove() + } + document.head.appendChild(script) + } + useEffect(() => { + persistentId && addJsonLdScript(persistentId) + }, [persistentId]) + return <> +} From a99508a8fd857558035f58e3525910540069cde9 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 24 May 2024 08:40:37 -0400 Subject: [PATCH 2/9] test: deploy to beta --- .github/workflows/deploy-beta-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-beta-testing.yml b/.github/workflows/deploy-beta-testing.yml index cad70ab87..52509f1b5 100644 --- a/.github/workflows/deploy-beta-testing.yml +++ b/.github/workflows/deploy-beta-testing.yml @@ -3,7 +3,7 @@ name: 'Deploy to Beta Testing' on: push: branches: - - develop + - feature/350-json-ld jobs: build: From 72e32d53111b933013cf9535f6f8d4c611ff517f Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Fri, 24 May 2024 09:11:51 -0400 Subject: [PATCH 3/9] test: allow all in robots.txt --- public/robots.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/robots.txt b/public/robots.txt index e9e57dc4d..349360ba8 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,3 +1,3 @@ # https://www.robotstxt.org/robotstxt.html User-agent: * -Disallow: +Allow: / From a20c1a13681f7717a847f528390bbdbcda277941 Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Wed, 29 May 2024 13:16:29 -0400 Subject: [PATCH 4/9] replace component with a custom hook --- src/sections/dataset/Dataset.tsx | 4 +- .../dataset/dataset-json-ld/DatasetJsonLd.tsx | 39 ------------------- 2 files changed, 2 insertions(+), 41 deletions(-) delete mode 100644 src/sections/dataset/dataset-json-ld/DatasetJsonLd.tsx diff --git a/src/sections/dataset/Dataset.tsx b/src/sections/dataset/Dataset.tsx index 2aa2be672..45d06ee81 100644 --- a/src/sections/dataset/Dataset.tsx +++ b/src/sections/dataset/Dataset.tsx @@ -20,7 +20,7 @@ import { SeparationLine } from '../shared/layout/SeparationLine/SeparationLine' import { BreadcrumbsGenerator } from '../shared/hierarchy/BreadcrumbsGenerator' import { useAlertContext } from '../alerts/AlertContext' import { AlertMessageKey } from '../../alert/domain/models/Alert' -import { DatasetJsonLd } from './dataset-json-ld/DatasetJsonLd' +import { useAddDatasetJsonLd } from './useAddDatasetJsonLd' interface DatasetProps { fileRepository: FileRepository @@ -33,6 +33,7 @@ export function Dataset({ fileRepository, created }: DatasetProps) { const { t } = useTranslation('dataset') const { hideModal, isModalOpen } = useNotImplementedModal() const { addDatasetAlert } = useAlertContext() + useAddDatasetJsonLd({ persistentId: dataset?.persistentId }) if (created) { addDatasetAlert({ messageKey: AlertMessageKey.DATASET_CREATED, variant: 'success' }) @@ -47,7 +48,6 @@ export function Dataset({ fileRepository, created }: DatasetProps) { return ( <> - {!dataset ? ( diff --git a/src/sections/dataset/dataset-json-ld/DatasetJsonLd.tsx b/src/sections/dataset/dataset-json-ld/DatasetJsonLd.tsx deleted file mode 100644 index 188754ca6..000000000 --- a/src/sections/dataset/dataset-json-ld/DatasetJsonLd.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { useEffect } from 'react' - -interface DatasetJsonLdProps { - persistentId: string | undefined -} - -export function DatasetJsonLd({ persistentId }: DatasetJsonLdProps) { - const addJsonLdScript = (persistentId: string) => { - const jsonLdData = { - '@context': 'http://schema.org', - '@type': 'Dataset', - '@id': persistentId, - identifier: persistentId, - name: 'test', - creator: [ - { - '@type': 'Person', - givenName: 'Guillermo', - familyName: 'Portas', - name: 'Portas, Guillermo' - } - ] - } - //TODO: replace string with data from server - const script = document.createElement('script') - script.type = 'application/ld+json' - script.text = JSON.stringify(jsonLdData) - - const existingScript = document.querySelector('script[type="application/ld+json"]') - if (existingScript) { - existingScript.remove() - } - document.head.appendChild(script) - } - useEffect(() => { - persistentId && addJsonLdScript(persistentId) - }, [persistentId]) - return <> -} From 475512eb2aa81983f6cfe054de1542aa49cf096b Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Wed, 29 May 2024 13:17:00 -0400 Subject: [PATCH 5/9] add file useAddDatasetJsonLd.ts --- src/sections/dataset/useAddDatasetJsonLd.ts | 47 +++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/sections/dataset/useAddDatasetJsonLd.ts diff --git a/src/sections/dataset/useAddDatasetJsonLd.ts b/src/sections/dataset/useAddDatasetJsonLd.ts new file mode 100644 index 000000000..0277d8a96 --- /dev/null +++ b/src/sections/dataset/useAddDatasetJsonLd.ts @@ -0,0 +1,47 @@ +import { useEffect, useRef } from 'react' +interface DatasetJsonLdProps { + persistentId: string | undefined +} + +export const useAddDatasetJsonLd = ({ persistentId }: DatasetJsonLdProps) => { + const scriptRef = useRef(null) + // const persistentIdRef = useRef('') + + const addJsonLdScript = (persistentId: string) => { + const jsonLdData = { + '@context': 'http://schema.org', + '@type': 'Dataset', + '@id': persistentId, + identifier: persistentId, + name: 'test', + creator: [ + { + '@type': 'Person', + givenName: 'Guillermo', + familyName: 'Portas', + name: 'Portas, Guillermo' + } + ] + } + //TODO: replace string with data from server + const script = document.createElement('script') + scriptRef.current = script + //persistentIdRef.current = persistentId + script.type = 'application/ld+json' + script.text = JSON.stringify(jsonLdData) + document.head.append(script) + } + useEffect(() => { + if (persistentId && scriptRef.current !== null) { + addJsonLdScript(persistentId) + } + + return () => { + if (scriptRef.current !== null) { + scriptRef.current.remove() + } + + console.log('Component unmounted') + } + }, [persistentId]) +} From 58f0a95e299bae4b605080b49f9d22feb1671c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Wed, 3 Jul 2024 08:29:31 -0300 Subject: [PATCH 6/9] feat: test removing error-page with Don changes --- deployment/payara/web.xml | 5 ----- public/robots.txt | 2 +- src/sections/dataset/useAddDatasetJsonLd.ts | 7 +++---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/deployment/payara/web.xml b/deployment/payara/web.xml index c27edd5de..6ec4205fa 100644 --- a/deployment/payara/web.xml +++ b/deployment/payara/web.xml @@ -6,9 +6,4 @@ spa-servlet - - 404 - /index.html - - diff --git a/public/robots.txt b/public/robots.txt index 349360ba8..e9e57dc4d 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,3 +1,3 @@ # https://www.robotstxt.org/robotstxt.html User-agent: * -Allow: / +Disallow: diff --git a/src/sections/dataset/useAddDatasetJsonLd.ts b/src/sections/dataset/useAddDatasetJsonLd.ts index 0277d8a96..5478cfbde 100644 --- a/src/sections/dataset/useAddDatasetJsonLd.ts +++ b/src/sections/dataset/useAddDatasetJsonLd.ts @@ -5,7 +5,6 @@ interface DatasetJsonLdProps { export const useAddDatasetJsonLd = ({ persistentId }: DatasetJsonLdProps) => { const scriptRef = useRef(null) - // const persistentIdRef = useRef('') const addJsonLdScript = (persistentId: string) => { const jsonLdData = { @@ -32,16 +31,16 @@ export const useAddDatasetJsonLd = ({ persistentId }: DatasetJsonLdProps) => { document.head.append(script) } useEffect(() => { - if (persistentId && scriptRef.current !== null) { + if (persistentId && scriptRef.current === null) { + console.log('%c Adding script', 'color: white; background: green; padding: 4px;') addJsonLdScript(persistentId) } return () => { if (scriptRef.current !== null) { + console.log('%c Removing script', 'color: white; background: orange; padding: 4px;') scriptRef.current.remove() } - - console.log('Component unmounted') } }, [persistentId]) } From cc2521ba774be14444149b465fbc6b10b4ae963a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Wed, 3 Jul 2024 09:13:52 -0300 Subject: [PATCH 7/9] test one more thing --- deployment/payara/web.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deployment/payara/web.xml b/deployment/payara/web.xml index 6ec4205fa..ab7d409db 100644 --- a/deployment/payara/web.xml +++ b/deployment/payara/web.xml @@ -6,4 +6,9 @@ spa-servlet + + 200 + /index.html + + From 7dde3b96d1e8e04ce23c1052fa0428d42034eafb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Wed, 3 Jul 2024 09:21:21 -0300 Subject: [PATCH 8/9] chore: revert web.xml file --- deployment/payara/web.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/payara/web.xml b/deployment/payara/web.xml index ab7d409db..c27edd5de 100644 --- a/deployment/payara/web.xml +++ b/deployment/payara/web.xml @@ -7,7 +7,7 @@ spa-servlet - 200 + 404 /index.html From 161106509c1eb0de522714cd6ffaa24302324431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Wed, 3 Jul 2024 09:24:23 -0300 Subject: [PATCH 9/9] chore: to not deploy feature branch on beta --- .github/workflows/deploy-beta-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-beta-testing.yml b/.github/workflows/deploy-beta-testing.yml index 52509f1b5..cad70ab87 100644 --- a/.github/workflows/deploy-beta-testing.yml +++ b/.github/workflows/deploy-beta-testing.yml @@ -3,7 +3,7 @@ name: 'Deploy to Beta Testing' on: push: branches: - - feature/350-json-ld + - develop jobs: build: