From a2821b604d59c61e4eedb7a77e5d9e5dc9f897f9 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Thu, 25 Apr 2024 16:39:54 -0300 Subject: [PATCH 01/13] Report page for all reports --- .../page-creators/createReportPages.js | 2 +- .../src/components/reports/ReportCard.js | 23 +++++--------- site/gatsby-site/src/templates/report.js | 31 ++++++++++++++++--- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/site/gatsby-site/page-creators/createReportPages.js b/site/gatsby-site/page-creators/createReportPages.js index e66d9a2b29..45aa81ecef 100644 --- a/site/gatsby-site/page-creators/createReportPages.js +++ b/site/gatsby-site/page-creators/createReportPages.js @@ -6,7 +6,7 @@ const createReportPages = async (graphql, createPage, { languages }) => { const result = await graphql( ` query ReportPages { - reports: allMongodbAiidprodReports(filter: { is_incident_report: { eq: false } }) { + reports: allMongodbAiidprodReports { nodes { report_number language diff --git a/site/gatsby-site/src/components/reports/ReportCard.js b/site/gatsby-site/src/components/reports/ReportCard.js index c63be93492..876c1e73b4 100644 --- a/site/gatsby-site/src/components/reports/ReportCard.js +++ b/site/gatsby-site/src/components/reports/ReportCard.js @@ -14,6 +14,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faQuestionCircle } from '@fortawesome/free-solid-svg-icons'; import { hasVariantData } from 'utils/variants'; import { format, fromUnixTime } from 'date-fns'; +import { Link } from 'gatsby'; const ReportCard = ({ item, @@ -46,12 +47,6 @@ const ReportCard = ({ } }; - const toggleReadMoreKeyDown = (e) => { - if (e.key === 'Enter') { - toggleReadMore(); - } - }; - const [isBottomReached, setIsBottomReached] = useState(false); useEffect(() => { @@ -143,14 +138,10 @@ const ReportCard = ({
- {reportTitle ? ( - <>{reportTitle} - ) : ( - - )} + )} +
diff --git a/site/gatsby-site/src/templates/report.js b/site/gatsby-site/src/templates/report.js index ebcb8a62b7..15adfcb9d1 100644 --- a/site/gatsby-site/src/templates/report.js +++ b/site/gatsby-site/src/templates/report.js @@ -4,7 +4,7 @@ import { Trans, useTranslation } from 'react-i18next'; import Container from '../elements/Container'; import SocialShareButtons from '../components/ui/SocialShareButtons'; import { useLocalization } from 'plugins/gatsby-theme-i18n'; -import { graphql } from 'gatsby'; +import { Link, graphql } from 'gatsby'; import ReportCard from 'components/reports/ReportCard'; import { Button } from 'flowbite-react'; import { useUserContext } from 'contexts/userContext'; @@ -13,10 +13,12 @@ import ClassificationsDisplay from 'components/taxa/ClassificationsDisplay'; function ReportPage(props) { const { - data: { report, allMongodbAiidprodTaxa, allMongodbAiidprodClassifications }, + data: { report, allMongodbAiidprodTaxa, allMongodbAiidprodClassifications, incident }, data, } = props; + const incidentId = incident?.incident_id; + const { t } = useTranslation(); const { locale } = useLocalization(); @@ -41,19 +43,33 @@ function ReportPage(props) { data-cy="edit-report" size={'xs'} color="light" - href={`/cite/edit?report_number=${report.report_number}`} + href={`/cite/edit?report_number=${report.report_number}${ + incidentId ? `&incident_id=${incidentId}` : '' + }`} className="hover:no-underline " > Edit ); } - }, []); + }, [loading]); return ( <>
-

{locale == 'en' ? metaTitle : defaultTitle}

+
+

{locale == 'en' ? metaTitle : defaultTitle}

+ {incidentId && ( + + + + )} +
Date: Mon, 29 Apr 2024 14:13:18 -0300 Subject: [PATCH 02/13] Rollback change to test deploy --- site/gatsby-site/page-creators/createReportPages.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/gatsby-site/page-creators/createReportPages.js b/site/gatsby-site/page-creators/createReportPages.js index 45aa81ecef..e66d9a2b29 100644 --- a/site/gatsby-site/page-creators/createReportPages.js +++ b/site/gatsby-site/page-creators/createReportPages.js @@ -6,7 +6,7 @@ const createReportPages = async (graphql, createPage, { languages }) => { const result = await graphql( ` query ReportPages { - reports: allMongodbAiidprodReports { + reports: allMongodbAiidprodReports(filter: { is_incident_report: { eq: false } }) { nodes { report_number language From 785370320eff7cc3ffbf1c428e866df139fecb90 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Mon, 29 Apr 2024 14:41:36 -0300 Subject: [PATCH 03/13] Split into two queries to test deploy --- .../page-creators/createReportPages.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/site/gatsby-site/page-creators/createReportPages.js b/site/gatsby-site/page-creators/createReportPages.js index e66d9a2b29..ff64bcb9e4 100644 --- a/site/gatsby-site/page-creators/createReportPages.js +++ b/site/gatsby-site/page-creators/createReportPages.js @@ -6,7 +6,13 @@ const createReportPages = async (graphql, createPage, { languages }) => { const result = await graphql( ` query ReportPages { - reports: allMongodbAiidprodReports(filter: { is_incident_report: { eq: false } }) { + issueReports: allMongodbAiidprodReports(filter: { is_incident_report: { eq: false } }) { + nodes { + report_number + language + } + } + reports: allMongodbAiidprodReports(filter: { is_incident_report: { eq: true } }) { nodes { report_number language @@ -18,6 +24,7 @@ const createReportPages = async (graphql, createPage, { languages }) => { const { reports: { nodes: reports }, + issueReports: { nodes: issueReports }, } = result.data; const pageContexts = []; @@ -29,6 +36,13 @@ const createReportPages = async (graphql, createPage, { languages }) => { }); } + for (const report of issueReports) { + pageContexts.push({ + report_number: report.report_number, + language: report.language, + }); + } + for (const language of languages) { for (const context of pageContexts) { const pagePath = switchLocalizedPath({ From f7e1550010e268bfcfbf605472657547a71de45f Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 30 Apr 2024 11:26:47 -0300 Subject: [PATCH 04/13] Update build to test creating report pages before build --- .github/workflows/test-build.yml | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index a1ea584841..3af1bca92b 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -61,6 +61,44 @@ jobs: - name: Install Netlify CLI run: npm install netlify-cli -g + - name: Create report pages + run: node createReportPages.js + working-directory: site/gatsby-site + env: + INSTRUMENT: true + NETLIFY_SITE_ID: ${{ vars.NETLIFY_SITE_ID }} + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CYPRESS_PROJECT_ID: ${{ vars.CYPRESS_PROJECT_ID }} + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + E2E_ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }} + E2E_ADMIN_PASSWORD: ${{ secrets.E2E_ADMIN_PASSWORD }} + ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }} + GATSBY_ALGOLIA_APP_ID: ${{ vars.GATSBY_ALGOLIA_APP_ID }} + GATSBY_ALGOLIA_SEARCH_KEY: ${{ vars.GATSBY_ALGOLIA_SEARCH_KEY }} + GATSBY_AVAILABLE_LANGUAGES: ${{ vars.GATSBY_AVAILABLE_LANGUAGES }} + GATSBY_REALM_APP_ID: ${{ vars.GATSBY_REALM_APP_ID }} + GOOGLE_TRANSLATE_API_KEY: ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} + MONGODB_CONNECTION_STRING: ${{ secrets.MONGODB_CONNECTION_STRING }} + MONGODB_REPLICA_SET: ${{ secrets.MONGODB_REPLICA_SET }} + MONGODB_TRANSLATIONS_CONNECTION_STRING: ${{ secrets.MONGODB_TRANSLATIONS_CONNECTION_STRING }} + MONGODB_MIGRATIONS_CONNECTION_STRING: ${{ secrets.MONGODB_MIGRATIONS_CONNECTION_STRING }} + TRANSLATE_SUBMISSION_DATE_START: ${{ vars.TRANSLATE_SUBMISSION_DATE_START }} + GATSBY_REALM_APP_GRAPHQL_URL: ${{ secrets.GATSBY_REALM_APP_GRAPHQL_URL }} + GATSBY_PRISMIC_REPO_NAME: ${{ vars.GATSBY_PRISMIC_REPO_NAME }} + PRISMIC_ACCESS_TOKEN: ${{ secrets.PRISMIC_ACCESS_TOKEN }} + NODE_OPTIONS: --dns-result-order=ipv4first + GATSBY_ROLLBAR_TOKEN: ${{ secrets.GATSBY_ROLLBAR_TOKEN }} + SKIP_PAGE_CREATOR: ${{ vars.SKIP_PAGE_CREATOR }} + CLOUDFLARE_R2_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_R2_ACCOUNT_ID }} + CLOUDFLARE_R2_BUCKET_NAME: ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} + GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL: ${{ vars.GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL }} + CLOUDFLARE_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }} + CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }} + REALM_GRAPHQL_API_KEY: ${{ secrets.REALM_GRAPHQL_API_KEY }} + GATSBY_COMMIT_SHA: ${{ inputs.sha }} + + - name: Build using Netlify run: netlify build --context ${{ inputs.netlify-context }} --offline working-directory: site/gatsby-site From 8c61a3847f46c48897157c1af8468cbc0455193a Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 30 Apr 2024 11:29:33 -0300 Subject: [PATCH 05/13] Update deploy.yml --- .github/workflows/deploy.yml | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6284354a18..9742003358 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -67,6 +67,43 @@ jobs: - name: Install Netlify CLI run: npm install netlify-cli -g + - name: Create report pages + run: node createReportPages.js + working-directory: site/gatsby-site + env: + INSTRUMENT: true + NETLIFY_SITE_ID: ${{ vars.NETLIFY_SITE_ID }} + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CYPRESS_PROJECT_ID: ${{ vars.CYPRESS_PROJECT_ID }} + CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} + E2E_ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }} + E2E_ADMIN_PASSWORD: ${{ secrets.E2E_ADMIN_PASSWORD }} + ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }} + GATSBY_ALGOLIA_APP_ID: ${{ vars.GATSBY_ALGOLIA_APP_ID }} + GATSBY_ALGOLIA_SEARCH_KEY: ${{ vars.GATSBY_ALGOLIA_SEARCH_KEY }} + GATSBY_AVAILABLE_LANGUAGES: ${{ vars.GATSBY_AVAILABLE_LANGUAGES }} + GATSBY_REALM_APP_ID: ${{ vars.GATSBY_REALM_APP_ID }} + GOOGLE_TRANSLATE_API_KEY: ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} + MONGODB_CONNECTION_STRING: ${{ secrets.MONGODB_CONNECTION_STRING }} + MONGODB_REPLICA_SET: ${{ secrets.MONGODB_REPLICA_SET }} + MONGODB_TRANSLATIONS_CONNECTION_STRING: ${{ secrets.MONGODB_TRANSLATIONS_CONNECTION_STRING }} + MONGODB_MIGRATIONS_CONNECTION_STRING: ${{ secrets.MONGODB_MIGRATIONS_CONNECTION_STRING }} + TRANSLATE_SUBMISSION_DATE_START: ${{ vars.TRANSLATE_SUBMISSION_DATE_START }} + GATSBY_REALM_APP_GRAPHQL_URL: ${{ secrets.GATSBY_REALM_APP_GRAPHQL_URL }} + GATSBY_PRISMIC_REPO_NAME: ${{ vars.GATSBY_PRISMIC_REPO_NAME }} + PRISMIC_ACCESS_TOKEN: ${{ secrets.PRISMIC_ACCESS_TOKEN }} + NODE_OPTIONS: --dns-result-order=ipv4first + GATSBY_ROLLBAR_TOKEN: ${{ secrets.GATSBY_ROLLBAR_TOKEN }} + SKIP_PAGE_CREATOR: ${{ vars.SKIP_PAGE_CREATOR }} + CLOUDFLARE_R2_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_R2_ACCOUNT_ID }} + CLOUDFLARE_R2_BUCKET_NAME: ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} + GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL: ${{ vars.GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL }} + CLOUDFLARE_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }} + CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }} + REALM_GRAPHQL_API_KEY: ${{ secrets.REALM_GRAPHQL_API_KEY }} + GATSBY_COMMIT_SHA: ${{ inputs.sha }} + - name: Build using Netlify run: netlify build --context ${{ inputs.netlify-context }} --offline env: From 4b2be5cb0520be899e59916ba8807270f72a6c97 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 30 Apr 2024 12:23:52 -0300 Subject: [PATCH 06/13] Update preview.yml --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 18c748fae9..4998bdde91 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -37,7 +37,7 @@ jobs: secrets: inherit with: sha: ${{ github.event.pull_request.head.sha }} - environment: staging + environment: feature/report-page netlify-context: deploy-preview call-test: From f91f9b773174f407ddbfa0114abd7bf5953e523b Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 30 Apr 2024 12:25:37 -0300 Subject: [PATCH 07/13] Update preview.yml --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 4998bdde91..18c748fae9 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -37,7 +37,7 @@ jobs: secrets: inherit with: sha: ${{ github.event.pull_request.head.sha }} - environment: feature/report-page + environment: staging netlify-context: deploy-preview call-test: From 0c2fca46557bea6c7181649e520be977c6aa24a9 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Thu, 2 May 2024 11:30:51 -0300 Subject: [PATCH 08/13] Add correct link to reports in table view --- .../page-creators/createReportPages.js | 14 --- .../src/components/reports/ReportsTable.js | 11 ++- site/gatsby-site/src/graphql/reports.js | 2 +- site/gatsby-site/src/pages/apps/incidents.js | 93 ++++++++++++++----- 4 files changed, 82 insertions(+), 38 deletions(-) diff --git a/site/gatsby-site/page-creators/createReportPages.js b/site/gatsby-site/page-creators/createReportPages.js index ff64bcb9e4..c5b04be5bd 100644 --- a/site/gatsby-site/page-creators/createReportPages.js +++ b/site/gatsby-site/page-creators/createReportPages.js @@ -12,30 +12,16 @@ const createReportPages = async (graphql, createPage, { languages }) => { language } } - reports: allMongodbAiidprodReports(filter: { is_incident_report: { eq: true } }) { - nodes { - report_number - language - } - } } ` ); const { - reports: { nodes: reports }, issueReports: { nodes: issueReports }, } = result.data; const pageContexts = []; - for (const report of reports) { - pageContexts.push({ - report_number: report.report_number, - language: report.language, - }); - } - for (const report of issueReports) { pageContexts.push({ report_number: report.report_number, diff --git a/site/gatsby-site/src/components/reports/ReportsTable.js b/site/gatsby-site/src/components/reports/ReportsTable.js index b460ffd8c7..ce1f4eabbe 100644 --- a/site/gatsby-site/src/components/reports/ReportsTable.js +++ b/site/gatsby-site/src/components/reports/ReportsTable.js @@ -32,8 +32,15 @@ export default function ReportsTable({ data, isLiveData, setIsLiveData }) { { title: t('Report Number'), accessor: 'report_number', - Cell: ({ row: { values } }) => ( - + Cell: ({ row: { values, original } }) => ( + Report {values.report_number} ), diff --git a/site/gatsby-site/src/graphql/reports.js b/site/gatsby-site/src/graphql/reports.js index 3a197086d3..4b686a5a3f 100644 --- a/site/gatsby-site/src/graphql/reports.js +++ b/site/gatsby-site/src/graphql/reports.js @@ -209,7 +209,7 @@ export const FIND_REPORTS = gql` export const FIND_REPORTS_TABLE = gql` query FindReports($query: ReportQueryInput!) { - reports(query: $query, sort: { report_number: DESC }, limit: 999) { + reports(query: $query, sortBy: REPORT_NUMBER_DESC, limit: 9999) { _id submitters date_published diff --git a/site/gatsby-site/src/pages/apps/incidents.js b/site/gatsby-site/src/pages/apps/incidents.js index 8a48f2ee6b..5b6527512f 100644 --- a/site/gatsby-site/src/pages/apps/incidents.js +++ b/site/gatsby-site/src/pages/apps/incidents.js @@ -83,7 +83,7 @@ const IncidentsPage = ({ data, ...props }) => { break; case 'reports': - if (isLiveData && reports) { + if (isLiveData && reports && !reportsLoading) { setReportsData(transformReports(reports.reports)); } else if (data?.reports?.nodes) { setReportsData(transformReports(data.reports.nodes)); @@ -91,10 +91,57 @@ const IncidentsPage = ({ data, ...props }) => { break; default: } - }, [isLiveData, incidents, data, selectedView]); + }, [isLiveData, incidents, data, selectedView, reportsLoading]); function transformReports(reports) { - return reports.map((report) => ({ + let reportsData = reports; + + // Since we don't currently have report pages for reports, we need to add the incident_id to the reports to create the correct link /cite/:incident_id#r:report_number + if (selectedView === 'reports') { + const incidents = data.reports.nodes; + + if (isLiveData) { + if (data?.reports?.nodes) { + const reportToIncidentMap = []; + + incidents.forEach((incident) => { + incident.reports.forEach((report) => { + reportToIncidentMap[report.report_number] = incident.incident_id; + }); + }); + const updatedReports = reports.map((report) => ({ + ...report, + incident_id: reportToIncidentMap[report.report_number], + })); + + reportsData = updatedReports; + } else { + reportsData = reports; + } + } else { + // Adds the incident_id to reports in order to create the correct link /cite/:incident_id#r:report_number + const reportsMap = new Map(); + + reports.forEach((incident) => { + incident.reports.forEach((report) => { + if (!reportsMap.has(report.report_number) && report.is_incident_report) { + reportsMap.set(report.report_number, { + ...report, + incident_id: incident.incident_id, + }); + } + }); + }); + + const flattenReports = Array.from(reportsMap.values()).sort( + (a, b) => b.report_number - a.report_number + ); + + reportsData = flattenReports; + } + } + + return reportsData.map((report) => ({ ...report, flag: report.flag ? 'Yes' : 'No', is_incident_report: report.is_incident_report ? 'No' : 'Yes', @@ -239,26 +286,30 @@ export const query = graphql` name } } - reports: allMongodbAiidprodReports( - filter: { is_incident_report: { eq: true } } - sort: { report_number: DESC } + + reports: allMongodbAiidprodIncidents( + filter: { reports: { elemMatch: { is_incident_report: { eq: true } } } } + sort: { reports: { report_number: DESC } } ) { nodes { - report_number - title - url - authors - date_downloaded - date_modified - date_published - date_submitted - description - flag - image_url - language - source_domain - submitters - is_incident_report + incident_id + reports { + report_number + title + url + authors + date_downloaded + date_modified + date_published + date_submitted + description + flag + image_url + language + source_domain + submitters + is_incident_report + } } } From 3965388ff2fc258072e5583ba39ec8cb09970e49 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Thu, 2 May 2024 14:20:34 -0300 Subject: [PATCH 09/13] Revert yml and creation changes --- .github/workflows/deploy.yml | 37 ------------------ .github/workflows/test-build.yml | 38 ------------------- .../page-creators/createReportPages.js | 6 +-- 3 files changed, 3 insertions(+), 78 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9742003358..6284354a18 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -67,43 +67,6 @@ jobs: - name: Install Netlify CLI run: npm install netlify-cli -g - - name: Create report pages - run: node createReportPages.js - working-directory: site/gatsby-site - env: - INSTRUMENT: true - NETLIFY_SITE_ID: ${{ vars.NETLIFY_SITE_ID }} - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CYPRESS_PROJECT_ID: ${{ vars.CYPRESS_PROJECT_ID }} - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - E2E_ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }} - E2E_ADMIN_PASSWORD: ${{ secrets.E2E_ADMIN_PASSWORD }} - ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }} - GATSBY_ALGOLIA_APP_ID: ${{ vars.GATSBY_ALGOLIA_APP_ID }} - GATSBY_ALGOLIA_SEARCH_KEY: ${{ vars.GATSBY_ALGOLIA_SEARCH_KEY }} - GATSBY_AVAILABLE_LANGUAGES: ${{ vars.GATSBY_AVAILABLE_LANGUAGES }} - GATSBY_REALM_APP_ID: ${{ vars.GATSBY_REALM_APP_ID }} - GOOGLE_TRANSLATE_API_KEY: ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} - MONGODB_CONNECTION_STRING: ${{ secrets.MONGODB_CONNECTION_STRING }} - MONGODB_REPLICA_SET: ${{ secrets.MONGODB_REPLICA_SET }} - MONGODB_TRANSLATIONS_CONNECTION_STRING: ${{ secrets.MONGODB_TRANSLATIONS_CONNECTION_STRING }} - MONGODB_MIGRATIONS_CONNECTION_STRING: ${{ secrets.MONGODB_MIGRATIONS_CONNECTION_STRING }} - TRANSLATE_SUBMISSION_DATE_START: ${{ vars.TRANSLATE_SUBMISSION_DATE_START }} - GATSBY_REALM_APP_GRAPHQL_URL: ${{ secrets.GATSBY_REALM_APP_GRAPHQL_URL }} - GATSBY_PRISMIC_REPO_NAME: ${{ vars.GATSBY_PRISMIC_REPO_NAME }} - PRISMIC_ACCESS_TOKEN: ${{ secrets.PRISMIC_ACCESS_TOKEN }} - NODE_OPTIONS: --dns-result-order=ipv4first - GATSBY_ROLLBAR_TOKEN: ${{ secrets.GATSBY_ROLLBAR_TOKEN }} - SKIP_PAGE_CREATOR: ${{ vars.SKIP_PAGE_CREATOR }} - CLOUDFLARE_R2_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_R2_ACCOUNT_ID }} - CLOUDFLARE_R2_BUCKET_NAME: ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} - GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL: ${{ vars.GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL }} - CLOUDFLARE_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }} - CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }} - REALM_GRAPHQL_API_KEY: ${{ secrets.REALM_GRAPHQL_API_KEY }} - GATSBY_COMMIT_SHA: ${{ inputs.sha }} - - name: Build using Netlify run: netlify build --context ${{ inputs.netlify-context }} --offline env: diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 3af1bca92b..a1ea584841 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -61,44 +61,6 @@ jobs: - name: Install Netlify CLI run: npm install netlify-cli -g - - name: Create report pages - run: node createReportPages.js - working-directory: site/gatsby-site - env: - INSTRUMENT: true - NETLIFY_SITE_ID: ${{ vars.NETLIFY_SITE_ID }} - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CYPRESS_PROJECT_ID: ${{ vars.CYPRESS_PROJECT_ID }} - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - E2E_ADMIN_USERNAME: ${{ secrets.E2E_ADMIN_USERNAME }} - E2E_ADMIN_PASSWORD: ${{ secrets.E2E_ADMIN_PASSWORD }} - ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }} - GATSBY_ALGOLIA_APP_ID: ${{ vars.GATSBY_ALGOLIA_APP_ID }} - GATSBY_ALGOLIA_SEARCH_KEY: ${{ vars.GATSBY_ALGOLIA_SEARCH_KEY }} - GATSBY_AVAILABLE_LANGUAGES: ${{ vars.GATSBY_AVAILABLE_LANGUAGES }} - GATSBY_REALM_APP_ID: ${{ vars.GATSBY_REALM_APP_ID }} - GOOGLE_TRANSLATE_API_KEY: ${{ secrets.GOOGLE_TRANSLATE_API_KEY }} - MONGODB_CONNECTION_STRING: ${{ secrets.MONGODB_CONNECTION_STRING }} - MONGODB_REPLICA_SET: ${{ secrets.MONGODB_REPLICA_SET }} - MONGODB_TRANSLATIONS_CONNECTION_STRING: ${{ secrets.MONGODB_TRANSLATIONS_CONNECTION_STRING }} - MONGODB_MIGRATIONS_CONNECTION_STRING: ${{ secrets.MONGODB_MIGRATIONS_CONNECTION_STRING }} - TRANSLATE_SUBMISSION_DATE_START: ${{ vars.TRANSLATE_SUBMISSION_DATE_START }} - GATSBY_REALM_APP_GRAPHQL_URL: ${{ secrets.GATSBY_REALM_APP_GRAPHQL_URL }} - GATSBY_PRISMIC_REPO_NAME: ${{ vars.GATSBY_PRISMIC_REPO_NAME }} - PRISMIC_ACCESS_TOKEN: ${{ secrets.PRISMIC_ACCESS_TOKEN }} - NODE_OPTIONS: --dns-result-order=ipv4first - GATSBY_ROLLBAR_TOKEN: ${{ secrets.GATSBY_ROLLBAR_TOKEN }} - SKIP_PAGE_CREATOR: ${{ vars.SKIP_PAGE_CREATOR }} - CLOUDFLARE_R2_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_R2_ACCOUNT_ID }} - CLOUDFLARE_R2_BUCKET_NAME: ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} - GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL: ${{ vars.GATSBY_CLOUDFLARE_R2_PUBLIC_BUCKET_URL }} - CLOUDFLARE_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }} - CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }} - REALM_GRAPHQL_API_KEY: ${{ secrets.REALM_GRAPHQL_API_KEY }} - GATSBY_COMMIT_SHA: ${{ inputs.sha }} - - - name: Build using Netlify run: netlify build --context ${{ inputs.netlify-context }} --offline working-directory: site/gatsby-site diff --git a/site/gatsby-site/page-creators/createReportPages.js b/site/gatsby-site/page-creators/createReportPages.js index c5b04be5bd..e66d9a2b29 100644 --- a/site/gatsby-site/page-creators/createReportPages.js +++ b/site/gatsby-site/page-creators/createReportPages.js @@ -6,7 +6,7 @@ const createReportPages = async (graphql, createPage, { languages }) => { const result = await graphql( ` query ReportPages { - issueReports: allMongodbAiidprodReports(filter: { is_incident_report: { eq: false } }) { + reports: allMongodbAiidprodReports(filter: { is_incident_report: { eq: false } }) { nodes { report_number language @@ -17,12 +17,12 @@ const createReportPages = async (graphql, createPage, { languages }) => { ); const { - issueReports: { nodes: issueReports }, + reports: { nodes: reports }, } = result.data; const pageContexts = []; - for (const report of issueReports) { + for (const report of reports) { pageContexts.push({ report_number: report.report_number, language: report.language, From dcb4efcd06ea164d834ee3c69ffdaa5e4f2d0cde Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 7 May 2024 12:01:37 -0300 Subject: [PATCH 10/13] Check if not live data before fallback --- site/gatsby-site/src/pages/apps/incidents.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/gatsby-site/src/pages/apps/incidents.js b/site/gatsby-site/src/pages/apps/incidents.js index 5b6527512f..324770827a 100644 --- a/site/gatsby-site/src/pages/apps/incidents.js +++ b/site/gatsby-site/src/pages/apps/incidents.js @@ -85,7 +85,7 @@ const IncidentsPage = ({ data, ...props }) => { case 'reports': if (isLiveData && reports && !reportsLoading) { setReportsData(transformReports(reports.reports)); - } else if (data?.reports?.nodes) { + } else if (!isLiveData && data?.reports?.nodes) { setReportsData(transformReports(data.reports.nodes)); } break; @@ -101,7 +101,7 @@ const IncidentsPage = ({ data, ...props }) => { const incidents = data.reports.nodes; if (isLiveData) { - if (data?.reports?.nodes) { + if (incidents) { const reportToIncidentMap = []; incidents.forEach((incident) => { From df318d4991b027810d335e17ff04ea0dbf949812 Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 21 May 2024 16:16:39 -0300 Subject: [PATCH 11/13] Add test for view switch and url check --- .../e2e/integration/apps/incidents.cy.js | 30 +++++++++++++++++++ site/gatsby-site/src/pages/apps/incidents.js | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/site/gatsby-site/cypress/e2e/integration/apps/incidents.cy.js b/site/gatsby-site/cypress/e2e/integration/apps/incidents.cy.js index c77afd1ecc..6689fa88ae 100644 --- a/site/gatsby-site/cypress/e2e/integration/apps/incidents.cy.js +++ b/site/gatsby-site/cypress/e2e/integration/apps/incidents.cy.js @@ -390,6 +390,36 @@ describe('Incidents App', () => { }); }); + conditionalIt(!Cypress.env('isEmptyEnvironment'), 'Should switch between views', () => { + cy.visit(url); + + cy.waitForStableDOM(); + + cy.get('[data-cy="table-view"] button').contains('Issue Reports').click(); + + cy.waitForStableDOM(); + + cy.get('[data-cy="row"]').should('have.length.at.least', 10); + + cy.get('[data-cy="row"] td a') + .first() + .should('have.attr', 'href') + .and('match', /^\/reports\/\d+$/); + + cy.get('[data-cy="table-view"] button') + .contains(/^Reports$/) + .click(); + + cy.waitForStableDOM(); + + cy.get('[data-cy="row"]').should('have.length.at.least', 10); + + cy.get('[data-cy="row"] td a') + .first() + .should('have.attr', 'href') + .and('match', /^\/cite\/\d+#r\d+$/); + }); + conditionalIt( !Cypress.env('isEmptyEnvironment'), 'Should navigate to the last page, and the first page', diff --git a/site/gatsby-site/src/pages/apps/incidents.js b/site/gatsby-site/src/pages/apps/incidents.js index 324770827a..ab718a49f9 100644 --- a/site/gatsby-site/src/pages/apps/incidents.js +++ b/site/gatsby-site/src/pages/apps/incidents.js @@ -151,7 +151,7 @@ const IncidentsPage = ({ data, ...props }) => { return (
- +
- - {reportTitle ? ( - <>{reportTitle} - ) : ( + {reportTitle ? ( + <>{reportTitle} + ) : ( + + )}