diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 4743b89d0..07ede2b2c 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -6,6 +6,10 @@ on: - dev - main +permissions: + contents: read + packages: write + jobs: php-lint: name: PHP Lint diff --git a/.github/workflows/test-cypress-prod-links.yml b/.github/workflows/test-cypress-prod-links.yml index 4d1e036dd..9691138f5 100644 --- a/.github/workflows/test-cypress-prod-links.yml +++ b/.github/workflows/test-cypress-prod-links.yml @@ -30,7 +30,7 @@ jobs: with: browser: chrome env: NODE_ENV=test - config-file: cypress.prod.config.js + config-file: cypress.prod.links.config.js working-directory: benefit-finder - name: create github issue diff --git a/.github/workflows/thog_scan.yml b/.github/workflows/thog_scan.yml deleted file mode 100644 index 89c0b6f0c..000000000 --- a/.github/workflows/thog_scan.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: TruffleHog Scan - -on: - # schedule: - # - cron: '0 8 * * *' # Runs daily at 8 AM UTC - workflow_dispatch: - -jobs: - scan: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: scan - uses: trufflesecurity/trufflehog@main - with: - base: "" - head: ${{ github.ref_name }} - extra_args: --only-verified - - - name: Upload TruffleHog scan results - uses: actions/upload-artifact@v3 - with: - name: trufflehog-results - path: truffleHogResults.json diff --git a/.github/workflows/thog_scan_commit.yml b/.github/workflows/thog_scan_commit.yml new file mode 100644 index 000000000..00074f653 --- /dev/null +++ b/.github/workflows/thog_scan_commit.yml @@ -0,0 +1,83 @@ +name: TruffleHog Scan + +on: + push: + branches: + - main + - develop + pull_request: + +jobs: + scan: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install GitHub CLI + run: | + sudo apt-get update + sudo apt-get install -y gh + + - name: Authenticate GitHub CLI + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + run: | + gh auth setup-git + + - name: Run TruffleHog scan + id: trufflehog_scan + uses: trufflesecurity/trufflehog@v3.79.0 + with: + base: "" + head: ${{ github.ref_name }} + extra_args: --only-verified --json --entropy --max-depth=50 + continue-on-error: true + + - name: Check TruffleHog Results + id: check_results + run: | + if [ -f truffleHogResults.json ]; then + echo "file_exists=true" >> $GITHUB_ENV + else + echo "file_exists=false" >> $GITHUB_ENV + fi + + - name: Upload TruffleHog scan results + if: always() && env.file_exists == 'true' + uses: actions/upload-artifact@v3 + with: + name: trufflehog-results + path: truffleHogResults.json + + - name: Convert JSON to Readable Report + if: always() && env.file_exists == 'true' + run: | + jq -r '.results[] | "File: \(.path)\nCommit: \(.commit)\nDate: \(.date)\nReason: \(.reason)\n---------------------------"' truffleHogResults.json > truffleHogReport.txt + + - name: Upload Readable Report + if: always() && env.file_exists == 'true' + uses: actions/upload-artifact@v3 + with: + name: trufflehog-readable-report + path: truffleHogReport.txt + + - name: Check for findings and create issue + if: failure() && env.file_exists == 'true' + env: + GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} + run: | + if jq -e '.results | length > 0' truffleHogResults.json > /dev/null; then + echo "Secrets found. Creating GitHub issue." + gh issue create --title "TruffleHog Scan Results" --body "$(cat truffleHogReport.txt)" --label "bug,security" --assignee "@me" + exit 1 + else + echo "No secrets found or no results file." + fi + + - name: Fail the job if any secrets are found + if: steps.trufflehog_scan.outcome == 'failure' + run: exit 1 diff --git a/.github/workflows/thog_scan_scheduled.yml b/.github/workflows/thog_scan_scheduled.yml new file mode 100644 index 000000000..e69de29bb diff --git a/benefit-finder/cypress.prod.config.js b/benefit-finder/cypress.prod.config.js deleted file mode 100644 index aabff4890..000000000 --- a/benefit-finder/cypress.prod.config.js +++ /dev/null @@ -1,12 +0,0 @@ -const { defineConfig } = require('cypress') - -module.exports = defineConfig({ - retries: { - runMode: 2, - openMode: 0, - }, - e2e: { - baseUrl: 'https://www.usa.gov', - specPattern: 'cypress/e2e/usagov-public-site/*.cy.js' - }, -}) diff --git a/benefit-finder/cypress/e2e/storybook/dataLayer.cy.js b/benefit-finder/cypress/e2e/storybook/dataLayer.cy.js index 19091367c..31dc6e51a 100644 --- a/benefit-finder/cypress/e2e/storybook/dataLayer.cy.js +++ b/benefit-finder/cypress/e2e/storybook/dataLayer.cy.js @@ -5,7 +5,7 @@ import { pageObjects } from '../../support/pageObjects' import * as EN_LOCALE_DATA from '../../../../benefit-finder/src/shared/locales/en/en.json' import * as BENEFITS_ELIBILITY_DATA from '../../fixtures/benefits-eligibility.json' -const { intro, lifeEventSection, resultsView, benefitCount } = +const { intro, lifeEventSection, resultsView, openAllBenefitAccordions } = dataLayerUtils.dataLayerStructure const dataLayerValues = [ @@ -26,17 +26,17 @@ const dataLayerValues = [ { event: resultsView.event, bfData: { - pageView: resultsView.bfData.pageView, + pageView: resultsView.bfData.pageView[0], viewTitle: 'Your potential benefits', - viewState: resultsView.bfData.viewState[1], + eligibleBenefitCount: { number: 4, string: '4' }, + moreInfoBenefitCount: { number: 1, string: '1' }, + notEligibleBenefitCount: { number: 25, string: '25' }, }, }, { - event: benefitCount.event, + event: openAllBenefitAccordions.event, bfData: { - eligible: 4, - moreInfo: 1, - notEligible: 25, + accordionsOpen: openAllBenefitAccordions.bfData.accordionsOpen, }, }, ] @@ -120,19 +120,49 @@ describe('Calls to Google Analytics Object', function () { } delete ev[0]['gtm.uniqueEventId'] - expect(dataLayerValues[2]).to.deep.equal(ev[0]) + expect(ev[0]).to.deep.equal(dataLayerValues[2]) + }) + }) + }) + }) - // // check count event - const evCount = { - ...window.dataLayer.filter( - x => x.event === dataLayerValues[3].event - ), - } + it('clicking open all on results page has a bf_open_all_accordions event', function () { + const selectedData = BENEFITS_ELIBILITY_DATA.scenario_1_covid.en.param + const scenario = utils.encodeURIFromObject(selectedData) + cy.visit(`${utils.storybookUri}${scenario}`) - delete evCount[0]['gtm.uniqueEventId'] + cy.window().then(window => { + assert.isDefined(window.dataLayer, 'window.dataLayer is defined') - expect(dataLayerValues[3]).to.deep.equal(evCount[0]) - }) + pageObjects + .expandAll() + .click() + .then(() => { + // check last page change event + const ev = { + ...window.dataLayer.filter( + x => x?.event === dataLayerValues[3].event + ), + } + delete ev[0]['gtm.uniqueEventId'] + + expect(dataLayerValues[3]).to.deep.equal(ev[0]) + }) + + pageObjects + .expandAll() + .click() + .then(() => { + // check last page change event + const ev = { + ...window.dataLayer.filter( + x => x?.event === dataLayerValues[3].event + ), + } + // we ignore dedup here so there can be multiple fires + delete ev[1]['gtm.uniqueEventId'] + + expect(dataLayerValues[4]).to.not.deep.equal(ev[1]) }) }) }) diff --git a/benefit-finder/cypress/e2e/usagov-public-site/links.cy.js b/benefit-finder/cypress/e2e/usagov-public-site/links.cy.js index 496485c77..9fc879911 100644 --- a/benefit-finder/cypress/e2e/usagov-public-site/links.cy.js +++ b/benefit-finder/cypress/e2e/usagov-public-site/links.cy.js @@ -1,64 +1,108 @@ import * as utils from '../../support/utils' import * as BENEFITS_ELIBILITY_DATA from '../../fixtures/benefits-eligibility.json' -describe('Verify correct status code when user navigates links', () => { - // to be removed when uncaught exceptions are addressed - Cypress.on('uncaught:exception', (_err, runnable) => { - return false - }) - it('Verify success status code response for links in Death of a loved one English page', () => { - const selectedData = - BENEFITS_ELIBILITY_DATA['death-of-a-loved-one'].en.param - const scenario = utils.encodeURIFromObject(selectedData) - cy.visit(`benefit-finder/death?${scenario}`) - cy.get('main a[href]').each(link => { - cy.request(link.prop('href')) +const localePaths = { + en: [ + { key: 'death-of-a-loved-one', path: 'death' }, + { key: 'retirement', path: 'retirement' }, + { key: 'disability', path: 'disability' }, + ], + es: [ + { key: 'death-of-a-loved-one', path: 'muerte' }, + { key: 'retirement', path: 'jubilacion' }, + { key: 'disability', path: 'discapacidad' }, + ], +} + +const handlerequest = ({ testLink, link }) => { + const url = testLink || link.prop('href') + return cy + .request({ + url, + failOnStatusCode: false, + }) + .then(response => { + if (response.status === 200) { + expect(response.status).to.eq(200) + } else if (response.status === 403) { + cy.get('body').children().its('length').should('be.gt', 0) + } else if (response.status === 503) { + throw new Error(`site down - gave a 503 ${url}`) + } else if (response.status === 404) { + throw new Error(`page not found - gave a 404 ${url}`) + } else { + cy.get('body').children().its('length').should('be.gt', 0) + } }) +} + +const validateErrorCodes = test => { + // we verify site is alive and fail on 404 || 503 + cy.get('#benefit-finder a[href]').each(link => { + handlerequest({ link }) }) +} - it('Verify success status code response for links in Death of a Loved One Spanish page', () => { - const selectedData = - BENEFITS_ELIBILITY_DATA['death-of-a-loved-one'].es.param - const scenario = utils.encodeURIFromObject(selectedData) - cy.visit(`es/buscador-beneficios/muerte?${scenario}`) - cy.get('main a[href]').each(link => { - cy.request(link.prop('href')) - }) +const validateLinks = ({ selectedData, path }) => { + const scenario = utils.encodeURIFromObject(selectedData) + cy.visit(`${path}?${scenario}`) + validateErrorCodes() +} + +// to be removed when uncaught exceptions are addressed +// eslint-disable-next-line n/handle-callback-err +Cypress.on('uncaught:exception', (error, runnable) => { + return false +}) + +describe('Verify correct status code handling', () => { + // negate validation on our functional code + Cypress.on('fail', (error, runnable) => { + if (JSON.stringify(error).includes('httpstat')) { + // eslint-disable-next-line no-unused-expressions + expect(error).to.not.be.undefined + } else { + throw error + } }) - it('Verify success status code response for links in Retirement English page', () => { - const selectedData = BENEFITS_ELIBILITY_DATA.retirement.en.param - const scenario = utils.encodeURIFromObject(selectedData) - cy.visit(`benefit-finder/retirement?${scenario}`) - cy.get('main a[href]').each(link => { - cy.request(link.prop('href')) - }) + it(`handles 404 with an error`, () => { + handlerequest({ testLink: 'https://httpstat.us/404' }) }) - it('Verify success status code response for links in Retirement Spanish page', () => { - const selectedData = BENEFITS_ELIBILITY_DATA.retirement.es.param - const scenario = utils.encodeURIFromObject(selectedData) - cy.visit(`es/buscador-beneficios/jubilacion?${scenario}`) - cy.get('main a[href]').each(link => { - cy.request(link.prop('href')) - }) + it(`handles 503 with an error`, () => { + handlerequest({ testLink: 'https://httpstat.us/503' }) + }) + + it(`handles 200 successfully`, () => { + handlerequest({ testLink: 'https://httpstat.us/200' }) + }) + + it(`handles any 403 successfully`, () => { + handlerequest({ testLink: 'https://httpstat.us/403' }) + }) + + it(`handles any other request successfully`, () => { + handlerequest({ testLink: 'https://httpstat.us/201' }) }) +}) - it('Verify success status code response for links in Disability English page', () => { - const selectedData = BENEFITS_ELIBILITY_DATA.disability.en.param - const scenario = utils.encodeURIFromObject(selectedData) - cy.visit(`benefit-finder/disability?${scenario}`) - cy.get('main a[href]').each(link => { - cy.request(link.prop('href')) +describe('Verify correct status code when user navigates links in each locales', () => { + localePaths.en.forEach(location => { + it(`Verify success status code response for links in ${location.key} en page`, () => { + validateLinks({ + selectedData: BENEFITS_ELIBILITY_DATA[`${location.key}`].en.param, + path: `benefit-finder/${location.path}`, + }) }) }) - it('Verify success status code response for links in Disability English page', () => { - const selectedData = BENEFITS_ELIBILITY_DATA.disability.es.param - const scenario = utils.encodeURIFromObject(selectedData) - cy.visit(`es/buscador-beneficios/discapacidad?${scenario}`) - cy.get('main a[href]').each(link => { - cy.request(link.prop('href')) + localePaths.es.forEach(location => { + it(`Verify success status code response for links in ${location.key} es page`, () => { + validateLinks({ + selectedData: BENEFITS_ELIBILITY_DATA[`${location.key}`].en.param, + path: `es/buscador-beneficios/${location.path}`, + }) }) }) }) diff --git a/benefit-finder/package.json b/benefit-finder/package.json index 4c59003bb..6013308c5 100644 --- a/benefit-finder/package.json +++ b/benefit-finder/package.json @@ -32,7 +32,7 @@ "cy:run:component": "NODE_ENV=test npx cypress run --component --browser chrome", "cy:run:e2e": "NODE_ENV=test npx cypress run --browser chrome", "cy:run": "NODE_ENV=test npm run cy:run:component && npm run cy:run:e2e", - "cy:run:prod:e2e": "NODE_ENV=test npx cypress run --config-file cypress.prod.config.js --browser chrome", + "cy:run:prod:e2e": "NODE_ENV=test npx cypress run --config-file cypress.prod.links.config.js --browser chrome", "cy:run:prod:links:e2e": "NODE_ENV=test npx cypress run --config-file cypress.prod.links.config.js --browser chrome", "cy:run:pipeline": "NODE_ENV=test concurrently -k -s first -n \"SB,TEST\" -c \"magenta,blue\" \"http-server ./storybook-static --port 6006 --silent\" -Y", "cy:run:edge:e2e": "NODE_ENV=test npx cypress run --browser edge", diff --git a/benefit-finder/src/App/__tests__/__snapshots__/index.spec.jsx.snap b/benefit-finder/src/App/__tests__/__snapshots__/index.spec.jsx.snap index 578df2ebb..30b9f84ac 100644 --- a/benefit-finder/src/App/__tests__/__snapshots__/index.spec.jsx.snap +++ b/benefit-finder/src/App/__tests__/__snapshots__/index.spec.jsx.snap @@ -348,7 +348,7 @@ exports[`loads window query scenario 1 1`] = ` >

