@orchestrator-ui/orchestrator-ui-components 1.38.2 → 2.1.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 +11 -9
- package/.turbo/turbo-lint.log +5 -2
- package/.turbo/turbo-test.log +14 -14
- package/CHANGELOG.md +30 -0
- package/dist/index.d.ts +329 -172
- package/dist/index.js +6152 -5545
- package/dist/index.js.map +1 -0
- package/package.json +2 -2
- package/src/components/WfoContentHeader/WfoContentHeader.tsx +55 -0
- package/src/components/WfoContentHeader/index.ts +1 -0
- package/src/components/WfoForms/formFields/SubscriptionSummaryField.tsx +6 -5
- package/src/components/WfoInlineNoteEdit/WfoInlineNoteEdit.tsx +105 -0
- package/src/components/WfoInlineNoteEdit/index.ts +1 -0
- package/src/components/WfoPageTemplate/WfoPageHeader/WfoPageHeader.tsx +3 -1
- package/src/components/WfoPageTemplate/WfoSidebar/WfoCopyright.tsx +1 -1
- package/src/components/WfoPageTemplate/WfoSidebar/WfoSidebar.tsx +6 -6
- package/src/components/WfoProcessList/WfoProcessesList.tsx +52 -51
- package/src/components/WfoRadioDropdown/WfoRadioDropdown.tsx +88 -0
- package/src/components/WfoRadioDropdown/index.ts +1 -0
- package/src/components/WfoRenderElementOrString/WfoRenderElementOrString.tsx +16 -0
- package/src/components/WfoRenderElementOrString/index.ts +1 -0
- package/src/components/WfoSubscription/WfoInSyncField.tsx +13 -9
- package/src/components/WfoSubscription/WfoInUseByRelations.tsx +4 -2
- package/src/components/WfoSubscription/WfoProcessesTimeline.tsx +76 -29
- package/src/components/WfoSubscription/WfoRelatedSubscriptions.tsx +92 -84
- package/src/components/WfoSubscription/WfoSubscription.tsx +19 -37
- package/src/components/WfoSubscription/WfoSubscriptionDetailTree.tsx +17 -9
- package/src/components/WfoSubscription/WfoSubscriptionGeneral.tsx +18 -156
- package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionDetailSection.tsx +119 -0
- package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionFixedInputSection.tsx +28 -0
- package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionMetadataSection.tsx +29 -0
- package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionProductInfoSection.tsx +55 -0
- package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/index.ts +4 -0
- package/src/components/WfoSubscription/index.ts +3 -0
- package/src/components/WfoSubscription/overrides/index.ts +1 -0
- package/src/components/WfoSubscription/styles.ts +4 -1
- package/src/components/WfoSubscription/utils/relatedSubscriptionsListItemsObjectMappers.ts +62 -0
- package/src/components/WfoSubscription/utils/utils.spec.ts +0 -13
- package/src/components/WfoSubscription/utils/utils.ts +18 -5
- package/src/components/WfoSubscriptionsList/WfoSubscriptionsList.tsx +105 -100
- package/src/components/WfoTable/{WfoTableWithFilter/WfoTableWithFilter.tsx → WfoAdvancedTable/WfoAdvancedTable.tsx} +65 -123
- package/src/components/WfoTable/WfoAdvancedTable/getRowDetailData.tsx +55 -0
- package/src/components/WfoTable/WfoAdvancedTable/index.ts +4 -0
- package/src/components/WfoTable/WfoAdvancedTable/toSortedTableColumnConfig.ts +12 -0
- package/src/components/WfoTable/WfoAdvancedTable/types.ts +23 -0
- package/src/components/WfoTable/WfoStatusColorField/WfoStatusColorField.tsx +16 -0
- package/src/components/WfoTable/WfoStatusColorField/index.ts +1 -0
- package/src/components/WfoTable/WfoStatusColorField/styles.ts +20 -0
- package/src/components/WfoTable/WfoTable/WfoExpandedRow.tsx +33 -0
- package/src/components/WfoTable/WfoTable/WfoGroupedTable/WfoExpandableRow.tsx +48 -0
- package/src/components/WfoTable/WfoTable/WfoGroupedTable/WfoExpandedGroupRow.tsx +71 -0
- package/src/components/WfoTable/WfoTable/WfoGroupedTable/WfoGroupedTable.tsx +100 -0
- package/src/components/WfoTable/WfoTable/WfoGroupedTable/WfoGroupedTableGroups.tsx +74 -0
- package/src/components/WfoTable/WfoTable/WfoGroupedTable/styles.ts +39 -0
- package/src/components/WfoTable/WfoTable/WfoGroupedTable/useGroupedTableConfig.tsx +184 -0
- package/src/components/WfoTable/WfoTable/WfoGroupedTable/utils.spec.ts +133 -0
- package/src/components/WfoTable/WfoTable/WfoGroupedTable/utils.ts +41 -0
- package/src/components/WfoTable/WfoTable/WfoMultilineCell.tsx +13 -0
- package/src/components/WfoTable/WfoTable/WfoTable.tsx +201 -0
- package/src/components/WfoTable/WfoTable/WfoTableDataRows.tsx +112 -0
- package/src/components/WfoTable/{WfoBasicTable → WfoTable/WfoTableHeaderCell}/WfoSortDirectionIcon.tsx +3 -3
- package/src/components/WfoTable/{WfoBasicTable → WfoTable/WfoTableHeaderCell}/WfoTableHeaderCell.tsx +4 -3
- package/src/components/WfoTable/WfoTable/WfoTableHeaderCell/index.ts +2 -0
- package/src/components/WfoTable/WfoTable/WfoTableHeaderRow.tsx +114 -0
- package/src/components/WfoTable/WfoTable/WfoTruncateCell.tsx +23 -0
- package/src/components/WfoTable/WfoTable/constants.ts +1 -0
- package/src/components/WfoTable/WfoTable/index.ts +14 -0
- package/src/components/WfoTable/WfoTable/styles.ts +117 -0
- package/src/components/WfoTable/WfoTable/utils.spec.ts +79 -0
- package/src/components/WfoTable/WfoTable/utils.ts +78 -0
- package/src/components/WfoTable/WfoTableSettingsModal/WfoTableSettingsModal.tsx +13 -12
- package/src/components/WfoTable/WfoTableWithFilter/index.ts +1 -1
- package/src/components/WfoTable/index.ts +4 -5
- package/src/components/WfoTable/utils/columns.ts +1 -48
- package/src/components/WfoTable/utils/tableUtils.ts +13 -10
- package/src/components/WfoTree/WfoTreeBranch.tsx +10 -1
- package/src/components/WfoTree/WfoTreeNode.tsx +8 -57
- package/src/components/WfoTree/WfoTreeNodeListItem.tsx +65 -0
- package/src/components/WfoTree/styles.ts +28 -4
- package/src/components/index.ts +4 -0
- package/src/configuration/policy-resources.ts +1 -0
- package/src/configuration/version.ts +1 -1
- package/src/icons/WfoXMarkSmall.tsx +29 -0
- package/src/messages/en-GB.json +4 -0
- package/src/messages/nl-NL.json +4 -0
- package/src/pages/metadata/WfoMetadataPageLayout.tsx +4 -4
- package/src/pages/metadata/WfoProductBlocksPage.tsx +42 -59
- package/src/pages/metadata/WfoProductsPage.tsx +41 -47
- package/src/pages/metadata/WfoResourceTypesPage.tsx +26 -35
- package/src/pages/metadata/WfoTasksPage.tsx +35 -33
- package/src/pages/metadata/WfoWorkflowsPage.tsx +33 -29
- package/src/pages/processes/WfoProcessDetail.tsx +47 -55
- package/src/pages/settings/WfoSettingsPage.tsx +9 -4
- package/src/pages/startPage/WfoStartPage.tsx +17 -1
- package/src/pages/subscriptions/WfoSubscriptionsListPage.tsx +4 -5
- package/src/pages/tasks/WfoTasksListPage.tsx +44 -52
- package/src/pages/workflows/WfoWorkflowsListPage.tsx +4 -5
- package/src/rtk/endpoints/index.ts +1 -0
- package/src/rtk/endpoints/relatedSubscriptions.ts +5 -4
- package/src/rtk/endpoints/subscriptionActions.ts +11 -1
- package/src/utils/getObjectKeys.ts +3 -0
- package/src/utils/index.ts +5 -3
- package/tsup.config.ts +10 -0
- package/src/components/WfoTable/WfoBasicTable/WfoBasicTable.tsx +0 -194
- package/src/components/WfoTable/WfoBasicTable/WfoStatusColorField.tsx +0 -21
- package/src/components/WfoTable/WfoBasicTable/index.ts +0 -5
- package/src/components/WfoTable/WfoDataGridTable/WfoDataGridTable.stories.tsx +0 -136
- package/src/components/WfoTable/WfoDataGridTable/WfoDataGridTable.tsx +0 -146
- package/src/components/WfoTable/WfoDataGridTable/WfodataGridColumns.spec.ts +0 -113
- package/src/components/WfoTable/WfoDataGridTable/WfodataGridColumns.ts +0 -81
- package/src/components/WfoTable/utils/mapSortableAndFilterableValuesToTableColumnConfig.spec.ts +0 -52
- package/src/components/WfoTable/utils/mapSortableAndFilterableValuesToTableColumnConfig.ts +0 -23
- /package/src/components/WfoTable/{WfoBasicTable → WfoTable/WfoTableHeaderCell}/styles.ts +0 -0
|
@@ -4,17 +4,22 @@ import { useTranslations } from 'next-intl';
|
|
|
4
4
|
import Link from 'next/link';
|
|
5
5
|
import { useRouter } from 'next/router';
|
|
6
6
|
|
|
7
|
-
import { Pagination } from '@elastic/eui';
|
|
8
|
-
|
|
9
7
|
import {
|
|
10
8
|
FilterQuery,
|
|
11
9
|
PATH_SUBSCRIPTIONS,
|
|
10
|
+
Pagination,
|
|
12
11
|
WfoDateTime,
|
|
13
12
|
WfoInlineJson,
|
|
14
13
|
WfoInsyncIcon,
|
|
15
14
|
WfoJsonCodeBlock,
|
|
16
15
|
WfoSubscriptionStatusBadge,
|
|
16
|
+
getPageIndexChangeHandler,
|
|
17
|
+
getPageSizeChangeHandler,
|
|
17
18
|
} from '@/components';
|
|
19
|
+
import { WfoAdvancedTable } from '@/components/WfoTable/WfoAdvancedTable';
|
|
20
|
+
import { WfoAdvancedTableColumnConfig } from '@/components/WfoTable/WfoAdvancedTable/types';
|
|
21
|
+
import { ColumnType } from '@/components/WfoTable/WfoTable';
|
|
22
|
+
import { mapSortableAndFilterableValuesToTableColumnConfig } from '@/components/WfoTable/WfoTable/utils';
|
|
18
23
|
import { DataDisplayParams, useShowToastMessage } from '@/hooks';
|
|
19
24
|
import {
|
|
20
25
|
useGetSubscriptionListQuery,
|
|
@@ -37,14 +42,10 @@ import {
|
|
|
37
42
|
SUBSCRIPTIONS_TABLE_LOCAL_STORAGE_KEY,
|
|
38
43
|
TableColumnKeys,
|
|
39
44
|
WfoDataSorting,
|
|
40
|
-
|
|
41
|
-
WfoTableWithFilter,
|
|
45
|
+
WfoFirstPartUUID,
|
|
42
46
|
getDataSortHandler,
|
|
43
|
-
getPageChangeHandler,
|
|
44
47
|
getQueryStringHandler,
|
|
45
48
|
} from '../WfoTable';
|
|
46
|
-
import { WfoFirstPartUUID } from '../WfoTable/WfoFirstPartUUID';
|
|
47
|
-
import { mapSortableAndFilterableValuesToTableColumnConfig } from '../WfoTable/utils/mapSortableAndFilterableValuesToTableColumnConfig';
|
|
48
49
|
import {
|
|
49
50
|
SubscriptionListItem,
|
|
50
51
|
mapGraphQlSubscriptionsResultToPageInfo,
|
|
@@ -69,91 +70,88 @@ export const WfoSubscriptionsList: FC<WfoSubscriptionsListProps> = ({
|
|
|
69
70
|
setDataDisplayParam,
|
|
70
71
|
hiddenColumns,
|
|
71
72
|
}) => {
|
|
72
|
-
// TODO: There seems to be a problem showing the product/productName in this list
|
|
73
|
-
// https://github.com/workfloworchestrator/orchestrator-ui/issues/262
|
|
74
|
-
|
|
75
73
|
const router = useRouter();
|
|
76
74
|
const t = useTranslations('subscriptions.index');
|
|
77
75
|
const tError = useTranslations('errors');
|
|
78
76
|
const { showToastMessage } = useShowToastMessage();
|
|
79
77
|
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
78
|
+
const tableColumnConfig: WfoAdvancedTableColumnConfig<SubscriptionListItem> =
|
|
79
|
+
{
|
|
80
|
+
subscriptionId: {
|
|
81
|
+
columnType: ColumnType.DATA,
|
|
82
|
+
label: t('id'),
|
|
83
|
+
renderData: (value) => <WfoFirstPartUUID UUID={value} />,
|
|
84
|
+
renderDetails: (value) => value,
|
|
85
|
+
},
|
|
86
|
+
description: {
|
|
87
|
+
columnType: ColumnType.DATA,
|
|
88
|
+
label: t('description'),
|
|
89
|
+
width: '400px',
|
|
90
|
+
renderData: (value, record) => (
|
|
91
|
+
<Link href={`/subscriptions/${record.subscriptionId}`}>
|
|
92
|
+
{value}
|
|
93
|
+
</Link>
|
|
94
|
+
),
|
|
95
|
+
},
|
|
96
|
+
status: {
|
|
97
|
+
columnType: ColumnType.DATA,
|
|
98
|
+
label: t('status'),
|
|
99
|
+
renderData: (value) => (
|
|
100
|
+
<WfoSubscriptionStatusBadge status={value} />
|
|
101
|
+
),
|
|
102
|
+
},
|
|
103
|
+
insync: {
|
|
104
|
+
columnType: ColumnType.DATA,
|
|
105
|
+
label: t('insync'),
|
|
106
|
+
renderData: (value) => <WfoInsyncIcon inSync={value} />,
|
|
107
|
+
},
|
|
108
|
+
productName: {
|
|
109
|
+
columnType: ColumnType.DATA,
|
|
110
|
+
label: t('product'),
|
|
111
|
+
},
|
|
112
|
+
tag: {
|
|
113
|
+
columnType: ColumnType.DATA,
|
|
114
|
+
label: t('tag'),
|
|
115
|
+
width: '100px',
|
|
116
|
+
},
|
|
117
|
+
customerFullname: {
|
|
118
|
+
columnType: ColumnType.DATA,
|
|
119
|
+
label: t('customerFullname'),
|
|
120
|
+
width: '150px',
|
|
121
|
+
},
|
|
122
|
+
customerShortcode: {
|
|
123
|
+
columnType: ColumnType.DATA,
|
|
124
|
+
label: t('customerShortcode'),
|
|
125
|
+
width: '150px',
|
|
126
|
+
},
|
|
127
|
+
startDate: {
|
|
128
|
+
columnType: ColumnType.DATA,
|
|
129
|
+
label: t('startDate'),
|
|
130
|
+
renderData: (value) => <WfoDateTime dateOrIsoString={value} />,
|
|
131
|
+
renderDetails: parseDateToLocaleDateTimeString,
|
|
132
|
+
clipboardText: parseDateToLocaleDateTimeString,
|
|
133
|
+
},
|
|
134
|
+
endDate: {
|
|
135
|
+
columnType: ColumnType.DATA,
|
|
136
|
+
label: t('endDate'),
|
|
137
|
+
renderData: (value) => <WfoDateTime dateOrIsoString={value} />,
|
|
138
|
+
renderDetails: parseDateToLocaleDateTimeString,
|
|
139
|
+
clipboardText: parseDateToLocaleDateTimeString,
|
|
140
|
+
},
|
|
141
|
+
note: {
|
|
142
|
+
columnType: ColumnType.DATA,
|
|
143
|
+
label: t('note'),
|
|
144
|
+
width: '100px',
|
|
145
|
+
},
|
|
146
|
+
metadata: {
|
|
147
|
+
columnType: ColumnType.DATA,
|
|
148
|
+
label: t('metadata'),
|
|
149
|
+
width: '100px',
|
|
150
|
+
renderData: (value) => <WfoInlineJson data={value} />,
|
|
151
|
+
renderDetails: (value) =>
|
|
152
|
+
value && <WfoJsonCodeBlock data={value} isBasicStyle />,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
157
155
|
|
|
158
156
|
const { sortBy, queryString, pageIndex, pageSize } = dataDisplayParams;
|
|
159
157
|
|
|
@@ -175,7 +173,10 @@ export const WfoSubscriptionsList: FC<WfoSubscriptionsListProps> = ({
|
|
|
175
173
|
getQueryVariablesForExport(graphqlQueryVariables),
|
|
176
174
|
).unwrap();
|
|
177
175
|
|
|
178
|
-
const sortedColumnId = getTypedFieldFromObject(
|
|
176
|
+
const sortedColumnId = getTypedFieldFromObject(
|
|
177
|
+
sortBy?.field,
|
|
178
|
+
tableColumnConfig,
|
|
179
|
+
);
|
|
179
180
|
if (!sortedColumnId) {
|
|
180
181
|
router.replace(PATH_SUBSCRIPTIONS);
|
|
181
182
|
return null;
|
|
@@ -186,15 +187,22 @@ export const WfoSubscriptionsList: FC<WfoSubscriptionsListProps> = ({
|
|
|
186
187
|
sortOrder: dataDisplayParams.sortBy?.order ?? SortOrder.ASC,
|
|
187
188
|
};
|
|
188
189
|
const { totalItems, sortFields, filterFields } = data?.pageInfo ?? {};
|
|
190
|
+
|
|
189
191
|
const pagination: Pagination = {
|
|
190
|
-
pageSize: dataDisplayParams.pageSize,
|
|
191
192
|
pageIndex: dataDisplayParams.pageIndex,
|
|
193
|
+
pageSize: dataDisplayParams.pageSize,
|
|
192
194
|
pageSizeOptions: DEFAULT_PAGE_SIZES,
|
|
193
195
|
totalItemCount: totalItems ?? 0,
|
|
196
|
+
onChangePage:
|
|
197
|
+
getPageIndexChangeHandler<SubscriptionListItem>(
|
|
198
|
+
setDataDisplayParam,
|
|
199
|
+
),
|
|
200
|
+
onChangeItemsPerPage:
|
|
201
|
+
getPageSizeChangeHandler<SubscriptionListItem>(setDataDisplayParam),
|
|
194
202
|
};
|
|
195
203
|
|
|
196
204
|
return (
|
|
197
|
-
<
|
|
205
|
+
<WfoAdvancedTable
|
|
198
206
|
queryString={dataDisplayParams.queryString}
|
|
199
207
|
onUpdateQueryString={getQueryStringHandler<SubscriptionListItem>(
|
|
200
208
|
setDataDisplayParam,
|
|
@@ -204,29 +212,26 @@ export const WfoSubscriptionsList: FC<WfoSubscriptionsListProps> = ({
|
|
|
204
212
|
? mapGraphQlSubscriptionsResultToSubscriptionListItems(data)
|
|
205
213
|
: []
|
|
206
214
|
}
|
|
207
|
-
|
|
208
|
-
|
|
215
|
+
tableColumnConfig={mapSortableAndFilterableValuesToTableColumnConfig(
|
|
216
|
+
tableColumnConfig,
|
|
209
217
|
sortFields,
|
|
210
218
|
filterFields,
|
|
211
219
|
)}
|
|
212
220
|
defaultHiddenColumns={hiddenColumns}
|
|
213
|
-
dataSorting={dataSorting}
|
|
214
|
-
pagination={pagination}
|
|
221
|
+
dataSorting={[dataSorting]}
|
|
215
222
|
isLoading={isFetching}
|
|
216
223
|
localStorageKey={SUBSCRIPTIONS_TABLE_LOCAL_STORAGE_KEY}
|
|
217
224
|
detailModalTitle={'Details - Subscription'}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
onUpdateDataSort={getDataSortHandler<SubscriptionListItem>(
|
|
225
|
+
pagination={pagination}
|
|
226
|
+
error={mapRtkErrorToWfoError(error)}
|
|
227
|
+
onUpdateDataSorting={getDataSortHandler<SubscriptionListItem>(
|
|
222
228
|
setDataDisplayParam,
|
|
223
229
|
)}
|
|
224
|
-
error={mapRtkErrorToWfoError(error)}
|
|
225
230
|
onExportData={csvDownloadHandler(
|
|
226
231
|
getSubscriptionListForExport,
|
|
227
232
|
mapGraphQlSubscriptionsResultToSubscriptionListItems,
|
|
228
233
|
mapGraphQlSubscriptionsResultToPageInfo,
|
|
229
|
-
Object.keys(
|
|
234
|
+
Object.keys(tableColumnConfig),
|
|
230
235
|
getCsvFileNameWithDate('Subscriptions'),
|
|
231
236
|
showToastMessage,
|
|
232
237
|
tError,
|
|
@@ -3,94 +3,70 @@ import React, { useEffect, useState } from 'react';
|
|
|
3
3
|
import { useTranslations } from 'next-intl';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
Criteria,
|
|
7
6
|
EuiButton,
|
|
8
7
|
EuiButtonIcon,
|
|
9
8
|
EuiFlexGroup,
|
|
10
9
|
EuiFlexItem,
|
|
11
10
|
EuiSpacer,
|
|
12
11
|
EuiText,
|
|
13
|
-
Pagination,
|
|
14
12
|
} from '@elastic/eui';
|
|
15
13
|
|
|
16
|
-
import { WfoErrorWithMessage } from '@/components';
|
|
17
|
-
import { useOrchestratorTheme } from '@/hooks';
|
|
18
|
-
import { WfoArrowsExpand } from '@/icons';
|
|
19
|
-
import { WfoGraphqlError } from '@/rtk';
|
|
20
|
-
import { getDefaultTableConfig } from '@/utils/getDefaultTableConfig';
|
|
21
|
-
|
|
22
|
-
import { getTypedFieldFromObject } from '../../../utils';
|
|
23
14
|
import {
|
|
15
|
+
DEFAULT_PAGE_SIZE,
|
|
16
|
+
DEFAULT_PAGE_SIZES,
|
|
17
|
+
TableColumnKeys,
|
|
18
|
+
TableSettingsColumnConfig,
|
|
19
|
+
TableSettingsConfig,
|
|
20
|
+
TableSettingsModal,
|
|
21
|
+
WfoErrorWithMessage,
|
|
22
|
+
WfoInformationModal,
|
|
24
23
|
WfoKeyValueTable,
|
|
25
24
|
WfoKeyValueTableDataType,
|
|
26
|
-
|
|
27
|
-
import { WfoSearchField } from '../../WfoSearchBar';
|
|
28
|
-
import { WfoInformationModal } from '../../WfoSettingsModal';
|
|
29
|
-
import {
|
|
30
|
-
WfoBasicTable,
|
|
31
|
-
WfoBasicTableColumnsWithControlColumns,
|
|
32
|
-
} from '../WfoBasicTable';
|
|
33
|
-
import {
|
|
34
|
-
ColumnConfig,
|
|
35
|
-
TableConfig,
|
|
36
|
-
TableSettingsModal,
|
|
37
|
-
} from '../WfoTableSettingsModal';
|
|
38
|
-
import {
|
|
39
|
-
TableColumnKeys,
|
|
40
|
-
WfoDataSorting,
|
|
41
|
-
WfoTableColumns,
|
|
42
|
-
WfoTableControlColumnConfig,
|
|
43
|
-
WfoTableDataColumnConfig,
|
|
44
|
-
} from '../utils/columns';
|
|
45
|
-
import { DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZES } from '../utils/constants';
|
|
46
|
-
import {
|
|
25
|
+
WfoSearchField,
|
|
47
26
|
clearTableConfigFromLocalStorage,
|
|
48
27
|
setTableConfigToLocalStorage,
|
|
49
|
-
} from '
|
|
50
|
-
import {
|
|
28
|
+
} from '@/components';
|
|
29
|
+
import { getRowDetailData } from '@/components/WfoTable/WfoAdvancedTable/getRowDetailData';
|
|
30
|
+
import { useOrchestratorTheme } from '@/hooks';
|
|
31
|
+
import { WfoArrowsExpand } from '@/icons';
|
|
32
|
+
import { WfoGraphqlError } from '@/rtk';
|
|
33
|
+
import { getDefaultTableConfig } from '@/utils';
|
|
34
|
+
|
|
35
|
+
import { ColumnType, WfoTable, WfoTableProps } from '../WfoTable';
|
|
36
|
+
import { updateQueryString } from '../WfoTableWithFilter/updateQueryString';
|
|
37
|
+
import { WfoAdvancedTableColumnConfig } from './types';
|
|
51
38
|
|
|
52
|
-
export type
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
39
|
+
export type WfoAdvancedTableProps<T extends object> = Omit<
|
|
40
|
+
WfoTableProps<T>,
|
|
41
|
+
'columnConfig'
|
|
42
|
+
> & {
|
|
43
|
+
tableColumnConfig: WfoAdvancedTableColumnConfig<T>;
|
|
57
44
|
defaultHiddenColumns?: TableColumnKeys<T>;
|
|
58
|
-
dataSorting: WfoDataSorting<T>;
|
|
59
|
-
pagination: Pagination;
|
|
60
45
|
queryString?: string;
|
|
61
|
-
isLoading: boolean;
|
|
62
46
|
localStorageKey: string;
|
|
63
47
|
detailModal?: boolean;
|
|
64
48
|
detailModalTitle?: string;
|
|
65
|
-
|
|
66
|
-
onUpdatePage: (criterion: Criteria<T>['page']) => void;
|
|
67
|
-
onUpdateDataSort: (dataSorting: WfoDataSorting<T>) => void;
|
|
49
|
+
exportDataIsLoading?: boolean;
|
|
68
50
|
error?: WfoGraphqlError[];
|
|
51
|
+
onUpdateQueryString: (queryString: string) => void;
|
|
69
52
|
onExportData?: () => void;
|
|
70
|
-
exportDataIsLoading?: boolean;
|
|
71
53
|
};
|
|
72
54
|
|
|
73
|
-
export const
|
|
74
|
-
|
|
75
|
-
tableColumns,
|
|
76
|
-
leadingControlColumns,
|
|
77
|
-
trailingControlColumns,
|
|
55
|
+
export const WfoAdvancedTable = <T extends object>({
|
|
56
|
+
tableColumnConfig,
|
|
78
57
|
defaultHiddenColumns = [],
|
|
79
|
-
dataSorting,
|
|
80
|
-
pagination,
|
|
81
58
|
queryString,
|
|
82
|
-
isLoading,
|
|
83
59
|
localStorageKey,
|
|
84
60
|
detailModal = true,
|
|
85
61
|
detailModalTitle = 'Details',
|
|
86
|
-
|
|
87
|
-
onUpdatePage,
|
|
88
|
-
onUpdateDataSort,
|
|
62
|
+
exportDataIsLoading,
|
|
89
63
|
error,
|
|
64
|
+
onUpdateQueryString,
|
|
90
65
|
onExportData,
|
|
91
|
-
|
|
92
|
-
}:
|
|
66
|
+
...tableProps
|
|
67
|
+
}: WfoAdvancedTableProps<T>) => {
|
|
93
68
|
const { theme } = useOrchestratorTheme();
|
|
69
|
+
|
|
94
70
|
const [hiddenColumns, setHiddenColumns] =
|
|
95
71
|
useState<TableColumnKeys<T>>(defaultHiddenColumns);
|
|
96
72
|
const [showSettingsModal, setShowSettingsModal] = useState(false);
|
|
@@ -105,11 +81,13 @@ export const WfoTableWithFilter = <T extends object>({
|
|
|
105
81
|
}
|
|
106
82
|
}, [defaultHiddenColumns]);
|
|
107
83
|
|
|
108
|
-
const
|
|
84
|
+
const { pagination } = tableProps;
|
|
85
|
+
|
|
86
|
+
const detailsIconColumn: WfoAdvancedTableColumnConfig<T> = {
|
|
109
87
|
viewDetails: {
|
|
110
|
-
|
|
88
|
+
columnType: ColumnType.CONTROL,
|
|
111
89
|
width: '36px',
|
|
112
|
-
|
|
90
|
+
renderControl: (row) => (
|
|
113
91
|
<EuiFlexItem
|
|
114
92
|
css={{ cursor: 'pointer' }}
|
|
115
93
|
onClick={() => setSelectedDataForDetailModal(row)}
|
|
@@ -120,54 +98,30 @@ export const WfoTableWithFilter = <T extends object>({
|
|
|
120
98
|
},
|
|
121
99
|
};
|
|
122
100
|
|
|
123
|
-
const tableColumnsWithControlColumns:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
101
|
+
const tableColumnsWithControlColumns: WfoAdvancedTableColumnConfig<T> = {
|
|
102
|
+
...(detailModal && detailsIconColumn),
|
|
103
|
+
...tableColumnConfig,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const tableSettingsColumns: TableSettingsColumnConfig<T>[] = Object.entries(
|
|
107
|
+
tableColumnConfig,
|
|
108
|
+
).map(([key, { label }]): TableSettingsColumnConfig<T> => {
|
|
109
|
+
const field = key as keyof T;
|
|
130
110
|
|
|
131
|
-
const tableSettingsColumns: ColumnConfig<T>[] = Object.entries<
|
|
132
|
-
WfoTableDataColumnConfig<T, keyof T>
|
|
133
|
-
>(tableColumns).map((keyValuePair) => {
|
|
134
|
-
const { field, name } = keyValuePair[1];
|
|
135
111
|
return {
|
|
136
112
|
field,
|
|
137
|
-
name,
|
|
113
|
+
name: label,
|
|
138
114
|
isVisible: hiddenColumns.indexOf(field) === -1,
|
|
139
115
|
};
|
|
140
116
|
});
|
|
141
117
|
|
|
142
118
|
const rowDetailData: WfoKeyValueTableDataType[] | undefined =
|
|
143
119
|
selectedDataForDetailModal &&
|
|
144
|
-
|
|
145
|
-
const dataField = getTypedFieldFromObject(key, tableColumns);
|
|
146
|
-
if (dataField === null) {
|
|
147
|
-
return {
|
|
148
|
-
key,
|
|
149
|
-
value: undefined,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
120
|
+
getRowDetailData(selectedDataForDetailModal, tableColumnConfig);
|
|
152
121
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return {
|
|
157
|
-
key: name ?? dataField.toString(),
|
|
158
|
-
value: (renderDetails &&
|
|
159
|
-
renderDetails(dataValue, selectedDataForDetailModal)) ??
|
|
160
|
-
(render &&
|
|
161
|
-
render(dataValue, selectedDataForDetailModal)) ?? (
|
|
162
|
-
<>{dataValue}</>
|
|
163
|
-
),
|
|
164
|
-
textToCopy:
|
|
165
|
-
clipboardText?.(dataValue, selectedDataForDetailModal) ??
|
|
166
|
-
(typeof dataValue === 'string' ? dataValue : undefined),
|
|
167
|
-
};
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const handleUpdateTableConfig = (updatedTableConfig: TableConfig<T>) => {
|
|
122
|
+
const handleUpdateTableConfig = (
|
|
123
|
+
updatedTableConfig: TableSettingsConfig<T>,
|
|
124
|
+
) => {
|
|
171
125
|
const updatedHiddenColumns = updatedTableConfig.columns
|
|
172
126
|
.filter((column) => !column.isVisible)
|
|
173
127
|
.map((hiddenColumn) => hiddenColumn.field);
|
|
@@ -177,10 +131,8 @@ export const WfoTableWithFilter = <T extends object>({
|
|
|
177
131
|
hiddenColumns: updatedHiddenColumns,
|
|
178
132
|
selectedPageSize: updatedTableConfig.selectedPageSize,
|
|
179
133
|
});
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
size: updatedTableConfig.selectedPageSize,
|
|
183
|
-
});
|
|
134
|
+
pagination?.onChangeItemsPerPage?.(updatedTableConfig.selectedPageSize);
|
|
135
|
+
pagination?.onChangePage?.(0);
|
|
184
136
|
};
|
|
185
137
|
|
|
186
138
|
const handleResetToDefaults = () => {
|
|
@@ -188,16 +140,10 @@ export const WfoTableWithFilter = <T extends object>({
|
|
|
188
140
|
setHiddenColumns(defaultTableConfig.hiddenColumns);
|
|
189
141
|
setShowSettingsModal(false);
|
|
190
142
|
clearTableConfigFromLocalStorage(localStorageKey);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const onCriteriaChange = (criterion: Criteria<T>) => {
|
|
198
|
-
if (criterion.page) {
|
|
199
|
-
onUpdatePage(criterion.page);
|
|
200
|
-
}
|
|
143
|
+
pagination?.onChangeItemsPerPage?.(
|
|
144
|
+
defaultTableConfig.selectedPageSize ?? DEFAULT_PAGE_SIZE,
|
|
145
|
+
);
|
|
146
|
+
pagination?.onChangePage?.(0);
|
|
201
147
|
};
|
|
202
148
|
|
|
203
149
|
const searchModalText = t.rich('searchModalText', {
|
|
@@ -240,16 +186,10 @@ export const WfoTableWithFilter = <T extends object>({
|
|
|
240
186
|
</EuiFlexGroup>
|
|
241
187
|
{error && <WfoErrorWithMessage error={error} />}
|
|
242
188
|
<EuiSpacer size="m" />
|
|
243
|
-
<
|
|
244
|
-
|
|
245
|
-
columns={tableColumnsWithControlColumns}
|
|
189
|
+
<WfoTable
|
|
190
|
+
columnConfig={tableColumnsWithControlColumns}
|
|
246
191
|
hiddenColumns={hiddenColumns}
|
|
247
|
-
|
|
248
|
-
onUpdateDataSorting={onUpdateDataSort}
|
|
249
|
-
pagination={pagination}
|
|
250
|
-
isLoading={isLoading}
|
|
251
|
-
onCriteriaChange={onCriteriaChange}
|
|
252
|
-
onDataSearch={({ field, searchText }) =>
|
|
192
|
+
onUpdateDataSearch={({ field, searchText }) =>
|
|
253
193
|
onUpdateQueryString(
|
|
254
194
|
updateQueryString(
|
|
255
195
|
queryString ?? '',
|
|
@@ -258,16 +198,18 @@ export const WfoTableWithFilter = <T extends object>({
|
|
|
258
198
|
),
|
|
259
199
|
)
|
|
260
200
|
}
|
|
201
|
+
{...tableProps}
|
|
261
202
|
/>
|
|
203
|
+
|
|
262
204
|
{showSettingsModal && (
|
|
263
205
|
<TableSettingsModal
|
|
264
206
|
tableConfig={{
|
|
265
207
|
columns: tableSettingsColumns,
|
|
266
208
|
selectedPageSize:
|
|
267
|
-
pagination
|
|
209
|
+
pagination?.pageSize ?? DEFAULT_PAGE_SIZE,
|
|
268
210
|
}}
|
|
269
211
|
pageSizeOptions={
|
|
270
|
-
pagination
|
|
212
|
+
pagination?.pageSizeOptions ?? DEFAULT_PAGE_SIZES
|
|
271
213
|
}
|
|
272
214
|
onClose={() => setShowSettingsModal(false)}
|
|
273
215
|
onUpdateTableConfig={handleUpdateTableConfig}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
WfoAdvancedTableColumnConfig,
|
|
5
|
+
WfoAdvancedTableDataColumnConfigItem,
|
|
6
|
+
} from '@/components/WfoTable/WfoAdvancedTable/types';
|
|
7
|
+
import {
|
|
8
|
+
ColumnType,
|
|
9
|
+
WfoTableControlColumnConfigItem,
|
|
10
|
+
} from '@/components/WfoTable/WfoTable';
|
|
11
|
+
import { getTypedFieldFromObject } from '@/utils';
|
|
12
|
+
|
|
13
|
+
export const getRowDetailData = <T extends object>(
|
|
14
|
+
selectedDataForDetailModal: T,
|
|
15
|
+
tableColumnConfig: WfoAdvancedTableColumnConfig<T>,
|
|
16
|
+
) => {
|
|
17
|
+
const tableColumnConfigEntries: [
|
|
18
|
+
string,
|
|
19
|
+
(
|
|
20
|
+
| WfoTableControlColumnConfigItem<T>
|
|
21
|
+
| WfoAdvancedTableDataColumnConfigItem<T, keyof T>
|
|
22
|
+
),
|
|
23
|
+
][] = Object.entries(tableColumnConfig);
|
|
24
|
+
|
|
25
|
+
const dataColumnEntries = tableColumnConfigEntries.filter(
|
|
26
|
+
([, tableColumnConfig]) =>
|
|
27
|
+
tableColumnConfig.columnType === ColumnType.DATA,
|
|
28
|
+
) as [string, WfoAdvancedTableDataColumnConfigItem<T, keyof T>][];
|
|
29
|
+
|
|
30
|
+
return dataColumnEntries.map(([key, value]) => {
|
|
31
|
+
const dataField = getTypedFieldFromObject(key, tableColumnConfig);
|
|
32
|
+
if (dataField === null) {
|
|
33
|
+
return {
|
|
34
|
+
key,
|
|
35
|
+
value: undefined,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { renderDetails, renderData, clipboardText, label } = value;
|
|
40
|
+
const dataValue = selectedDataForDetailModal[dataField];
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
key: label ?? dataField.toString(),
|
|
44
|
+
value: (renderDetails &&
|
|
45
|
+
renderDetails(dataValue, selectedDataForDetailModal)) ??
|
|
46
|
+
(renderData &&
|
|
47
|
+
renderData(dataValue, selectedDataForDetailModal)) ?? (
|
|
48
|
+
<>{dataValue}</>
|
|
49
|
+
),
|
|
50
|
+
textToCopy:
|
|
51
|
+
clipboardText?.(dataValue, selectedDataForDetailModal) ??
|
|
52
|
+
(typeof dataValue === 'string' ? dataValue : undefined),
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WfoAdvancedTableColumnConfig } from '@/components/WfoTable/WfoAdvancedTable/types';
|
|
2
|
+
|
|
3
|
+
export const toSortedTableColumnConfig = <T extends object>(
|
|
4
|
+
columnConfig: WfoAdvancedTableColumnConfig<T>,
|
|
5
|
+
columnKeys: (keyof WfoAdvancedTableColumnConfig<T>)[],
|
|
6
|
+
): WfoAdvancedTableColumnConfig<T> =>
|
|
7
|
+
columnKeys.reduce((sortedConfig, key) => {
|
|
8
|
+
if (key in columnConfig) {
|
|
9
|
+
sortedConfig[key] = columnConfig[key];
|
|
10
|
+
}
|
|
11
|
+
return sortedConfig;
|
|
12
|
+
}, {} as WfoAdvancedTableColumnConfig<T>);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
WfoTableControlColumnConfig,
|
|
5
|
+
WfoTableControlColumnConfigItem,
|
|
6
|
+
WfoTableDataColumnConfigItem,
|
|
7
|
+
} from '@/components/WfoTable/WfoTable';
|
|
8
|
+
|
|
9
|
+
export type WfoAdvancedTableDataColumnConfigItem<
|
|
10
|
+
T extends object,
|
|
11
|
+
Property extends keyof T,
|
|
12
|
+
> = WfoTableDataColumnConfigItem<T, Property> & {
|
|
13
|
+
renderDetails?: (cellValue: T[Property], row: T) => ReactNode;
|
|
14
|
+
clipboardText?: (cellValue: T[Property], row: T) => string;
|
|
15
|
+
};
|
|
16
|
+
export type WfoAdvancedTableDataColumnConfig<T extends object> = {
|
|
17
|
+
[Property in keyof T]:
|
|
18
|
+
| WfoAdvancedTableDataColumnConfigItem<T, Property>
|
|
19
|
+
| WfoTableControlColumnConfigItem<T>;
|
|
20
|
+
};
|
|
21
|
+
export type WfoAdvancedTableColumnConfig<T extends object> = Partial<
|
|
22
|
+
WfoTableControlColumnConfig<T> | WfoAdvancedTableDataColumnConfig<T>
|
|
23
|
+
>;
|