@@ -6,17 +6,16 @@ import { StatefulPanel } from 'baseui/accordion';
66import { Button } from 'baseui/button' ;
77import { mergeOverrides } from 'baseui/helpers/overrides' ;
88import { Input } from 'baseui/input' ;
9+ import { Select } from 'baseui/select' ;
910import { LabelXSmall } from 'baseui/typography' ;
10- import { Controller } from 'react-hook-form' ;
11+ import { Controller , useWatch } from 'react-hook-form' ;
1112import { MdExpandLess , MdExpandMore } from 'react-icons/md' ;
1213
14+ import { ScheduleOverlapPolicy } from '@/__generated__/proto-ts/uber/cadence/api/v1/ScheduleOverlapPolicy' ;
1315import DomainSchedulesHorizontalField from '@/views/domain-schedules/domain-schedules-horizontal-field/domain-schedules-horizontal-field' ;
1416import getFieldErrorMessage from '@/views/workflow-actions/workflow-action-start-form/helpers/get-field-error-message' ;
1517
16- import {
17- CREATE_SCHEDULE_ADVANCED_FIELD_DESCRIPTIONS ,
18- CREATE_SCHEDULE_ADVANCED_FIELD_IDS ,
19- } from './domain-schedules-create-advanced-form.constants' ;
18+ import { OVERLAP_POLICY_OPTIONS } from './domain-schedules-create-advanced-form.constants' ;
2019import {
2120 overrides ,
2221 styled ,
@@ -27,6 +26,12 @@ export default function DomainSchedulesCreateAdvancedForm({
2726 control,
2827 fieldErrors,
2928} : Props ) {
29+ const overlapPolicy = useWatch ( {
30+ control,
31+ name : 'overlapPolicy' ,
32+ defaultValue : ScheduleOverlapPolicy . SCHEDULE_OVERLAP_POLICY_CONCURRENT ,
33+ } ) ;
34+
3035 return (
3136 < StatefulPanel
3237 overrides = { mergeOverrides ( overrides . panel , {
@@ -59,18 +64,18 @@ export default function DomainSchedulesCreateAdvancedForm({
5964 < >
6065 < DomainSchedulesHorizontalField
6166 label = "Schedule Id"
62- description = { CREATE_SCHEDULE_ADVANCED_FIELD_DESCRIPTIONS . scheduleId }
63- htmlFor = { CREATE_SCHEDULE_ADVANCED_FIELD_IDS . scheduleId }
67+ description = "Unique name provided by users to name the schedule."
68+ htmlFor = "create-schedule-form-schedule-id"
6469 error = { getFieldErrorMessage ( fieldErrors , 'scheduleId' ) }
6570 >
6671 < Controller
6772 name = "scheduleId"
6873 control = { control }
69- defaultValue = ""
7074 render = { ( { field : { ref, ...field } } ) => (
7175 < Input
7276 { ...field }
73- id = { CREATE_SCHEDULE_ADVANCED_FIELD_IDS . scheduleId }
77+ value = { field . value ?? '' }
78+ id = "create-schedule-form-schedule-id"
7479 // @ts -expect-error - inputRef expects ref object while ref is a callback. It should support both.
7580 inputRef = { ref }
7681 aria-label = "Schedule Id"
@@ -84,22 +89,115 @@ export default function DomainSchedulesCreateAdvancedForm({
8489 />
8590 </ DomainSchedulesHorizontalField >
8691
92+ < DomainSchedulesHorizontalField
93+ label = "Overlap Policy"
94+ description = "Policy that controls what the scheduler should do if the previous action is still running."
95+ error = { getFieldErrorMessage ( fieldErrors , 'overlapPolicy' ) }
96+ >
97+ < Controller
98+ name = "overlapPolicy"
99+ control = { control }
100+ render = { ( { field : { value, onChange, ref, ...field } } ) => (
101+ < Select
102+ { ...field }
103+ inputRef = { ref }
104+ aria-label = "Overlap Policy"
105+ options = { OVERLAP_POLICY_OPTIONS }
106+ value = { value ? [ { id : value } ] : [ ] }
107+ onChange = { ( params ) => {
108+ onChange ( params . value [ 0 ] ?. id ) ;
109+ } }
110+ error = { Boolean (
111+ getFieldErrorMessage ( fieldErrors , 'overlapPolicy' )
112+ ) }
113+ size = "compact"
114+ clearable = { false }
115+ />
116+ ) }
117+ />
118+ </ DomainSchedulesHorizontalField >
119+
120+ { overlapPolicy ===
121+ ScheduleOverlapPolicy . SCHEDULE_OVERLAP_POLICY_BUFFER && (
122+ < DomainSchedulesHorizontalField
123+ subfield = { true }
124+ label = "Buffer limit"
125+ description = "Max number of pending workflows allowed when using Buffer overlap policy."
126+ htmlFor = "create-schedule-form-buffer-limit"
127+ caption = "Defaults to 0 (unlimited)"
128+ error = { getFieldErrorMessage ( fieldErrors , 'bufferLimit' ) }
129+ >
130+ < Controller
131+ name = "bufferLimit"
132+ control = { control }
133+ render = { ( { field : { ref, ...field } } ) => (
134+ < Input
135+ { ...field }
136+ id = "create-schedule-form-buffer-limit"
137+ // @ts -expect-error - inputRef expects ref object while ref is a callback. It should support both.
138+ inputRef = { ref }
139+ aria-label = "Buffer limit"
140+ type = "number"
141+ min = { 0 }
142+ onBlur = { field . onBlur }
143+ error = { Boolean (
144+ getFieldErrorMessage ( fieldErrors , 'bufferLimit' )
145+ ) }
146+ size = "compact"
147+ placeholder = "Set buffer limit"
148+ />
149+ ) }
150+ />
151+ </ DomainSchedulesHorizontalField >
152+ ) }
153+
154+ { overlapPolicy ===
155+ ScheduleOverlapPolicy . SCHEDULE_OVERLAP_POLICY_CONCURRENT && (
156+ < DomainSchedulesHorizontalField
157+ subfield = { true }
158+ label = "Concurrency limit"
159+ description = "Max number of concurrently running workflows allowed for Concurrent overlap policy."
160+ htmlFor = "create-schedule-form-concurrency-limit"
161+ caption = "Defaults to 0 (unlimited)"
162+ error = { getFieldErrorMessage ( fieldErrors , 'concurrencyLimit' ) }
163+ >
164+ < Controller
165+ name = "concurrencyLimit"
166+ control = { control }
167+ render = { ( { field : { ref, ...field } } ) => (
168+ < Input
169+ { ...field }
170+ id = "create-schedule-form-concurrency-limit"
171+ // @ts -expect-error - inputRef expects ref object while ref is a callback. It should support both.
172+ inputRef = { ref }
173+ aria-label = "Concurrency limit"
174+ type = "number"
175+ min = { 0 }
176+ onBlur = { field . onBlur }
177+ error = { Boolean (
178+ getFieldErrorMessage ( fieldErrors , 'concurrencyLimit' )
179+ ) }
180+ size = "compact"
181+ placeholder = "Set concurrency limit"
182+ />
183+ ) }
184+ />
185+ </ DomainSchedulesHorizontalField >
186+ ) }
187+
87188 < DomainSchedulesHorizontalField
88189 label = "Jitter duration"
89- description = {
90- CREATE_SCHEDULE_ADVANCED_FIELD_DESCRIPTIONS . jitterSeconds
91- }
92- htmlFor = { CREATE_SCHEDULE_ADVANCED_FIELD_IDS . jitterSeconds }
190+ description = "Time range to distribute starting workflows across. This helps avoiding burst of workflow creations in a single point of time."
191+ htmlFor = "create-schedule-form-jitter"
93192 error = { getFieldErrorMessage ( fieldErrors , 'jitterSeconds' ) }
94193 >
95194 < Controller
96195 name = "jitterSeconds"
97196 control = { control }
98- defaultValue = ""
99197 render = { ( { field : { ref, ...field } } ) => (
100198 < Input
101199 { ...field }
102- id = { CREATE_SCHEDULE_ADVANCED_FIELD_IDS . jitterSeconds }
200+ id = "create-schedule-form-jitter"
103201 // @ts -expect-error - inputRef expects ref object while ref is a callback. It should support both.
104202 inputRef = { ref }
105203 aria-label = "Jitter duration"
@@ -119,20 +217,18 @@ export default function DomainSchedulesCreateAdvancedForm({
119217
120218 < DomainSchedulesHorizontalField
121219 label = "Workflow Id Prefix"
122- description = {
123- CREATE_SCHEDULE_ADVANCED_FIELD_DESCRIPTIONS . workflowIdPrefix
124- }
125- htmlFor = { CREATE_SCHEDULE_ADVANCED_FIELD_IDS . workflowIdPrefix }
220+ description = "Prefix text to add into started workflows. Ids are formed as `${Prefix}+{auto generated postfix}`."
221+ htmlFor = "create-schedule-form-workflow-id-prefix"
126222 error = { getFieldErrorMessage ( fieldErrors , 'workflowIdPrefix' ) }
127223 >
128224 < Controller
129225 name = "workflowIdPrefix"
130226 control = { control }
131- defaultValue = ""
132227 render = { ( { field : { ref, ...field } } ) => (
133228 < Input
134229 { ...field }
135- id = { CREATE_SCHEDULE_ADVANCED_FIELD_IDS . workflowIdPrefix }
230+ value = { field . value ?? '' }
231+ id = "create-schedule-form-workflow-id-prefix"
136232 // @ts -expect-error - inputRef expects ref object while ref is a callback. It should support both.
137233 inputRef = { ref }
138234 aria-label = "Workflow Id Prefix"
0 commit comments