Skip to content

Commit

Permalink
Merge pull request #958 from ibi-group/add-outside-merge-warning
Browse files Browse the repository at this point in the history
Add Merge Warning For Externally Merged Feeds
  • Loading branch information
philip-cline authored Jul 4, 2023
2 parents eb3fb07 + 2c4c12e commit c90f112
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
5 changes: 5 additions & 0 deletions i18n/english.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ components:
next: Next
of: of
previous: Previous
uploadBody: "Select a GTFS feed to upload:"
uploadError: Uploaded file must be a valid zip file (.zip).
uploadTitle: Upload Feed
version: Version
FeedVersionTabs:
agencyCount: Agency count
Expand Down Expand Up @@ -732,6 +735,8 @@ components:
line: Line
priority: Priority
problemType: Problem Type
SelectFileModal:
mtcMergeWarning: Warning! Feeds merged outside of TDM are not recognized as a merged feed within TDM.
ServerSettings:
deployment:
otpServers:
Expand Down
5 changes: 5 additions & 0 deletions i18n/polish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ components:
next: Next
of: of
previous: Previous
uploadBody: "Select a GTFS feed to upload:"
uploadError: Uploaded file must be a valid zip file (.zip).
uploadTitle: Upload Feed
version: Version
FeedVersionTabs:
agencyCount: Agency count
Expand Down Expand Up @@ -767,6 +770,8 @@ components:
line: Line
priority: Priority
problemType: Problem Type
SelectFileModal:
mtcMergeWarning: Warning! Feeds merged outside of TDM are not recognized as a merged feed within TDM.
ServerSettings:
deployment:
otpServers:
Expand Down
24 changes: 20 additions & 4 deletions lib/common/components/SelectFileModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import React, { Component } from 'react'
import { Modal, Button, FormControl } from 'react-bootstrap'
import ReactDOM from 'react-dom'

import { getComponentMessages, isExtensionEnabled } from '../util/config'

type Props = {
body?: string,
errorMessage?: string,
Expand All @@ -18,22 +20,26 @@ type State = {
errorMessage?: string,
onClose?: () => void,
onConfirm?: (any) => Promise<boolean> | boolean,
showMTCMergeWarning: boolean,
showModal: boolean,
title?: string
}

export default class SelectFileModal extends Component<Props, State> {
messages = getComponentMessages('SelectFileModal')
state = {
disabled: false,
errorMessage: '',
onConfirm: (args: any) => false,
showModal: false
showModal: false,
showMTCMergeWarning: false
}

close = () => {
if (this.props.onClose) this.props.onClose()
this.setState({
showModal: false
showModal: false,
showMTCMergeWarning: false
})
}

Expand Down Expand Up @@ -82,9 +88,14 @@ export default class SelectFileModal extends Component<Props, State> {
}
}

onFileChangeCapture = () => {
this.setState({...this.state, showMTCMergeWarning: isExtensionEnabled('mtc')})
}

render () {
const {Body, Footer, Header, Title} = Modal
const {disabled, errorMessage} = this.state
const {disabled, errorMessage, showMTCMergeWarning} = this.state

return (
<Modal show={this.state.showModal} onHide={this.close}>
<Header>
Expand All @@ -93,11 +104,16 @@ export default class SelectFileModal extends Component<Props, State> {

<Body>
<p>{this.props.body || this.state.body || ''}</p>
{showMTCMergeWarning &&
<p style={{color: 'red'}}>
{this.messages('mtcMergeWarning')}
</p>
}
{errorMessage
? <p>{errorMessage}</p>
: null
}
<FormControl ref='fileInput' type='file' />
<FormControl onChangeCapture={this.onFileChangeCapture} ref='fileInput' type='file' />
</Body>

<Footer>
Expand Down
6 changes: 3 additions & 3 deletions lib/manager/components/version/FeedVersionNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ export default class FeedVersionNavigator extends Component<Props, State> {
return (
<div>
<SelectFileModal ref='uploadModal'
title='Upload Feed'
body='Select a GTFS feed to upload:'
body={this.messages('uploadBody')}
errorMessage={this.messages('uploadError')}
onConfirm={this._onConfirmUpload}
errorMessage='Uploaded file must be a valid zip file (.zip).' />
title={this.messages('uploadTitle')} />
<Row style={{marginBottom: '20px'}}>
{/* Version Navigation Widget and Name Editor */}
<Col xs={12} style={versionTitleStyle}>
Expand Down

0 comments on commit c90f112

Please sign in to comment.