@orchestrator-ui/orchestrator-ui-components 4.0.1 → 4.1.1
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 +6 -6
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +6 -6
- package/CHANGELOG.md +13 -0
- package/dist/index.d.ts +78 -26
- package/dist/index.js +104 -78
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/WfoForms/formFields/SelectField/SelectField.tsx +3 -1
- package/src/components/WfoForms/formFields/deprecated/VlanField.tsx +3 -1
- package/src/components/WfoPydanticForm/Footer.tsx +1 -1
- package/src/components/WfoPydanticForm/WfoPydanticForm.tsx +26 -16
- package/src/components/WfoWorkflowSteps/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/configuration/version.ts +1 -1
- package/src/pages/processes/index.ts +1 -0
- package/src/rtk/slices/pydanticForm.ts +18 -0
- package/src/rtk/store.ts +9 -1
- package/src/rtk/storeProvider.tsx +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orchestrator-ui/orchestrator-ui-components",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Library of UI Components used to display the workflow orchestrator frontend",
|
|
6
6
|
"author": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"next-query-params": "^5.0.0",
|
|
49
49
|
"object-hash": "^3.0.0",
|
|
50
50
|
"prism-themes": "^1.9.0",
|
|
51
|
-
"pydantic-forms": "^0.1.
|
|
51
|
+
"pydantic-forms": "^0.1.5",
|
|
52
52
|
"react-diff-view": "^3.2.0",
|
|
53
53
|
"react-draggable": "^4.4.6",
|
|
54
54
|
"react-redux": "^9.1.2",
|
|
@@ -101,7 +101,9 @@ export function UnconnectedSelectField({
|
|
|
101
101
|
if (selectedValue && selectedValue.value !== 'undefined') {
|
|
102
102
|
onChange(selectedValue.value);
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
// Adding the missing dependencies to the dependency array leads to an infinite loop
|
|
105
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
106
|
+
}, []);
|
|
105
107
|
|
|
106
108
|
if (fieldType === Array) {
|
|
107
109
|
// Avoid circular import with our own ListSelectField (instead of recursively trying to use SelectField)
|
|
@@ -165,7 +165,9 @@ function Vlan({
|
|
|
165
165
|
) {
|
|
166
166
|
onChange('');
|
|
167
167
|
}
|
|
168
|
-
|
|
168
|
+
// Adding the missing dependencies to the dependency array leads to an infinite loop
|
|
169
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
170
|
+
}, [onChange, subscriptionId, isFetched, portIsTagged]);
|
|
169
171
|
|
|
170
172
|
const [usedVlansInIms, setUsedVlansInIms] = useState<VlanRange[]>([]);
|
|
171
173
|
const [missingInIms, setMissingInIms] = useState(false);
|
|
@@ -15,7 +15,7 @@ import { WfoPlayFill } from '@/icons';
|
|
|
15
15
|
|
|
16
16
|
export const Footer = () => {
|
|
17
17
|
const { theme } = useOrchestratorTheme();
|
|
18
|
-
const t = useTranslations(
|
|
18
|
+
const t = useTranslations();
|
|
19
19
|
const { rhf, onCancel, allowUntouchedSubmit, isLoading } =
|
|
20
20
|
usePydanticFormContext();
|
|
21
21
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { AbstractIntlMessages, useMessages } from 'next-intl';
|
|
3
|
+
import { AbstractIntlMessages, useMessages, useTranslations } from 'next-intl';
|
|
4
4
|
import { useRouter } from 'next/router';
|
|
5
5
|
import {
|
|
6
6
|
PydanticForm,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
PydanticFormFieldType,
|
|
9
9
|
} from 'pydantic-forms';
|
|
10
10
|
import type {
|
|
11
|
+
ComponentMatcher,
|
|
11
12
|
PydanticComponentMatcher,
|
|
12
13
|
PydanticFormApiProvider,
|
|
13
14
|
PydanticFormLabelProvider,
|
|
@@ -19,6 +20,7 @@ import { PATH_TASKS, PATH_WORKFLOWS, WfoLoading } from '@/components';
|
|
|
19
20
|
import { StartWorkflowPayload } from '@/pages/processes/WfoStartProcessPage';
|
|
20
21
|
import { HttpStatus } from '@/rtk';
|
|
21
22
|
import { useStartProcessMutation } from '@/rtk/endpoints/forms';
|
|
23
|
+
import { useAppSelector } from '@/rtk/hooks';
|
|
22
24
|
|
|
23
25
|
import { Footer } from './Footer';
|
|
24
26
|
import { Row } from './Row';
|
|
@@ -41,6 +43,10 @@ export const WfoPydanticForm = ({
|
|
|
41
43
|
}: WfoPydanticFormProps) => {
|
|
42
44
|
const [startProcess] = useStartProcessMutation();
|
|
43
45
|
const router = useRouter();
|
|
46
|
+
const t = useTranslations('pydanticForms.userInputForm');
|
|
47
|
+
const componentMatcher = useAppSelector(
|
|
48
|
+
(state) => state.pydanticForm?.componentMatcher,
|
|
49
|
+
);
|
|
44
50
|
|
|
45
51
|
const translationMessages: AbstractIntlMessages = useMessages();
|
|
46
52
|
const formTranslations =
|
|
@@ -106,10 +112,19 @@ export const WfoPydanticForm = ({
|
|
|
106
112
|
return pydanticFormProvider;
|
|
107
113
|
};
|
|
108
114
|
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
const pydanticLabelProvider: PydanticFormLabelProvider = async () => {
|
|
116
|
+
return new Promise((resolve) => {
|
|
117
|
+
resolve({
|
|
118
|
+
labels: {
|
|
119
|
+
...(formTranslations as object),
|
|
120
|
+
},
|
|
121
|
+
data: {},
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const wfoComponentMatcher: ComponentMatcher = (currentMatchers) => {
|
|
127
|
+
const wfoMatchers: PydanticComponentMatcher[] = [
|
|
113
128
|
{
|
|
114
129
|
id: 'textarea',
|
|
115
130
|
ElementMatch: {
|
|
@@ -125,17 +140,8 @@ export const WfoPydanticForm = ({
|
|
|
125
140
|
},
|
|
126
141
|
...currentMatchers,
|
|
127
142
|
];
|
|
128
|
-
};
|
|
129
143
|
|
|
130
|
-
|
|
131
|
-
return new Promise((resolve) => {
|
|
132
|
-
resolve({
|
|
133
|
-
labels: {
|
|
134
|
-
...(formTranslations as object),
|
|
135
|
-
},
|
|
136
|
-
data: {},
|
|
137
|
-
});
|
|
138
|
-
});
|
|
144
|
+
return componentMatcher ? componentMatcher(wfoMatchers) : wfoMatchers;
|
|
139
145
|
};
|
|
140
146
|
|
|
141
147
|
return (
|
|
@@ -149,9 +155,13 @@ export const WfoPydanticForm = ({
|
|
|
149
155
|
allowUntouchedSubmit: true,
|
|
150
156
|
footerRenderer: Footer,
|
|
151
157
|
skipSuccessNotice: true,
|
|
152
|
-
componentMatcher:
|
|
158
|
+
componentMatcher: wfoComponentMatcher,
|
|
153
159
|
labelProvider: pydanticLabelProvider,
|
|
154
160
|
rowRenderer: Row,
|
|
161
|
+
customTranslations: {
|
|
162
|
+
cancel: t('cancel'),
|
|
163
|
+
startWorkflow: t('startWorkflow'),
|
|
164
|
+
},
|
|
155
165
|
}}
|
|
156
166
|
/>
|
|
157
167
|
);
|
package/src/components/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ORCHESTRATOR_UI_LIBRARY_VERSION = '4.
|
|
1
|
+
export const ORCHESTRATOR_UI_LIBRARY_VERSION = '4.1.1';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentMatcher } from 'pydantic-forms';
|
|
2
|
+
|
|
3
|
+
import { Slice, createSlice } from '@reduxjs/toolkit';
|
|
4
|
+
|
|
5
|
+
export type PydanticForm = {
|
|
6
|
+
componentMatcher?: ComponentMatcher;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type PydanticFormComponentMatcherSlice = Slice<PydanticForm>;
|
|
10
|
+
|
|
11
|
+
export const getPydanticFormSlice = (
|
|
12
|
+
pydanticForm: PydanticForm,
|
|
13
|
+
): PydanticFormComponentMatcherSlice =>
|
|
14
|
+
createSlice({
|
|
15
|
+
name: 'pydanticForm',
|
|
16
|
+
initialState: pydanticForm,
|
|
17
|
+
reducers: {},
|
|
18
|
+
});
|
package/src/rtk/store.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
OrchestratorComponentOverride,
|
|
9
9
|
getOrchestratorComponentOverrideSlice,
|
|
10
10
|
} from '@/rtk/slices/orchestratorComponentOverride';
|
|
11
|
+
import { PydanticForm, getPydanticFormSlice } from '@/rtk/slices/pydanticForm';
|
|
11
12
|
import type { OrchestratorConfig } from '@/types';
|
|
12
13
|
|
|
13
14
|
import { orchestratorApi } from './api';
|
|
@@ -22,23 +23,29 @@ export type RootState = {
|
|
|
22
23
|
toastMessages: ReturnType<typeof toastMessagesReducer>;
|
|
23
24
|
orchestratorConfig: OrchestratorConfig;
|
|
24
25
|
orchestratorComponentOverride?: OrchestratorComponentOverride;
|
|
26
|
+
pydanticForm?: PydanticForm;
|
|
25
27
|
customApis: CustomApiConfig[];
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
export type InitialOrchestratorStoreConfig = Pick<
|
|
29
31
|
RootState,
|
|
30
|
-
|
|
32
|
+
| 'orchestratorConfig'
|
|
33
|
+
| 'customApis'
|
|
34
|
+
| 'orchestratorComponentOverride'
|
|
35
|
+
| 'pydanticForm'
|
|
31
36
|
>;
|
|
32
37
|
|
|
33
38
|
export const getOrchestratorStore = ({
|
|
34
39
|
orchestratorConfig,
|
|
35
40
|
orchestratorComponentOverride = {},
|
|
41
|
+
pydanticForm = {},
|
|
36
42
|
customApis,
|
|
37
43
|
}: InitialOrchestratorStoreConfig): EnhancedStore<RootState> => {
|
|
38
44
|
const configSlice = getOrchestratorConfigSlice(orchestratorConfig);
|
|
39
45
|
const orchestratorComponentOverrideSlice =
|
|
40
46
|
getOrchestratorComponentOverrideSlice(orchestratorComponentOverride);
|
|
41
47
|
const customApisSlice = getCustomApiSlice(customApis);
|
|
48
|
+
const componentMatcherSlice = getPydanticFormSlice(pydanticForm);
|
|
42
49
|
|
|
43
50
|
const orchestratorStore = configureStore({
|
|
44
51
|
reducer: {
|
|
@@ -48,6 +55,7 @@ export const getOrchestratorStore = ({
|
|
|
48
55
|
orchestratorComponentOverride:
|
|
49
56
|
orchestratorComponentOverrideSlice.reducer,
|
|
50
57
|
customApis: customApisSlice?.reducer,
|
|
58
|
+
pydanticForm: componentMatcherSlice?.reducer,
|
|
51
59
|
},
|
|
52
60
|
middleware: (getDefaultMiddleware) =>
|
|
53
61
|
getDefaultMiddleware({
|
|
@@ -2,6 +2,8 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
import { Provider } from 'react-redux';
|
|
4
4
|
|
|
5
|
+
import type { ComponentMatcher } from 'pydantic-forms';
|
|
6
|
+
|
|
5
7
|
import { emptyOrchestratorConfig } from '@/contexts';
|
|
6
8
|
import { CustomApiConfig } from '@/rtk/slices/customApis';
|
|
7
9
|
import { OrchestratorComponentOverride } from '@/rtk/slices/orchestratorComponentOverride';
|
|
@@ -12,6 +14,7 @@ import { getOrchestratorStore } from './store';
|
|
|
12
14
|
export type StoreProviderProps = {
|
|
13
15
|
initialOrchestratorConfig: OrchestratorConfig | null;
|
|
14
16
|
orchestratorComponentOverride?: OrchestratorComponentOverride;
|
|
17
|
+
componentMatcher?: ComponentMatcher;
|
|
15
18
|
customApis?: CustomApiConfig[];
|
|
16
19
|
children: ReactNode;
|
|
17
20
|
};
|
|
@@ -19,6 +22,7 @@ export type StoreProviderProps = {
|
|
|
19
22
|
export const StoreProvider = ({
|
|
20
23
|
initialOrchestratorConfig,
|
|
21
24
|
orchestratorComponentOverride,
|
|
25
|
+
componentMatcher,
|
|
22
26
|
customApis = [],
|
|
23
27
|
children,
|
|
24
28
|
}: StoreProviderProps) => {
|
|
@@ -26,6 +30,9 @@ export const StoreProvider = ({
|
|
|
26
30
|
orchestratorConfig:
|
|
27
31
|
initialOrchestratorConfig ?? emptyOrchestratorConfig,
|
|
28
32
|
orchestratorComponentOverride,
|
|
33
|
+
pydanticForm: {
|
|
34
|
+
componentMatcher: componentMatcher || undefined,
|
|
35
|
+
},
|
|
29
36
|
customApis,
|
|
30
37
|
});
|
|
31
38
|
const [orchestratorStore] = useState(store);
|