From 47787389c36814825173418b58eafe41737d08d7 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Fri, 13 Dec 2024 11:49:26 -0500 Subject: [PATCH] remove project-wide deployment settings --- lib/manager/components/ProjectSettings.js | 68 +--- .../deployment/DeploymentSettings.js | 336 ------------------ 2 files changed, 17 insertions(+), 387 deletions(-) delete mode 100644 lib/manager/components/deployment/DeploymentSettings.js diff --git a/lib/manager/components/ProjectSettings.js b/lib/manager/components/ProjectSettings.js index 62bc9e474..d513880ba 100644 --- a/lib/manager/components/ProjectSettings.js +++ b/lib/manager/components/ProjectSettings.js @@ -1,18 +1,15 @@ // @flow import React, { Component } from 'react' -import { Row, Col, Panel, ListGroup, ListGroupItem } from 'react-bootstrap' -import { LinkContainer } from 'react-router-bootstrap' +import { Row, Col } from 'react-bootstrap' import * as projectActions from '../actions/projects' import { - getComponentMessages, - isModuleEnabled + getComponentMessages } from '../../common/util/config' import type { ManagerUserState } from '../../types/reducers' import type { Project } from '../../types' -import DeploymentSettings from './deployment/DeploymentSettings' import ProjectSettingsForm from './ProjectSettingsForm' type Props = { @@ -28,63 +25,32 @@ export default class ProjectSettings extends Component { messages = getComponentMessages('ProjectSettings') _updateProjectSettings = (project: Project, settings: Object) => { - const {updateProject} = this.props + const { updateProject } = this.props // Update project and re-fetch feeds. updateProject(project.id, settings, true) } render () { const { - activeSettingsPanel, deleteProject, project, projectEditDisabled, updateProject, user } = this.props - const activePanel = !activeSettingsPanel - ? - : - return ( - - - - - - - {this.messages('title')} - - - {isModuleEnabled('deployment') - ? ( - - {this.messages('deployment.title')} - - ) - : null - } - - - - - {activePanel} - - - ) + return + + + + + } } diff --git a/lib/manager/components/deployment/DeploymentSettings.js b/lib/manager/components/deployment/DeploymentSettings.js deleted file mode 100644 index 31faf4eb8..000000000 --- a/lib/manager/components/deployment/DeploymentSettings.js +++ /dev/null @@ -1,336 +0,0 @@ -// @flow - -import Icon from '@conveyal/woonerf/components/icon' -// $FlowFixMe coalesce method is missing in flow type -import {coalesce, get, set} from 'object-path' -import React, {Component} from 'react' -import { - Button, - Col, - ControlLabel, - FormControl, - FormGroup, - Glyphicon, - Panel, - Radio, - Row -} from 'react-bootstrap' -import update from 'react-addons-update' -import {shallowEqual} from 'react-pure-render' -import {withRouter} from 'react-router' - -import FormInput from '../../../common/components/FormInput' -import {getComponentMessages} from '../../../common/util/config' -import CollapsiblePanel from '../CollapsiblePanel' -import {parseBounds} from '../../util' -import {FIELDS, SERVER_FIELDS, UPDATER_FIELDS} from '../../util/deployment' -import {updateProject} from '../../actions/projects' -import type {Project} from '../../../types' - -type Props = { - editDisabled: boolean, - project: Project, - updateProject: typeof updateProject -} - -type State = { - buildConfig: Object, - routerConfig: Object, - useCustomOsmBounds?: boolean -} - -class DeploymentSettings extends Component { - messages = getComponentMessages('DeploymentSettings') - - state = { - buildConfig: get(this.props, 'project.buildConfig') || {}, - routerConfig: get(this.props, 'project.routerConfig') || {} - } - - componentWillReceiveProps (nextProps) { - if (nextProps.project.lastUpdated !== this.props.project.lastUpdated) { - // Reset state using project data if it is updated. - this.setState({ - buildConfig: get(nextProps, 'project.buildConfig') || {}, - routerConfig: get(nextProps, 'project.routerConfig') || {} - }) - } - } - - _clearBuildConfig = () => { - this.props.updateProject(this.props.project.id, {buildConfig: {}}) - } - - _clearRouterConfig = () => { - this.props.updateProject(this.props.project.id, {routerConfig: {}}) - } - - _getOnChange = (evt, index = null) => { - let item = FIELDS.find(f => f.name === evt.target.name) - if (!item) item = UPDATER_FIELDS.find(f => f.name === evt.target.name) - if (!item) item = SERVER_FIELDS.find(f => f.name === evt.target.name) - if (item) { - const stateUpdate = {} - item.effects && item.effects.forEach(e => { - set(stateUpdate, `${e.key}.$set`, e.value) - }) - switch (item.type) { - case 'checkbox': - return this._onChangeCheckbox(evt, stateUpdate, index) - case 'select-bool': - return this._onSelectBool(evt, stateUpdate, index) - case 'number': - return this._onChangeNumber(evt, stateUpdate, index) - default: - // check for split property, which indicates that comma-separated list should be split into array - if (item.split) { - return this._onChangeSplit(evt, stateUpdate, index) - } else { - return this._onChange(evt, stateUpdate, index) - } - } - } else { - console.warn('no onChange function available') - } - } - - _onChangeCheckbox = (evt, stateUpdate = {}, index = null) => { - const name = index !== null ? evt.target.name.replace('$index', `${index}`) : evt.target.name - set(stateUpdate, `${name}.$set`, evt.target.checked) - this.setState(update(this.state, stateUpdate)) - } - - _onChangeSplit = (evt, stateUpdate = {}, index = null) => { - const name = index !== null ? evt.target.name.replace('$index', `${index}`) : evt.target.name - set(stateUpdate, `${name}.$set`, evt.target.value.split(',')) - this.setState(update(this.state, stateUpdate)) - } - - _onAddUpdater = () => { - const stateUpdate = {} - set(stateUpdate, - `routerConfig.updaters.$${this.state.routerConfig.updaters ? 'push' : 'set'}`, - [{type: '', url: '', frequencySec: 30, sourceType: '', feedId: ''}] - ) - this.setState(update(this.state, stateUpdate)) - } - - _onRemoveUpdater = (index) => { - const stateUpdate = {} - set(stateUpdate, `routerConfig.updaters.$splice`, [[index, 1]]) - this.setState(update(this.state, stateUpdate)) - } - - _onChange = (evt, stateUpdate = {}, index = null) => { - const name = index !== null ? evt.target.name.replace('$index', `${index}`) : evt.target.name - // If value is empty string or undefined, set to null in settings object. - // Otherwise, certain fields (such as 'fares') would cause issues with OTP. - set(stateUpdate, `${name}.$set`, evt.target.value || null) - this.setState(update(this.state, stateUpdate)) - } - - _onChangeNumber = (evt, stateUpdate = {}, index = null) => { - const name = index !== null ? evt.target.name.replace('$index', `${index}`) : evt.target.name - set(stateUpdate, `${name}.$set`, +evt.target.value) - this.setState(update(this.state, stateUpdate)) - } - - _onSelectBool = (evt, stateUpdate = {}, index = null) => { - const name = index !== null ? evt.target.name.replace('$index', `${index}`) : evt.target.name - set(stateUpdate, `${name}.$set`, (evt.target.value === 'true')) - this.setState(update(this.state, stateUpdate)) - } - - _getFields = (fields, state, filter) => { - return fields - .filter(f => filter ? f.name.startsWith(filter) : f) - .map((f, index) => { - const shouldRender = () => { - // check for conditional render, e.g. elevationBucket is dependent on fetchElevationUS - if (f.condition) { - const {key, value} = f.condition - const val = get(state, `${key}`) - if (val !== value) return false - } - return true - } - return ( - - ) - }) - } - - _onSave = (evt) => this.props.updateProject(this.props.project.id, this.state, true) - - _onToggleCustomBounds = (evt) => { - const stateUpdate = { useCustomOsmBounds: { $set: (evt.target.value === 'true') } } - this.setState(update(this.state, stateUpdate)) - } - - _onChangeBounds = (evt) => { - const parsedBoundsResult = parseBounds(evt.target.value) - if (parsedBoundsResult.valid) { - this.setState( - update( - this.state, - { - $set: { - bounds: parsedBoundsResult.bounds - } - } - ) - ) - } - } - - /** - * Get value for key from state or, if undefined, default to project property - * from props. - */ - _getValue = (key) => coalesce(this.state, [key], this.props.project[key]) - - /** - * Determine if deployment settings have been modified by checking that every - * item in the state matches the original object found in the project object. - */ - _noEdits = () => Object.keys(this.state) - // $FlowFixMe it's fine if key doesn't exist in this.props.project - .every(key => shallowEqual(this.state[key], this.props.project[key])) - - render () { - const updaters = get(this.state, 'routerConfig.updaters') || [] - const {editDisabled, project} = this.props - return ( -
- {/* Build config settings */} - - - - {this.messages('buildConfig.title')} - - - {this._getFields(FIELDS, this.state, 'buildConfig')} - - - {/* Router config settings */} - - - - {' '} - {this.messages('routerConfig.title')} - - - {this._getFields(FIELDS, this.state, 'routerConfig')} - - - {/* Real-time Updaters (technically still a part of router config) */} - - - - {' '} - {this.messages('routerConfig.updaters.title')} - - - {updaters.map((u, i) => ( - - {u.type}{' '} - {u.url} - - : `[${this.messages('routerConfig.updaters.placeholder')}]` - } - /> - ))} - - - {/* OSM extract settings */} - - {this.messages('osm.title')} - - - - {this.messages('osm.gtfs')} - - - {this.messages('osm.custom')} - - - {project.useCustomOsmBounds || this.state.useCustomOsmBounds - ? - - - {this.messages('osm.bounds')} - - - - - : null - } - - - - - {/* Save button */} - - - -
- ) - } -} - -export default withRouter(DeploymentSettings)