From 633b7acd80b531273796bb286ebc2e3ba60437d7 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Mon, 31 Jul 2023 08:59:17 -0400 Subject: [PATCH 01/12] fix: Shared Stops CSV Entry Support --- lib/manager/components/ProjectSettingsForm.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/manager/components/ProjectSettingsForm.js b/lib/manager/components/ProjectSettingsForm.js index 3977560ff..f0f356a1b 100644 --- a/lib/manager/components/ProjectSettingsForm.js +++ b/lib/manager/components/ProjectSettingsForm.js @@ -39,7 +39,8 @@ type ProjectModel = { defaultTimeZone?: string, id?: string, name?: string, - peliasWebhookUrl?: string + peliasWebhookUrl?: string, + sharedStopsConfig?: string } type Props = { @@ -223,6 +224,7 @@ export default class ProjectSettingsForm extends Component { return Object.keys(validation).every(k => validation[k]) } + // eslint-disable-next-line complexity render () { const {editDisabled, showDangerZone} = this.props const {model, validation} = this.state @@ -324,6 +326,24 @@ export default class ProjectSettingsForm extends Component { + + Shared Stops + + + + {/* TODO: on enter, textarea should NOT submit */} + + + + + {this.messages('fields.localPlacesIndex.title')} From f090ea52c626265ba14fdeb2dcdca517d0fabd86 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Mon, 31 Jul 2023 09:36:49 -0400 Subject: [PATCH 02/12] chore: fix flow types --- __tests__/test-utils/mock-data/manager.js | 1 + lib/manager/components/ProjectSettingsForm.js | 1 + lib/types/index.js | 1 + 3 files changed, 3 insertions(+) diff --git a/__tests__/test-utils/mock-data/manager.js b/__tests__/test-utils/mock-data/manager.js index 61a5da7a3..e60d5fffd 100644 --- a/__tests__/test-utils/mock-data/manager.js +++ b/__tests__/test-utils/mock-data/manager.js @@ -116,6 +116,7 @@ export const mockProject = { updaters: null, walkSpeed: null }, + sharedStopsConfig: null, useCustomOsmBounds: false, user: null } diff --git a/lib/manager/components/ProjectSettingsForm.js b/lib/manager/components/ProjectSettingsForm.js index f0f356a1b..acdd55cbf 100644 --- a/lib/manager/components/ProjectSettingsForm.js +++ b/lib/manager/components/ProjectSettingsForm.js @@ -332,6 +332,7 @@ export default class ProjectSettingsForm extends Component { {/* TODO: on enter, textarea should NOT submit */} + {/* TODO: Validate CSV? */} Date: Mon, 31 Jul 2023 09:42:15 -0400 Subject: [PATCH 03/12] test: update snapshots --- .../actions/__tests__/__snapshots__/projects.js.snap | 1 + .../__tests__/__snapshots__/ActiveProjectViewer.js.snap | 8 ++++++++ .../__tests__/__snapshots__/DeploymentsPanel.js.snap | 5 +++++ .../__tests__/__snapshots__/FeedSourceTable.js.snap | 9 +++++++++ 4 files changed, 23 insertions(+) diff --git a/lib/manager/actions/__tests__/__snapshots__/projects.js.snap b/lib/manager/actions/__tests__/__snapshots__/projects.js.snap index 4ccf98c3d..86704af54 100644 --- a/lib/manager/actions/__tests__/__snapshots__/projects.js.snap +++ b/lib/manager/actions/__tests__/__snapshots__/projects.js.snap @@ -98,6 +98,7 @@ Object { "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, }, diff --git a/lib/manager/containers/__tests__/__snapshots__/ActiveProjectViewer.js.snap b/lib/manager/containers/__tests__/__snapshots__/ActiveProjectViewer.js.snap index 2463f87d1..8724597fc 100644 --- a/lib/manager/containers/__tests__/__snapshots__/ActiveProjectViewer.js.snap +++ b/lib/manager/containers/__tests__/__snapshots__/ActiveProjectViewer.js.snap @@ -84,6 +84,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -2035,6 +2036,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -2084,6 +2086,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -2223,6 +2226,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -2294,6 +2298,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -4224,6 +4229,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -4350,6 +4356,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -4435,6 +4442,7 @@ exports[`lib > manager > ActiveProjectViewer should render with newly created pr "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } diff --git a/lib/manager/containers/__tests__/__snapshots__/DeploymentsPanel.js.snap b/lib/manager/containers/__tests__/__snapshots__/DeploymentsPanel.js.snap index 0c58ddea2..f7d57ddcd 100644 --- a/lib/manager/containers/__tests__/__snapshots__/DeploymentsPanel.js.snap +++ b/lib/manager/containers/__tests__/__snapshots__/DeploymentsPanel.js.snap @@ -245,6 +245,7 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -484,6 +485,7 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -945,6 +947,7 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -1430,6 +1433,7 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -1841,6 +1845,7 @@ exports[`lib > manager > DeploymentsPanel should render with the list of deploym "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } diff --git a/lib/manager/containers/__tests__/__snapshots__/FeedSourceTable.js.snap b/lib/manager/containers/__tests__/__snapshots__/FeedSourceTable.js.snap index 892a97c4c..d1f001c26 100644 --- a/lib/manager/containers/__tests__/__snapshots__/FeedSourceTable.js.snap +++ b/lib/manager/containers/__tests__/__snapshots__/FeedSourceTable.js.snap @@ -209,6 +209,7 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -511,6 +512,7 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -807,6 +809,7 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -1036,6 +1039,7 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -3164,6 +3168,7 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -3439,6 +3444,7 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -3767,6 +3773,7 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -4169,6 +4176,7 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } @@ -4589,6 +4597,7 @@ exports[`lib > manager > FeedSourceTable should render with a project with feeds "updaters": null, "walkSpeed": null, }, + "sharedStopsConfig": null, "useCustomOsmBounds": false, "user": null, } From c72dcf55be94fa569a3569fcf12dd7170e4ad655 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Fri, 11 Aug 2023 13:26:22 -0400 Subject: [PATCH 04/12] refactor: address pr feedback --- i18n/english.yml | 3 +++ lib/manager/components/ProjectSettingsForm.js | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/i18n/english.yml b/i18n/english.yml index c631577d3..a90f603f5 100644 --- a/i18n/english.yml +++ b/i18n/english.yml @@ -972,6 +972,9 @@ components: defaultLocation: 'Default location (lat, lng)' defaultTimeZone: Default time zone title: Location + sharedStops: + title: Shared Stops + placeholder: Shared stops config CSV name: Project name title: General updates: diff --git a/lib/manager/components/ProjectSettingsForm.js b/lib/manager/components/ProjectSettingsForm.js index acdd55cbf..ea6e6d957 100644 --- a/lib/manager/components/ProjectSettingsForm.js +++ b/lib/manager/components/ProjectSettingsForm.js @@ -327,11 +327,14 @@ export default class ProjectSettingsForm extends Component { - Shared Stops + {this.messages('fields.sharedStops.title')} - {/* TODO: on enter, textarea should NOT submit */} + {/* TODO: on enter, textarea should NOT submit. This causes strange behavior when + editing in the textarea + + see: https://github.com/ibi-group/datatools-ui/pull/977#discussion_r1288916749 */} {/* TODO: Validate CSV? */} { value={model.sharedStopsConfig || ''} style={{height: model.sharedStopsConfig ? 200 : 150}} componentClass='textarea' - placeholder='Shared stops config CSV' + placeholder={this.messages('fields.sharedStops.placeholder')} /> From 279d14c8b0f0f5d54d9525928b5085c4307c9d93 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Fri, 11 Aug 2023 14:10:53 -0400 Subject: [PATCH 05/12] refactor: use shared CustomCSVForm element --- lib/manager/components/ProjectSettingsForm.js | 14 ++++++++------ lib/manager/components/transform/CustomCSVForm.js | 13 ++++++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/manager/components/ProjectSettingsForm.js b/lib/manager/components/ProjectSettingsForm.js index ea6e6d957..493e1a94e 100644 --- a/lib/manager/components/ProjectSettingsForm.js +++ b/lib/manager/components/ProjectSettingsForm.js @@ -31,6 +31,8 @@ import { parseBounds, validationState } from '../util' import type { Bounds, Project } from '../../types' import type { ManagerUserState } from '../../types/reducers' +import CustomCSVForm from './transform/CustomCSVForm' + type ProjectModel = { autoFetchFeeds?: boolean, autoFetchHour?: number, @@ -336,13 +338,13 @@ export default class ProjectSettingsForm extends Component { see: https://github.com/ibi-group/datatools-ui/pull/977#discussion_r1288916749 */} {/* TODO: Validate CSV? */} - this._onChangeTextInput(e)} + onSaveCsvData={() => { alert('save') }} /> diff --git a/lib/manager/components/transform/CustomCSVForm.js b/lib/manager/components/transform/CustomCSVForm.js index e2144e492..1aac36e0b 100644 --- a/lib/manager/components/transform/CustomCSVForm.js +++ b/lib/manager/components/transform/CustomCSVForm.js @@ -6,15 +6,17 @@ import { Button } from 'react-bootstrap' import { getComponentMessages } from '../../../common/util/config' type Props = { - buttonText: string, + buttonText: ?string, csvData: ?string, headerText: string, - inputIsSame: boolean, + hideSaveButton: ?boolean, + inputIsSame: ?boolean, + name: ?string, onChangeCsvData: (SyntheticInputEvent) => void, onSaveCsvData: () => void, } const CustomCSVForm = (props: Props) => { - const { buttonText, csvData, headerText, inputIsSame, onChangeCsvData, onSaveCsvData } = props + const { buttonText, csvData, headerText, hideSaveButton, inputIsSame, name, onChangeCsvData, onSaveCsvData } = props const numLines = !csvData ? 0 : csvData.split(/\r*\n/).length const messages = getComponentMessages('CustomCSVForm') @@ -32,6 +34,7 @@ const CustomCSVForm = (props: Props) => { {headerText}