Skip to content

Commit 4da358e

Browse files
committed
feat(feed): add cancel buttons to create project/feed forms
1 parent 49178ed commit 4da358e

File tree

7 files changed

+24
-7
lines changed

7 files changed

+24
-7
lines changed

i18n/english.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ components:
456456
save: Save
457457
title: Settings
458458
ProjectSettingsForm:
459+
cancel: Cancel
459460
confirmDelete: Are you sure you want to delete this project? This action cannot be undone and all feed sources and their versions will be permanently deleted.
460461
deleteProject: Delete Project?
461462
fields:

i18n/espanol.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ components:
452452
save: Save
453453
title: Settings
454454
ProjectSettingsForm:
455+
cancel: Cancel
455456
confirmDelete: Are you sure you want to delete this project? This action cannot be undone and all feed sources and their versions will be permanently deleted.
456457
deleteProject: Delete Project?
457458
fields:

i18n/francais.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ components:
451451
save: Save
452452
title: Settings
453453
ProjectSettingsForm:
454+
cancel: Cancel
454455
confirmDelete: Are you sure you want to delete this project? This action cannot be undone and all feed sources and their versions will be permanently deleted.
455456
deleteProject: Delete Project?
456457
fields:

lib/manager/components/CreateFeedSource.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ export default class CreateFeedSource extends Component<Props, State> {
182182
</Panel>
183183
</Col>
184184
<Col xs={12}>
185+
<Button
186+
onClick={this.props.onCancel}
187+
style={{marginRight: 10}}
188+
>
189+
Cancel
190+
</Button>
185191
<Button
186192
bsStyle='primary'
187193
data-test-id='create-feed-source-button'
@@ -190,13 +196,6 @@ export default class CreateFeedSource extends Component<Props, State> {
190196
>
191197
Save
192198
</Button>
193-
<Button
194-
bsStyle='warning'
195-
onClick={this.props.onCancel}
196-
style={{marginLeft: 10}}
197-
>
198-
Cancel
199-
</Button>
200199
</Col>
201200
</Row>
202201
)

lib/manager/components/CreateProject.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default class CreateProject extends Component<Props> {
2929
<Col xs={12} sm={8}>
3030
<h2>Create New Project</h2>
3131
<ProjectSettingsForm
32+
onCancelUrl='/project'
3233
project={{ name: '' }}
3334
updateProject={this._saveProject}
3435
/>

lib/manager/components/ProjectSettings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default class ProjectSettings extends MessageComponent<Props> {
3939
? <ProjectSettingsForm
4040
deleteProject={deleteProject}
4141
editDisabled={projectEditDisabled}
42+
onCancelUrl={`project/${project.id}/`}
4243
project={project}
4344
updateProject={updateProject}
4445
showDangerZone

lib/manager/components/ProjectSettingsForm.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
import DateTimeField from 'react-bootstrap-datetimepicker'
2424
import ReactDOM from 'react-dom'
2525
import {shallowEqual} from 'react-pure-render'
26+
import {browserHistory} from 'react-router'
2627

2728
import {deleteProject, updateProject} from '../actions/projects'
2829
import MapModal from '../../common/components/MapModal.js'
@@ -50,6 +51,7 @@ type ProjectModel = {
5051
type Props = {
5152
deleteProject?: typeof deleteProject,
5253
editDisabled?: boolean,
54+
onCancelUrl: string,
5355
project: Project | ProjectModel,
5456
showDangerZone?: boolean,
5557
updateProject: typeof updateProject
@@ -94,6 +96,10 @@ export default class ProjectSettingsForm extends MessageComponent<Props, State>
9496
this.setState({ model })
9597
}
9698

99+
_onCancel = () => {
100+
browserHistory.push(this.props.onCancelUrl)
101+
}
102+
97103
_onDeleteProject = () => {
98104
const {deleteProject, project} = this.props
99105
if (!deleteProject) {
@@ -463,6 +469,13 @@ export default class ProjectSettingsForm extends MessageComponent<Props, State>
463469
}
464470
<Row>
465471
<Col xs={12}>
472+
{/* Cancel button */}
473+
<Button
474+
onClick={this._onCancel}
475+
style={{marginRight: 10}}
476+
>
477+
{this.messages('cancel')}
478+
</Button>
466479
{/* Save button */}
467480
<Button
468481
bsStyle='primary'

0 commit comments

Comments
 (0)