From 600c3ad2815f8cceb3516527b47b33c1bde99aaf Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Tue, 4 Jun 2024 12:20:41 -0300 Subject: [PATCH 01/14] Display incidents instead of reports for similar/dissimilar incidents --- .../src/components/incidents/IncidentForm.js | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/site/gatsby-site/src/components/incidents/IncidentForm.js b/site/gatsby-site/src/components/incidents/IncidentForm.js index dbb82972f8..eff4ebfce3 100644 --- a/site/gatsby-site/src/components/incidents/IncidentForm.js +++ b/site/gatsby-site/src/components/incidents/IncidentForm.js @@ -16,6 +16,8 @@ const relatedIncidentIdsQuery = gql` query IncidentWithReports($query: IncidentQueryInput) { incidents(query: $query) { incident_id + title + description reports { report_number title @@ -48,6 +50,7 @@ function IncidentForm() { incident_id_in: [], }, }, + notifyOnNetworkStatusChange: true, }); const selectedSimilarId = useRef(null); @@ -66,15 +69,15 @@ function IncidentForm() { }) ).current; - const similarReportsById = + const similarIncidentsById = similarReportsByIdQuery.loading || similarReportsByIdQuery.error || similarReportsByIdQuery.data.incidents.length == 0 || selectedSimilarId == null ? [] - : similarReportsByIdQuery.data.incidents[0].reports.map((report) => ({ + : similarReportsByIdQuery.data.incidents.map((incident) => ({ incident_id: selectedSimilarId.current, - ...report, + ...incident, })); const editorSimilarIncidentReportsQuery = useQuery(relatedIncidentIdsQuery, { @@ -85,19 +88,19 @@ function IncidentForm() { ), }, }, + notifyOnNetworkStatusChange: true, }); - const editorSimilarIncidentReports = + const editorSimilarIncidents = editorSimilarIncidentReportsQuery.loading || editorSimilarIncidentReportsQuery.error || editorSimilarIncidentReportsQuery.data.incidents.length === 0 ? [] - : editorSimilarIncidentReportsQuery.data.incidents.flatMap((incident) => - incident.reports.map((report) => ({ - ...report, - incident_id: incident.incident_id, - })) - ); + : editorSimilarIncidentReportsQuery.data.incidents.map((incident) => { + return { + ...incident, + }; + }); useEffect(() => { window.location.hash && document.querySelector(window.location.hash).scrollIntoView(); @@ -226,8 +229,8 @@ function IncidentForm() { Date: Wed, 5 Jun 2024 11:45:46 -0300 Subject: [PATCH 02/14] Improve UI for similar incidents and add popovers --- .../gatsby-site/i18n/locales/en/popovers.json | 4 +++ .../gatsby-site/i18n/locales/es/popovers.json | 4 +++ .../gatsby-site/i18n/locales/fr/popovers.json | 4 +++ .../gatsby-site/i18n/locales/ja/popovers.json | 4 +++ .../src/components/RelatedIncidentsArea.js | 14 ++++++-- .../src/components/incidents/IncidentForm.js | 34 +++++++++++-------- 6 files changed, 47 insertions(+), 17 deletions(-) diff --git a/site/gatsby-site/i18n/locales/en/popovers.json b/site/gatsby-site/i18n/locales/en/popovers.json index f3bebfbea1..f70efde010 100644 --- a/site/gatsby-site/i18n/locales/en/popovers.json +++ b/site/gatsby-site/i18n/locales/en/popovers.json @@ -78,5 +78,9 @@ "quiet": { "title": "Quiet", "text": "Quiet reports are those that will not be published in the 'Latest Reports' section of the homepage. Quiet reports are used for reports that are useful for internal data but do not need to be promoted. If you are unsure, leave this field blank." + }, + "similarIncidentSearch": { + "title": "Search for similar incidents", + "text": "Search for a similar or dissimilar incident by typing an incident ID. If the resulting incident is similar click 'Yes', if it's dissimilar click 'No'. If you're not sure click 'Not sure'. Once selected, the incident will be added to the 'Manually-selected similar and dissimilar incidents' section of the form." } } diff --git a/site/gatsby-site/i18n/locales/es/popovers.json b/site/gatsby-site/i18n/locales/es/popovers.json index a7a0c6179f..41e8f24099 100644 --- a/site/gatsby-site/i18n/locales/es/popovers.json +++ b/site/gatsby-site/i18n/locales/es/popovers.json @@ -78,5 +78,9 @@ "quiet": { "title": "¿Es un informe silencioso?", "text": "Los informes silenciosos son aquellos que no se publicarán en la sección 'Últimos informes' de la página de inicio. Los informes silenciosos se utilizan para informes que son útiles para datos internos pero que no necesitan promocionarse. Si no está seguro, deje este campo en blanco." + }, + "similarIncidentSearch": { + "title": "Buscar incidentes similares", + "text": "Busque un incidente similar o diferente escribiendo un ID de incidente. Si el incidente resultante es similar, haga clic en 'Sí', si es diferente, haga clic en 'No'. Si no está seguro, haga clic en 'No estoy seguro'. Una vez seleccionado, el incidente se agregará a la sección del formulario 'Incidentes similares y diferentes seleccionados manualmente'." } } diff --git a/site/gatsby-site/i18n/locales/fr/popovers.json b/site/gatsby-site/i18n/locales/fr/popovers.json index 206584a553..cb93818234 100644 --- a/site/gatsby-site/i18n/locales/fr/popovers.json +++ b/site/gatsby-site/i18n/locales/fr/popovers.json @@ -66,5 +66,9 @@ "quiet": { "title": "Est-ce un rapport silencieux ?", "text": "Les rapports silencieux sont ceux qui ne seront pas publiés dans la section « Derniers rapports » de la page d'accueil. Les rapports silencieux sont utilisés pour les rapports utiles pour les données internes mais qui n'ont pas besoin d'être promus. Si vous n'êtes pas sûr, laissez ce champ vide." + }, + "similarIncidentSearch": { + "title": "Rechercher des incidents similaires", + "text": "Recherchez un incident similaire ou différent en saisissant un ID d'incident. Si l'incident qui en résulte est similaire, cliquez sur « Oui », s'il est différent, cliquez sur « Non ». Si vous n'êtes pas sûr, cliquez sur « Pas sûr ». Une fois sélectionné, l'incident sera ajouté à la section « Incidents similaires et différents sélectionnés manuellement » du formulaire." } } \ No newline at end of file diff --git a/site/gatsby-site/i18n/locales/ja/popovers.json b/site/gatsby-site/i18n/locales/ja/popovers.json index 20daf0a06c..fd66d2a5f6 100644 --- a/site/gatsby-site/i18n/locales/ja/popovers.json +++ b/site/gatsby-site/i18n/locales/ja/popovers.json @@ -74,5 +74,9 @@ "submittersLoggedIn": { "title": "あなたです!", "text": "現在ログイン中なのでこの投稿は自動的にあなたのアカウントに関連づけられます。匿名で投稿するには、ブラウザウィンドウを匿名モードで開いて投稿してください。" + }, + "similarIncidentSearch": { + "title": "類似の事件を検索", + "text": "インシデント ID を入力して、類似または非類似のインシデントを検索します。結果のインシデントが類似している場合は「はい」をクリックし、非類似の場合は「いいえ」をクリックします。不明な場合は「不明」をクリックします。選択すると、インシデントはフォームの「手動で選択された類似および非類似のインシデント」セクションに追加されます。" } } diff --git a/site/gatsby-site/src/components/RelatedIncidentsArea.js b/site/gatsby-site/src/components/RelatedIncidentsArea.js index 91cfadb3d3..96d7911217 100644 --- a/site/gatsby-site/src/components/RelatedIncidentsArea.js +++ b/site/gatsby-site/src/components/RelatedIncidentsArea.js @@ -17,6 +17,7 @@ const RelatedIncidentsArea = ({ editSimilar = true, editId = true, error, + notFoundText = null, }) => { const { t } = useTranslation(); @@ -66,7 +67,9 @@ const RelatedIncidentsArea = ({ return (
- {header} + {loading && ( <> {' '} @@ -146,7 +149,14 @@ const RelatedIncidentsArea = ({
))} {!loading && (error || reports?.length == 0 || incidents?.length == 0) && ( - {error ? error : t('No related reports found.')} + + {error ? error : ''} + + {notFoundText + ? notFoundText + : t(`No related ${!reports ? 'incidents' : 'reports'} found.`)} + + )}
{similarList.length > maxIncidents && ( diff --git a/site/gatsby-site/src/components/incidents/IncidentForm.js b/site/gatsby-site/src/components/incidents/IncidentForm.js index eff4ebfce3..0c8669c8fd 100644 --- a/site/gatsby-site/src/components/incidents/IncidentForm.js +++ b/site/gatsby-site/src/components/incidents/IncidentForm.js @@ -226,14 +226,15 @@ function IncidentForm() {
+
From 19ed85c568d995d172605cf56d99fe24f13adb2a Mon Sep 17 00:00:00 2001 From: Clara Youdale Date: Wed, 5 Jun 2024 13:51:26 -0300 Subject: [PATCH 03/14] Add missing translations --- site/gatsby-site/i18n/locales/es/translation.json | 4 +++- site/gatsby-site/i18n/locales/fr/translation.json | 4 +++- site/gatsby-site/i18n/locales/ja/translation.json | 4 +++- site/gatsby-site/src/components/incidents/IncidentForm.js | 5 ++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/site/gatsby-site/i18n/locales/es/translation.json b/site/gatsby-site/i18n/locales/es/translation.json index 952ca78d69..f15658baa9 100644 --- a/site/gatsby-site/i18n/locales/es/translation.json +++ b/site/gatsby-site/i18n/locales/es/translation.json @@ -563,5 +563,7 @@ "Read the Source": "Leer la Fuente", "Redirecting...": "Redirigiendo", "Random Incident": "Incidente aleatorio", - "Risk Checklists": "Control de Riesgos" + "Risk Checklists": "Control de Riesgos", + "Manually-selected similar and dissimilar incidents": "Incidentes similares y disímiles seleccionados manualmente", + "Search similar/dissimilar Incident Id": "Buscar incidente similar/disímil por ID" } diff --git a/site/gatsby-site/i18n/locales/fr/translation.json b/site/gatsby-site/i18n/locales/fr/translation.json index 6ccf56f411..de2196d1c0 100644 --- a/site/gatsby-site/i18n/locales/fr/translation.json +++ b/site/gatsby-site/i18n/locales/fr/translation.json @@ -550,5 +550,7 @@ "Redirecting...": "En train de rediriger...", "Random Incident": "Incident au hasard", "Read the Source": "Lire la source", - "Risk Checklists": "Contrôle des risques" + "Risk Checklists": "Contrôle des risques", + "Manually-selected similar and dissimilar incidents": "Incidents similaires et dissemblables sélectionnés manuellement", + "Search similar/dissimilar Incident Id": "Rechercher un incident similaire/dissimilaire" } diff --git a/site/gatsby-site/i18n/locales/ja/translation.json b/site/gatsby-site/i18n/locales/ja/translation.json index 037357c3fb..cb947562b2 100644 --- a/site/gatsby-site/i18n/locales/ja/translation.json +++ b/site/gatsby-site/i18n/locales/ja/translation.json @@ -543,5 +543,7 @@ "Read the Source": "情報源を読む", "Redirecting...": "リダイレクト中...", "Random Incident": "おまかせ表示", - "Risk Checklists": "Risk Checklists" + "Risk Checklists": "Risk Checklists", + "Manually-selected similar and dissimilar incidents": "手動で選択された類似および非類似のインシデント", + "Search similar/dissimilar Incident Id": "類似/非類似のインシデントIDを検索" } diff --git a/site/gatsby-site/src/components/incidents/IncidentForm.js b/site/gatsby-site/src/components/incidents/IncidentForm.js index 0c8669c8fd..1a931d5a80 100644 --- a/site/gatsby-site/src/components/incidents/IncidentForm.js +++ b/site/gatsby-site/src/components/incidents/IncidentForm.js @@ -245,7 +245,10 @@ function IncidentForm() {
-