Skip to content

Commit 807fba2

Browse files
authored
Merge branch 'master' into fix_empty_screen_on_array
2 parents 1cc4c9f + 9c578e2 commit 807fba2

File tree

7 files changed

+82
-9
lines changed

7 files changed

+82
-9
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ then you need to bootstrap the micromodules
3939
$ lerna bootstrap
4040
```
4141

42+
to avoid conflicts on node_modules, delete those generated by lerna:
43+
44+
```shell
45+
$ rm -rf apps/st2-workflows/node_modules/
46+
```
47+
4248
and finally run build system to fetch the font, compile css and so on
4349

4450
```shell

apps/st2-actions/actions-details.component.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export default class ActionsDetails extends React.Component {
5757
static propTypes = {
5858
handleNavigate: PropTypes.func.isRequired,
5959
handleRun: PropTypes.func.isRequired,
60+
handleDelete: PropTypes.func.isRequired,
6061

6162
id: PropTypes.string,
6263
section: PropTypes.string,
@@ -127,8 +128,6 @@ export default class ActionsDetails extends React.Component {
127128
}
128129
}
129130

130-
131-
132131
componentDidUpdate(prevProps) {
133132
const { id } = this.props;
134133
if (id && id !== prevProps.id) {
@@ -242,6 +241,15 @@ export default class ActionsDetails extends React.Component {
242241
return this.props.handleRun(...args);
243242
}
244243

244+
handleDelete (ref) {
245+
const { id } = this.props;
246+
247+
if (!window.confirm(`You are about to delete the action "${id}". This operation is irreversible. Are you sure?`)) {
248+
return undefined;
249+
}
250+
return this.props.handleDelete(id);
251+
}
252+
245253
render() {
246254
const { section, action, executions, entrypoint } = this.props;
247255
if (!action) {
@@ -281,6 +289,8 @@ export default class ActionsDetails extends React.Component {
281289
/>
282290
<Button flat value="Preview" onClick={() => this.handleToggleRunPreview()} />
283291
<DetailsToolbarSeparator />
292+
<Button className="st2-forms__button st2-details__toolbar-button" value="Delete" onClick={() => this.handleDelete()} />
293+
284294
{ action.runner_type === 'mistral-v2' || action.runner_type === 'orquesta' ? (
285295
<Link
286296
target="_blank"

apps/st2-actions/actions-panel.component.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ import './style.css';
5555
return { collapsed, ...props };
5656
}, (dispatch, props) => {
5757
const { uid } = props;
58-
5958
return {
6059
onToggle: () => store.dispatch(flexActions.toggle(uid)),
6160
};
@@ -116,7 +115,6 @@ export default class ActionsPanel extends React.Component {
116115
.then(() => {
117116
const { id } = this.urlParams;
118117
const { groups } = this.props;
119-
120118
if (id && groups && !groups.some(({ actions }) => actions.some(({ ref }) => ref === id))) {
121119
this.navigate({ id: false });
122120
}
@@ -128,8 +126,7 @@ export default class ActionsPanel extends React.Component {
128126
const {
129127
ref = get('groups[0].actions[0].ref', this.props),
130128
section = 'general',
131-
} = this.props.match.params;
132-
129+
} = this.props.match.params;
133130
return {
134131
id: ref,
135132
section,
@@ -211,6 +208,30 @@ export default class ActionsPanel extends React.Component {
211208
});
212209
}
213210

211+
handleDelete (ref) {
212+
return store.dispatch({
213+
type: 'DELETE_ACTION',
214+
ref,
215+
promise: api.request({
216+
method: 'delete',
217+
path: `/actions/${ref}`,
218+
})
219+
.then((res) => {
220+
notification.success(`Action "${ref}" has been deleted successfully.`);
221+
this.navigate({ id: null });
222+
store.dispatch(flexActions.toggleAll());
223+
return res;
224+
})
225+
.catch((err) => {
226+
notification.error(`Unable to delete action "${ref}".`, {
227+
err,
228+
229+
});
230+
throw err;
231+
}),
232+
});
233+
}
234+
214235
render() {
215236
const { groups, filter, collapsed } = this.props;
216237
const { id, section } = this.urlParams;
@@ -282,6 +303,7 @@ export default class ActionsPanel extends React.Component {
282303
ref={(ref) => this._details = ref}
283304
handleNavigate={(...args) => this.navigate(...args)}
284305
handleRun={(...args) => this.handleRun(...args)}
306+
handleDelete={(...arg) => this.handleDelete(...arg)}
285307

286308
id={id}
287309
section={section}

apps/st2-actions/store.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,32 @@ const actionReducer = (state = {}, input) => {
154154
};
155155
}
156156

157+
case 'DELETE_ACTION': {
158+
const { ref } = input;
159+
160+
161+
162+
switch(input.status) {
163+
case 'success':
164+
actions = [ ...actions ]
165+
.filter(action => action.ref !== ref)
166+
;
167+
groups = makeGroups( actions, filter);
168+
169+
break;
170+
case 'error':
171+
break;
172+
default:
173+
break;
174+
}
175+
176+
return {
177+
...state,
178+
actions,
179+
groups,
180+
};
181+
}
182+
157183
case 'SET_FILTER': {
158184
filter = input.filter;
159185
groups = makeGroups(actions, filter);

modules/st2-action-reporter/reporters/run-local.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ export default function runLocal(execution) {
2828
execution.result && execution.result.stderr ? [
2929
<div key="error" className={style.source}>Error</div>,
3030
<Highlight well lines={20} className={style.highlight} key="error-code" code={execution.result.stderr} type="result" id={execution.id} />,
31+
] : execution.result && execution.result.error ? [
32+
<div key="error" className={style.source}>Error</div>,
33+
<Highlight well lines={20} className={style.highlight} key="error-code" code={execution.result.error} type="result" id={execution.id} />,
3134
] : null,
3235

3336
execution.result && execution.result.traceback ? [
3437
<div key="traceback" className={style.source}>Traceback</div>,
3538
<Highlight well lines={20} className={style.highlight} key="traceback-code" code={[ execution.result.error, execution.result.traceback ].join('\n')} type="result" id={execution.id} />,
3639
] : null,
3740

38-
!execution.result || (!execution.result.stdout && !execution.result.stderr && !execution.result.traceback) ? (
41+
!execution.result || (!execution.result.stdout && !execution.result.stderr && !execution.result.error && !execution.result.traceback) ? (
3942
<Highlight well className={style.highlight} key="none" code="// Action produced no data" type="result" id={execution.id} />
4043
) : null,
4144
];

modules/st2-action-reporter/reporters/run-python.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@ export default function runPython(execution) {
3333
execution.result && execution.result.stderr ? [
3434
<div key="error" className={style.source}>Error</div>,
3535
<Highlight well lines={20} className={style.highlight} key="error-code" code={execution.result.stderr} type="result" id={execution.id} />,
36+
] : execution.result && execution.result.error ? [
37+
<div key="error" className={style.source}>Error</div>,
38+
<Highlight well lines={20} className={style.highlight} key="error-code" code={execution.result.error} type="result" id={execution.id} />,
3639
] : null,
3740

3841
execution.result && execution.result.traceback ? [
3942
<div key="traceback" className={style.source}>Traceback</div>,
4043
<Highlight well lines={20} className={style.highlight} key="traceback-code" code={[ execution.result.error, execution.result.traceback ].join('\n')} type="result" id={execution.id} />,
4144
] : null,
4245

43-
!execution.result || (!execution.result.result && !execution.result.stdout && !execution.result.stderr && !execution.result.traceback) ? (
46+
!execution.result || (!execution.result.result && !execution.result.stdout && !execution.result.stderr && !execution.result.error && !execution.result.traceback) ? (
4447
<Highlight well className={style.highlight} key="none" code="// Action produced no data" />
4548
) : null,
4649
].filter(v => v);

modules/st2-action-reporter/reporters/run-remote.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ export default function runRemote(execution) {
3939
result && result.stderr ? [
4040
<div key="error" className={style.source}>Error</div>,
4141
<Highlight well lines={20} className={style.highlight} key="error-code" code={result.stderr} type="result" id={execution.id} />,
42+
] :result && result.error ? [
43+
<div key="error" className={style.source}>Error</div>,
44+
<Highlight well lines={20} className={style.highlight} key="error-code" code={result.error} type="result" id={execution.id} />,
4245
] : null,
4346

4447
result && result.traceback ? [
4548
<div key="traceback" className={style.source}>Traceback</div>,
4649
<Highlight well lines={20} className={style.highlight} key="traceback-code" code={[ result.error, result.traceback ].join('\n')} type="result" id={execution.id} />,
4750
] : null,
4851

49-
!result || (!result.result && !result.stderr && !result.stdout && !result.traceback) ? (
52+
!result || (!result.result && !result.stderr && !result.stdout && !result.error && !result.traceback) ? (
5053
<Highlight well className={style.highlight} key="none" code="// Action produced no data" />
5154
) : null,
5255
];

0 commit comments

Comments
 (0)