Skip to content

Commit

Permalink
Merge pull request #858 from shital-orchestral/task-delay-model
Browse files Browse the repository at this point in the history
Task delay model
  • Loading branch information
m4dcoder authored Mar 30, 2021
2 parents 16a5b2a + cd471d0 commit b80301b
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 13 deletions.
13 changes: 13 additions & 0 deletions modules/st2-auto-form/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,17 @@
}
}

.tooltiptext {
visibility: hidden;
}
.showtooltiptext {
visibility: visible;
width: auto;
padding: 0;
color: #6c6c6c;
background: none;
display: inline-block;
margin-top: 4px;
margin-left: 35px;
}

44 changes: 33 additions & 11 deletions modules/st2flow-details/orquesta-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type TransitionProps = {
})
)
export default class OrquestaTransition extends Component<TransitionProps, {}> {

static propTypes = {
task: PropTypes.object.isRequired,
issueModelCommand: PropTypes.func,
Expand All @@ -63,10 +64,10 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
}

getValue(value) {
console.log("getValue called",value);
if(!isNaN(value) && value!== '') value = parseInt(value,10);
return value;
}

style = style
joinFieldRef = React.createRef();

Expand Down Expand Up @@ -105,23 +106,44 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
)
}
</Property>,
<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)}>
<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)}>
{
task.retry && (
task.with && (
<div className={this.style.propertyChild}>
<StringField name="when" value={task.retry.when} className="when-title" onChange={value => this.handleTaskProperty([ 'retry', 'when' ], value)} spec={{'default':'enter expression'}} />
<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'}} />
<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'}} />
<StringField name="items" value={task.with.items} onChange={value => this.handleTaskProperty([ 'with', 'items' ], value)} />
<StringField name="concurrency" value={task.with.concurrency} onChange={value => this.handleTaskProperty([ 'with', 'concurrency' ], value)} />
</div>
)
}
}
</Property>,
<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)}>
<Property key="delay" name="Delay" description="Add delay before task execution" value={task.delay != null} onChange={value => this.handleTaskProperty('delay', value ? '10' : false)}>
{
task.with && (
task.delay != null && (
<div className={this.style.propertyChild}>
<label htmlFor="delay" >
delay (seconds)
<input
type="text"
id="delayField"
size="3"
className={this.style.delayField}
value={(task.delay)}
placeholder ="enter expression or integer"
onChange={e => this.handleTaskProperty('delay',this.getValue(e.target.value), true)}
onBlur={ e => this.handleTaskProperty('delay',this.getValue(e.target.value), true)}
/>
</label>
</div>
)
}
</Property>,
<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)}>
{
task.retry && (
<div className={this.style.propertyChild}>
<StringField name="items" value={task.with.items} onChange={value => this.handleTaskProperty([ 'with', 'items' ], value)} />
<StringField name="concurrency" value={task.with.concurrency} onChange={value => this.handleTaskProperty([ 'with', 'concurrency' ], value)} />
<StringField name="when" value={task.retry.when} className="when-title" onChange={value => this.handleTaskProperty([ 'retry', 'when' ], value)} spec={{'default':'enter expression'}} />
<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'}} />
<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'}} />
</div>
)
}
Expand Down
20 changes: 19 additions & 1 deletion modules/st2flow-details/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,22 @@ limitations under the License.
background-color: white;
box-shadow: 0 1px 0 #bbbbbc;
}

.delayField {
width: 100%;
margin: 0 7px;
display: block;
font-weight: normal;
box-sizing: border-box;
height: 36px;
padding: 0 7;
color: black;
border: none;
outline: 0;
background-color: white;
box-shadow: 0 1px 0 #bbbbbc;
margin-top: 7px;
margin-left: 0px;
}
.string-properties {
grid-column: 1 / -1;
display: grid;
Expand Down Expand Up @@ -379,3 +394,6 @@ limitations under the License.

}
}
.tooltip {
position: relative;
}
1 change: 1 addition & 0 deletions modules/st2flow-model/interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface TaskInterface {
delay?: string,
};
join?: ?string;
delay?:?string;
ref?: any;
}

Expand Down
4 changes: 3 additions & 1 deletion modules/st2flow-model/model-orquesta.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ type RawTask = {
__meta: TokenMeta,
action: string,
input?: Object,
delay?: string,
next?: Array<NextItem>,
with?: string | Object,
join?: string,
Expand Down Expand Up @@ -141,7 +142,7 @@ class OrquestaModel extends BaseModel implements ModelInterface {
}
}

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

// if (inputPartials.length) {
Expand All @@ -163,6 +164,7 @@ class OrquestaModel extends BaseModel implements ModelInterface {
},
with: typeof _with === 'string' ? { items: _with } : _with,
join,
delay,
retry: typeof _retry === 'string' ?{ when: _retry} : _retry,
};

Expand Down
12 changes: 12 additions & 0 deletions modules/st2flow-model/schemas/orquesta.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
"minLength": 1,
"type": "string"
},
"delay": {
"oneOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "integer",
"minimum": 0
}
]
},
"join": {
"oneOf": [
{
Expand Down

0 comments on commit b80301b

Please sign in to comment.