@@ -6728,7 +6728,7 @@ exports[`loads window query scenario 1 1`] = ` >

@@ -7104,7 +7104,7 @@ exports[`loads window query scenario 2 1`] = ` >

@@ -13496,7 +13496,7 @@ exports[`loads window query scenario 2 1`] = ` >

diff --git a/benefit-finder/src/shared/components/Accordion/index.jsx b/benefit-finder/src/shared/components/Accordion/index.jsx index f0cfc316d..f9fa10d35 100644 --- a/benefit-finder/src/shared/components/Accordion/index.jsx +++ b/benefit-finder/src/shared/components/Accordion/index.jsx @@ -39,18 +39,22 @@ const Accordion = ({ */ const [isOpen, setOpen] = useState(false) - const { benefitClick } = dataLayerUtils.dataLayerStructure + const { benefitAccordion } = dataLayerUtils.dataLayerStructure // handle dataLayer const handleOpenClose = isOpen => { setOpen(isOpen) isOpen === true && - dataLayerUtils.dataLayerPush(window, { - event: benefitClick.event, - bfData: { - benefitTitle: heading, + dataLayerUtils.dataLayerPush( + window, + { + event: benefitAccordion.event, + bfData: { + benefitTitle: heading, + }, }, - }) + false + ) } // handle expand all diff --git a/benefit-finder/src/shared/components/BenefitAccordionGroup/index.jsx b/benefit-finder/src/shared/components/BenefitAccordionGroup/index.jsx index b92f22b0b..492e1f791 100644 --- a/benefit-finder/src/shared/components/BenefitAccordionGroup/index.jsx +++ b/benefit-finder/src/shared/components/BenefitAccordionGroup/index.jsx @@ -34,7 +34,8 @@ const BenefitAccordionGroup = ({ sourceIsEnglish, } = benefitAccordion const { closedState, openState } = benefitAccordionGroup - const { benefitLink } = dataLayerUtils.dataLayerStructure + const { benefitLink, openAllBenefitAccordions } = + dataLayerUtils.dataLayerStructure /** * a hook that hanldes our open state of the accordions in our group * @function @@ -49,6 +50,7 @@ const BenefitAccordionGroup = ({ */ const handleExpandIcon = isExpandAll ? `${openState} -` : `${closedState} +` + // handle dataLayer /** * a function that pushes dataLayer events when the user clicks the link of that benefit * @function @@ -62,6 +64,25 @@ const BenefitAccordionGroup = ({ }) } + /** + * a function that handles expanded state and pushes dataLayer events when the user clicks the "open all" action + * @function + * @prop {boolean} isExpandAll true or false + */ + const handleExpandAll = isExpandAll => { + setExpandAll(!isExpandAll) + dataLayerUtils.dataLayerPush( + window, + { + event: openAllBenefitAccordions.event, + bfData: { + accordionsOpen: !isExpandAll, + }, + }, + false + ) + } + /** * a functional component that renders a button and controls the expansion of our accordions * @component @@ -74,7 +95,7 @@ const BenefitAccordionGroup = ({ className="bf-expand-all" aria-label={handleExpandIcon} unstyled - onClick={() => setExpandAll(!isExpandAll)} + onClick={() => handleExpandAll(isExpandAll)} > {handleExpandIcon} diff --git a/benefit-finder/src/shared/components/LifeEventSection/index.jsx b/benefit-finder/src/shared/components/LifeEventSection/index.jsx index 702431cca..185f0bd26 100644 --- a/benefit-finder/src/shared/components/LifeEventSection/index.jsx +++ b/benefit-finder/src/shared/components/LifeEventSection/index.jsx @@ -561,6 +561,7 @@ const LifeEventSection = ({
{ // state const triggerRef = useRef(null) @@ -107,7 +108,8 @@ const Modal = ({ dataLayerUtils.dataLayerPush(window, { event: modal.event, bfData: { - modalOpen, + pageView: modal.bfData.pageView, + viewTitle: `${dataLayerValue.viewTitle} modal`, }, }) }, []) diff --git a/benefit-finder/src/shared/components/ResultsView/index.jsx b/benefit-finder/src/shared/components/ResultsView/index.jsx index 8b23dac69..f1dd28a31 100644 --- a/benefit-finder/src/shared/components/ResultsView/index.jsx +++ b/benefit-finder/src/shared/components/ResultsView/index.jsx @@ -47,11 +47,7 @@ const ResultsView = ({ } = ui const [notEligibleView, setnotEligibleView] = useState(false) - const [eligibilityCount, setEligibilityCount] = useState({ - eligible: 0, - notEligible, - moreInfo: 0, - }) + const [eligibilityCount, setEligibilityCount] = useState(null) const resetElement = useResetElement() @@ -81,7 +77,7 @@ const ResultsView = ({ matches.push(div) } } - return matches.length + return { number: matches.length, string: `${matches.length}` } } const handleViewToggle = () => { @@ -90,18 +86,18 @@ const ResultsView = ({ resetElement.current.focus() } - const zeroBenefitsResult = eligibilityCount.eligible === 0 + const zeroBenefitsResult = eligibilityCount?.eligibleBenefitCount.number === 0 useEffect(() => { window.scrollTo(0, 0) setEligibilityCount({ - eligible: handleEligibilityLength( + eligibleBenefitCount: handleEligibilityLength( ui.benefitAccordion.eligibleStatusLabels[0] ), - moreInfo: handleEligibilityLength( + moreInfoBenefitCount: handleEligibilityLength( ui.benefitAccordion.eligibleStatusLabels[1] ), - notEligible: handleEligibilityLength( + notEligibleBenefitCount: handleEligibilityLength( ui.benefitAccordion.eligibleStatusLabels[2] ), }) @@ -110,37 +106,25 @@ const ResultsView = ({ // handle dataLayer useEffect(() => { const { resultsView } = dataLayerUtils.dataLayerStructure - eligibilityCount.notEligible >= 0 && + eligibilityCount !== null && dataLayerUtils.dataLayerPush(window, { event: resultsView.event, bfData: { - pageView: resultsView.bfData.pageView, + pageView: + notEligibleView === true + ? resultsView.bfData.pageView[1] + : resultsView.bfData.pageView[0], viewTitle: notEligibleView === false ? (zeroBenefitsResult && zeroBenefits.chevron.heading) || eligible.chevron.heading : (zeroBenefitsResult && zeroBenefits.chevron.heading) || notEligible.chevron.heading, - viewState: - notEligibleView === true - ? (zeroBenefitsResult && resultsView.bfData.viewState[2]) || - resultsView.bfData.viewState[0] - : (zeroBenefitsResult && resultsView.bfData.viewState[3]) || - resultsView.bfData.viewState[1], + ...eligibilityCount, }, }) }, [notEligibleView, eligibilityCount]) - // handle dataLayer - useEffect(() => { - const { benefitCount } = dataLayerUtils.dataLayerStructure - eligibilityCount.notEligible >= 0 && - dataLayerUtils.dataLayerPush(window, { - event: benefitCount.event, - bfData: eligibilityCount, - }) - }, [eligibilityCount]) - // compare the selected criteria array with benefits return (

If you reached these results by mistake, please go back to review your answers.

" + "heading": "You are likely not eligible for these benefits.", + "description": "

If you reached these results by mistake, please go back to review your answers.

" }, - "heading": "No eligible results", + "heading": "No eligible results.", "description": "Based on your answers you are likely not eligible for benefits. You may become eligible if you enter more information or your situation changes.", "cta": "See all benefits" }, diff --git a/benefit-finder/src/shared/locales/es/es.json b/benefit-finder/src/shared/locales/es/es.json index 74873b516..02afd10e3 100644 --- a/benefit-finder/src/shared/locales/es/es.json +++ b/benefit-finder/src/shared/locales/es/es.json @@ -105,6 +105,15 @@ "heading": "Resultados", "description": "Según sus respuestas no es elegible para estos beneficios. Podría calificar si tiene información adicional o si su situación cambia." }, + "zeroBenefits": { + "chevron": { + "heading": "Usted parece no ser elegible para estos beneficios.", + "description": "

Si cree que cometió un error, por favor regrese para corregir sus respuestas.

" + }, + "heading": "No tiene resultados elegibles.", + "description": "Basado en sus respuestas usted no es elegible para estos beneficios. Podría ser elegible si ingresa más información o si su situación cambia.", + "cta": "Ver todos los beneficios" + }, "stepBackLink": "Volver", "eligibleResults": { "heading": "Resultados", diff --git a/benefit-finder/src/shared/utils/dataLayerUtils/dataLayerPush.js b/benefit-finder/src/shared/utils/dataLayerUtils/dataLayerPush.js index 79bf5ebf2..1ac74c008 100644 --- a/benefit-finder/src/shared/utils/dataLayerUtils/dataLayerPush.js +++ b/benefit-finder/src/shared/utils/dataLayerUtils/dataLayerPush.js @@ -1,4 +1,4 @@ -const dataLayerPush = (w, dataLayerObj, dedup) => { +const dataLayerPush = (w, dataLayerObj, dedup = true) => { const isObject = object => { return object != null && typeof object === 'object' } @@ -31,12 +31,15 @@ const dataLayerPush = (w, dataLayerObj, dedup) => { if (w.dataLayer) { // get the last index of the dataLayer array const lastItem = { ...window.dataLayer[window.dataLayer.length - 1] } - delete lastItem['gtm.uniqueEventId'] - // to prevent pushing duplicate objects unecessarily, as long as our last item doesn't match our current data obj, we push - isDeepEqual(lastItem, dataLayerObj) === false && + if (dedup === true) { + // to prevent pushing duplicate objects unecessarily, as long as our last item doesn't match our current data obj, we push + isDeepEqual(lastItem, dataLayerObj) === false && + w.dataLayer.push(dataLayerObj) + } else { w.dataLayer.push(dataLayerObj) + } } } diff --git a/benefit-finder/src/shared/utils/dataLayerUtils/dataLayerStructure.js b/benefit-finder/src/shared/utils/dataLayerUtils/dataLayerStructure.js index 428d5c226..73b7127bf 100644 --- a/benefit-finder/src/shared/utils/dataLayerUtils/dataLayerStructure.js +++ b/benefit-finder/src/shared/utils/dataLayerUtils/dataLayerStructure.js @@ -11,9 +11,10 @@ const dataLayerStructure = { }, }, modal: { - event: 'bf_modal_open', + event: 'bf_page_change', bfData: { - modalOpen: false, + pageView: 'bf-form-completion-modal', + viewTitle: null, }, }, verifySelections: { @@ -26,18 +27,18 @@ const dataLayerStructure = { resultsView: { event: 'bf_page_change', bfData: { - pageView: 'bf-result-view', + pageView: ['bf-result-eligible-view', 'bf-result-not-eligible-view'], viewTitle: null, - viewState: [ - 'bf-not-eligible-view', - 'bf-eligible-view', - 'bf-not-eligible-view-zero-benefits', - 'bf-eligible-view-zero-benefits', - ], }, }, - benefitClick: { - event: 'bf_benefit_click', + openAllBenefitAccordions: { + event: 'bf_open_all_accordions', + bfData: { + accordionsOpen: true, + }, + }, + benefitAccordion: { + event: 'bf_accordion_open', bfData: { benefitTitle: null, }, @@ -48,7 +49,6 @@ const dataLayerStructure = { benefitTitle: null, }, }, - benefitCount: { event: 'bf_count', bfData: null }, } export default dataLayerStructure diff --git a/restore.txt b/restore.txt deleted file mode 100644 index 80c81b179..000000000 --- a/restore.txt +++ /dev/null @@ -1,12 +0,0 @@ -Finding the service instance details... -Setting up SSH tunnel... -SSH tunnel created. -Skipping call to client CLI. Connection information: - -Host: localhost -Port: 44265 -Username: u1pqgr5amf7bbsm3 -Password: o95jv0wxlkynbk5qx7fxbmc6o -Name: cgawsbrokerprodoly1e52tnaanm56 - -Leave this terminal open while you want to use the SSH tunnel. Press Control-C to stop. diff --git a/scripts/pipeline/mv-usagov_benefit_finder.sh b/scripts/pipeline/mv-usagov_benefit_finder.sh index 8ff856a6a..6e8314c97 100755 --- a/scripts/pipeline/mv-usagov_benefit_finder.sh +++ b/scripts/pipeline/mv-usagov_benefit_finder.sh @@ -35,6 +35,7 @@ if test -d "$BENEFIT_FINDER_MODULE_LOCATION" then echo "usa.gov benefit-finder module exist" echo "Moving BENEFIT_FINDER custom module to usa.gov project..." + rm -r "${USAGOV_PROJECT_CUSTOM_MODULES_LOCATION}/${BENEFIT_FINDER_MODULE}"/* || exit 1 cp -r "${BENEFIT_FINDER_MODULE_LOCATION}" "${USAGOV_PROJECT_CUSTOM_MODULES_LOCATION}" || exit 1 - test -f "${USAGOV_PROJECT_CUSTOM_MODULES_LOCATION}${BENEFIT_FINDER_MODULE}"; echo -e "BENEFIT_FINDER Module successfully moved" + test -f "${USAGOV_PROJECT_CUSTOM_MODULES_LOCATION}/${BENEFIT_FINDER_MODULE}"; echo -e "BENEFIT_FINDER Module successfully moved" fi diff --git a/usagov_benefit_finder/configuration/.gitkeep b/usagov_benefit_finder/configuration/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/usagov_benefit_finder/configuration/core.entity_form_display.node.bears_benefit.default.yml b/usagov_benefit_finder/configuration/core.entity_form_display.node.bears_benefit.default.yml deleted file mode 100644 index 34d53aa65..000000000 --- a/usagov_benefit_finder/configuration/core.entity_form_display.node.bears_benefit.default.yml +++ /dev/null @@ -1,191 +0,0 @@ -uuid: d4fdb095-25a3-43ea-879c-0ddf2ef649ae -langcode: en -status: true -dependencies: - config: - - field.field.node.bears_benefit.field_b_agency - - field.field.node.bears_benefit.field_b_eligibility - - field.field.node.bears_benefit.field_b_headline - - field.field.node.bears_benefit.field_b_initial_elg_length - - field.field.node.bears_benefit.field_b_life_event_forms - - field.field.node.bears_benefit.field_b_source_is_english - - field.field.node.bears_benefit.field_b_source_link - - field.field.node.bears_benefit.field_b_summary - - field.field.node.bears_benefit.field_b_tags - - field.field.node.bears_benefit.field_language_toggle - - node.type.bears_benefit - module: - - content_moderation - - paragraphs - - path - - text -id: node.bears_benefit.default -targetEntityType: node -bundle: bears_benefit -mode: default -content: - created: - type: datetime_timestamp - weight: 12 - region: content - settings: { } - third_party_settings: { } - field_b_agency: - type: options_select - weight: 8 - region: content - settings: { } - third_party_settings: { } - field_b_eligibility: - type: paragraphs - weight: 18 - region: content - settings: - title: Paragraph - title_plural: Paragraphs - edit_mode: open - closed_mode: summary - autocollapse: none - closed_mode_threshold: 0 - add_mode: dropdown - form_display_mode: default - default_paragraph_type: '' - features: - collapse_edit_all: collapse_edit_all - duplicate: duplicate - third_party_settings: { } - field_b_headline: - type: text_textarea - weight: 3 - region: content - settings: - rows: 5 - placeholder: '' - third_party_settings: { } - field_b_initial_elg_length: - type: number - weight: 17 - region: content - settings: - placeholder: '' - third_party_settings: { } - field_b_life_event_forms: - type: options_buttons - weight: 7 - region: content - settings: { } - third_party_settings: { } - field_b_source_is_english: - type: boolean_checkbox - weight: 10 - region: content - settings: - display_label: true - third_party_settings: { } - field_b_source_link: - type: string_textfield - weight: 9 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - field_b_summary: - type: text_textarea - weight: 4 - region: content - settings: - rows: 5 - placeholder: '' - third_party_settings: { } - field_b_tags: - type: options_buttons - weight: 5 - region: content - settings: { } - third_party_settings: { } - field_language_toggle: - type: entity_reference_autocomplete - weight: 1 - region: content - settings: - match_operator: CONTAINS - match_limit: 10 - size: 60 - placeholder: '' - third_party_settings: { } - langcode: - type: language_select - weight: 0 - region: content - settings: - include_locked: true - third_party_settings: { } - moderation_state: - type: moderation_state_default - weight: 20 - region: content - settings: { } - third_party_settings: { } - path: - type: path - weight: 15 - region: content - settings: { } - third_party_settings: { } - promote: - type: boolean_checkbox - weight: 13 - region: content - settings: - display_label: true - third_party_settings: { } - simple_sitemap: - weight: 10 - region: content - settings: { } - third_party_settings: { } - status: - type: boolean_checkbox - weight: 16 - region: content - settings: - display_label: true - third_party_settings: { } - sticky: - type: boolean_checkbox - weight: 14 - region: content - settings: - display_label: true - third_party_settings: { } - title: - type: string_textfield - weight: 2 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - translation: - weight: 10 - region: content - settings: { } - third_party_settings: { } - uid: - type: entity_reference_autocomplete - weight: 11 - region: content - settings: - match_operator: CONTAINS - match_limit: 10 - size: 60 - placeholder: '' - third_party_settings: { } - url_redirects: - weight: 19 - region: content - settings: { } - third_party_settings: { } -hidden: - menu_entity_index: true diff --git a/usagov_benefit_finder/configuration/core.entity_form_display.node.bears_criteria.default.yml b/usagov_benefit_finder/configuration/core.entity_form_display.node.bears_criteria.default.yml deleted file mode 100644 index 569a12dc2..000000000 --- a/usagov_benefit_finder/configuration/core.entity_form_display.node.bears_criteria.default.yml +++ /dev/null @@ -1,210 +0,0 @@ -uuid: 7b0ea4b3-ad18-416a-81a4-6515572f433f -langcode: en -status: true -dependencies: - config: - - field.field.node.bears_criteria.field_b_child_dependency_option - - field.field.node.bears_criteria.field_b_criteria_key - - field.field.node.bears_criteria.field_b_has_child - - field.field.node.bears_criteria.field_b_id - - field.field.node.bears_criteria.field_b_label - - field.field.node.bears_criteria.field_b_name - - field.field.node.bears_criteria.field_b_type - - field.field.node.bears_criteria.field_b_values - - field.field.node.bears_criteria.field_language_toggle - - node.type.bears_criteria - module: - - content_moderation - - path -id: node.bears_criteria.default -targetEntityType: node -bundle: bears_criteria -mode: default -content: - created: - type: datetime_timestamp - weight: 3 - region: content - settings: { } - third_party_settings: { } - field_b_child_dependency_option: - type: string_textfield - weight: 16 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: - conditional_fields: - 7d256aff-5858-4005-83b2-7a6221d75c58: - entity_type: node - bundle: bears_criteria - dependee: field_b_has_child - settings: - state: required - reset: false - condition: checked - grouping: AND - values_set: 1 - value: '' - values: { } - value_form: - value: false - effect: show - effect_options: { } - selector: '' - 91ce84c7-8a94-49dc-a41c-d5c0f369a2d0: - entity_type: node - bundle: bears_criteria - dependee: field_b_has_child - settings: - state: visible - reset: false - condition: checked - grouping: AND - values_set: 1 - value: '' - values: { } - value_form: - value: false - effect: show - effect_options: { } - selector: '' - field_b_criteria_key: - type: string_textfield - weight: 9 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - field_b_has_child: - type: boolean_checkbox - weight: 15 - region: content - settings: - display_label: true - third_party_settings: { } - field_b_id: - type: string_textfield - weight: 10 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - field_b_label: - type: string_textfield - weight: 12 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - field_b_name: - type: string_textfield - weight: 13 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - field_b_type: - type: options_select - weight: 11 - region: content - settings: { } - third_party_settings: { } - field_b_values: - type: string_textfield - weight: 14 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - field_language_toggle: - type: entity_reference_autocomplete - weight: 1 - region: content - settings: - match_operator: CONTAINS - match_limit: 10 - size: 60 - placeholder: '' - third_party_settings: { } - langcode: - type: language_select - weight: 0 - region: content - settings: - include_locked: true - third_party_settings: { } - moderation_state: - type: moderation_state_default - weight: 18 - region: content - settings: { } - third_party_settings: { } - path: - type: path - weight: 6 - region: content - settings: { } - third_party_settings: { } - promote: - type: boolean_checkbox - weight: 4 - region: content - settings: - display_label: true - third_party_settings: { } - simple_sitemap: - weight: 10 - region: content - settings: { } - third_party_settings: { } - status: - type: boolean_checkbox - weight: 7 - region: content - settings: - display_label: true - third_party_settings: { } - sticky: - type: boolean_checkbox - weight: 5 - region: content - settings: - display_label: true - third_party_settings: { } - title: - type: string_textfield - weight: 8 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - translation: - weight: 3 - region: content - settings: { } - third_party_settings: { } - uid: - type: entity_reference_autocomplete - weight: 2 - region: content - settings: - match_operator: CONTAINS - match_limit: 10 - size: 60 - placeholder: '' - third_party_settings: { } - url_redirects: - weight: 17 - region: content - settings: { } - third_party_settings: { } -hidden: - menu_entity_index: true diff --git a/usagov_benefit_finder/configuration/core.entity_form_display.node.bears_life_event.default.yml b/usagov_benefit_finder/configuration/core.entity_form_display.node.bears_life_event.default.yml deleted file mode 100644 index 94335f34f..000000000 --- a/usagov_benefit_finder/configuration/core.entity_form_display.node.bears_life_event.default.yml +++ /dev/null @@ -1,209 +0,0 @@ -uuid: 99c745fb-37ed-4061-89ac-3bf52d328117 -langcode: en -status: true -dependencies: - config: - - field.field.node.bears_life_event.field_b_id - - field.field.node.bears_life_event.field_b_search_title - - field.field.node.bears_life_event.field_draft_json_data_file - - field.field.node.bears_life_event.field_draft_json_data_file_path - - field.field.node.bears_life_event.field_header_html - - field.field.node.bears_life_event.field_json_data_file - - field.field.node.bears_life_event.field_json_data_file_path - - field.field.node.bears_life_event.field_language_toggle - - field.field.node.bears_life_event.field_meta_description - - field.field.node.bears_life_event.field_page_intro - - field.field.node.bears_life_event.field_short_description - - field.field.node.bears_life_event.field_summary - - node.type.bears_life_event - module: - - allowed_formats - - content_moderation - - file - - path - - text -id: node.bears_life_event.default -targetEntityType: node -bundle: bears_life_event -mode: default -content: - created: - type: datetime_timestamp - weight: 10 - region: content - settings: { } - third_party_settings: { } - field_b_id: - type: string_textfield - weight: 3 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - field_b_search_title: - type: string_textfield - weight: 7 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - field_draft_json_data_file: - type: file_generic - weight: 21 - region: content - settings: - progress_indicator: throbber - third_party_settings: { } - field_draft_json_data_file_path: - type: string_textfield - weight: 19 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - field_header_html: - type: text_textarea - weight: 22 - region: content - settings: - rows: 5 - placeholder: '' - third_party_settings: - allowed_formats: - hide_help: '1' - hide_guidelines: '0' - field_json_data_file: - type: file_generic - weight: 20 - region: content - settings: - progress_indicator: throbber - third_party_settings: { } - field_json_data_file_path: - type: string_textfield - weight: 18 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - field_language_toggle: - type: entity_reference_autocomplete - weight: 1 - region: content - settings: - match_operator: CONTAINS - match_limit: 10 - size: 60 - placeholder: '' - third_party_settings: { } - field_meta_description: - type: string_textarea - weight: 5 - region: content - settings: - rows: 1 - placeholder: '' - third_party_settings: { } - field_page_intro: - type: string_textarea - weight: 4 - region: content - settings: - rows: 1 - placeholder: '' - third_party_settings: { } - field_short_description: - type: string_textarea - weight: 6 - region: content - settings: - rows: 1 - placeholder: '' - third_party_settings: { } - field_summary: - type: string_textarea - weight: 8 - region: content - settings: - rows: 5 - placeholder: '' - third_party_settings: { } - langcode: - type: language_select - weight: 0 - region: content - settings: - include_locked: true - third_party_settings: { } - moderation_state: - type: moderation_state_default - weight: 16 - region: content - settings: { } - third_party_settings: { } - path: - type: path - weight: 13 - region: content - settings: { } - third_party_settings: { } - promote: - type: boolean_checkbox - weight: 11 - region: content - settings: - display_label: true - third_party_settings: { } - simple_sitemap: - weight: 15 - region: content - settings: { } - third_party_settings: { } - status: - type: boolean_checkbox - weight: 17 - region: content - settings: - display_label: true - third_party_settings: { } - sticky: - type: boolean_checkbox - weight: 12 - region: content - settings: - display_label: true - third_party_settings: { } - title: - type: string_textfield - weight: 2 - region: content - settings: - size: 60 - placeholder: '' - third_party_settings: { } - translation: - weight: 10 - region: content - settings: { } - third_party_settings: { } - uid: - type: entity_reference_autocomplete - weight: 9 - region: content - settings: - match_operator: CONTAINS - match_limit: 10 - size: 60 - placeholder: '' - third_party_settings: { } - url_redirects: - weight: 14 - region: content - settings: { } - third_party_settings: { } -hidden: - menu_entity_index: true diff --git a/usagov_benefit_finder/configuration/core.entity_view_display.node.bears_benefit.default.yml b/usagov_benefit_finder/configuration/core.entity_view_display.node.bears_benefit.default.yml deleted file mode 100644 index ee07784d0..000000000 --- a/usagov_benefit_finder/configuration/core.entity_view_display.node.bears_benefit.default.yml +++ /dev/null @@ -1,122 +0,0 @@ -uuid: 6c74929f-e325-431f-be4a-a55e5ff5254f -langcode: en -status: true -dependencies: - config: - - field.field.node.bears_benefit.field_b_agency - - field.field.node.bears_benefit.field_b_eligibility - - field.field.node.bears_benefit.field_b_headline - - field.field.node.bears_benefit.field_b_initial_elg_length - - field.field.node.bears_benefit.field_b_life_event_forms - - field.field.node.bears_benefit.field_b_source_is_english - - field.field.node.bears_benefit.field_b_source_link - - field.field.node.bears_benefit.field_b_summary - - field.field.node.bears_benefit.field_b_tags - - field.field.node.bears_benefit.field_language_toggle - - node.type.bears_benefit - module: - - entity_reference_revisions - - text - - user -id: node.bears_benefit.default -targetEntityType: node -bundle: bears_benefit -mode: default -content: - field_b_agency: - type: entity_reference_label - label: above - settings: - link: true - third_party_settings: { } - weight: 6 - region: content - field_b_eligibility: - type: entity_reference_revisions_entity_view - label: above - settings: - view_mode: default - link: '' - third_party_settings: { } - weight: 10 - region: content - field_b_headline: - type: text_default - label: above - settings: { } - third_party_settings: { } - weight: 1 - region: content - field_b_initial_elg_length: - type: number_integer - label: above - settings: - thousand_separator: '' - prefix_suffix: true - third_party_settings: { } - weight: 9 - region: content - field_b_life_event_forms: - type: entity_reference_label - label: above - settings: - link: true - third_party_settings: { } - weight: 5 - region: content - field_b_source_is_english: - type: boolean - label: above - settings: - format: default - format_custom_false: '' - format_custom_true: '' - third_party_settings: { } - weight: 8 - region: content - field_b_source_link: - type: string - label: above - settings: - link_to_entity: false - third_party_settings: { } - weight: 7 - region: content - field_b_summary: - type: text_default - label: above - settings: { } - third_party_settings: { } - weight: 2 - region: content - field_b_tags: - type: entity_reference_label - label: above - settings: - link: true - third_party_settings: { } - weight: 3 - region: content - field_language_toggle: - type: entity_reference_label - label: above - settings: - link: true - third_party_settings: { } - weight: 12 - region: content - langcode: - type: language - label: above - settings: - link_to_entity: false - native_language: false - third_party_settings: { } - weight: 11 - region: content - links: - settings: { } - third_party_settings: { } - weight: 0 - region: content -hidden: { } diff --git a/usagov_benefit_finder/configuration/core.entity_view_display.node.bears_benefit.teaser.yml b/usagov_benefit_finder/configuration/core.entity_view_display.node.bears_benefit.teaser.yml deleted file mode 100644 index 4f693d923..000000000 --- a/usagov_benefit_finder/configuration/core.entity_view_display.node.bears_benefit.teaser.yml +++ /dev/null @@ -1,41 +0,0 @@ -uuid: dab1fae4-5630-49c4-820a-d787fba71e65 -langcode: en -status: true -dependencies: - config: - - core.entity_view_mode.node.teaser - - field.field.node.bears_benefit.field_b_agency - - field.field.node.bears_benefit.field_b_eligibility - - field.field.node.bears_benefit.field_b_headline - - field.field.node.bears_benefit.field_b_initial_elg_length - - field.field.node.bears_benefit.field_b_life_event_forms - - field.field.node.bears_benefit.field_b_source_is_english - - field.field.node.bears_benefit.field_b_source_link - - field.field.node.bears_benefit.field_b_summary - - field.field.node.bears_benefit.field_b_tags - - field.field.node.bears_benefit.field_language_toggle - - node.type.bears_benefit - module: - - user -id: node.bears_benefit.teaser -targetEntityType: node -bundle: bears_benefit -mode: teaser -content: - links: - settings: { } - third_party_settings: { } - weight: 100 - region: content -hidden: - field_b_agency: true - field_b_eligibility: true - field_b_headline: true - field_b_initial_elg_length: true - field_b_life_event_forms: true - field_b_source_is_english: true - field_b_source_link: true - field_b_summary: true - field_b_tags: true - field_language_toggle: true - langcode: true diff --git a/usagov_benefit_finder/configuration/core.entity_view_display.node.bears_life_event.default.yml b/usagov_benefit_finder/configuration/core.entity_view_display.node.bears_life_event.default.yml deleted file mode 100644 index 502604726..000000000 --- a/usagov_benefit_finder/configuration/core.entity_view_display.node.bears_life_event.default.yml +++ /dev/null @@ -1,138 +0,0 @@ -uuid: 6a658720-5cd1-4c61-bf1c-a8f0c9a40680 -langcode: en -status: true -dependencies: - config: - - field.field.node.bears_life_event.field_b_id - - field.field.node.bears_life_event.field_b_search_title - - field.field.node.bears_life_event.field_draft_json_data_file - - field.field.node.bears_life_event.field_draft_json_data_file_path - - field.field.node.bears_life_event.field_header_html - - field.field.node.bears_life_event.field_json_data_file - - field.field.node.bears_life_event.field_json_data_file_path - - field.field.node.bears_life_event.field_language_toggle - - field.field.node.bears_life_event.field_meta_description - - field.field.node.bears_life_event.field_page_intro - - field.field.node.bears_life_event.field_short_description - - field.field.node.bears_life_event.field_summary - - node.type.bears_life_event - module: - - file - - text - - user -id: node.bears_life_event.default -targetEntityType: node -bundle: bears_life_event -mode: default -content: - content_moderation_control: - settings: { } - third_party_settings: { } - weight: -20 - region: content - field_b_id: - type: string - label: above - settings: - link_to_entity: false - third_party_settings: { } - weight: 2 - region: content - field_b_search_title: - type: string - label: above - settings: - link_to_entity: false - third_party_settings: { } - weight: 12 - region: content - field_draft_json_data_file: - type: file_default - label: above - settings: - use_description_as_link_text: true - third_party_settings: { } - weight: 9 - region: content - field_draft_json_data_file_path: - type: string - label: above - settings: - link_to_entity: false - third_party_settings: { } - weight: 7 - region: content - field_header_html: - type: text_default - label: above - settings: { } - third_party_settings: { } - weight: 10 - region: content - field_json_data_file: - type: file_default - label: above - settings: - use_description_as_link_text: true - third_party_settings: { } - weight: 8 - region: content - field_json_data_file_path: - type: string - label: above - settings: - link_to_entity: false - third_party_settings: { } - weight: 6 - region: content - field_language_toggle: - type: entity_reference_label - label: above - settings: - link: true - third_party_settings: { } - weight: 5 - region: content - field_meta_description: - type: basic_string - label: above - settings: { } - third_party_settings: { } - weight: 3 - region: content - field_page_intro: - type: basic_string - label: hidden - settings: { } - third_party_settings: { } - weight: 2 - region: content - field_short_description: - type: basic_string - label: above - settings: { } - third_party_settings: { } - weight: 11 - region: content - field_summary: - type: basic_string - label: above - settings: { } - third_party_settings: { } - weight: 1 - region: content - langcode: - type: language - label: above - settings: - link_to_entity: false - native_language: false - third_party_settings: { } - weight: 4 - region: content - links: - settings: { } - third_party_settings: { } - weight: 0 - region: content -hidden: { } diff --git a/usagov_benefit_finder/configuration/core.entity_view_display.node.bears_life_event.teaser.yml b/usagov_benefit_finder/configuration/core.entity_view_display.node.bears_life_event.teaser.yml deleted file mode 100644 index 7c76eec76..000000000 --- a/usagov_benefit_finder/configuration/core.entity_view_display.node.bears_life_event.teaser.yml +++ /dev/null @@ -1,50 +0,0 @@ -uuid: 75f24593-dd3f-4f75-aea4-27d8ca76f40b -langcode: en -status: true -dependencies: - config: - - core.entity_view_mode.node.teaser - - field.field.node.bears_life_event.field_b_id - - field.field.node.bears_life_event.field_b_search_title - - field.field.node.bears_life_event.field_draft_json_data_file - - field.field.node.bears_life_event.field_draft_json_data_file_path - - field.field.node.bears_life_event.field_header_html - - field.field.node.bears_life_event.field_json_data_file - - field.field.node.bears_life_event.field_json_data_file_path - - field.field.node.bears_life_event.field_language_toggle - - field.field.node.bears_life_event.field_meta_description - - field.field.node.bears_life_event.field_page_intro - - field.field.node.bears_life_event.field_short_description - - field.field.node.bears_life_event.field_summary - - node.type.bears_life_event - module: - - user -id: node.bears_life_event.teaser -targetEntityType: node -bundle: bears_life_event -mode: teaser -content: - content_moderation_control: - settings: { } - third_party_settings: { } - weight: -20 - region: content - links: - settings: { } - third_party_settings: { } - weight: 100 - region: content -hidden: - field_b_id: true - field_b_search_title: true - field_draft_json_data_file: true - field_draft_json_data_file_path: true - field_header_html: true - field_json_data_file: true - field_json_data_file_path: true - field_language_toggle: true - field_meta_description: true - field_page_intro: true - field_short_description: true - field_summary: true - langcode: true diff --git a/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_b_id.yml b/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_b_id.yml deleted file mode 100644 index 1c64ee604..000000000 --- a/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_b_id.yml +++ /dev/null @@ -1,19 +0,0 @@ -uuid: 1d3a2be6-3f91-4d75-8388-e26cde7882d0 -langcode: en -status: true -dependencies: - config: - - field.storage.node.field_b_id - - node.type.bears_life_event -id: node.bears_life_event.field_b_id -field_name: field_b_id -entity_type: node -bundle: bears_life_event -label: ID -description: '' -required: true -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string diff --git a/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_b_search_title.yml b/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_b_search_title.yml deleted file mode 100644 index 2d321559d..000000000 --- a/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_b_search_title.yml +++ /dev/null @@ -1,19 +0,0 @@ -uuid: 4cfe5edb-4b13-42ac-98b0-3cd6416cd289 -langcode: en -status: true -dependencies: - config: - - field.storage.node.field_b_search_title - - node.type.bears_life_event -id: node.bears_life_event.field_b_search_title -field_name: field_b_search_title -entity_type: node -bundle: bears_life_event -label: 'Search Title' -description: '' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string diff --git a/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_meta_description.yml b/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_meta_description.yml deleted file mode 100644 index 49b1522c3..000000000 --- a/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_meta_description.yml +++ /dev/null @@ -1,19 +0,0 @@ -uuid: b3333760-014c-45c3-9ac9-1d5c9a3e6a91 -langcode: en -status: true -dependencies: - config: - - field.storage.node.field_meta_description - - node.type.bears_life_event -id: node.bears_life_event.field_meta_description -field_name: field_meta_description -entity_type: node -bundle: bears_life_event -label: 'Meta Description' -description: 'Text to place in a "meta description" tag on this page. If this field is empty, the Page Intro will be used for the meta description. ' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string_long diff --git a/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_page_intro.yml b/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_page_intro.yml deleted file mode 100644 index aed5f3d4e..000000000 --- a/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_page_intro.yml +++ /dev/null @@ -1,19 +0,0 @@ -uuid: 1f6b04ec-e649-4672-8405-32a594ad93cb -langcode: en -status: true -dependencies: - config: - - field.storage.node.field_page_intro - - node.type.bears_life_event -id: node.bears_life_event.field_page_intro -field_name: field_page_intro -entity_type: node -bundle: bears_life_event -label: 'Page Intro' -description: '' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string_long diff --git a/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_short_description.yml b/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_short_description.yml deleted file mode 100644 index c7d9084e2..000000000 --- a/usagov_benefit_finder/configuration/field.field.node.bears_life_event.field_short_description.yml +++ /dev/null @@ -1,19 +0,0 @@ -uuid: d892bc96-def5-4e8f-9725-d670fdc2c382 -langcode: en -status: true -dependencies: - config: - - field.storage.node.field_short_description - - node.type.bears_life_event -id: node.bears_life_event.field_short_description -field_name: field_short_description -entity_type: node -bundle: bears_life_event -label: 'Short Description' -description: 'The short description appears on cards for the homepage and nav pages. Aim for less than 80 characters. If left blank the page intro will be used.' -required: false -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string_long diff --git a/usagov_benefit_finder/configuration/field.field.node.bears_life_event_form.field_b_id.yml b/usagov_benefit_finder/configuration/field.field.node.bears_life_event_form.field_b_id.yml deleted file mode 100644 index 9bd263382..000000000 --- a/usagov_benefit_finder/configuration/field.field.node.bears_life_event_form.field_b_id.yml +++ /dev/null @@ -1,19 +0,0 @@ -uuid: 27344f9c-03c7-4232-a628-107b8893f3cb -langcode: en -status: true -dependencies: - config: - - field.storage.node.field_b_id - - node.type.bears_life_event_form -id: node.bears_life_event_form.field_b_id -field_name: field_b_id -entity_type: node -bundle: bears_life_event_form -label: ID -description: '' -required: true -translatable: false -default_value: { } -default_value_callback: '' -settings: { } -field_type: string diff --git a/usagov_benefit_finder/configuration/field.field.paragraph.b_levent_relevant_benefit.field_b_life_event_form.yml b/usagov_benefit_finder/configuration/field.field.paragraph.b_levent_relevant_benefit.field_b_life_event_form.yml deleted file mode 100644 index 71829a0d7..000000000 --- a/usagov_benefit_finder/configuration/field.field.paragraph.b_levent_relevant_benefit.field_b_life_event_form.yml +++ /dev/null @@ -1,25 +0,0 @@ -uuid: ec5f36b1-45d7-4c91-b74d-3d8a49dd348f -langcode: en -status: true -dependencies: - config: - - field.storage.paragraph.field_b_life_event_form - - paragraphs.paragraphs_type.b_levent_relevant_benefit -id: paragraph.b_levent_relevant_benefit.field_b_life_event_form -field_name: field_b_life_event_form -entity_type: paragraph -bundle: b_levent_relevant_benefit -label: 'Life Event Form' -description: '' -required: true -translatable: false -default_value: { } -default_value_callback: '' -settings: - handler: views - handler_settings: - view: - view_name: benefit_finder - display_name: entity_reference_3 - arguments: { } -field_type: entity_reference diff --git a/usagov_benefit_finder/configuration/field.storage.node.field_b_search_title.yml b/usagov_benefit_finder/configuration/field.storage.node.field_b_search_title.yml deleted file mode 100644 index 802fb8742..000000000 --- a/usagov_benefit_finder/configuration/field.storage.node.field_b_search_title.yml +++ /dev/null @@ -1,25 +0,0 @@ -uuid: ee685fe0-3e6b-4b9a-8c8a-d1733cd1dabd -langcode: en -status: true -dependencies: - module: - - field_permissions - - node -third_party_settings: - field_permissions: - permission_type: public -id: node.field_b_search_title -field_name: field_b_search_title -entity_type: node -type: string -settings: - max_length: 255 - case_sensitive: false - is_ascii: false -module: core -locked: false -cardinality: 1 -translatable: true -indexes: { } -persist_with_no_fields: false -custom_storage: false diff --git a/usagov_benefit_finder/configuration/usagov_benefit_finder.settings.yml b/usagov_benefit_finder/configuration/usagov_benefit_finder.settings.yml deleted file mode 100644 index e6e3832be..000000000 --- a/usagov_benefit_finder/configuration/usagov_benefit_finder.settings.yml +++ /dev/null @@ -1,3 +0,0 @@ -_core: - default_config_hash: sgIXuoeVJ1TaEzDT2BEh-RcCvmocaPx_0QpNgfRpxQA -automate_json_data_file_generating: true diff --git a/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php b/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php index 7468c4b7b..83c3872d7 100644 --- a/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php +++ b/usagov_benefit_finder/modules/usagov_benefit_finder_api/src/Controller/LifeEventController.php @@ -531,32 +531,31 @@ public function getAgency($nid) { public function getNode($nid, $mode) { $vid = 0; - // Do not use node of moderation state archived. - $id = $this->database - ->query('SELECT id FROM content_moderation_state_field_data - WHERE moderation_state = :mstate AND content_entity_id = :nid', - [':mstate' => 'archived', ':nid' => $nid]) - ->fetchField(); - if ($id) { - return NULL; - } - if ($mode == "published") { - $vid = $this->database - ->query('SELECT MAX(vid) AS vid FROM node_field_revision WHERE status = 1 AND nid = :nid', [':nid' => $nid]) - ->fetchField(); + $query = $this->entityTypeManager->getStorage('node') + ->getQuery() + ->allRevisions() + ->condition('nid', $nid) + ->condition('status', 1) + ->sort('vid', 'DESC') + ->range(0, 1) + ->accessCheck(TRUE); } elseif ($mode == "draft") { - $vid = $this->database - ->query('SELECT MAX(vid) AS vid FROM node_field_revision WHERE nid = :nid', [':nid' => $nid]) - ->fetchField(); - } - else { - // @todo Unknown + $query = $this->entityTypeManager->getStorage('node') + ->getQuery() + ->allRevisions() + ->condition('nid', $nid) + ->sort('vid', 'DESC') + ->range(0, 1) + ->accessCheck(TRUE); } - if ($vid) { - $node = node_revision_load($vid); + $result = $query->execute(); + + if (!empty($result)) { + $revision_id = key($result); + $node = $this->entityTypeManager->getStorage('node')->loadRevision($revision_id); } else { $node = NULL; diff --git a/usagov_benefit_finder/modules/usagov_benefit_finder_content/usagov_benefit_finder_content.module b/usagov_benefit_finder/modules/usagov_benefit_finder_content/usagov_benefit_finder_content.module index 3b192ad52..24cc4d65f 100644 --- a/usagov_benefit_finder/modules/usagov_benefit_finder_content/usagov_benefit_finder_content.module +++ b/usagov_benefit_finder/modules/usagov_benefit_finder_content/usagov_benefit_finder_content.module @@ -389,3 +389,78 @@ function _usagov_benefit_finder_content_check_criteria_has_child(int $nid) { return $return; } + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function usagov_benefit_finder_content_form_node_bears_life_event_form_delete_form_alter(array &$form, FormStateInterface $form_state) { + _usagov_benefit_finder_content_check_life_event_form_usage($form); +} + +/** + * It checks life event form usage in relevant benefit of life event forms. + * If still used, it lists the life event forms and disables the delete confirmation button. + * + * @param array $form + * Form array. + */ +function _usagov_benefit_finder_content_check_life_event_form_usage(array &$form) { + $description = ''; + + $node = \Drupal::routeMatch()->getParameter('node'); + $nid = $node->id(); + + $result = _usagov_benefit_finder_content_check_life_event_form_usage_in_life_event_form($nid); + foreach ($result as $row) { + $description .= "
  • Life event form: $row[title] ($row[nid])
  • "; + } + + if (!empty($description)) { + $description = '
    ' + . 'This life event form cannot be deleted as it is still used in following content:' + . "
      $description
    " + . '
    '; + $form['description']['#markup'] = t($description); + $form['actions']['submit']['#access'] = FALSE; + } +} + +/** + * It checks life event form usage in relevant benefit of life event forms. + * + * @param int $nid + * Node ID of given life event form. + */ +function _usagov_benefit_finder_content_check_life_event_form_usage_in_life_event_form(int $nid) { + $return = []; + + $connection = Database::getConnection(); + + $query = $connection->select('paragraph__field_b_life_event_form', 't'); + $query->fields('t', ['entity_id']); + $query->condition('t.bundle', 'b_levent_relevant_benefit'); + $query->condition('t.field_b_life_event_form_target_id', $nid); + $result = $query->execute(); + + $entity_ids = []; + foreach ($result as $row) { + $entity_ids[] = $row->entity_id; + } + + if (empty($entity_ids)) { + return $return; + } + + $query = $connection->select('node_field_data', 't1'); + $query->join('node__field_b_relevant_benefits', 't2', 't1.nid = t2.entity_id'); + $query->fields('t1', ['title', 'nid']); + $query->condition('t2.field_b_relevant_benefits_target_id', $entity_ids, 'IN'); + $query->orderBy('title'); + $result = $query->execute(); + + foreach ($result as $row) { + $return[] = ['nid' => $row->nid, 'title' => $row->title]; + } + + return $return; +}