@orchestrator-ui/orchestrator-ui-components 6.8.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +8 -9
- package/CHANGELOG.md +10 -0
- package/dist/index.d.ts +155 -4305
- package/dist/index.js +1636 -5688
- package/dist/index.js.map +1 -1
- package/package.json +4 -8
- package/src/components/WfoPydanticForm/RenderFormErrors.tsx +2 -1
- package/src/components/WfoPydanticForm/Row.tsx +3 -1
- package/src/components/WfoPydanticForm/fields/WfoSummary.tsx +3 -5
- package/src/components/WfoPydanticForm/fields/styles.ts +72 -0
- package/src/components/WfoWorkflowSteps/WfoStep/WfoStep.tsx +10 -27
- package/src/components/WfoWorkflowSteps/WfoStep/WfoStepForm.tsx +1 -1
- package/src/components/index.ts +0 -1
- package/src/configuration/version.ts +1 -1
- package/src/contexts/OrchestratorConfigContext.tsx +0 -1
- package/src/pages/processes/WfoStartProcessPage.tsx +5 -107
- package/src/rtk/endpoints/index.ts +0 -2
- package/src/types/index.ts +0 -1
- package/src/types/types.ts +0 -1
- package/src/components/WfoForms/AutoFieldLoader.tsx +0 -118
- package/src/components/WfoForms/AutoFields.tsx +0 -49
- package/src/components/WfoForms/CreateForm.tsx +0 -75
- package/src/components/WfoForms/UserInputForm.tsx +0 -697
- package/src/components/WfoForms/UserInputFormStyling.ts +0 -80
- package/src/components/WfoForms/UserInputFormWizard.tsx +0 -127
- package/src/components/WfoForms/formFields/AcceptField.tsx +0 -243
- package/src/components/WfoForms/formFields/AcceptFieldStyling.ts +0 -35
- package/src/components/WfoForms/formFields/BoolField.tsx +0 -77
- package/src/components/WfoForms/formFields/BoolFieldStyling.ts +0 -64
- package/src/components/WfoForms/formFields/ConnectedSelectField.tsx +0 -19
- package/src/components/WfoForms/formFields/CustomerField.tsx +0 -77
- package/src/components/WfoForms/formFields/DateField.tsx +0 -72
- package/src/components/WfoForms/formFields/DividerField.tsx +0 -29
- package/src/components/WfoForms/formFields/ErrorField.tsx +0 -40
- package/src/components/WfoForms/formFields/ErrorsField.tsx +0 -34
- package/src/components/WfoForms/formFields/LabelField.tsx +0 -43
- package/src/components/WfoForms/formFields/ListAddField.tsx +0 -95
- package/src/components/WfoForms/formFields/ListDelField.tsx +0 -95
- package/src/components/WfoForms/formFields/ListField.tsx +0 -117
- package/src/components/WfoForms/formFields/ListItemField.tsx +0 -40
- package/src/components/WfoForms/formFields/ListSelectField.tsx +0 -95
- package/src/components/WfoForms/formFields/LocationCodeField.tsx +0 -60
- package/src/components/WfoForms/formFields/LongTextField.tsx +0 -68
- package/src/components/WfoForms/formFields/NestField.tsx +0 -107
- package/src/components/WfoForms/formFields/NumField.tsx +0 -85
- package/src/components/WfoForms/formFields/OptGroupField.tsx +0 -74
- package/src/components/WfoForms/formFields/RadioField.tsx +0 -87
- package/src/components/WfoForms/formFields/SelectField/SelectField.tsx +0 -177
- package/src/components/WfoForms/formFields/SelectField/index.ts +0 -1
- package/src/components/WfoForms/formFields/SelectField/styles.ts +0 -52
- package/src/components/WfoForms/formFields/SubmitField.tsx +0 -50
- package/src/components/WfoForms/formFields/SubscriptionSummaryField.tsx +0 -74
- package/src/components/WfoForms/formFields/SummaryField.tsx +0 -104
- package/src/components/WfoForms/formFields/SummaryFieldStyling.ts +0 -44
- package/src/components/WfoForms/formFields/TextField.tsx +0 -81
- package/src/components/WfoForms/formFields/commonStyles.ts +0 -32
- package/src/components/WfoForms/formFields/deprecated/ContactPersonAutocomplete.tsx +0 -99
- package/src/components/WfoForms/formFields/deprecated/ContactPersonAutocompleteStyles.ts +0 -41
- package/src/components/WfoForms/formFields/deprecated/ContactPersonNameField.tsx +0 -263
- package/src/components/WfoForms/formFields/deprecated/FileUploadField.tsx +0 -151
- package/src/components/WfoForms/formFields/deprecated/ImsNodeIdField.tsx +0 -109
- package/src/components/WfoForms/formFields/deprecated/ImsPortIdField.tsx +0 -233
- package/src/components/WfoForms/formFields/deprecated/ImsPortIdFieldStyling.ts +0 -17
- package/src/components/WfoForms/formFields/deprecated/IpNetworkField.tsx +0 -105
- package/src/components/WfoForms/formFields/deprecated/IpPrefixTableField.tsx +0 -390
- package/src/components/WfoForms/formFields/deprecated/IpPrefixTableFieldStyling.ts +0 -117
- package/src/components/WfoForms/formFields/deprecated/SplitPrefix.tsx +0 -138
- package/src/components/WfoForms/formFields/deprecated/SplitPrefixStyling.ts +0 -11
- package/src/components/WfoForms/formFields/deprecated/SubscriptionField.tsx +0 -263
- package/src/components/WfoForms/formFields/deprecated/SubscriptionFieldStyling.ts +0 -33
- package/src/components/WfoForms/formFields/deprecated/TimestampField.tsx +0 -110
- package/src/components/WfoForms/formFields/deprecated/VlanField.tsx +0 -300
- package/src/components/WfoForms/formFields/deprecated/index.ts +0 -15
- package/src/components/WfoForms/formFields/deprecated/types.ts +0 -74
- package/src/components/WfoForms/formFields/deprecated/utils.ts +0 -1
- package/src/components/WfoForms/formFields/index.ts +0 -30
- package/src/components/WfoForms/formFields/listFieldStyling.ts +0 -86
- package/src/components/WfoForms/formFields/types.ts +0 -41
- package/src/components/WfoForms/formFields/utils.spec.ts +0 -296
- package/src/components/WfoForms/formFields/utils.ts +0 -69
- package/src/components/WfoForms/index.ts +0 -5
- package/src/components/WfoWorkflowSteps/WfoStep/WfoStepFormOld.tsx +0 -67
- package/src/hooks/deprecated/useGetSurfSubcriptionDropdownOptions.ts +0 -37
- package/src/hooks/deprecated/useIsTaggedPort.ts +0 -25
- package/src/rtk/endpoints/deprecated/index.ts +0 -1
- package/src/rtk/endpoints/deprecated/surfSubscriptionDropdownOptions.ts +0 -53
- package/src/rtk/endpoints/formFields.ts +0 -131
- package/src/rtk/endpoints/ipam.ts +0 -54
- package/src/types/deprecated/SurfSubscriptionDropdownOptionsFilterParams.ts +0 -10
- package/src/types/deprecated/index.ts +0 -1
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { css } from '@emotion/react';
|
|
2
|
-
|
|
3
|
-
// Todo: theme with decent colors from theme (style was copied from v1)
|
|
4
|
-
const PRIMARY_COLOR = '#0077cc';
|
|
5
|
-
|
|
6
|
-
export const userInputFormStyling = css`
|
|
7
|
-
.user-input-form {
|
|
8
|
-
h3 {
|
|
9
|
-
padding: 20px 0;
|
|
10
|
-
font-size: larger;
|
|
11
|
-
font-weight: bold;
|
|
12
|
-
margin-bottom: 15px;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.form-input {
|
|
16
|
-
margin: 20px 0;
|
|
17
|
-
|
|
18
|
-
padding-bottom: 20px;
|
|
19
|
-
|
|
20
|
-
em {
|
|
21
|
-
margin-bottom: 1px;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&.first_lightpath,
|
|
25
|
-
&.second_lightpath,
|
|
26
|
-
p.label {
|
|
27
|
-
text-transform: uppercase;
|
|
28
|
-
font-weight: bold;
|
|
29
|
-
color: ${PRIMARY_COLOR};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&.downgrade_redundant_lp_choice,
|
|
33
|
-
&.service_ports_primary,
|
|
34
|
-
&.service_ports_secondary {
|
|
35
|
-
margin-left: 40px;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
b {
|
|
39
|
-
// styles the arrows of numeric input
|
|
40
|
-
margin-top: 4px;
|
|
41
|
-
margin-left: 1px;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
section.form-errors {
|
|
46
|
-
padding-bottom: 20px;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.actions {
|
|
50
|
-
display: flex;
|
|
51
|
-
margin-top: 25px;
|
|
52
|
-
|
|
53
|
-
.notes {
|
|
54
|
-
display: flex;
|
|
55
|
-
align-items: center;
|
|
56
|
-
flex-grow: 2;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
label {
|
|
60
|
-
margin-right: 10px;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/* EUI specific styling for the forms */
|
|
66
|
-
|
|
67
|
-
.euiFormRow {
|
|
68
|
-
margin-bottom: 26px; // For service ports this add margin to the label??
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.euiFormRow__labelWrapper {
|
|
72
|
-
flex-direction: column;
|
|
73
|
-
margin-top: -10px;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.euiFormRow__label__large {
|
|
77
|
-
font-size: +1.1em;
|
|
78
|
-
margin-bottom: 0;
|
|
79
|
-
}
|
|
80
|
-
`;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2019-2023 SURF.
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
import React, { useEffect, useState } from 'react';
|
|
16
|
-
|
|
17
|
-
import { useRouter } from 'next/router';
|
|
18
|
-
import hash from 'object-hash';
|
|
19
|
-
|
|
20
|
-
import type { ConfirmDialogHandler } from '@/contexts';
|
|
21
|
-
import { HttpStatus, handlePromiseErrorWithCallback } from '@/rtk';
|
|
22
|
-
import { FormNotCompleteResponse, InputForm } from '@/types/forms';
|
|
23
|
-
|
|
24
|
-
import { WfoUserInputForm } from './UserInputForm';
|
|
25
|
-
|
|
26
|
-
interface Form {
|
|
27
|
-
form: InputForm;
|
|
28
|
-
hasNext?: boolean;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface UserInputFormWizardProps {
|
|
32
|
-
stepUserInput: InputForm;
|
|
33
|
-
stepSubmit: (processInput: object[]) => Promise<unknown>;
|
|
34
|
-
cancel?: ConfirmDialogHandler;
|
|
35
|
-
isTask: boolean;
|
|
36
|
-
hasNext?: boolean;
|
|
37
|
-
isResuming?: boolean;
|
|
38
|
-
allowSubmit?: boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function stop(e: React.SyntheticEvent) {
|
|
42
|
-
if (e !== undefined && e !== null) {
|
|
43
|
-
e.preventDefault();
|
|
44
|
-
e.stopPropagation();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const UserInputFormWizard = ({
|
|
49
|
-
hasNext = false,
|
|
50
|
-
stepUserInput,
|
|
51
|
-
stepSubmit,
|
|
52
|
-
cancel,
|
|
53
|
-
isTask,
|
|
54
|
-
isResuming = false,
|
|
55
|
-
allowSubmit = true,
|
|
56
|
-
}: UserInputFormWizardProps) => {
|
|
57
|
-
const router = useRouter();
|
|
58
|
-
const [forms, setForms] = useState<Form[]>([
|
|
59
|
-
{ form: stepUserInput, hasNext: hasNext },
|
|
60
|
-
]);
|
|
61
|
-
const [userInputs, setUserInputs] = useState<object[]>([]);
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
setForms([{ form: stepUserInput, hasNext: hasNext }]);
|
|
65
|
-
}, [hasNext, stepUserInput]);
|
|
66
|
-
|
|
67
|
-
const previous: ConfirmDialogHandler = (e) => {
|
|
68
|
-
if (e) {
|
|
69
|
-
stop(e);
|
|
70
|
-
}
|
|
71
|
-
const current = forms.pop();
|
|
72
|
-
setForms(forms.filter((item) => item !== current));
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const submit = (currentFormData: object) => {
|
|
76
|
-
const newUserInputs = userInputs.slice(0, forms.length - 1);
|
|
77
|
-
newUserInputs.push(currentFormData);
|
|
78
|
-
|
|
79
|
-
const promise = stepSubmit(newUserInputs);
|
|
80
|
-
const callback = (data: FormNotCompleteResponse) => {
|
|
81
|
-
window.scrollTo(0, 0);
|
|
82
|
-
setForms([
|
|
83
|
-
...forms,
|
|
84
|
-
{ form: data.form, hasNext: data.meta?.hasNext },
|
|
85
|
-
]);
|
|
86
|
-
setUserInputs(newUserInputs);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
return handlePromiseErrorWithCallback<FormNotCompleteResponse>(
|
|
90
|
-
promise,
|
|
91
|
-
HttpStatus.FormNotComplete,
|
|
92
|
-
callback,
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const currentForm = forms[forms.length - 1];
|
|
97
|
-
const currentUserInput = userInputs[forms.length - 1];
|
|
98
|
-
if (!currentForm || !currentForm.form.properties) {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/* Generate a key based on input widget names that results in a new
|
|
103
|
-
* clean instance + rerender of UserInputForm if the form changes. Without this, state of previous,
|
|
104
|
-
* wizard step can cause wrong/weird default values for forms inputs.
|
|
105
|
-
*
|
|
106
|
-
* Note: to ensure a new form for multiple form wizard steps with exactly the same fields and labels on
|
|
107
|
-
* the form the hash is calculated on the form object itself + length, which generates a unique hash as it
|
|
108
|
-
* has a changing ".length" attribute.
|
|
109
|
-
* */
|
|
110
|
-
const key = hash.sha1({ form: currentForm.form, length: forms.length });
|
|
111
|
-
return (
|
|
112
|
-
<WfoUserInputForm
|
|
113
|
-
key={key}
|
|
114
|
-
router={router}
|
|
115
|
-
stepUserInput={currentForm.form}
|
|
116
|
-
validSubmit={submit}
|
|
117
|
-
previous={previous}
|
|
118
|
-
hasNext={currentForm.hasNext}
|
|
119
|
-
hasPrev={forms.length > 1}
|
|
120
|
-
cancel={cancel}
|
|
121
|
-
userInput={currentUserInput}
|
|
122
|
-
isTask={isTask}
|
|
123
|
-
isResuming={isResuming}
|
|
124
|
-
disabled={!allowSubmit}
|
|
125
|
-
/>
|
|
126
|
-
);
|
|
127
|
-
};
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2019-2023 SURF.
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
import React, { useReducer } from 'react';
|
|
16
|
-
|
|
17
|
-
import { useTranslations } from 'next-intl';
|
|
18
|
-
import { connectField, filterDOMProps } from 'uniforms';
|
|
19
|
-
|
|
20
|
-
import { EuiCheckbox, EuiFlexItem, EuiText } from '@elastic/eui';
|
|
21
|
-
|
|
22
|
-
import { useWithOrchestratorTheme } from '@/hooks';
|
|
23
|
-
|
|
24
|
-
import { getAcceptFieldStyles } from './AcceptFieldStyling';
|
|
25
|
-
import { FieldProps } from './types';
|
|
26
|
-
|
|
27
|
-
type AcceptItemType =
|
|
28
|
-
| 'info'
|
|
29
|
-
| 'label'
|
|
30
|
-
| 'warning'
|
|
31
|
-
| 'url'
|
|
32
|
-
| 'checkbox'
|
|
33
|
-
| '>checkbox'
|
|
34
|
-
| 'checkbox?'
|
|
35
|
-
| '>checkbox?'
|
|
36
|
-
| 'skip'
|
|
37
|
-
| 'margin'
|
|
38
|
-
| 'value';
|
|
39
|
-
type AcceptItem = [string, AcceptItemType, Record<string, string>?];
|
|
40
|
-
type AcceptValue = 'SKIPPED' | 'ACCEPTED' | 'INCOMPLETE';
|
|
41
|
-
|
|
42
|
-
export type AcceptFieldProps = FieldProps<AcceptValue, { data?: AcceptItem[] }>;
|
|
43
|
-
|
|
44
|
-
declare module 'uniforms' {
|
|
45
|
-
interface FilterDOMProps {
|
|
46
|
-
data: never;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
filterDOMProps.register('data');
|
|
51
|
-
|
|
52
|
-
interface AcceptState {
|
|
53
|
-
checks: { [index: number]: boolean };
|
|
54
|
-
skip: boolean;
|
|
55
|
-
allChecked: boolean;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
interface Action {
|
|
59
|
-
field: number;
|
|
60
|
-
type: string;
|
|
61
|
-
value: boolean;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function Accept({
|
|
65
|
-
disabled,
|
|
66
|
-
className = '',
|
|
67
|
-
name,
|
|
68
|
-
onChange,
|
|
69
|
-
error,
|
|
70
|
-
showInlineError,
|
|
71
|
-
errorMessage,
|
|
72
|
-
data,
|
|
73
|
-
...props
|
|
74
|
-
}: AcceptFieldProps) {
|
|
75
|
-
const t = useTranslations();
|
|
76
|
-
const { acceptFieldStyle } = useWithOrchestratorTheme(getAcceptFieldStyles);
|
|
77
|
-
|
|
78
|
-
const legacy = !data;
|
|
79
|
-
const i18nBaseKey = data
|
|
80
|
-
? `pydanticForms.backendTranslations.${name}_accept`
|
|
81
|
-
: 'pydanticForms.backendTranslations';
|
|
82
|
-
|
|
83
|
-
data = data ?? [
|
|
84
|
-
[name, 'label', {}],
|
|
85
|
-
[`${name}_info`, 'info', {}],
|
|
86
|
-
[name, 'checkbox', {}],
|
|
87
|
-
];
|
|
88
|
-
|
|
89
|
-
const [state, dispatch] = useReducer(
|
|
90
|
-
(state: AcceptState, action: Action) => {
|
|
91
|
-
if (action.type === 'skip') {
|
|
92
|
-
state.skip = action.value;
|
|
93
|
-
state.checks = {};
|
|
94
|
-
} else {
|
|
95
|
-
state.checks[action.field] = action.value;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// We intentionally skip optional checkboxes here
|
|
99
|
-
state.allChecked = data!
|
|
100
|
-
.map(
|
|
101
|
-
(entry: AcceptItem, index: number) =>
|
|
102
|
-
[entry, state.checks[index] || false] as [
|
|
103
|
-
AcceptItem,
|
|
104
|
-
boolean,
|
|
105
|
-
],
|
|
106
|
-
)
|
|
107
|
-
.filter((entry: [AcceptItem, boolean]) =>
|
|
108
|
-
entry[0][1].endsWith('checkbox'),
|
|
109
|
-
)
|
|
110
|
-
.map((entry: [AcceptItem, boolean]) => entry[1])
|
|
111
|
-
.every((check: boolean) => check);
|
|
112
|
-
|
|
113
|
-
onChange(
|
|
114
|
-
state.skip
|
|
115
|
-
? 'SKIPPED'
|
|
116
|
-
: state.allChecked
|
|
117
|
-
? 'ACCEPTED'
|
|
118
|
-
: 'INCOMPLETE',
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
return { ...state };
|
|
122
|
-
},
|
|
123
|
-
{ checks: {}, skip: false, allChecked: false },
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<EuiFlexItem css={acceptFieldStyle}>
|
|
128
|
-
<section
|
|
129
|
-
{...filterDOMProps(props)}
|
|
130
|
-
className={`${className} acceptField`}
|
|
131
|
-
>
|
|
132
|
-
{data.map((entry, index) => {
|
|
133
|
-
const label = t(`${i18nBaseKey}.${entry[0]}`, entry[2]);
|
|
134
|
-
|
|
135
|
-
switch (entry[1]) {
|
|
136
|
-
case 'label':
|
|
137
|
-
return (
|
|
138
|
-
<label
|
|
139
|
-
key={index}
|
|
140
|
-
className="euiFormLabel euiFormRow__label"
|
|
141
|
-
>
|
|
142
|
-
{label}
|
|
143
|
-
</label>
|
|
144
|
-
);
|
|
145
|
-
case 'info':
|
|
146
|
-
return (
|
|
147
|
-
<EuiText key={index} size="m">
|
|
148
|
-
{label}
|
|
149
|
-
</EuiText>
|
|
150
|
-
);
|
|
151
|
-
case 'url':
|
|
152
|
-
return (
|
|
153
|
-
<div key={index}>
|
|
154
|
-
<a
|
|
155
|
-
href={entry[0]}
|
|
156
|
-
target="_blank"
|
|
157
|
-
rel="noopener noreferrer"
|
|
158
|
-
>
|
|
159
|
-
{entry[0]}
|
|
160
|
-
</a>
|
|
161
|
-
</div>
|
|
162
|
-
);
|
|
163
|
-
case 'value':
|
|
164
|
-
return (
|
|
165
|
-
<div key={index}>
|
|
166
|
-
<input value={entry[0]} disabled={true} />
|
|
167
|
-
</div>
|
|
168
|
-
);
|
|
169
|
-
case 'margin':
|
|
170
|
-
return <br key={index} />;
|
|
171
|
-
case 'warning':
|
|
172
|
-
return (
|
|
173
|
-
<label
|
|
174
|
-
key={index}
|
|
175
|
-
className="euiFormLabel euiFormRow__label warning"
|
|
176
|
-
>
|
|
177
|
-
{label}: <br />
|
|
178
|
-
</label>
|
|
179
|
-
);
|
|
180
|
-
case 'skip':
|
|
181
|
-
return (
|
|
182
|
-
<EuiCheckbox
|
|
183
|
-
id={entry[0]}
|
|
184
|
-
key={index}
|
|
185
|
-
name={entry[0]}
|
|
186
|
-
onChange={(
|
|
187
|
-
e: React.FormEvent<HTMLInputElement>,
|
|
188
|
-
) => {
|
|
189
|
-
const target =
|
|
190
|
-
e.target as HTMLInputElement;
|
|
191
|
-
dispatch({
|
|
192
|
-
field: index,
|
|
193
|
-
type: 'skip',
|
|
194
|
-
value: target.checked,
|
|
195
|
-
});
|
|
196
|
-
}}
|
|
197
|
-
checked={state.skip}
|
|
198
|
-
label={label}
|
|
199
|
-
className={'skip'}
|
|
200
|
-
/>
|
|
201
|
-
);
|
|
202
|
-
default:
|
|
203
|
-
return (
|
|
204
|
-
<EuiCheckbox
|
|
205
|
-
id={entry[0] + (legacy ? '' : index)}
|
|
206
|
-
key={index}
|
|
207
|
-
name={entry[0] + (legacy ? '' : index)} // Index needed to allow checkboxes with same name (we can skip this in legacy mode)
|
|
208
|
-
className={
|
|
209
|
-
entry[1].startsWith('>')
|
|
210
|
-
? 'level_2'
|
|
211
|
-
: undefined
|
|
212
|
-
}
|
|
213
|
-
onChange={(
|
|
214
|
-
e: React.FormEvent<HTMLInputElement>,
|
|
215
|
-
) => {
|
|
216
|
-
const target =
|
|
217
|
-
e.target as HTMLInputElement;
|
|
218
|
-
|
|
219
|
-
dispatch({
|
|
220
|
-
field: index,
|
|
221
|
-
type: 'check',
|
|
222
|
-
value: target.checked,
|
|
223
|
-
});
|
|
224
|
-
}}
|
|
225
|
-
checked={state.checks[index]}
|
|
226
|
-
label={label}
|
|
227
|
-
readOnly={state.skip || disabled}
|
|
228
|
-
/>
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
})}
|
|
232
|
-
|
|
233
|
-
{error && showInlineError && (
|
|
234
|
-
<em className="error">
|
|
235
|
-
<div className="backend-validation">{errorMessage}</div>
|
|
236
|
-
</em>
|
|
237
|
-
)}
|
|
238
|
-
</section>
|
|
239
|
-
</EuiFlexItem>
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
export const AcceptField = connectField(Accept);
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { css } from '@emotion/react';
|
|
2
|
-
|
|
3
|
-
import { WfoTheme } from '@/hooks';
|
|
4
|
-
|
|
5
|
-
export const getAcceptFieldStyles = ({ theme }: WfoTheme) => {
|
|
6
|
-
const acceptFieldStyle = css({
|
|
7
|
-
'.acceptField': {
|
|
8
|
-
'label.warning': {
|
|
9
|
-
color: theme.colors.danger,
|
|
10
|
-
},
|
|
11
|
-
'.skip': {
|
|
12
|
-
color: theme.colors.success,
|
|
13
|
-
fontStyle: 'italic',
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
// Don't touch the margin + padding: they also control if the user can click on the checkbox instead of label
|
|
17
|
-
'.level_2': {
|
|
18
|
-
marginLeft: '24px',
|
|
19
|
-
padding: 0,
|
|
20
|
-
label: {
|
|
21
|
-
marginTop: 0,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
'.labelTitle': {
|
|
26
|
-
fontWeight: '600',
|
|
27
|
-
color: theme.colors.text,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
acceptFieldStyle: acceptFieldStyle,
|
|
34
|
-
};
|
|
35
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2019-2023 SURF.
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*
|
|
8
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
* See the License for the specific language governing permissions and
|
|
12
|
-
* limitations under the License.
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
import React from 'react';
|
|
16
|
-
|
|
17
|
-
import { connectField, filterDOMProps } from 'uniforms';
|
|
18
|
-
|
|
19
|
-
import { EuiCheckbox, EuiFlexItem, EuiFormRow, EuiText } from '@elastic/eui';
|
|
20
|
-
|
|
21
|
-
import { FieldProps } from '@/components';
|
|
22
|
-
import { getCommonFormFieldStyles } from '@/components/WfoForms/formFields/commonStyles';
|
|
23
|
-
import { useWithOrchestratorTheme } from '@/hooks';
|
|
24
|
-
|
|
25
|
-
import { boolFieldStyling } from './BoolFieldStyling';
|
|
26
|
-
|
|
27
|
-
export type BoolFieldProps = FieldProps<boolean>;
|
|
28
|
-
|
|
29
|
-
function Bool({
|
|
30
|
-
disabled,
|
|
31
|
-
id,
|
|
32
|
-
className = '',
|
|
33
|
-
label,
|
|
34
|
-
description,
|
|
35
|
-
name,
|
|
36
|
-
onChange,
|
|
37
|
-
readOnly,
|
|
38
|
-
value,
|
|
39
|
-
error,
|
|
40
|
-
showInlineError,
|
|
41
|
-
errorMessage,
|
|
42
|
-
...props
|
|
43
|
-
}: BoolFieldProps) {
|
|
44
|
-
const { formRowStyle } = useWithOrchestratorTheme(getCommonFormFieldStyles);
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<EuiFlexItem css={boolFieldStyling}>
|
|
48
|
-
<section
|
|
49
|
-
{...filterDOMProps(props)}
|
|
50
|
-
className={`${className} bool-field`}
|
|
51
|
-
>
|
|
52
|
-
<EuiFormRow
|
|
53
|
-
css={formRowStyle}
|
|
54
|
-
label={label}
|
|
55
|
-
labelAppend={<EuiText size="m">{description}</EuiText>}
|
|
56
|
-
error={showInlineError ? errorMessage : false}
|
|
57
|
-
isInvalid={error}
|
|
58
|
-
id={id}
|
|
59
|
-
fullWidth
|
|
60
|
-
>
|
|
61
|
-
<EuiCheckbox
|
|
62
|
-
checked={value || false}
|
|
63
|
-
disabled={disabled}
|
|
64
|
-
id={id}
|
|
65
|
-
name={name}
|
|
66
|
-
label={label || <div> </div>}
|
|
67
|
-
onChange={() =>
|
|
68
|
-
!disabled && !readOnly && onChange(!value)
|
|
69
|
-
}
|
|
70
|
-
/>
|
|
71
|
-
</EuiFormRow>
|
|
72
|
-
</section>
|
|
73
|
-
</EuiFlexItem>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export const BoolField = connectField(Bool, { kind: 'leaf' });
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { css } from '@emotion/react';
|
|
2
|
-
|
|
3
|
-
// Todo: theme with decent colors from theme (style was copied from v1)
|
|
4
|
-
const PRIMARY_COLOR = '#0077cc';
|
|
5
|
-
const LIGHT_GREY_COLOR = '#eff2f3';
|
|
6
|
-
const MEDIUM_GREY_COLOR = '#a6b6be';
|
|
7
|
-
|
|
8
|
-
export const boolFieldStyling = css`
|
|
9
|
-
|
|
10
|
-
.bool-field {
|
|
11
|
-
.euiCheckbox .euiCheckbox__input ~ .euiCheckbox__label {
|
|
12
|
-
z-index: unset;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
label {
|
|
16
|
-
display: inline-block;
|
|
17
|
-
margin: 3px 0;
|
|
18
|
-
&.info {
|
|
19
|
-
margin-left: 10px;
|
|
20
|
-
cursor: pointer;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
input[type="checkbox"] + label span {
|
|
25
|
-
font-size: 11px;
|
|
26
|
-
background-color: white;
|
|
27
|
-
border: 1px solid ${PRIMARY_COLOR};
|
|
28
|
-
border-radius: 3px;
|
|
29
|
-
padding: 1px 2px;
|
|
30
|
-
margin: 2px 0;
|
|
31
|
-
cursor: pointer;
|
|
32
|
-
i {
|
|
33
|
-
color: transparent;
|
|
34
|
-
padding: 0 1px;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
input[type="checkbox"]:disabled + label span {
|
|
39
|
-
border: 1px solid ${MEDIUM_GREY_COLOR}
|
|
40
|
-
background-color: ${LIGHT_GREY_COLOR};
|
|
41
|
-
cursor: not-allowed;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
input[type="checkbox"]:checked + label span {
|
|
45
|
-
border: 2px solid ${PRIMARY_COLOR};
|
|
46
|
-
border-radius: 2px;
|
|
47
|
-
box-shadow: none;
|
|
48
|
-
padding: 0;
|
|
49
|
-
i {
|
|
50
|
-
background-color: ${PRIMARY_COLOR};
|
|
51
|
-
color: white;
|
|
52
|
-
padding: 3px 2px;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
input[type="checkbox"]:checked:disabled + label span {
|
|
57
|
-
border: 3px solid ${MEDIUM_GREY_COLOR};
|
|
58
|
-
cursor: default;
|
|
59
|
-
i {
|
|
60
|
-
background-color: ${MEDIUM_GREY_COLOR};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { connectField } from 'uniforms';
|
|
4
|
-
|
|
5
|
-
import type { SelectFieldProps } from './SelectField';
|
|
6
|
-
import { UnconnectedSelectField } from './SelectField';
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
The selectField has a connected and unconnected version. When a SelectField is called from another field that
|
|
10
|
-
is connected it can cause errors as described here: https://github.com/workfloworchestrator/orchestrator-ui-library/issues/681
|
|
11
|
-
When called directly it will still need the props that the connectField function provides so it has a connected version as well.
|
|
12
|
-
*/
|
|
13
|
-
const ConnectedSelect = (props: SelectFieldProps) => {
|
|
14
|
-
return <UnconnectedSelectField {...props} />;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const ConnectedSelectField = connectField(ConnectedSelect, {
|
|
18
|
-
kind: 'leaf',
|
|
19
|
-
});
|