From 171a36ca417ebfa3a94a21f350eae891a7486bd8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 13:56:10 +0000 Subject: [PATCH 1/5] Bump eslint-config-prettier from 8.8.0 to 9.0.0 Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 8.8.0 to 9.0.0. - [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/eslint-config-prettier/compare/v8.8.0...v9.0.0) --- updated-dependencies: - dependency-name: eslint-config-prettier dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index a2bea0a8..ca4c81a0 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "dotenv": "^16.3.1", "eslint": "^8.43.0", "eslint-config-airbnb": "^18.2.1", - "eslint-config-prettier": "^8.8.0", + "eslint-config-prettier": "^9.0.0", "eslint-config-react-app": "^7.0.1", "eslint-import-resolver-alias": "^1.1.2", "eslint-plugin-cypress": "^2.14.0", diff --git a/yarn.lock b/yarn.lock index ba9a3da1..3be03bcd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5562,10 +5562,10 @@ eslint-config-airbnb@^18.2.1: object.assign "^4.1.2" object.entries "^1.1.2" -eslint-config-prettier@^8.8.0: - version "8.8.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz#bfda738d412adc917fd7b038857110efe98c9348" - integrity sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA== +eslint-config-prettier@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.0.0.tgz#eb25485946dd0c66cd216a46232dc05451518d1f" + integrity sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw== eslint-config-react-app@^7.0.1: version "7.0.1" From b2be791955e4565d702829b0b59da5cb3251d54e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 12:27:55 +0000 Subject: [PATCH 2/5] Bump prettier from 2.8.8 to 3.1.0 Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.1.0. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.8.8...3.1.0) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 60fe1443..97a2efb3 100644 --- a/package.json +++ b/package.json @@ -138,7 +138,7 @@ "jest-environment-node": "^29.7.0", "jest-location-mock": "^1.0.10", "jest-transformer-svg": "^2.0.1", - "prettier": "^2.8.0", + "prettier": "^3.1.0", "prettier-eslint": "^15.0.1", "prettier-eslint-cli": "^7.1.0", "redux-mock-store": "^1.5.4", diff --git a/yarn.lock b/yarn.lock index 0ddba202..caafc78f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8876,11 +8876,16 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^2.5.1, prettier@^2.8.0: +prettier@^2.5.1: version "2.8.8" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== +prettier@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.0.tgz#c6d16474a5f764ea1a4a373c593b779697744d5e" + integrity sha512-TQLvXjq5IAibjh8EpBIkNKxO749UEWABoiIZehEPiY4GNpVdhaFKqSTu+QrlU6D2dPAfubRmtJTi4K4YkQ5eXw== + pretty-bytes@^5.6.0: version "5.6.0" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.6.0.tgz#356256f643804773c82f64723fe78c92c62beaeb" From 0ae5b11094187195652e2c659250886c8a7e5254 Mon Sep 17 00:00:00 2001 From: Gavin Reynolds Date: Mon, 20 Nov 2023 12:30:53 +0000 Subject: [PATCH 3/5] eslint Signed-off-by: Gavin Reynolds --- cypress/e2e/Incidents/incidents.spec.js | 44 +++++--- cypress/e2e/Search/search.spec.js | 30 +++-- jest.config.js | 4 +- .../subcomponents/PriorityMenu.jsx | 11 +- .../IncidentTable/IncidentTableComponent.jsx | 14 ++- .../subcomponents/ColumnFilterComponent.jsx | 3 +- .../subcomponents/GetAllModal.jsx | 26 +---- .../subcomponents/IncidentAlertsModal.jsx | 90 +++++++-------- .../subcomponents/LatestNoteComponent.jsx | 25 +---- .../subcomponents/LinksComponent.jsx | 4 +- .../subcomponents/NumAlertsComponent.jsx | 106 +++++++++--------- src/config/column-generator.jsx | 6 +- src/redux/incident_actions/sagas.js | 38 +++---- src/redux/incidents/reducers.js | 10 +- 14 files changed, 199 insertions(+), 212 deletions(-) diff --git a/cypress/e2e/Incidents/incidents.spec.js b/cypress/e2e/Incidents/incidents.spec.js index ef7733e4..39029b30 100644 --- a/cypress/e2e/Incidents/incidents.spec.js +++ b/cypress/e2e/Incidents/incidents.spec.js @@ -310,9 +310,7 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => { removeColumns.map((column) => column[1]), ); - const addColumns = [ - ['Num Alerts', 'num_alerts'], - ]; + const addColumns = [['Num Alerts', 'num_alerts']]; manageIncidentTableColumns( 'add', addColumns.map((column) => column[1]), @@ -324,7 +322,9 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => { .should('be.visible') .should('contain', '1'); - cy.get(`[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${incidentIdx}"]`).within(() => { + cy.get( + `[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${incidentIdx}"]`, + ).within(() => { cy.get('[aria-haspopup="dialog"]').realHover(); }); @@ -340,7 +340,9 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => { it('Split/move alert from one incident to a new incident', () => { const incidentIdx = 0; - cy.get(`[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${incidentIdx}"]`).within(() => { + cy.get( + `[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${incidentIdx}"]`, + ).within(() => { cy.get('[aria-haspopup="dialog"]').click(); }); @@ -348,7 +350,9 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => { cy.get('#alerts-modal-move-btn').click(); cy.get('#alerts-modal-move-select').type('Move all selected alerts to one new incident{enter}'); - cy.get('#alerts-modal-move-summary-input').clear().type('New incident created from split alert'); + cy.get('#alerts-modal-move-summary-input') + .clear() + .type('New incident created from split alert'); cy.get('#alerts-modal-complete-move-btn').click(); checkActionAlertsModalContent('Alerts moved'); @@ -368,7 +372,9 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => { waitForIncidentTable(); const incidentIdx = 0; - cy.get(`[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${incidentIdx}"]`).within(() => { + cy.get( + `[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${incidentIdx}"]`, + ).within(() => { cy.get('[aria-haspopup="dialog"]').should('be.visible').should('have.text', '2').click(); }); @@ -376,7 +382,9 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => { selectAlert(1); cy.get('#alerts-modal-move-btn').click(); - cy.get('#alerts-modal-move-select').type('Move each selected alert to its own new incident{enter}'); + cy.get('#alerts-modal-move-select').type( + 'Move each selected alert to its own new incident{enter}', + ); cy.get('#alerts-modal-complete-move-btn').click(); checkActionAlertsModalContent('Alerts moved'); @@ -389,16 +397,20 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => { selectIncident(targetIncidentIdx); cy.get(`@selectedIncidentId_${targetIncidentIdx}`).then((incidentId) => { - cy.get(`[data-incident-header="Num Alerts"][data-incident-cell-id="${incidentId}"]`).within(() => { - cy.get('[aria-haspopup="dialog"]').should('be.visible').should('have.text', '1'); - }); + cy.get(`[data-incident-header="Num Alerts"][data-incident-cell-id="${incidentId}"]`).within( + () => { + cy.get('[aria-haspopup="dialog"]').should('be.visible').should('have.text', '1'); + }, + ); cy.get(`[data-incident-header="Title"][data-incident-cell-id="${incidentId}"]`).within(() => { cy.get('a').invoke('text').as('targetIncidentTitle'); }); }); - cy.get(`[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${sourceIncidentIdx}"]`).within(() => { + cy.get( + `[data-incident-header="Num Alerts"][data-incident-row-cell-idx="${sourceIncidentIdx}"]`, + ).within(() => { cy.get('[aria-haspopup="dialog"]').should('be.visible').should('have.text', '1').click(); }); @@ -415,9 +427,11 @@ describe('Manage Open Incidents', { failFast: { enabled: false } }, () => { waitForIncidentTable(); cy.get(`@selectedIncidentId_${targetIncidentIdx}`).then((incidentId) => { - cy.get(`[data-incident-header="Num Alerts"][data-incident-cell-id="${incidentId}"]`).within(() => { - cy.get('[aria-haspopup="dialog"]').should('be.visible').should('have.text', '2'); - }); + cy.get(`[data-incident-header="Num Alerts"][data-incident-cell-id="${incidentId}"]`).within( + () => { + cy.get('[aria-haspopup="dialog"]').should('be.visible').should('have.text', '2'); + }, + ); }); // Tidy up by resolving the incident with two alerts diff --git a/cypress/e2e/Search/search.spec.js b/cypress/e2e/Search/search.spec.js index a52a5c4d..e3a8f180 100644 --- a/cypress/e2e/Search/search.spec.js +++ b/cypress/e2e/Search/search.spec.js @@ -70,10 +70,17 @@ describe('Search Incidents', { failFast: { enabled: false } }, () => { cy.wait(1000); cy.get('[data-incident-header="Latest Note"]').each(($el) => { // cy.wrap($el).should('have.text', 'foobar'); - cy.wrap($el).find('*').should((subElements) => { - const elementWithFoobar = subElements.toArray().find((el) => el.textContent.includes('foobar')); - assert.isNotNull(elementWithFoobar, 'Expected to find a subelement containing "foobar"'); - }); + cy.wrap($el) + .find('*') + .should((subElements) => { + const elementWithFoobar = subElements + .toArray() + .find((el) => el.textContent.includes('foobar')); + assert.isNotNull( + elementWithFoobar, + 'Expected to find a subelement containing "foobar"', + ); + }); }); }); cy.get('#global-search-input').clear(); @@ -95,10 +102,17 @@ describe('Search Incidents', { failFast: { enabled: false } }, () => { cy.get('#global-search-input').clear().type('foobaz'); cy.wait(1000); cy.get('[data-incident-header="Latest Note"]').each(($el) => { - cy.wrap($el).find('*').should((subElements) => { - const elementWithFoobar = subElements.toArray().find((el) => el.textContent.includes('foobar')); - assert.isNotNull(elementWithFoobar, 'Expected to find a subelement containing "foobar"'); - }); + cy.wrap($el) + .find('*') + .should((subElements) => { + const elementWithFoobar = subElements + .toArray() + .find((el) => el.textContent.includes('foobar')); + assert.isNotNull( + elementWithFoobar, + 'Expected to find a subelement containing "foobar"', + ); + }); }); }); cy.get('#global-search-input').clear(); diff --git a/jest.config.js b/jest.config.js index a844009b..f824c75a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -14,5 +14,7 @@ module.exports = { '^.+\\.(js|jsx|ts|tsx|mjs)$': 'babel-jest', '^.+\\.svg$': 'jest-transformer-svg', }, - transformIgnorePatterns: ['/node_modules/(?!(somePkg)|react-dnd|dnd-core|@react-dnd|jsonpath-plus)'], + transformIgnorePatterns: [ + '/node_modules/(?!(somePkg)|react-dnd|dnd-core|@react-dnd|jsonpath-plus)', + ], }; diff --git a/src/components/IncidentActions/subcomponents/PriorityMenu.jsx b/src/components/IncidentActions/subcomponents/PriorityMenu.jsx index 13a38d66..6712561d 100644 --- a/src/components/IncidentActions/subcomponents/PriorityMenu.jsx +++ b/src/components/IncidentActions/subcomponents/PriorityMenu.jsx @@ -40,11 +40,12 @@ const PriorityMenu = () => { dispatch(updatePriorityConnected(incidents, priorityId)); }; - const enabled = useMemo(() => ( - selectedRows.length > 0 - && Array.isArray(abilities) - && !abilities.includes('disable_edit_priority') - ), [selectedRows]); + const enabled = useMemo( + () => selectedRows.length > 0 + && Array.isArray(abilities) + && !abilities.includes('disable_edit_priority'), + [selectedRows], + ); return ( diff --git a/src/components/IncidentTable/IncidentTableComponent.jsx b/src/components/IncidentTable/IncidentTableComponent.jsx index fe337e57..c98595d4 100644 --- a/src/components/IncidentTable/IncidentTableComponent.jsx +++ b/src/components/IncidentTable/IncidentTableComponent.jsx @@ -21,7 +21,12 @@ import { } from 'react-window'; import { - useTable, useSortBy, useRowSelect, useBlockLayout, useResizeColumns, useFilters, + useTable, + useSortBy, + useRowSelect, + useBlockLayout, + useResizeColumns, + useFilters, } from 'react-table'; import { @@ -290,7 +295,9 @@ const IncidentTableComponent = () => { 0} + isIndeterminate={ + !tableInstance.isAllRowsSelected && tableInstance.selectedFlatRows.length > 0 + } isChecked={tableInstance.isAllRowsSelected} {...getToggleAllRowsSelectedProps()} /> @@ -380,7 +387,8 @@ const IncidentTableComponent = () => { if (inView) { if ( !row.original.alerts - || (Array.isArray(row.original.alerts) && row.original.alerts.length !== row.original.alert_counts?.all) + || (Array.isArray(row.original.alerts) + && row.original.alerts.length !== row.original.alert_counts?.all) ) { getIncidentAlerts(row.original.id); } diff --git a/src/components/IncidentTable/subcomponents/ColumnFilterComponent.jsx b/src/components/IncidentTable/subcomponents/ColumnFilterComponent.jsx index 3693dfe9..ae278826 100644 --- a/src/components/IncidentTable/subcomponents/ColumnFilterComponent.jsx +++ b/src/components/IncidentTable/subcomponents/ColumnFilterComponent.jsx @@ -14,8 +14,7 @@ import { } from '@chakra-ui/react'; import { - IoFunnel, - IoFunnelOutline, + IoFunnel, IoFunnelOutline, } from 'react-icons/io5'; import { diff --git a/src/components/IncidentTable/subcomponents/GetAllModal.jsx b/src/components/IncidentTable/subcomponents/GetAllModal.jsx index 7a3538eb..23176bd0 100644 --- a/src/components/IncidentTable/subcomponents/GetAllModal.jsx +++ b/src/components/IncidentTable/subcomponents/GetAllModal.jsx @@ -46,13 +46,9 @@ const GetAllModal = ({ const rowsFetching = useMemo( () => rowsToExport.filter((row) => { const { - alerts, - notes, + alerts, notes, } = row.original; - return ( - (alerts && alerts.status === 'fetching') - || (notes && notes.status === 'fetching') - ); + return (alerts && alerts.status === 'fetching') || (notes && notes.status === 'fetching'); }), [rowsToExport], ); @@ -60,13 +56,9 @@ const GetAllModal = ({ const rowsDoneFetching = useMemo( () => rowsToExport.filter((row) => { const { - alerts, - notes, + alerts, notes, } = row.original; - return ( - (alerts && alerts instanceof Array) - && (notes && notes instanceof Array) - ); + return alerts && alerts instanceof Array && notes && notes instanceof Array; }), [rowsToExport], ); @@ -79,9 +71,7 @@ const GetAllModal = ({ const fetchRows = useCallback(() => { rowsNeedingFetch.forEach((row) => { const { - id, - notes, - alerts, + id, notes, alerts, } = row.original; if (!notes) { getIncidentNotes(id); @@ -128,11 +118,7 @@ const GetAllModal = ({ {`${rowsFetching.length} remaining`} - + You can close this box and continue using the app, download will continue in the diff --git a/src/components/IncidentTable/subcomponents/IncidentAlertsModal.jsx b/src/components/IncidentTable/subcomponents/IncidentAlertsModal.jsx index 152b2766..0b4c8292 100644 --- a/src/components/IncidentTable/subcomponents/IncidentAlertsModal.jsx +++ b/src/components/IncidentTable/subcomponents/IncidentAlertsModal.jsx @@ -1,9 +1,7 @@ /* eslint-disable no-restricted-syntax */ import React, { - useEffect, - useState, - useMemo, + useEffect, useState, useMemo, } from 'react'; import { @@ -106,16 +104,20 @@ const alertsToCsv = (alerts) => { ]; const header = paths.join(','); - const rows = alerts.map((alert) => paths.map((path) => { - let value = null; - try { - value = path.split('.').reduce((o, i) => o[i], alert); - } catch (e) { /* ignore */ } - if (typeof value === 'string') { - return `"${value.replace(/"/g, '""')}"`; - } - return value; - }).join(',')); + const rows = alerts.map((alert) => paths + .map((path) => { + let value = null; + try { + value = path.split('.').reduce((o, i) => o[i], alert); + } catch (e) { + /* ignore */ + } + if (typeof value === 'string') { + return `"${value.replace(/"/g, '""')}"`; + } + return value; + }) + .join(',')); return `${header}\n${rows.join('\n')}`; }; @@ -128,8 +130,7 @@ const IncidentAlertsModal = () => { showIncidentAlertsModalForIncidentId, } = useSelector((state) => state.settings); const { - filteredIncidentsByQuery, - incidentAlerts, + filteredIncidentsByQuery, incidentAlerts, } = useSelector((state) => state.incidents); const serviceList = useSelector((state) => state.services.services); const serviceListOptions = useMemo(() => { @@ -184,7 +185,9 @@ const IncidentAlertsModal = () => { dispatch(moveAlertsConnected(fromIncidentId, toIncidentId, alertsToMove, options)); }; - const incident = filteredIncidentsByQuery.find((i) => i.id === showIncidentAlertsModalForIncidentId); + const incident = filteredIncidentsByQuery.find( + (i) => i.id === showIncidentAlertsModalForIncidentId, + ); const alerts = incidentAlerts[showIncidentAlertsModalForIncidentId]; const moveToNewIncidentOptions = { @@ -278,8 +281,9 @@ const IncidentAlertsModal = () => { id="alerts-modal-checkbox-all" isChecked={selectedAlerts.length === alertsSortedDescendingDate.length} isIndeterminate={ - selectedAlerts.length > 0 && selectedAlerts.length < alertsSortedDescendingDate.length - } + selectedAlerts.length > 0 + && selectedAlerts.length < alertsSortedDescendingDate.length + } onChange={(e) => { if (e.target.checked) { setSelectedAlerts(alertsSortedDescendingDate.map((alert) => alert.id)); @@ -320,12 +324,7 @@ const IncidentAlertsModal = () => { )} - + {alert.summary} @@ -343,7 +342,9 @@ const IncidentAlertsModal = () => { mr={3} onClick={() => { const alertsCsv = alertsToCsv( - alerts.filter((a) => selectedAlerts.length === 0 || selectedAlerts.includes(a.id)), + alerts.filter( + (a) => selectedAlerts.length === 0 || selectedAlerts.includes(a.id), + ), ); const blob = new Blob([alertsCsv], { type: 'text/csv;charset=utf-8;' }); const url = URL.createObjectURL(blob); @@ -382,11 +383,7 @@ const IncidentAlertsModal = () => { - setShowMoveModal(false)} - size="xl" - > + setShowMoveModal(false)} size="xl"> @@ -395,9 +392,7 @@ const IncidentAlertsModal = () => { - - {t('Move to')} - + {t('Move to')} { /> - - {t('Service')} - + {t('Service')} { ? priorityListOptions.find((s) => s.value === incident.priority.id) : priorityListOptions.find((s) => s.value === '--') } - onChange={ - (selected) => setMoveTargetOptions((prev) => ({ ...prev, priorityId: selected.value })) - } + onChange={(selected) => setMoveTargetOptions((prev) => ({ ...prev, priorityId: selected.value }))} placeholder={`${t('Select dotdotdot')}`} chakraStyles={{ // Ensure that dropdowns appear over table header diff --git a/src/components/IncidentTable/subcomponents/LatestNoteComponent.jsx b/src/components/IncidentTable/subcomponents/LatestNoteComponent.jsx index 1e14257f..3de283b2 100644 --- a/src/components/IncidentTable/subcomponents/LatestNoteComponent.jsx +++ b/src/components/IncidentTable/subcomponents/LatestNoteComponent.jsx @@ -1,6 +1,5 @@ import React, { - useRef, - useState, + useRef, useState, } from 'react'; import { @@ -24,8 +23,7 @@ import { } from '@chakra-ui/react'; import { - AddIcon, - CheckIcon, + AddIcon, CheckIcon, } from '@chakra-ui/icons'; import i18next from 'i18next'; @@ -44,9 +42,7 @@ const LatestNoteComponent = ({ const noteRef = useRef(null); const [note, setNote] = useState(''); const { - isOpen, - onToggle, - onClose, + isOpen, onToggle, onClose, } = useDisclosure(); const dispatch = useDispatch(); const addNote = (incidents, noteContent) => dispatch(addNoteConnected(incidents, noteContent, true, false)); @@ -59,21 +55,14 @@ const LatestNoteComponent = ({ alignItems="center" justifyContent="space-between" > - + {incident.notes?.length > 0 && incident.notes.slice(-1)[0].content} {incident.notes?.length === 0 && '--'} {incident.notes?.status === 'fetching' && fetching} - + - - {i18next.t('Add Note')} - + {i18next.t('Add Note')}