@orchestrator-ui/orchestrator-ui-components 1.6.1 → 1.8.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 +5 -5
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +9 -9
- package/CHANGELOG.md +18 -0
- package/dist/index.d.ts +115 -17
- package/dist/index.js +1645 -1322
- package/package.json +1 -1
- package/src/components/WfoBadges/WfoProductBlockBadge/WfoProductBlockBadge.tsx +1 -0
- package/src/components/WfoExpandableField/WfoExpandableField.tsx +46 -0
- package/src/components/WfoExpandableField/index.ts +1 -0
- package/src/components/WfoExpandableField/styles.ts +18 -0
- package/src/components/WfoPageTemplate/WfoSidebar/WfoSidebar.tsx +10 -0
- package/src/components/WfoPageTemplate/paths.ts +1 -0
- package/src/components/WfoSubscription/WfoSubscriptionProductBlock/WfoProductBlockKeyValueRow.tsx +46 -0
- package/src/components/WfoSubscription/{WfoSubscriptionProductBlock.tsx → WfoSubscriptionProductBlock/WfoSubscriptionProductBlock.tsx} +34 -91
- package/src/components/WfoSubscription/WfoSubscriptionProductBlock/index.ts +2 -0
- package/src/components/WfoSubscription/WfoSubscriptionProductBlock/styles.ts +48 -0
- package/src/components/WfoSubscription/index.ts +2 -0
- package/src/components/WfoSubscription/overrides/index.ts +1 -0
- package/src/components/WfoSubscription/overrides/useSubscriptionDetailValueOverride.ts +35 -0
- package/src/components/WfoSubscription/styles.ts +0 -48
- package/src/components/WfoTable/utils/constants.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/messages/en-GB.json +10 -1
- package/src/messages/nl-NL.json +10 -1
- package/src/pages/metadata/WfoMetadataPageLayout.tsx +6 -1
- package/src/pages/metadata/WfoTasksPage.tsx +226 -0
- package/src/pages/metadata/WfoWorkflowsPage.tsx +5 -4
- package/src/pages/metadata/index.ts +1 -0
- package/src/pages/metadata/taskListObjectMapper.ts +40 -0
- package/src/rtk/endpoints/metadata/index.ts +1 -0
- package/src/rtk/endpoints/metadata/tasks.ts +74 -0
- package/src/rtk/slices/index.ts +2 -1
- package/src/rtk/slices/orchestratorComponentOverride.ts +26 -0
- package/src/rtk/store.ts +22 -5
- package/src/rtk/storeProvider.tsx +8 -1
- package/src/types/types.ts +12 -6
- package/src/utils/getDefaultTableConfig.ts +2 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useTranslations } from 'next-intl';
|
|
4
|
+
|
|
5
|
+
import { EuiBadgeGroup } from '@elastic/eui';
|
|
6
|
+
import type { Pagination } from '@elastic/eui/src/components';
|
|
7
|
+
|
|
8
|
+
import { WfoTableWithFilter, WfoWorkflowTargetBadge } from '@/components';
|
|
9
|
+
import type { WfoDataSorting, WfoTableColumns } from '@/components';
|
|
10
|
+
import { StoredTableConfig } from '@/components';
|
|
11
|
+
import {
|
|
12
|
+
DEFAULT_PAGE_SIZE,
|
|
13
|
+
DEFAULT_PAGE_SIZES,
|
|
14
|
+
METADATA_TASKS_TABLE_LOCAL_STORAGE_KEY,
|
|
15
|
+
WfoProductBlockBadge,
|
|
16
|
+
} from '@/components';
|
|
17
|
+
import {
|
|
18
|
+
getDataSortHandler,
|
|
19
|
+
getPageChangeHandler,
|
|
20
|
+
getQueryStringHandler,
|
|
21
|
+
} from '@/components';
|
|
22
|
+
import { WfoDateTime } from '@/components/WfoDateTime/WfoDateTime';
|
|
23
|
+
import { mapSortableAndFilterableValuesToTableColumnConfig } from '@/components/WfoTable/utils/mapSortableAndFilterableValuesToTableColumnConfig';
|
|
24
|
+
import {
|
|
25
|
+
useDataDisplayParams,
|
|
26
|
+
useShowToastMessage,
|
|
27
|
+
useStoredTableConfig,
|
|
28
|
+
} from '@/hooks';
|
|
29
|
+
import { useGetTasksQuery, useLazyGetTasksQuery } from '@/rtk';
|
|
30
|
+
import type { GraphqlQueryVariables, TaskDefinition } from '@/types';
|
|
31
|
+
import { BadgeType, SortOrder } from '@/types';
|
|
32
|
+
import {
|
|
33
|
+
getQueryVariablesForExport,
|
|
34
|
+
onlyUnique,
|
|
35
|
+
parseDateToLocaleDateTimeString,
|
|
36
|
+
parseIsoString,
|
|
37
|
+
} from '@/utils';
|
|
38
|
+
import {
|
|
39
|
+
csvDownloadHandler,
|
|
40
|
+
getCsvFileNameWithDate,
|
|
41
|
+
} from '@/utils/csvDownload';
|
|
42
|
+
|
|
43
|
+
import { WfoMetadataPageLayout } from './WfoMetadataPageLayout';
|
|
44
|
+
import {
|
|
45
|
+
graphQlTaskListMapper,
|
|
46
|
+
mapTaskDefinitionToTaskListItem,
|
|
47
|
+
} from './taskListObjectMapper';
|
|
48
|
+
|
|
49
|
+
export type TaskListItem = Pick<
|
|
50
|
+
TaskDefinition,
|
|
51
|
+
'name' | 'description' | 'target' | 'createdAt'
|
|
52
|
+
> & {
|
|
53
|
+
productTags: string[];
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const WfoTasksPage = () => {
|
|
57
|
+
const t = useTranslations('metadata.tasks');
|
|
58
|
+
const tError = useTranslations('errors');
|
|
59
|
+
const { showToastMessage } = useShowToastMessage();
|
|
60
|
+
|
|
61
|
+
const [tableDefaults, setTableDefaults] =
|
|
62
|
+
useState<StoredTableConfig<TaskListItem>>();
|
|
63
|
+
|
|
64
|
+
const getStoredTableConfig = useStoredTableConfig<TaskListItem>(
|
|
65
|
+
METADATA_TASKS_TABLE_LOCAL_STORAGE_KEY,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const storedConfig = getStoredTableConfig();
|
|
70
|
+
|
|
71
|
+
if (storedConfig) {
|
|
72
|
+
setTableDefaults(storedConfig);
|
|
73
|
+
}
|
|
74
|
+
}, [getStoredTableConfig]);
|
|
75
|
+
|
|
76
|
+
const { dataDisplayParams, setDataDisplayParam } =
|
|
77
|
+
useDataDisplayParams<TaskListItem>({
|
|
78
|
+
// TODO: Improvement: A default pageSize value is set to avoid a graphql error when the query is executed
|
|
79
|
+
// the fist time before the useEffect has populated the tableDefaults. Better is to create a way for
|
|
80
|
+
// the query to wait for the values to be available
|
|
81
|
+
// https://github.com/workfloworchestrator/orchestrator-ui/issues/261
|
|
82
|
+
pageSize: tableDefaults?.selectedPageSize || DEFAULT_PAGE_SIZE,
|
|
83
|
+
sortBy: {
|
|
84
|
+
field: 'name',
|
|
85
|
+
order: SortOrder.ASC,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const tableColumns: WfoTableColumns<TaskListItem> = {
|
|
90
|
+
name: {
|
|
91
|
+
field: 'name',
|
|
92
|
+
name: t('name'),
|
|
93
|
+
width: '20%',
|
|
94
|
+
render: (name) => (
|
|
95
|
+
<WfoProductBlockBadge badgeType={BadgeType.TASK}>
|
|
96
|
+
{name}
|
|
97
|
+
</WfoProductBlockBadge>
|
|
98
|
+
),
|
|
99
|
+
},
|
|
100
|
+
description: {
|
|
101
|
+
field: 'description',
|
|
102
|
+
name: t('description'),
|
|
103
|
+
width: '40%',
|
|
104
|
+
},
|
|
105
|
+
target: {
|
|
106
|
+
field: 'target',
|
|
107
|
+
name: t('target'),
|
|
108
|
+
width: '15%',
|
|
109
|
+
render: (target) => <WfoWorkflowTargetBadge target={target} />,
|
|
110
|
+
},
|
|
111
|
+
productTags: {
|
|
112
|
+
field: 'productTags',
|
|
113
|
+
name: t('productTags'),
|
|
114
|
+
width: '20%',
|
|
115
|
+
render: (productTags) => (
|
|
116
|
+
<>
|
|
117
|
+
{productTags
|
|
118
|
+
?.filter(onlyUnique)
|
|
119
|
+
.map((productTag, index) => (
|
|
120
|
+
<WfoProductBlockBadge
|
|
121
|
+
key={index}
|
|
122
|
+
badgeType={BadgeType.PRODUCT_TAG}
|
|
123
|
+
>
|
|
124
|
+
{productTag}
|
|
125
|
+
</WfoProductBlockBadge>
|
|
126
|
+
))}
|
|
127
|
+
</>
|
|
128
|
+
),
|
|
129
|
+
renderDetails: (productTags) => (
|
|
130
|
+
<EuiBadgeGroup gutterSize="s">
|
|
131
|
+
{productTags
|
|
132
|
+
?.filter(onlyUnique)
|
|
133
|
+
.map((productTag, index) => (
|
|
134
|
+
<WfoProductBlockBadge
|
|
135
|
+
key={index}
|
|
136
|
+
badgeType={BadgeType.PRODUCT_TAG}
|
|
137
|
+
>
|
|
138
|
+
{productTag}
|
|
139
|
+
</WfoProductBlockBadge>
|
|
140
|
+
))}
|
|
141
|
+
</EuiBadgeGroup>
|
|
142
|
+
),
|
|
143
|
+
},
|
|
144
|
+
createdAt: {
|
|
145
|
+
field: 'createdAt',
|
|
146
|
+
name: t('createdAt'),
|
|
147
|
+
width: '15%',
|
|
148
|
+
render: (date) => <WfoDateTime dateOrIsoString={date} />,
|
|
149
|
+
renderDetails: parseIsoString(parseDateToLocaleDateTimeString),
|
|
150
|
+
clipboardText: parseIsoString(parseDateToLocaleDateTimeString),
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const { pageSize, pageIndex, sortBy, queryString } = dataDisplayParams;
|
|
155
|
+
|
|
156
|
+
const taskListQueryVariables: GraphqlQueryVariables<TaskDefinition> = {
|
|
157
|
+
first: pageSize,
|
|
158
|
+
after: pageIndex * pageSize,
|
|
159
|
+
sortBy: graphQlTaskListMapper(sortBy),
|
|
160
|
+
query: queryString || undefined,
|
|
161
|
+
};
|
|
162
|
+
const { data, isFetching, isError } = useGetTasksQuery(
|
|
163
|
+
taskListQueryVariables,
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const [getTasksTrigger, { isFetching: isFetchingCsv }] =
|
|
167
|
+
useLazyGetTasksQuery();
|
|
168
|
+
|
|
169
|
+
const getTasksForExport = () =>
|
|
170
|
+
getTasksTrigger(
|
|
171
|
+
getQueryVariablesForExport(taskListQueryVariables),
|
|
172
|
+
).unwrap();
|
|
173
|
+
|
|
174
|
+
const dataSorting: WfoDataSorting<TaskListItem> = {
|
|
175
|
+
field: sortBy?.field ?? 'name',
|
|
176
|
+
sortOrder: sortBy?.order ?? SortOrder.ASC,
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const { totalItems, sortFields, filterFields } = data?.pageInfo || {};
|
|
180
|
+
|
|
181
|
+
const pagination: Pagination = {
|
|
182
|
+
pageSize: pageSize,
|
|
183
|
+
pageIndex: pageIndex,
|
|
184
|
+
pageSizeOptions: DEFAULT_PAGE_SIZES,
|
|
185
|
+
totalItemCount: totalItems ? totalItems : 0,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<WfoMetadataPageLayout>
|
|
190
|
+
<WfoTableWithFilter<TaskListItem>
|
|
191
|
+
data={data ? mapTaskDefinitionToTaskListItem(data.tasks) : []}
|
|
192
|
+
tableColumns={mapSortableAndFilterableValuesToTableColumnConfig(
|
|
193
|
+
tableColumns,
|
|
194
|
+
sortFields,
|
|
195
|
+
filterFields,
|
|
196
|
+
)}
|
|
197
|
+
dataSorting={dataSorting}
|
|
198
|
+
defaultHiddenColumns={tableDefaults?.hiddenColumns}
|
|
199
|
+
onUpdateDataSort={getDataSortHandler<TaskListItem>(
|
|
200
|
+
setDataDisplayParam,
|
|
201
|
+
)}
|
|
202
|
+
onUpdatePage={getPageChangeHandler<TaskListItem>(
|
|
203
|
+
setDataDisplayParam,
|
|
204
|
+
)}
|
|
205
|
+
onUpdateQueryString={getQueryStringHandler<TaskListItem>(
|
|
206
|
+
setDataDisplayParam,
|
|
207
|
+
)}
|
|
208
|
+
pagination={pagination}
|
|
209
|
+
isLoading={isFetching}
|
|
210
|
+
hasError={isError}
|
|
211
|
+
queryString={queryString}
|
|
212
|
+
localStorageKey={METADATA_TASKS_TABLE_LOCAL_STORAGE_KEY}
|
|
213
|
+
onExportData={csvDownloadHandler(
|
|
214
|
+
getTasksForExport,
|
|
215
|
+
(data) => data.tasks,
|
|
216
|
+
(data) => data.pageInfo,
|
|
217
|
+
Object.keys(tableColumns),
|
|
218
|
+
getCsvFileNameWithDate('Tasks'),
|
|
219
|
+
showToastMessage,
|
|
220
|
+
tError,
|
|
221
|
+
)}
|
|
222
|
+
exportDataIsLoading={isFetchingCsv}
|
|
223
|
+
/>
|
|
224
|
+
</WfoMetadataPageLayout>
|
|
225
|
+
);
|
|
226
|
+
};
|
|
@@ -98,7 +98,7 @@ export const WfoWorkflowsPage = () => {
|
|
|
98
98
|
name: {
|
|
99
99
|
field: 'name',
|
|
100
100
|
name: t('name'),
|
|
101
|
-
width: '
|
|
101
|
+
width: '20%',
|
|
102
102
|
render: (name) => (
|
|
103
103
|
<WfoProductBlockBadge badgeType={BadgeType.WORKFLOW}>
|
|
104
104
|
{name}
|
|
@@ -108,17 +108,18 @@ export const WfoWorkflowsPage = () => {
|
|
|
108
108
|
description: {
|
|
109
109
|
field: 'description',
|
|
110
110
|
name: t('description'),
|
|
111
|
-
width: '
|
|
111
|
+
width: '40%',
|
|
112
112
|
},
|
|
113
113
|
target: {
|
|
114
114
|
field: 'target',
|
|
115
115
|
name: t('target'),
|
|
116
|
-
width: '
|
|
116
|
+
width: '15%',
|
|
117
117
|
render: (target) => <WfoWorkflowTargetBadge target={target} />,
|
|
118
118
|
},
|
|
119
119
|
productTags: {
|
|
120
120
|
field: 'productTags',
|
|
121
121
|
name: t('productTags'),
|
|
122
|
+
width: '20%',
|
|
122
123
|
render: (productTags) => (
|
|
123
124
|
<>
|
|
124
125
|
{productTags
|
|
@@ -151,7 +152,7 @@ export const WfoWorkflowsPage = () => {
|
|
|
151
152
|
createdAt: {
|
|
152
153
|
field: 'createdAt',
|
|
153
154
|
name: t('createdAt'),
|
|
154
|
-
width: '
|
|
155
|
+
width: '15%',
|
|
155
156
|
render: (date) => <WfoDateTime dateOrIsoString={date} />,
|
|
156
157
|
renderDetails: parseIsoString(parseDateToLocaleDateTimeString),
|
|
157
158
|
clipboardText: parseIsoString(parseDateToLocaleDateTimeString),
|
|
@@ -2,5 +2,6 @@ export * from './WfoProductBlocksPage';
|
|
|
2
2
|
export * from './WfoResourceTypesPage';
|
|
3
3
|
export * from './WfoProductsPage';
|
|
4
4
|
export * from './WfoWorkflowsPage';
|
|
5
|
+
export * from './WfoTasksPage';
|
|
5
6
|
export * from './WfoMetadataPageLayout';
|
|
6
7
|
export * from './workflowListObjectMapper';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { GraphQLSort, TaskDefinition } from '@/types';
|
|
2
|
+
|
|
3
|
+
import { TaskListItem } from './WfoTasksPage';
|
|
4
|
+
|
|
5
|
+
export const mapTaskDefinitionToTaskListItem = (
|
|
6
|
+
tasks: TaskDefinition[],
|
|
7
|
+
): TaskListItem[] =>
|
|
8
|
+
tasks.map((taskDefinition) => {
|
|
9
|
+
const { name, target, description, createdAt, products } =
|
|
10
|
+
taskDefinition;
|
|
11
|
+
|
|
12
|
+
const productTags = products.map((product) => product.tag);
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
name,
|
|
16
|
+
description,
|
|
17
|
+
target,
|
|
18
|
+
createdAt,
|
|
19
|
+
productTags,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const taskFieldMapper = (
|
|
24
|
+
field: keyof TaskListItem,
|
|
25
|
+
): keyof TaskDefinition => {
|
|
26
|
+
switch (field) {
|
|
27
|
+
case 'productTags':
|
|
28
|
+
return 'productTag' as keyof TaskDefinition;
|
|
29
|
+
default:
|
|
30
|
+
return field;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const graphQlTaskListMapper = ({
|
|
35
|
+
field,
|
|
36
|
+
order,
|
|
37
|
+
}: GraphQLSort<TaskListItem>) => ({
|
|
38
|
+
field: taskFieldMapper(field),
|
|
39
|
+
order,
|
|
40
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { orchestratorApi } from '@/rtk';
|
|
2
|
+
import {
|
|
3
|
+
BaseGraphQlResult,
|
|
4
|
+
GraphqlQueryVariables,
|
|
5
|
+
TaskDefinition,
|
|
6
|
+
TaskDefinitionsResult,
|
|
7
|
+
} from '@/types';
|
|
8
|
+
|
|
9
|
+
export const tasksQuery = `
|
|
10
|
+
query MetadataWorkflows(
|
|
11
|
+
$first: Int!
|
|
12
|
+
$after: Int!
|
|
13
|
+
$sortBy: [GraphqlSort!]
|
|
14
|
+
$query: String
|
|
15
|
+
) {
|
|
16
|
+
workflows(
|
|
17
|
+
first: $first
|
|
18
|
+
after: $after
|
|
19
|
+
sortBy: $sortBy
|
|
20
|
+
query: $query
|
|
21
|
+
filterBy: { field: "target", value: "SYSTEM" }
|
|
22
|
+
) {
|
|
23
|
+
page {
|
|
24
|
+
name
|
|
25
|
+
description
|
|
26
|
+
target
|
|
27
|
+
products {
|
|
28
|
+
tag
|
|
29
|
+
}
|
|
30
|
+
createdAt
|
|
31
|
+
}
|
|
32
|
+
pageInfo {
|
|
33
|
+
endCursor
|
|
34
|
+
hasNextPage
|
|
35
|
+
hasPreviousPage
|
|
36
|
+
startCursor
|
|
37
|
+
totalItems
|
|
38
|
+
sortFields
|
|
39
|
+
filterFields
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
export type TasksResponse = {
|
|
46
|
+
tasks: TaskDefinition[];
|
|
47
|
+
} & BaseGraphQlResult;
|
|
48
|
+
|
|
49
|
+
const tasksApi = orchestratorApi.injectEndpoints({
|
|
50
|
+
endpoints: (builder) => ({
|
|
51
|
+
getTasks: builder.query<
|
|
52
|
+
TasksResponse,
|
|
53
|
+
GraphqlQueryVariables<TaskDefinition>
|
|
54
|
+
>({
|
|
55
|
+
query: (variables) => ({
|
|
56
|
+
document: tasksQuery,
|
|
57
|
+
variables,
|
|
58
|
+
}),
|
|
59
|
+
transformResponse: (
|
|
60
|
+
response: TaskDefinitionsResult,
|
|
61
|
+
): TasksResponse => {
|
|
62
|
+
const tasks = response.workflows.page || [];
|
|
63
|
+
const pageInfo = response.workflows.pageInfo || {};
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
tasks,
|
|
67
|
+
pageInfo,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
}),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export const { useGetTasksQuery, useLazyGetTasksQuery } = tasksApi;
|
package/src/rtk/slices/index.ts
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Slice, createSlice } from '@reduxjs/toolkit';
|
|
4
|
+
|
|
5
|
+
import { FieldValue } from '@/types';
|
|
6
|
+
|
|
7
|
+
export type ValueOverrideFunction = (fieldValue: FieldValue) => ReactNode;
|
|
8
|
+
export type ValueOverrideConfiguration = Record<string, ValueOverrideFunction>;
|
|
9
|
+
|
|
10
|
+
export type OrchestratorComponentOverride = {
|
|
11
|
+
subscriptionDetail?: {
|
|
12
|
+
valueOverrides?: ValueOverrideConfiguration;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type OrchestratorComponentOverrideSlice = Slice<OrchestratorComponentOverride>;
|
|
17
|
+
|
|
18
|
+
export const getOrchestratorComponentOverrideSlice = (
|
|
19
|
+
config: OrchestratorComponentOverride,
|
|
20
|
+
): OrchestratorComponentOverrideSlice => {
|
|
21
|
+
return createSlice({
|
|
22
|
+
name: 'orchestratorComponentOverride',
|
|
23
|
+
initialState: config,
|
|
24
|
+
reducers: {},
|
|
25
|
+
});
|
|
26
|
+
};
|
package/src/rtk/store.ts
CHANGED
|
@@ -4,6 +4,10 @@ import type { Dispatch, UnknownAction } from '@reduxjs/toolkit';
|
|
|
4
4
|
import { CombinedState } from '@reduxjs/toolkit/query';
|
|
5
5
|
|
|
6
6
|
import { CustomApiConfig, getCustomApiSlice } from '@/rtk/slices';
|
|
7
|
+
import {
|
|
8
|
+
OrchestratorComponentOverride,
|
|
9
|
+
getOrchestratorComponentOverrideSlice,
|
|
10
|
+
} from '@/rtk/slices/orchestratorComponentOverride';
|
|
7
11
|
import type { OrchestratorConfig } from '@/types';
|
|
8
12
|
|
|
9
13
|
import { orchestratorApi } from './api';
|
|
@@ -17,14 +21,23 @@ export type RootState = {
|
|
|
17
21
|
>;
|
|
18
22
|
toastMessages: ReturnType<typeof toastMessagesReducer>;
|
|
19
23
|
orchestratorConfig: OrchestratorConfig;
|
|
24
|
+
orchestratorComponentOverride?: OrchestratorComponentOverride;
|
|
20
25
|
customApis: CustomApiConfig[];
|
|
21
26
|
};
|
|
22
27
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
customApis
|
|
26
|
-
|
|
28
|
+
export type InitialOrchestratorStoreConfig = Pick<
|
|
29
|
+
RootState,
|
|
30
|
+
'orchestratorConfig' | 'customApis' | 'orchestratorComponentOverride'
|
|
31
|
+
>;
|
|
32
|
+
|
|
33
|
+
export const getOrchestratorStore = ({
|
|
34
|
+
orchestratorConfig,
|
|
35
|
+
orchestratorComponentOverride = {},
|
|
36
|
+
customApis,
|
|
37
|
+
}: InitialOrchestratorStoreConfig): EnhancedStore<RootState> => {
|
|
27
38
|
const configSlice = getOrchestratorConfigSlice(orchestratorConfig);
|
|
39
|
+
const orchestratorComponentOverrideSlice =
|
|
40
|
+
getOrchestratorComponentOverrideSlice(orchestratorComponentOverride);
|
|
28
41
|
const customApisSlice = getCustomApiSlice(customApis);
|
|
29
42
|
|
|
30
43
|
const orchestratorStore = configureStore({
|
|
@@ -32,10 +45,14 @@ export const getOrchestratorStore = (
|
|
|
32
45
|
[orchestratorApi.reducerPath]: orchestratorApi.reducer,
|
|
33
46
|
toastMessages: toastMessagesReducer,
|
|
34
47
|
orchestratorConfig: configSlice.reducer,
|
|
48
|
+
orchestratorComponentOverride:
|
|
49
|
+
orchestratorComponentOverrideSlice.reducer,
|
|
35
50
|
customApis: customApisSlice?.reducer,
|
|
36
51
|
},
|
|
37
52
|
middleware: (getDefaultMiddleware) =>
|
|
38
|
-
getDefaultMiddleware(
|
|
53
|
+
getDefaultMiddleware({
|
|
54
|
+
serializableCheck: false,
|
|
55
|
+
}).concat(orchestratorApi.middleware),
|
|
39
56
|
});
|
|
40
57
|
|
|
41
58
|
return orchestratorStore;
|
|
@@ -3,22 +3,29 @@ import type { ReactNode } from 'react';
|
|
|
3
3
|
import { Provider } from 'react-redux';
|
|
4
4
|
|
|
5
5
|
import { CustomApiConfig } from '@/rtk/slices/customApis';
|
|
6
|
+
import { OrchestratorComponentOverride } from '@/rtk/slices/orchestratorComponentOverride';
|
|
6
7
|
import type { OrchestratorConfig } from '@/types';
|
|
7
8
|
|
|
8
9
|
import { getOrchestratorStore } from './store';
|
|
9
10
|
|
|
10
11
|
export type StoreProviderProps = {
|
|
11
12
|
initialOrchestratorConfig: OrchestratorConfig;
|
|
13
|
+
orchestratorComponentOverride?: OrchestratorComponentOverride;
|
|
12
14
|
customApis?: CustomApiConfig[];
|
|
13
15
|
children: ReactNode;
|
|
14
16
|
};
|
|
15
17
|
|
|
16
18
|
export const StoreProvider = ({
|
|
17
19
|
initialOrchestratorConfig,
|
|
20
|
+
orchestratorComponentOverride,
|
|
18
21
|
customApis = [],
|
|
19
22
|
children,
|
|
20
23
|
}: StoreProviderProps) => {
|
|
21
|
-
const store = getOrchestratorStore(
|
|
24
|
+
const store = getOrchestratorStore({
|
|
25
|
+
orchestratorConfig: initialOrchestratorConfig,
|
|
26
|
+
orchestratorComponentOverride,
|
|
27
|
+
customApis,
|
|
28
|
+
});
|
|
22
29
|
const [orchestratorStore] = useState(store);
|
|
23
30
|
|
|
24
31
|
return <Provider store={orchestratorStore}>{children}</Provider>;
|
package/src/types/types.ts
CHANGED
|
@@ -11,11 +11,6 @@ export type FieldValue = {
|
|
|
11
11
|
value: string | number | boolean;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export type KeyValue = {
|
|
15
|
-
key: string;
|
|
16
|
-
value: string | number | boolean | undefined;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
14
|
export enum EngineStatus {
|
|
20
15
|
RUNNING = 'RUNNING',
|
|
21
16
|
PAUSING = 'PAUSING',
|
|
@@ -77,6 +72,7 @@ export enum BadgeType {
|
|
|
77
72
|
PRODUCT_BLOCK_TAG = 'product_block_tag',
|
|
78
73
|
PRODUCT_TAG = 'product_tag',
|
|
79
74
|
PRODUCT = 'product',
|
|
75
|
+
TASK = 'task',
|
|
80
76
|
}
|
|
81
77
|
|
|
82
78
|
export interface FixedInputDefinition {
|
|
@@ -236,7 +232,13 @@ export interface WorkflowDefinition {
|
|
|
236
232
|
createdAt: string;
|
|
237
233
|
}
|
|
238
234
|
|
|
239
|
-
export
|
|
235
|
+
export interface TaskDefinition {
|
|
236
|
+
name: string;
|
|
237
|
+
description?: string;
|
|
238
|
+
target: WorkflowTarget;
|
|
239
|
+
products: Pick<ProductDefinition, 'tag' | 'productId' | 'name'>[];
|
|
240
|
+
createdAt: string;
|
|
241
|
+
}
|
|
240
242
|
|
|
241
243
|
//// Utility types
|
|
242
244
|
|
|
@@ -333,6 +335,10 @@ export interface CustomersResult {
|
|
|
333
335
|
customers: GraphQlSinglePage<Customer>;
|
|
334
336
|
}
|
|
335
337
|
|
|
338
|
+
export interface TaskDefinitionsResult<T = TaskDefinition> {
|
|
339
|
+
workflows: GraphQlResultPage<T>;
|
|
340
|
+
}
|
|
341
|
+
|
|
336
342
|
export interface WorkflowDefinitionsResult<T = WorkflowDefinition> {
|
|
337
343
|
workflows: GraphQlResultPage<T>;
|
|
338
344
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
METADATA_PRODUCT_BLOCKS_TABLE_LOCAL_STORAGE_KEY,
|
|
8
8
|
METADATA_PRODUCT_TABLE_LOCAL_STORAGE_KEY,
|
|
9
9
|
METADATA_RESOURCE_TYPES_TABLE_LOCAL_STORAGE_KEY,
|
|
10
|
+
METADATA_TASKS_TABLE_LOCAL_STORAGE_KEY,
|
|
10
11
|
METADATA_WORKFLOWS_TABLE_LOCAL_STORAGE_KEY,
|
|
11
12
|
SUBSCRIPTIONS_TABLE_LOCAL_STORAGE_KEY,
|
|
12
13
|
} from '@/components';
|
|
@@ -57,6 +58,7 @@ export const getDefaultTableConfig = <T>(storageKey: string) => {
|
|
|
57
58
|
return getTableConfig<T>(productColumns as (keyof T)[]);
|
|
58
59
|
|
|
59
60
|
case METADATA_WORKFLOWS_TABLE_LOCAL_STORAGE_KEY:
|
|
61
|
+
case METADATA_TASKS_TABLE_LOCAL_STORAGE_KEY:
|
|
60
62
|
const workflowColumns: (keyof WorkflowDefinition)[] = ['createdAt'];
|
|
61
63
|
return getTableConfig<T>(workflowColumns as (keyof T)[]);
|
|
62
64
|
|