@@ -12,15 +12,23 @@ import { EuiButton, EuiFlexGroup, EuiHorizontalRule } from '@elastic/eui';
1212
1313import { ConfirmationDialogContext } from '@/contexts' ;
1414import { useOrchestratorTheme } from '@/hooks' ;
15+ import { WfoPlayCircle } from '@/icons' ;
16+ import { WfoThemeExtraColors } from '@/theme' ;
1517
1618import { RenderFormErrors } from './RenderFormErrors' ;
1719
20+ type FooterProps = PydanticFormFooterProps & {
21+ isTask ?: boolean ;
22+ } ;
23+
1824export const Footer = ( {
1925 onCancel,
2026 onPrevious,
2127 hasNext,
2228 hasPrevious,
23- } : PydanticFormFooterProps ) => {
29+ isTask = false ,
30+ buttons,
31+ } : FooterProps ) => {
2432 const { theme } = useOrchestratorTheme ( ) ;
2533 const t = useTranslations ( 'pydanticForms.userInputForm' ) ;
2634 const { showConfirmDialog } = useContext ( ConfirmationDialogContext ) ;
@@ -34,24 +42,37 @@ export const Footer = ({
3442 }
3543 } ;
3644
37- const PreviousButton = ( ) => (
38- < EuiButton
39- data-testid = "button-submit-form-previous"
40- id = "button-submit-form-submit"
41- tabIndex = { 0 }
42- fill
43- onClick = { ( ) => {
44- if ( onPrevious ) {
45- onPrevious ( ) ;
46- }
47- } }
48- color = { 'primary' }
49- iconSide = "right"
50- aria-label = { t ( 'previous' ) }
51- >
52- { t ( 'previous' ) }
53- </ EuiButton >
54- ) ;
45+ const { next, previous } = buttons || { } ;
46+
47+ const PreviousButton = ( ) => {
48+ const previousButtonColor =
49+ theme . colors [
50+ ( previous ?. color as keyof WfoThemeExtraColors [ 'colors' ] ) ??
51+ 'primary'
52+ ] ;
53+
54+ return (
55+ < EuiButton
56+ data-testid = "button-submit-form-previous"
57+ id = "button-submit-form-submit"
58+ tabIndex = { 0 }
59+ fill
60+ onClick = { ( ) => {
61+ if ( onPrevious ) {
62+ onPrevious ( ) ;
63+ }
64+ } }
65+ css = { {
66+ backgroundColor : previousButtonColor ,
67+ padding : '12px' ,
68+ } }
69+ iconSide = "right"
70+ aria-label = { t ( 'previous' ) }
71+ >
72+ { previous ?. text ?? t ( 'previous' ) }
73+ </ EuiButton >
74+ ) ;
75+ } ;
5576
5677 const CancelButton = ( ) => (
5778 < div
@@ -71,26 +92,45 @@ export const Footer = ({
7192 ) ;
7293
7394 const SubmitButton = ( ) => {
74- const submitButtonLabel = hasNext ? t ( 'next' ) : t ( 'startWorkflow' ) ;
75-
7695 /*
7796 * The submit button is used to submit the form data.
7897 * If there is a next step, it will be labeled as "Next".
7998 * If there is no next step, it will be labeled as "Start Workflow".
99+ * If there is a label provided in the buttonNextProps, it will be used instead.
80100 * The button is styled with primary color and has an icon on the right side.
81101 * We don't use the disable property based on the form valid state here. When calculating the form valid state
82102 * react-hook-form might return a false negative - marking the form invalid - when not all fields have a defaultValue
83103 * which is a valid use case. https://chatgpt.com/share/6874ce66-35e8-800c-9434-725ff895ac44
84104 */
105+
106+ const submitButtonTranslated = hasNext
107+ ? t ( 'next' )
108+ : isTask
109+ ? t ( 'startTask' )
110+ : t ( 'startWorkflow' ) ;
111+
112+ const submitButtonLabel = next ?. text ?? submitButtonTranslated ;
113+ const submitIconType =
114+ ! hasNext && ! next ?. text
115+ ? ( ) => < WfoPlayCircle color = "currentColor" />
116+ : undefined ;
117+ const submitButtonColor = next ?. color
118+ ? ( next ?. color as keyof WfoThemeExtraColors [ 'colors' ] )
119+ : 'primary' ;
120+
85121 return (
86122 < EuiButton
87123 data-testid = "button-submit-form-submit"
88124 id = "button-submit-form-submit"
89125 tabIndex = { 0 }
90126 fill
91- color = { 'primary' }
127+ css = { {
128+ backgroundColor : submitButtonColor ,
129+ padding : '12px' ,
130+ } }
92131 type = "submit"
93132 iconSide = "right"
133+ iconType = { submitIconType }
94134 aria-label = { submitButtonLabel }
95135 >
96136 { submitButtonLabel }
0 commit comments