Skip to content

Commit cd471d0

Browse files
committed
Merge remote-tracking branch 'origin' into task-delay-model
2 parents bdc6e6f + 16a5b2a commit cd471d0

File tree

5 files changed

+63
-11
lines changed

5 files changed

+63
-11
lines changed

modules/st2-auto-form/style.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,5 +495,3 @@
495495
margin-left: 35px;
496496
}
497497

498-
499-

modules/st2flow-details/orquesta-properties.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
5454

5555
handleTaskProperty(name: string | Array<string>, value: any, noDelete: boolean = false) {
5656
const { task, issueModelCommand } = this.props;
57-
57+
5858
if (value || noDelete) {
5959
issueModelCommand && issueModelCommand('setTaskProperty', task, name, value);
6060
}
@@ -70,7 +70,6 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
7070

7171
style = style
7272
joinFieldRef = React.createRef();
73-
7473

7574
render() {
7675
const { task } = this.props;
@@ -107,6 +106,16 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
107106
)
108107
}
109108
</Property>,
109+
<Property key="with" name="With Items" description="Run an action or workflow associated with a task multiple times." value={!!task.with} onChange={value => this.handleTaskProperty('with', value ? { items: 'x in <% ctx(y) %>' } : false)}>
110+
{
111+
task.with && (
112+
<div className={this.style.propertyChild}>
113+
<StringField name="items" value={task.with.items} onChange={value => this.handleTaskProperty([ 'with', 'items' ], value)} />
114+
<StringField name="concurrency" value={task.with.concurrency} onChange={value => this.handleTaskProperty([ 'with', 'concurrency' ], value)} />
115+
</div>
116+
)
117+
}
118+
</Property>,
110119
<Property key="delay" name="Delay" description="Add delay before task execution" value={task.delay != null} onChange={value => this.handleTaskProperty('delay', value ? '10' : false)}>
111120
{
112121
task.delay != null && (
@@ -128,12 +137,13 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
128137
)
129138
}
130139
</Property>,
131-
<Property key="with" name="With Items" description="Run an action or workflow associated with a task multiple times." value={!!task.with} onChange={value => this.handleTaskProperty('with', value ? { items: 'x in <% ctx(y) %>' } : false)}>
140+
<Property key="retry" name="Retry" description="Define the retry condition for the task execution." value={!!task.retry} onChange={value => this.handleTaskProperty('retry', value ? { when: '<% failed() %>' } : false)}>
132141
{
133-
task.with && (
142+
task.retry && (
134143
<div className={this.style.propertyChild}>
135-
<StringField name="items" value={task.with.items} onChange={value => this.handleTaskProperty([ 'with', 'items' ], value)} />
136-
<StringField name="concurrency" value={task.with.concurrency} onChange={value => this.handleTaskProperty([ 'with', 'concurrency' ], value)} />
144+
<StringField name="when" value={task.retry.when} className="when-title" onChange={value => this.handleTaskProperty([ 'retry', 'when' ], value)} spec={{'default':'enter expression'}} />
145+
<StringField name="count" value={task.retry.count} className="count-title" onChange={value => this.handleTaskProperty([ 'retry', 'count' ], this.getValue(value))} spec={{'default':'enter expression or integer'}} />
146+
<StringField name="delay (seconds)" value={task.retry.delay} className="delay-title" onChange={value => this.handleTaskProperty([ 'retry', 'delay'], this.getValue(value))} spec={{'default':'enter expression or integer'}} />
137147
</div>
138148
)
139149
}

modules/st2flow-model/interfaces.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ export interface TaskInterface {
4040
items: string,
4141
concurrency?: string,
4242
};
43+
retry?: ?{
44+
when: string,
45+
count?: string,
46+
delay?: string,
47+
};
4348
join?: ?string;
4449
delay?:?string;
4550
ref?: any;

modules/st2flow-model/model-orquesta.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ type RawTask = {
8888
delay?: string,
8989
next?: Array<NextItem>,
9090
with?: string | Object,
91-
join?: string
91+
join?: string,
92+
retry?:string | Object
9293
};
9394

9495
type RawTasks = {
@@ -141,7 +142,7 @@ class OrquestaModel extends BaseModel implements ModelInterface {
141142
}
142143
}
143144

144-
const { action = '', input, 'with': _with, join, delay } = task;
145+
const { action = '', input, 'with': _with, 'retry': _retry, join, delay } = task;
145146
const [ actionRef, ...inputPartials ] = `${action}`.split(' ');
146147

147148
// if (inputPartials.length) {
@@ -164,6 +165,7 @@ class OrquestaModel extends BaseModel implements ModelInterface {
164165
with: typeof _with === 'string' ? { items: _with } : _with,
165166
join,
166167
delay,
168+
retry: typeof _retry === 'string' ?{ when: _retry} : _retry,
167169
};
168170

169171
return retVal;

modules/st2flow-model/schemas/orquesta.json

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,43 @@
6363
}
6464
}
6565
},
66+
"retry": {
67+
"type": "object",
68+
"properties": {
69+
"when": {
70+
"type": "string",
71+
"minLength": 1
72+
},
73+
"count": {
74+
"oneOf": [
75+
{
76+
"type": "string",
77+
"minLength": 1
78+
},
79+
{
80+
"type": "integer",
81+
"minimum": 0
82+
}
83+
]
84+
},
85+
"delay": {
86+
"oneOf": [
87+
{
88+
"type": "string",
89+
"minLength": 1
90+
},
91+
{
92+
"type": "integer",
93+
"minimum": 0
94+
}
95+
]
96+
}
97+
},
98+
"required": [
99+
"count"
100+
],
101+
"additionalProperties": false
102+
},
66103
"input": {
67104
"oneOf": [
68105
{
@@ -339,4 +376,4 @@
339376
"type": "string"
340377
}
341378
}
342-
}
379+
}

0 commit comments

Comments
 (0)