Skip to content

Commit 06aceaa

Browse files
Ruben van LeeuwenDutchBen
authored andcommitted
1904: gs
1 parent 8cac509 commit 06aceaa

File tree

3 files changed

+89
-79
lines changed

3 files changed

+89
-79
lines changed

packages/orchestrator-ui-components/src/components/WfoPydanticForm/Footer.tsx

Lines changed: 62 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -31,65 +31,77 @@ export const Footer = () => {
3131
!rhf.formState.isDirty &&
3232
!rhf.formState.isSubmitting);
3333

34-
const submitButtonLabel = hasNext ? t('next') : t('startWorkflow');
34+
const handlePrevious = () => {
35+
if (onCancel) {
36+
onCancel();
37+
}
38+
};
39+
40+
const PreviousButton = () => (
41+
<EuiButton
42+
id="button-submit-form-submit"
43+
tabIndex={0}
44+
fill
45+
onClick={() => {
46+
if (onPrevious) {
47+
onPrevious();
48+
}
49+
}}
50+
color={'primary'}
51+
iconSide="right"
52+
aria-label={t('previous')}
53+
disabled={isDisabled}
54+
>
55+
{t('previous')}
56+
</EuiButton>
57+
);
58+
59+
const CancelButton = () => (
60+
<div
61+
onClick={handlePrevious}
62+
css={{
63+
cursor: 'pointer',
64+
color: theme.colors.link,
65+
fontWeight: theme.font.weight.bold,
66+
marginLeft: theme.base / 2,
67+
display: 'flex',
68+
alignItems: 'center',
69+
}}
70+
>
71+
{t('cancel')}
72+
</div>
73+
);
74+
75+
const SubmitButton = () => {
76+
const submitButtonLabel = hasNext ? t('next') : t('startWorkflow');
77+
78+
return (
79+
<EuiButton
80+
id="button-submit-form-submit"
81+
tabIndex={0}
82+
fill
83+
color={'primary'}
84+
type="submit"
85+
iconSide="right"
86+
aria-label={submitButtonLabel}
87+
disabled={isDisabled}
88+
>
89+
{submitButtonLabel}
90+
</EuiButton>
91+
);
92+
};
3593

3694
return (
3795
<div>
3896
<EuiHorizontalRule />
3997
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
4098
<div>
4199
{(formInputData && formInputData.length > 0 && (
42-
<EuiButton
43-
id="button-submit-form-submit"
44-
tabIndex={0}
45-
fill
46-
onClick={() => {
47-
if (onPrevious) {
48-
onPrevious();
49-
}
50-
}}
51-
color={'primary'}
52-
isLoading={false}
53-
iconSide="right"
54-
aria-label={t('previous')}
55-
disabled={isDisabled}
56-
>
57-
{t('previous')}
58-
</EuiButton>
59-
)) || (
60-
<div
61-
onClick={() => {
62-
if (onCancel) {
63-
onCancel();
64-
}
65-
}}
66-
css={{
67-
cursor: 'pointer',
68-
color: theme.colors.link,
69-
fontWeight: theme.font.weight.bold,
70-
marginLeft: theme.base / 2,
71-
display: 'flex',
72-
alignItems: 'center',
73-
}}
74-
>
75-
{t('cancel')}
76-
</div>
77-
)}
100+
<PreviousButton />
101+
)) || <CancelButton />}
78102
</div>
79103

80-
<EuiButton
81-
id="button-submit-form-submit"
82-
tabIndex={0}
83-
fill
84-
color={'primary'}
85-
isLoading={false}
86-
type="submit"
87-
iconSide="right"
88-
aria-label={submitButtonLabel}
89-
disabled={isDisabled}
90-
>
91-
{submitButtonLabel}
92-
</EuiButton>
104+
<SubmitButton />
93105
</div>
94106
</div>
95107
);

packages/orchestrator-ui-components/src/components/WfoPydanticForm/WfoPydanticForm.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,17 @@ export const WfoPydanticForm = ({
225225
return componentMatcher ? componentMatcher(wfoMatchers) : wfoMatchers;
226226
};
227227

228+
const handleCancel = () => {
229+
const pfBasePath = isTask ? PATH_TASKS : PATH_WORKFLOWS;
230+
router.replace(pfBasePath);
231+
};
232+
228233
return (
229234
<PydanticForm
230235
title={''}
231236
id={processName}
232237
onSuccess={onSuccess}
233-
onCancel={() => {
234-
const pfBasePath = isTask ? PATH_TASKS : PATH_WORKFLOWS;
235-
router.replace(pfBasePath);
236-
}}
238+
onCancel={handleCancel}
237239
loadingComponent={<WfoLoading />}
238240
config={{
239241
apiProvider: getPydanticFormProvider(),

packages/orchestrator-ui-components/src/components/WfoPydanticForm/fields/Summary.tsx

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,31 +71,27 @@ export const Summary: PydanticFormElement = ({ pydanticFormField }) => {
7171

7272
const extraColumnsData = columns.filter((_, index) => index !== 0);
7373

74-
const rows =
75-
columns &&
76-
columns[0] &&
77-
columns[0].map((row, index) => (
78-
<tr key={index}>
79-
{labels && <td className={`label`}>{labels[index]}</td>}
80-
<td className={`value`}>
81-
{typeof row === 'string' &&
82-
row.includes('<!doctype html>') ? (
83-
<div
84-
className="emailMessage"
85-
dangerouslySetInnerHTML={{ __html: row }}
86-
></div>
87-
) : (
88-
row
89-
)}
90-
</td>
91-
{extraColumnsData &&
92-
extraColumnsData.map((_, idx) => (
93-
<td className={`value`} key={idx}>
94-
{extraColumnsData[idx][index]}
95-
</td>
96-
))}
97-
</tr>
98-
));
74+
const rows = columns[0].map((row, index) => (
75+
<tr key={index}>
76+
{labels && <td className={`label`}>{labels[index]}</td>}
77+
<td className={`value`}>
78+
{typeof row === 'string' && row.includes('<!doctype html>') ? (
79+
<div
80+
className="emailMessage"
81+
dangerouslySetInnerHTML={{ __html: row }}
82+
></div>
83+
) : (
84+
row
85+
)}
86+
</td>
87+
{extraColumnsData &&
88+
extraColumnsData.map((_, idx) => (
89+
<td className={`value`} key={idx}>
90+
{extraColumnsData[idx][index]}
91+
</td>
92+
))}
93+
</tr>
94+
));
9995

10096
const tableHeader =
10197
!headers || headers.length === 0 ? null : (

0 commit comments

Comments
 (0)