Skip to content

Commit

Permalink
fix error with new pipeline creation after editing, show normal forbi…
Browse files Browse the repository at this point in the history
…dden error
  • Loading branch information
yamalight committed Feb 22, 2016
1 parent 255a243 commit 0e08d38
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/pages/pipeline/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {RxState} from '../../stores/util';
import PipelineEditor from '../../components/pipelineEditor';
import pipelineStore, {getPipeline} from '../../stores/pipeline';
import pipelineStore, {getPipeline, newPipeline} from '../../stores/pipeline';

const Pipeline = React.createClass({
mixins: [RxState],
Expand Down Expand Up @@ -29,6 +29,7 @@ const Pipeline = React.createClass({
updatePipeline(props) {
// clear if new route
if (props.params.user === 'new') {
newPipeline();
return;
}
// if user and component name present - get component from server
Expand All @@ -43,6 +44,18 @@ const Pipeline = React.createClass({
},

render() {
if (this.state.pipeline && this.state.pipeline.error) {
return (
<div className="row">
<div className="col-xs-6 col-xs-offset-3 text-center">
<h4>{this.state.pipeline.error === 'Forbidden' ? (
`Looks like you don't have rights to see this!`
) : this.state.pipeline.error}</h4>
</div>
</div>
);
}

return <PipelineEditor {...this.state.pipeline} />;
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/stores/pipeline/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const stream = getPipeline.$
.map(res => res.body)
.catch(e => {
createNotification({type: 'danger', message: e.message});
return Observable.return([]);
return Observable.return({error: e.message});
})
)
.map(data => fromJS({
Expand Down
3 changes: 3 additions & 0 deletions src/stores/pipeline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import logStream, {getPipelineLog} from './getLog';
import getStream, {getPipeline} from './get';
import statusStream, {pipelineStatus} from './status';
import deleteStream, {deletePipeline} from './delete';
import newStream, {newPipeline} from './new';

// create bus
const pipelinesSubject = new ReplaySubject(1);
Expand All @@ -26,6 +27,7 @@ stopStream.subscribe(pipelinesSubject);
getStream.subscribe(pipelinesSubject);
statusStream.subscribe(pipelinesSubject);
deleteStream.subscribe(pipelinesSubject);
newStream.subscribe(pipelinesSubject);

// create result store stream
const pipelines = pipelinesSubject
Expand All @@ -44,5 +46,6 @@ export {
getPipeline,
pipelineStatus,
deletePipeline,
newPipeline,
};
export default pipelines;
16 changes: 16 additions & 0 deletions src/stores/pipeline/new.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {fromJS} from 'immutable';
import {createAction} from '../util';

const newPipeline = createAction();

const stream = newPipeline.$
.map(() => fromJS({
pipeline: {
id: undefined,
name: 'My new pipeline',
isPublic: false,
},
}));

export {newPipeline};
export default stream;

0 comments on commit 0e08d38

Please sign in to comment.