From 28269ec4c7765a9bdffca4f3c2f52e2f87e8fd8c Mon Sep 17 00:00:00 2001 From: Mansoor Sajjad Date: Mon, 29 Apr 2024 06:51:02 +0200 Subject: [PATCH] Remove unused features and adjust features for rb and non-rb providers. (#230) Remove unused features and adjust features for rb and non-rb providers. --- src/actions/SuppliersActions.js | 47 --- src/actions/actionTypes.js | 1 - src/modals/ModalEditProvider.js | 267 +++++++++--------- src/reducers/SuppliersReducer.js | 4 - .../components/DataMigrationDetails.js | 2 + .../components/SupplierTabWrapper.js | 32 --- 6 files changed, 129 insertions(+), 224 deletions(-) diff --git a/src/actions/SuppliersActions.js b/src/actions/SuppliersActions.js index af87be7a..8b83e7af 100644 --- a/src/actions/SuppliersActions.js +++ b/src/actions/SuppliersActions.js @@ -144,47 +144,6 @@ SuppliersActions.executePeliasTask = tasks => async (dispatch, getState) => { }); }; -SuppliersActions.uploadFiles = (files, providerId) => async ( - dispatch, - getState -) => { - dispatch(sendData(0, types.UPDATED_FILE_UPLOAD_PROGRESS)); - - const url = `${window.config.timetableAdminBaseUrl}${providerId}/files`; - - var data = new FormData(); - - files.forEach(file => { - data.append('files', file); - }); - - var config = { - onUploadProgress: function(progressEvent) { - let percentCompleted = (progressEvent.loaded / progressEvent.total) * 100; - dispatch(sendData(percentCompleted, types.UPDATED_FILE_UPLOAD_PROGRESS)); - }, - ...(await getApiConfig(getState().UserReducer.auth)) - }; - - return axios - .post(url, data, config) - .then(function(response) { - dispatch(SuppliersActions.addNotification('Uploaded file(s)', 'success')); - dispatch( - SuppliersActions.logEvent({ - title: 'Uploaded file(s): ' + files.join(',') - }) - ); - dispatch(sendData(0, types.UPDATED_FILE_UPLOAD_PROGRESS)); - }) - .catch(function(response) { - dispatch( - SuppliersActions.addNotification('Unable to upload file(s)', 'error') - ); - dispatch(sendData(0, types.UPDATED_FILE_UPLOAD_PROGRESS)); - }); -}; - SuppliersActions.uploadTariffZonesFiles = (files, provider) => async ( dispatch, getState @@ -387,17 +346,11 @@ const getProviderPayload = data => { referential: trimmedData._referential, organisation: trimmedData._organisation, user: trimmedData._user, - dataFormat: trimmedData._dataFormat, - enableValidation: trimmedData._enableValidation, allowCreateMissingStopPlace: trimmedData._allowCreateMissingStopPlace, - enableStopPlaceIdMapping: trimmedData._enableStopPlaceIdMapping, - enableCleanImport: trimmedData._enableCleanImport, generateDatedServiceJourneyIds: trimmedData._generateDatedServiceJourneyIds, generateMissingServiceLinksForModes: trimmedData._generateMissingServiceLinksForModes, - googleUpload: trimmedData._googleUpload, - googleQAUpload: trimmedData._googleQAUpload, migrateDataToProvider: trimmedData._migrateDataToProvider, enableAutoImport: trimmedData._enableAutoImport, enableAutoValidation: trimmedData._enableAutoValidation, diff --git a/src/actions/actionTypes.js b/src/actions/actionTypes.js index 7c2961eb..aa982c4b 100644 --- a/src/actions/actionTypes.js +++ b/src/actions/actionTypes.js @@ -166,7 +166,6 @@ export const ERRORS_SUPPLIERS = 'ERRORS_SUPPLIERS'; export const REQUESTED_ALL_SUPPLIERS_STATUS = 'REQUESTED_ALL_SUPPLIERS_STATUS'; export const RECEIVED_ALL_SUPPLIERS_STATUS = 'RECEIVED_ALL_SUPPLIERS_STATUS'; -export const UPDATED_FILE_UPLOAD_PROGRESS = 'UPDATED_FILE_UPLOAD_PROGRESS'; export const UPDATED_TARIFF_ZONE_FILE_UPLOAD_PROGRESS = 'UPDATED_TARIFF_ZONE_FILE_UPLOAD_PROGRESS'; diff --git a/src/modals/ModalEditProvider.js b/src/modals/ModalEditProvider.js index 326c5857..b77db5b4 100644 --- a/src/modals/ModalEditProvider.js +++ b/src/modals/ModalEditProvider.js @@ -24,6 +24,15 @@ import FlatButton from 'material-ui/FlatButton'; import { connect } from 'react-redux'; import SuppliersActions from 'actions/SuppliersActions'; import TransportModesPopover from './TransportModesPopover'; +import { Tooltip } from '@material-ui/core'; +import HelpOutlineIcon from '@material-ui/icons/HelpOutline'; +import { withStyles } from '@material-ui/core/styles'; + +const LightTooltip = withStyles(() => ({ + tooltip: { + fontSize: 12 + } +}))(Tooltip); const getEmptyForm = () => ({ _providerId: null, @@ -34,15 +43,9 @@ const getEmptyForm = () => ({ _referential: '', _organisation: '', _user: '', - _dataFormat: '', - _enableValidation: false, _allowCreateMissingStopPlace: false, - _enableStopPlaceIdMapping: false, - _enableCleanImport: false, _generateDatedServiceJourneyIds: false, _generateMissingServiceLinksForModes: [], - _googleUpload: false, - _googleQAUpload: false, _migrateDataToProvider: null, _enableAutoImport: false, _enableAutoValidation: false, @@ -86,15 +89,9 @@ class ModalEditProvider extends Component { referential, organisation, user, - dataFormat, - enableValidation, allowCreateMissingStopPlace, - enableStopPlaceIdMapping, - enableCleanImport, generateDatedServiceJourneyIds, generateMissingServiceLinksForModes, - googleUpload, - googleQAUpload, migrateDataToProvider, enableAutoImport, enableAutoValidation, @@ -109,15 +106,9 @@ class ModalEditProvider extends Component { _referential: referential, _organisation: organisation, _user: user, - _dataFormat: dataFormat, - _enableValidation: enableValidation, _allowCreateMissingStopPlace: allowCreateMissingStopPlace, - _enableStopPlaceIdMapping: enableStopPlaceIdMapping, - _enableCleanImport: enableCleanImport, _generateDatedServiceJourneyIds: generateDatedServiceJourneyIds, _generateMissingServiceLinksForModes: generateMissingServiceLinksForModes, - _googleUpload: googleUpload, - _googleQAUpload: googleQAUpload, _migrateDataToProvider: migrateDataToProvider, _enableAutoImport: enableAutoImport, _enableAutoValidation: enableAutoValidation, @@ -146,21 +137,6 @@ class ModalEditProvider extends Component { return provider && provider.id && shouldUpdate; } - getDataFormats() { - const formats = [ - { value: '', text: 'None' }, - { value: 'netexprofile', text: 'NeTEx Profile' }, - { value: 'gtfs', text: 'GTFS' } - ]; - return formats.map(format => ( - - )); - } - handleCheckTransportMode(transportMode, isChecked) { let transportModes = this.state.form._generateMissingServiceLinksForModes; var idx = transportModes.indexOf(transportMode); @@ -208,6 +184,16 @@ class ModalEditProvider extends Component { } } + toolTip(title) { + return ( + + + + + + ); + } + render() { const { open, providers, handleClose, allTransportModes } = this.props; @@ -216,7 +202,6 @@ class ModalEditProvider extends Component { const { errors } = this.state; const title = this.getTitle(); - const dataFormats = this.getDataFormats(); const isEdit = this.isEdit(); const rowStyle = { @@ -225,6 +210,11 @@ class ModalEditProvider extends Component { alignItems: 'center' }; + const formElement = { + display: 'flex', + alignItems: 'center' + }; + const actions = [ -
- { - this.handleChange('_dataFormat', v); - }} - > - {dataFormats} - -
+ + {this.state.form._referential.indexOf('rb_') !== 0 && ( + <> +
+ +
+
+
+ + this.handleChange('_allowCreateMissingStopPlace', v) + } + /> + {this.toolTip( + 'Allow Chouette to create new stop places in its database. ' + + 'Since stop places should be already present in the Chouette database (imported from NSR) the default setting is "off". ' + + 'Used only when testing non-Norwegian datasets' + )} +
+
+
+
+ this.handleChange('_enableAutoImport', v)} + /> + {this.toolTip( + 'Automatically trigger the import pipeline after a file delivery, ' + + 'either through the operator portal or the HTTP endpoint. ' + + 'If disabled the received file is saved in the file storage but not imported' + )} +
+
+
+
+ + this.handleChange('_generateDatedServiceJourneyIds', v) + } + /> + {this.toolTip( + 'Deprecated. Generates a dated NeTEx export to be processed by Namtar' + )} +
+
+ + )}
- -
-
- - this.handleChange('_allowCreateMissingStopPlace', v) - } - /> - - this.handleChange('_enableStopPlaceIdMapping', v) - } - /> -
-
- this.handleChange('_enableCleanImport', v)} - /> - this.handleChange('_enableValidation', v)} - /> -
-
- this.handleChange('_enableAutoImport', v)} - /> - this.handleChange('_enableAutoValidation', v)} - /> -
-
- this.handleChange('_googleUpload', v)} - /> - this.handleChange('_googleQAUpload', v)} - /> -
-
- - this.handleChange('_generateDatedServiceJourneyIds', v) - } - /> - this.handleChange('_enableBlocksExport', v)} - /> +
+ this.handleChange('_enableAutoValidation', v)} + /> + {this.toolTip( + this.state.form._referential.indexOf('rb_') !== 0 + ? 'Allow Chouette to create new stop places in its database. ' + + 'Since stop places should be already present in the Chouette database (imported from NSR) the default setting is "off". ' + + 'Used only when testing non-Norwegian datasets' + : 'Enable nightly automatic triggering of "validation Level 2" steps. ' + + 'This option does not affect the execution of the "validation Level 2" step triggered by a file delivery.' + )} +
+ {this.state.form._referential.indexOf('rb_') === 0 && ( +
+
+ this.handleChange('_enableBlocksExport', v)} + /> + {this.toolTip( + 'When activated, a second NeTEx export is generated, ' + + 'that will include private/sensitive data ' + + '(Blocks, DeadRuns, ServiceJourneys marked with publication=restricted). ' + + 'This export is accessible only through a private, authorized API.' + )} +
+
+ )} ); } } + const mapStateToProps = state => ({ allTransportModes: state.SuppliersReducer.allTransportModes }); diff --git a/src/reducers/SuppliersReducer.js b/src/reducers/SuppliersReducer.js index a13d52a7..8371dfe8 100644 --- a/src/reducers/SuppliersReducer.js +++ b/src/reducers/SuppliersReducer.js @@ -22,7 +22,6 @@ const initialState = { statusListAllProviders: [], all_suppliers_selected: true, activeId: 0, - fileUploadProgress: 0, allTransportModes: [], exportedFiles: null }; @@ -91,9 +90,6 @@ const SuppliersReducer = (state = initialState, action) => { statusListAllProviders: action.payLoad }); - case types.UPDATED_FILE_UPLOAD_PROGRESS: - return Object.assign({}, state, { fileUploadProgress: action.payLoad }); - case types.UPDATED_TARIFF_ZONE_FILE_UPLOAD_PROGRESS: return Object.assign({}, state, { tariffZoneFileUploadProgress: action.payLoad diff --git a/src/screens/providers/components/DataMigrationDetails.js b/src/screens/providers/components/DataMigrationDetails.js index 3032bf0a..75ddcd79 100644 --- a/src/screens/providers/components/DataMigrationDetails.js +++ b/src/screens/providers/components/DataMigrationDetails.js @@ -439,6 +439,8 @@ class DataMigrationDetails extends React.Component { provider.chouetteInfo && provider.chouetteInfo.enableCleanImport && outboundFiles.length > 1 + // TODO: enableCleanImport is removed, hva skjer her? + // Can we import multiple files now? ) { alert( 'Clean before import enabled, does not make sense to import multiple files' diff --git a/src/screens/providers/components/SupplierTabWrapper.js b/src/screens/providers/components/SupplierTabWrapper.js index 31ca7300..c08127b7 100644 --- a/src/screens/providers/components/SupplierTabWrapper.js +++ b/src/screens/providers/components/SupplierTabWrapper.js @@ -180,33 +180,11 @@ class SupplierTabWrapper extends React.Component { this.onTabChangeForAllProviders(0, 'migrateData', null, null); return 0; } - case 'uploadFiles': { - if (displayAllSuppliers) { - this.onTabChangeForAllProviders(0, 'chouetteJobs', null, null); - return 0; - } else { - return 4; - } - } default: return 0; } } - handleFileUpload(files) { - const { dispatch, activeId } = this.props; - dispatch(SuppliersActions.uploadFiles(files, activeId)); - } - - handleRefreshAllProviders() { - this.props.dispatch(SuppliersActions.getAllProviderStatus()); - } - - handleRefreshActiveProvider() { - const { dispatch, activeId } = this.props; - dispatch(SuppliersActions.getProviderStatus(activeId)); - } - componentDidUpdate() { const tabIndexFromParams = this.getTabIndexFromParams(); const { allProvidersTabs } = this.refs; @@ -237,7 +215,6 @@ class SupplierTabWrapper extends React.Component { activeId, suppliers, fileListIsLoading, - fileUploadProgress, auth } = this.props; @@ -402,14 +379,6 @@ class SupplierTabWrapper extends React.Component { /> )} - -
- -
-
); } @@ -432,7 +401,6 @@ const mapStateToProps = state => ({ displayAllSuppliers: state.SuppliersReducer.all_suppliers_selected, providerEvents: state.SuppliersReducer.statusList, allProvidersEvents: state.SuppliersReducer.statusListAllProviders, - fileUploadProgress: state.SuppliersReducer.fileUploadProgress, auth: state.UserReducer.auth });