Skip to content

Commit b80301b

Browse files
authored
Merge pull request #858 from shital-orchestral/task-delay-model
Task delay model
2 parents 16a5b2a + cd471d0 commit b80301b

File tree

6 files changed

+81
-13
lines changed

6 files changed

+81
-13
lines changed

modules/st2-auto-form/style.css

+13
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,17 @@
481481
}
482482
}
483483

484+
.tooltiptext {
485+
visibility: hidden;
486+
}
487+
.showtooltiptext {
488+
visibility: visible;
489+
width: auto;
490+
padding: 0;
491+
color: #6c6c6c;
492+
background: none;
493+
display: inline-block;
494+
margin-top: 4px;
495+
margin-left: 35px;
496+
}
484497

modules/st2flow-details/orquesta-properties.js

+33-11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type TransitionProps = {
4646
})
4747
)
4848
export default class OrquestaTransition extends Component<TransitionProps, {}> {
49+
4950
static propTypes = {
5051
task: PropTypes.object.isRequired,
5152
issueModelCommand: PropTypes.func,
@@ -63,10 +64,10 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
6364
}
6465

6566
getValue(value) {
66-
console.log("getValue called",value);
6767
if(!isNaN(value) && value!== '') value = parseInt(value,10);
6868
return value;
6969
}
70+
7071
style = style
7172
joinFieldRef = React.createRef();
7273

@@ -105,23 +106,44 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
105106
)
106107
}
107108
</Property>,
108-
<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)}>
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)}>
109110
{
110-
task.retry && (
111+
task.with && (
111112
<div className={this.style.propertyChild}>
112-
<StringField name="when" value={task.retry.when} className="when-title" onChange={value => this.handleTaskProperty([ 'retry', 'when' ], value)} spec={{'default':'enter expression'}} />
113-
<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'}} />
114-
<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'}} />
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)} />
115115
</div>
116116
)
117-
}
117+
}
118118
</Property>,
119-
<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)}>
119+
<Property key="delay" name="Delay" description="Add delay before task execution" value={task.delay != null} onChange={value => this.handleTaskProperty('delay', value ? '10' : false)}>
120120
{
121-
task.with && (
121+
task.delay != null && (
122+
<div className={this.style.propertyChild}>
123+
<label htmlFor="delay" >
124+
delay (seconds)
125+
<input
126+
type="text"
127+
id="delayField"
128+
size="3"
129+
className={this.style.delayField}
130+
value={(task.delay)}
131+
placeholder ="enter expression or integer"
132+
onChange={e => this.handleTaskProperty('delay',this.getValue(e.target.value), true)}
133+
onBlur={ e => this.handleTaskProperty('delay',this.getValue(e.target.value), true)}
134+
/>
135+
</label>
136+
</div>
137+
)
138+
}
139+
</Property>,
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)}>
141+
{
142+
task.retry && (
122143
<div className={this.style.propertyChild}>
123-
<StringField name="items" value={task.with.items} onChange={value => this.handleTaskProperty([ 'with', 'items' ], value)} />
124-
<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'}} />
125147
</div>
126148
)
127149
}

modules/st2flow-details/style.css

+19-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,22 @@ limitations under the License.
351351
background-color: white;
352352
box-shadow: 0 1px 0 #bbbbbc;
353353
}
354-
354+
.delayField {
355+
width: 100%;
356+
margin: 0 7px;
357+
display: block;
358+
font-weight: normal;
359+
box-sizing: border-box;
360+
height: 36px;
361+
padding: 0 7;
362+
color: black;
363+
border: none;
364+
outline: 0;
365+
background-color: white;
366+
box-shadow: 0 1px 0 #bbbbbc;
367+
margin-top: 7px;
368+
margin-left: 0px;
369+
}
355370
.string-properties {
356371
grid-column: 1 / -1;
357372
display: grid;
@@ -379,3 +394,6 @@ limitations under the License.
379394

380395
}
381396
}
397+
.tooltip {
398+
position: relative;
399+
}

modules/st2flow-model/interfaces.js

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export interface TaskInterface {
4646
delay?: string,
4747
};
4848
join?: ?string;
49+
delay?:?string;
4950
ref?: any;
5051
}
5152

modules/st2flow-model/model-orquesta.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type RawTask = {
8585
__meta: TokenMeta,
8686
action: string,
8787
input?: Object,
88+
delay?: string,
8889
next?: Array<NextItem>,
8990
with?: string | Object,
9091
join?: string,
@@ -141,7 +142,7 @@ class OrquestaModel extends BaseModel implements ModelInterface {
141142
}
142143
}
143144

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

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

modules/st2flow-model/schemas/orquesta.json

+12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616
"minLength": 1,
1717
"type": "string"
1818
},
19+
"delay": {
20+
"oneOf": [
21+
{
22+
"type": "string",
23+
"minLength": 1
24+
},
25+
{
26+
"type": "integer",
27+
"minimum": 0
28+
}
29+
]
30+
},
1931
"join": {
2032
"oneOf": [
2133
{

0 commit comments

Comments
 (0)