@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
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { GroupedData } from './WfoGroupedTable';
|
|
2
|
+
import { getTotalNumberOfRows, groupData } from './utils';
|
|
3
|
+
|
|
4
|
+
type TestObject = {
|
|
5
|
+
name: string;
|
|
6
|
+
age: number;
|
|
7
|
+
group: 'group1' | 'group2';
|
|
8
|
+
subGroup: 'subGroup1' | 'subGroup2';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
describe('WfoGroupedTable - utils', () => {
|
|
12
|
+
describe('groupData()', () => {
|
|
13
|
+
it('successfully groups the data', () => {
|
|
14
|
+
// Given
|
|
15
|
+
const testData: TestObject[] = [
|
|
16
|
+
{
|
|
17
|
+
name: 'John',
|
|
18
|
+
age: 25,
|
|
19
|
+
group: 'group2',
|
|
20
|
+
subGroup: 'subGroup1',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'Bob',
|
|
24
|
+
age: 40,
|
|
25
|
+
group: 'group2',
|
|
26
|
+
subGroup: 'subGroup2',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'Jane',
|
|
30
|
+
age: 30,
|
|
31
|
+
group: 'group2',
|
|
32
|
+
subGroup: 'subGroup2',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'Tom',
|
|
36
|
+
age: 35,
|
|
37
|
+
group: 'group1',
|
|
38
|
+
subGroup: 'subGroup1',
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
// When
|
|
43
|
+
const result = groupData(testData, [
|
|
44
|
+
(data) => data.group,
|
|
45
|
+
(data) => data.subGroup,
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
// Then
|
|
49
|
+
const expected: GroupedData<TestObject> = {
|
|
50
|
+
group1: {
|
|
51
|
+
subGroup1: [
|
|
52
|
+
{
|
|
53
|
+
name: 'Tom',
|
|
54
|
+
age: 35,
|
|
55
|
+
group: 'group1',
|
|
56
|
+
subGroup: 'subGroup1',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
group2: {
|
|
61
|
+
subGroup1: [
|
|
62
|
+
{
|
|
63
|
+
name: 'John',
|
|
64
|
+
age: 25,
|
|
65
|
+
group: 'group2',
|
|
66
|
+
subGroup: 'subGroup1',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
subGroup2: [
|
|
70
|
+
{
|
|
71
|
+
name: 'Bob',
|
|
72
|
+
age: 40,
|
|
73
|
+
group: 'group2',
|
|
74
|
+
subGroup: 'subGroup2',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'Jane',
|
|
78
|
+
age: 30,
|
|
79
|
+
group: 'group2',
|
|
80
|
+
subGroup: 'subGroup2',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
expect(result).toEqual(expected);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('getTotalNumberOfRows()', () => {
|
|
90
|
+
it('counts the total number of data rows', () => {
|
|
91
|
+
const testData: GroupedData<TestObject> = {
|
|
92
|
+
group1: {
|
|
93
|
+
subGroup1: [
|
|
94
|
+
{
|
|
95
|
+
name: 'John',
|
|
96
|
+
age: 25,
|
|
97
|
+
group: 'group1',
|
|
98
|
+
subGroup: 'subGroup1',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'Bob',
|
|
102
|
+
age: 40,
|
|
103
|
+
group: 'group1',
|
|
104
|
+
subGroup: 'subGroup1',
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
subGroup2: [
|
|
108
|
+
{
|
|
109
|
+
name: 'Jane',
|
|
110
|
+
age: 30,
|
|
111
|
+
group: 'group1',
|
|
112
|
+
subGroup: 'subGroup2',
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
group2: {
|
|
117
|
+
subGroup1: [
|
|
118
|
+
{
|
|
119
|
+
name: 'Tom',
|
|
120
|
+
age: 35,
|
|
121
|
+
group: 'group1',
|
|
122
|
+
subGroup: 'subGroup1',
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const result = getTotalNumberOfRows(testData);
|
|
129
|
+
|
|
130
|
+
expect(result).toEqual(4);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { GroupedData } from './WfoGroupedTable';
|
|
2
|
+
|
|
3
|
+
export const groupData = <T>(
|
|
4
|
+
data: T[],
|
|
5
|
+
groupByFunctions: Array<(data: T) => string>,
|
|
6
|
+
): GroupedData<T> => {
|
|
7
|
+
const groupedData = data.reduce<Record<string, T[]>>(
|
|
8
|
+
(groupedData, relatedSubscription) => {
|
|
9
|
+
// In case the array of groupedByFunctions is empty
|
|
10
|
+
const groupName =
|
|
11
|
+
groupByFunctions[0]?.(relatedSubscription) ?? 'Ungrouped';
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
...groupedData,
|
|
15
|
+
[groupName]: [
|
|
16
|
+
...(groupedData[groupName] || []),
|
|
17
|
+
relatedSubscription,
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
{},
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
if (groupByFunctions.length <= 1) {
|
|
25
|
+
return groupedData;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const entries = Object.entries(groupedData).map(([key, value]) => [
|
|
29
|
+
key,
|
|
30
|
+
groupData(value, groupByFunctions.slice(1)),
|
|
31
|
+
]);
|
|
32
|
+
return Object.fromEntries(entries);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const getTotalNumberOfRows = <T>(groupedData: GroupedData<T>): number =>
|
|
36
|
+
Object.entries(groupedData).reduce((totalEntries, entry) => {
|
|
37
|
+
const value = entry[1];
|
|
38
|
+
return Array.isArray(value)
|
|
39
|
+
? totalEntries + value.length
|
|
40
|
+
: totalEntries + getTotalNumberOfRows(value);
|
|
41
|
+
}, 0);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { FC, ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
export type WfoMultilineCellProps = {
|
|
4
|
+
children?: ReactElement | string | null;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const WfoMultilineCell: FC<WfoMultilineCellProps> = ({ children }) => {
|
|
8
|
+
if (!children) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return <p css={{ textWrap: 'wrap' }}>{children}</p>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import React, { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useTranslations } from 'next-intl';
|
|
4
|
+
|
|
5
|
+
import { EuiSpacer, EuiTablePagination, useEuiScrollBar } from '@elastic/eui';
|
|
6
|
+
|
|
7
|
+
import { useWithOrchestratorTheme } from '@/hooks';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
TableColumnKeys,
|
|
11
|
+
WfoDataSearch,
|
|
12
|
+
WfoDataSorting,
|
|
13
|
+
} from '../utils/columns';
|
|
14
|
+
import { DEFAULT_PAGE_SIZES } from '../utils/constants';
|
|
15
|
+
import { WfoTableDataRows } from './WfoTableDataRows';
|
|
16
|
+
import { WfoTableHeaderRow } from './WfoTableHeaderRow';
|
|
17
|
+
import { getWfoTableStyles } from './styles';
|
|
18
|
+
import { getSortedVisibleColumns } from './utils';
|
|
19
|
+
|
|
20
|
+
export type Pagination = {
|
|
21
|
+
pageSize: number;
|
|
22
|
+
pageIndex: number;
|
|
23
|
+
totalItemCount: number;
|
|
24
|
+
pageSizeOptions?: number[];
|
|
25
|
+
onChangeItemsPerPage?: (pageSize: number) => void;
|
|
26
|
+
onChangePage?: (pageIndex: number) => void;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export enum ColumnType {
|
|
30
|
+
DATA = 'data',
|
|
31
|
+
CONTROL = 'control',
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type CommonTableColumnConfigItemProps = {
|
|
35
|
+
numberOfColumnsToSpan?: number;
|
|
36
|
+
disableDefaultCellStyle?: boolean;
|
|
37
|
+
width?: CSSProperties['width'];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type WfoTableDataColumnConfigItem<
|
|
41
|
+
T extends object,
|
|
42
|
+
Property extends keyof T,
|
|
43
|
+
> = CommonTableColumnConfigItemProps & {
|
|
44
|
+
columnType: ColumnType.DATA;
|
|
45
|
+
label: string;
|
|
46
|
+
isSortable?: boolean;
|
|
47
|
+
isFilterable?: boolean;
|
|
48
|
+
renderData?: (cellValue: T[Property], row: T) => ReactNode;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type WfoTableControlColumnConfigItem<T extends object> =
|
|
52
|
+
CommonTableColumnConfigItemProps & {
|
|
53
|
+
columnType: ColumnType.CONTROL;
|
|
54
|
+
label?: string;
|
|
55
|
+
renderControl: (row: T) => ReactNode;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type WfoTableDataColumnConfig<T extends object> = {
|
|
59
|
+
[Property in keyof T]:
|
|
60
|
+
| WfoTableDataColumnConfigItem<T, Property>
|
|
61
|
+
| WfoTableControlColumnConfigItem<T>;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type WfoTableControlColumnConfig<T extends object> = {
|
|
65
|
+
[key: string]: WfoTableControlColumnConfigItem<T>; // from WfoTableColumnConfig -- consider extracting type
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Applying "Partial" since data should not always be shown in the table, but can still be needed for rendering
|
|
69
|
+
// Not providing a config for a property of T means that the column will not be shown in the table
|
|
70
|
+
export type WfoTableColumnConfig<T extends object> = Partial<
|
|
71
|
+
WfoTableDataColumnConfig<T> | WfoTableControlColumnConfig<T>
|
|
72
|
+
>;
|
|
73
|
+
|
|
74
|
+
export type WfoTableProps<T extends object> = {
|
|
75
|
+
data: T[];
|
|
76
|
+
columnConfig: WfoTableColumnConfig<T>;
|
|
77
|
+
hiddenColumns?: TableColumnKeys<T>;
|
|
78
|
+
columnOrder?: TableColumnKeys<T>;
|
|
79
|
+
isLoading?: boolean;
|
|
80
|
+
dataSorting?: WfoDataSorting<T>[];
|
|
81
|
+
rowExpandingConfiguration?: {
|
|
82
|
+
uniqueRowId: keyof WfoTableColumnConfig<T>;
|
|
83
|
+
uniqueRowIdToExpandedRowMap: Record<string, ReactNode>;
|
|
84
|
+
};
|
|
85
|
+
pagination?: Pagination;
|
|
86
|
+
overrideHeader?: (
|
|
87
|
+
tableHeaderEntries: Array<
|
|
88
|
+
[
|
|
89
|
+
string,
|
|
90
|
+
(
|
|
91
|
+
| WfoTableControlColumnConfigItem<T>
|
|
92
|
+
| WfoTableDataColumnConfigItem<T, keyof T>
|
|
93
|
+
),
|
|
94
|
+
]
|
|
95
|
+
>,
|
|
96
|
+
) => ReactNode;
|
|
97
|
+
onRowClick?: (row: T) => void;
|
|
98
|
+
onUpdateDataSorting?: (updatedDataSorting: WfoDataSorting<T>) => void;
|
|
99
|
+
onUpdateDataSearch?: (updatedDataSearch: WfoDataSearch<T>) => void;
|
|
100
|
+
className?: string;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const WfoTable = <T extends object>({
|
|
104
|
+
data,
|
|
105
|
+
columnConfig,
|
|
106
|
+
hiddenColumns = [],
|
|
107
|
+
columnOrder = [],
|
|
108
|
+
isLoading = false,
|
|
109
|
+
dataSorting = [],
|
|
110
|
+
rowExpandingConfiguration,
|
|
111
|
+
pagination,
|
|
112
|
+
overrideHeader,
|
|
113
|
+
onUpdateDataSorting,
|
|
114
|
+
onUpdateDataSearch,
|
|
115
|
+
onRowClick,
|
|
116
|
+
className,
|
|
117
|
+
}: WfoTableProps<T>) => {
|
|
118
|
+
const {
|
|
119
|
+
tableContainerStyle,
|
|
120
|
+
tableStyle,
|
|
121
|
+
headerStyle,
|
|
122
|
+
bodyLoadingStyle,
|
|
123
|
+
cellStyle,
|
|
124
|
+
rowStyle,
|
|
125
|
+
emptyTableMessageStyle,
|
|
126
|
+
} = useWithOrchestratorTheme(getWfoTableStyles);
|
|
127
|
+
const t = useTranslations('common');
|
|
128
|
+
|
|
129
|
+
const sortedVisibleColumns = getSortedVisibleColumns(
|
|
130
|
+
columnConfig,
|
|
131
|
+
columnOrder,
|
|
132
|
+
hiddenColumns,
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<>
|
|
137
|
+
<div css={[tableContainerStyle, useEuiScrollBar()]}>
|
|
138
|
+
<table className={className} css={tableStyle}>
|
|
139
|
+
{overrideHeader ? (
|
|
140
|
+
overrideHeader(sortedVisibleColumns)
|
|
141
|
+
) : (
|
|
142
|
+
<thead css={headerStyle}>
|
|
143
|
+
<WfoTableHeaderRow
|
|
144
|
+
columnConfig={columnConfig}
|
|
145
|
+
hiddenColumns={hiddenColumns}
|
|
146
|
+
columnOrder={columnOrder}
|
|
147
|
+
dataSorting={dataSorting}
|
|
148
|
+
onUpdateDataSorting={onUpdateDataSorting}
|
|
149
|
+
onUpdateDataSearch={onUpdateDataSearch}
|
|
150
|
+
/>
|
|
151
|
+
</thead>
|
|
152
|
+
)}
|
|
153
|
+
{data.length === 0 ? (
|
|
154
|
+
<tbody css={isLoading && bodyLoadingStyle}>
|
|
155
|
+
<tr css={rowStyle}>
|
|
156
|
+
<td
|
|
157
|
+
colSpan={sortedVisibleColumns.length}
|
|
158
|
+
css={[cellStyle, emptyTableMessageStyle]}
|
|
159
|
+
>
|
|
160
|
+
{isLoading
|
|
161
|
+
? t('loading')
|
|
162
|
+
: t('noItemsFound')}
|
|
163
|
+
</td>
|
|
164
|
+
</tr>
|
|
165
|
+
</tbody>
|
|
166
|
+
) : (
|
|
167
|
+
<tbody css={isLoading && bodyLoadingStyle}>
|
|
168
|
+
<WfoTableDataRows
|
|
169
|
+
data={data}
|
|
170
|
+
columnConfig={columnConfig}
|
|
171
|
+
hiddenColumns={hiddenColumns}
|
|
172
|
+
columnOrder={columnOrder}
|
|
173
|
+
rowExpandingConfiguration={
|
|
174
|
+
rowExpandingConfiguration
|
|
175
|
+
}
|
|
176
|
+
onRowClick={onRowClick}
|
|
177
|
+
/>
|
|
178
|
+
</tbody>
|
|
179
|
+
)}
|
|
180
|
+
</table>
|
|
181
|
+
</div>
|
|
182
|
+
{pagination && (
|
|
183
|
+
<>
|
|
184
|
+
<EuiSpacer size="xs" />
|
|
185
|
+
<EuiTablePagination
|
|
186
|
+
pageCount={Math.ceil(
|
|
187
|
+
pagination.totalItemCount / pagination.pageSize,
|
|
188
|
+
)}
|
|
189
|
+
activePage={pagination.pageIndex}
|
|
190
|
+
itemsPerPage={pagination.pageSize}
|
|
191
|
+
itemsPerPageOptions={
|
|
192
|
+
pagination.pageSizeOptions ?? DEFAULT_PAGE_SIZES
|
|
193
|
+
}
|
|
194
|
+
onChangePage={pagination.onChangePage}
|
|
195
|
+
onChangeItemsPerPage={pagination.onChangeItemsPerPage}
|
|
196
|
+
/>
|
|
197
|
+
</>
|
|
198
|
+
)}
|
|
199
|
+
</>
|
|
200
|
+
);
|
|
201
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useWithOrchestratorTheme } from '@/hooks';
|
|
4
|
+
import { toOptionalArrayEntry } from '@/utils';
|
|
5
|
+
|
|
6
|
+
import { WfoExpandedRow } from './WfoExpandedRow';
|
|
7
|
+
import { ColumnType, WfoTableProps } from './WfoTable';
|
|
8
|
+
import { getWfoTableStyles } from './styles';
|
|
9
|
+
import { getSortedVisibleColumns } from './utils';
|
|
10
|
+
|
|
11
|
+
export type WfoTableDataRowsProps<T extends object> = Pick<
|
|
12
|
+
WfoTableProps<T>,
|
|
13
|
+
| 'data'
|
|
14
|
+
| 'columnConfig'
|
|
15
|
+
| 'hiddenColumns'
|
|
16
|
+
| 'columnOrder'
|
|
17
|
+
| 'rowExpandingConfiguration'
|
|
18
|
+
| 'onRowClick'
|
|
19
|
+
| 'className'
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
export const WfoTableDataRows = <T extends object>({
|
|
23
|
+
data,
|
|
24
|
+
columnConfig,
|
|
25
|
+
hiddenColumns = [],
|
|
26
|
+
columnOrder = [],
|
|
27
|
+
rowExpandingConfiguration,
|
|
28
|
+
onRowClick,
|
|
29
|
+
className,
|
|
30
|
+
}: WfoTableDataRowsProps<T>) => {
|
|
31
|
+
const { cellStyle, rowStyle, dataRowStyle, clickableStyle, setWidth } =
|
|
32
|
+
useWithOrchestratorTheme(getWfoTableStyles);
|
|
33
|
+
|
|
34
|
+
const sortedVisibleColumns = getSortedVisibleColumns(
|
|
35
|
+
columnConfig,
|
|
36
|
+
columnOrder,
|
|
37
|
+
hiddenColumns,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
{data.map((row, index) => (
|
|
43
|
+
<Fragment key={`table-data-row-${index}`}>
|
|
44
|
+
<tr
|
|
45
|
+
className={className}
|
|
46
|
+
css={[
|
|
47
|
+
rowStyle,
|
|
48
|
+
dataRowStyle,
|
|
49
|
+
onRowClick && clickableStyle,
|
|
50
|
+
]}
|
|
51
|
+
onClick={() => onRowClick?.(row)}
|
|
52
|
+
>
|
|
53
|
+
{sortedVisibleColumns.map(([key, columnConfig]) => {
|
|
54
|
+
if (
|
|
55
|
+
columnConfig.columnType === ColumnType.CONTROL
|
|
56
|
+
) {
|
|
57
|
+
return (
|
|
58
|
+
<td
|
|
59
|
+
colSpan={
|
|
60
|
+
columnConfig.numberOfColumnsToSpan ??
|
|
61
|
+
1
|
|
62
|
+
}
|
|
63
|
+
key={key}
|
|
64
|
+
css={[
|
|
65
|
+
...toOptionalArrayEntry(
|
|
66
|
+
cellStyle,
|
|
67
|
+
!columnConfig.disableDefaultCellStyle,
|
|
68
|
+
),
|
|
69
|
+
setWidth(columnConfig.width),
|
|
70
|
+
]}
|
|
71
|
+
>
|
|
72
|
+
<div>
|
|
73
|
+
{columnConfig.renderControl(row)}
|
|
74
|
+
</div>
|
|
75
|
+
</td>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Currently there is not a good way to tell Typescript that in some cases
|
|
80
|
+
// key is of type "keyof T"
|
|
81
|
+
const result = row[key as keyof T];
|
|
82
|
+
return (
|
|
83
|
+
<td
|
|
84
|
+
key={key}
|
|
85
|
+
css={[
|
|
86
|
+
...toOptionalArrayEntry(
|
|
87
|
+
cellStyle,
|
|
88
|
+
!columnConfig.disableDefaultCellStyle,
|
|
89
|
+
),
|
|
90
|
+
setWidth(columnConfig.width),
|
|
91
|
+
]}
|
|
92
|
+
>
|
|
93
|
+
<div>
|
|
94
|
+
{columnConfig.renderData?.(
|
|
95
|
+
result,
|
|
96
|
+
row,
|
|
97
|
+
) ?? result?.toString()}
|
|
98
|
+
</div>
|
|
99
|
+
</td>
|
|
100
|
+
);
|
|
101
|
+
})}
|
|
102
|
+
</tr>
|
|
103
|
+
|
|
104
|
+
<WfoExpandedRow
|
|
105
|
+
rowExpandingConfiguration={rowExpandingConfiguration}
|
|
106
|
+
rowData={row}
|
|
107
|
+
/>
|
|
108
|
+
</Fragment>
|
|
109
|
+
))}
|
|
110
|
+
</>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
|
|
3
|
-
import { useOrchestratorTheme } from '
|
|
4
|
-
import { WfoArrowNarrowDown, WfoArrowNarrowUp } from '
|
|
5
|
-
import { SortOrder } from '
|
|
3
|
+
import { useOrchestratorTheme } from '@/hooks';
|
|
4
|
+
import { WfoArrowNarrowDown, WfoArrowNarrowUp } from '@/icons';
|
|
5
|
+
import { SortOrder } from '@/types';
|
|
6
6
|
|
|
7
7
|
export type WfoSortDirectionIconProps = {
|
|
8
8
|
sortDirection: SortOrder;
|
package/src/components/WfoTable/{WfoBasicTable → WfoTable/WfoTableHeaderCell}/WfoTableHeaderCell.tsx
RENAMED
|
@@ -10,9 +10,10 @@ import {
|
|
|
10
10
|
useGeneratedHtmlId,
|
|
11
11
|
} from '@elastic/eui';
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
13
|
+
import { WfoSortButtons } from '@/components';
|
|
14
|
+
import { useWithOrchestratorTheme } from '@/hooks';
|
|
15
|
+
import { SortOrder } from '@/types';
|
|
16
|
+
|
|
16
17
|
import { WfoSortDirectionIcon } from './WfoSortDirectionIcon';
|
|
17
18
|
import { getWfoBasicTableStyles } from './styles';
|
|
18
19
|
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useWithOrchestratorTheme } from '@/hooks';
|
|
4
|
+
import { toOptionalArrayEntry } from '@/utils';
|
|
5
|
+
|
|
6
|
+
import { ColumnType, WfoTableProps } from './WfoTable';
|
|
7
|
+
import { WfoTableHeaderCell } from './WfoTableHeaderCell';
|
|
8
|
+
import { getWfoTableStyles } from './styles';
|
|
9
|
+
import { getSortedVisibleColumns } from './utils';
|
|
10
|
+
|
|
11
|
+
export type WfoTableHeaderRowProps<T extends object> = Pick<
|
|
12
|
+
WfoTableProps<T>,
|
|
13
|
+
| 'columnConfig'
|
|
14
|
+
| 'hiddenColumns'
|
|
15
|
+
| 'columnOrder'
|
|
16
|
+
| 'dataSorting'
|
|
17
|
+
| 'onUpdateDataSorting'
|
|
18
|
+
| 'onUpdateDataSearch'
|
|
19
|
+
| 'className'
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
export const WfoTableHeaderRow = <T extends object>({
|
|
23
|
+
columnConfig,
|
|
24
|
+
columnOrder = [],
|
|
25
|
+
hiddenColumns = [],
|
|
26
|
+
dataSorting = [],
|
|
27
|
+
onUpdateDataSorting,
|
|
28
|
+
onUpdateDataSearch,
|
|
29
|
+
className,
|
|
30
|
+
}: WfoTableHeaderRowProps<T>) => {
|
|
31
|
+
const { cellStyle, rowStyle, setWidth } =
|
|
32
|
+
useWithOrchestratorTheme(getWfoTableStyles);
|
|
33
|
+
|
|
34
|
+
const sortedVisibleColumns = getSortedVisibleColumns(
|
|
35
|
+
columnConfig,
|
|
36
|
+
columnOrder,
|
|
37
|
+
hiddenColumns,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
<tr className={className} css={rowStyle}>
|
|
43
|
+
{sortedVisibleColumns.map(([key, columnConfig]) => {
|
|
44
|
+
const dataSortingConfiguration = dataSorting.find(
|
|
45
|
+
(dataSorting) => dataSorting.field === key,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (columnConfig.columnType === ColumnType.DATA) {
|
|
49
|
+
return (
|
|
50
|
+
<th
|
|
51
|
+
colSpan={columnConfig.numberOfColumnsToSpan}
|
|
52
|
+
key={key}
|
|
53
|
+
css={[
|
|
54
|
+
...toOptionalArrayEntry(
|
|
55
|
+
cellStyle,
|
|
56
|
+
!columnConfig.disableDefaultCellStyle,
|
|
57
|
+
),
|
|
58
|
+
setWidth(columnConfig.width),
|
|
59
|
+
]}
|
|
60
|
+
>
|
|
61
|
+
<WfoTableHeaderCell
|
|
62
|
+
fieldName={key}
|
|
63
|
+
sortOrder={
|
|
64
|
+
dataSortingConfiguration?.sortOrder
|
|
65
|
+
}
|
|
66
|
+
onSetSortOrder={
|
|
67
|
+
columnConfig.isSortable
|
|
68
|
+
? (updatedSortOrder) =>
|
|
69
|
+
onUpdateDataSorting?.({
|
|
70
|
+
// Currently there is not a good way to tell Typescript that in some cases
|
|
71
|
+
// key is of type "keyof T"
|
|
72
|
+
field: key as keyof T,
|
|
73
|
+
sortOrder:
|
|
74
|
+
updatedSortOrder,
|
|
75
|
+
})
|
|
76
|
+
: undefined
|
|
77
|
+
}
|
|
78
|
+
onSearch={
|
|
79
|
+
columnConfig.isFilterable
|
|
80
|
+
? (searchText) =>
|
|
81
|
+
onUpdateDataSearch?.({
|
|
82
|
+
field: key as keyof T,
|
|
83
|
+
searchText,
|
|
84
|
+
})
|
|
85
|
+
: undefined
|
|
86
|
+
}
|
|
87
|
+
>
|
|
88
|
+
{columnConfig.label?.toString()}
|
|
89
|
+
</WfoTableHeaderCell>
|
|
90
|
+
</th>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Control column
|
|
95
|
+
return (
|
|
96
|
+
<th
|
|
97
|
+
key={key}
|
|
98
|
+
colSpan={columnConfig.numberOfColumnsToSpan}
|
|
99
|
+
css={[
|
|
100
|
+
...toOptionalArrayEntry(
|
|
101
|
+
cellStyle,
|
|
102
|
+
!columnConfig.disableDefaultCellStyle,
|
|
103
|
+
),
|
|
104
|
+
setWidth(columnConfig.width),
|
|
105
|
+
]}
|
|
106
|
+
>
|
|
107
|
+
<div>{columnConfig.label?.toString() || ''}</div>
|
|
108
|
+
</th>
|
|
109
|
+
);
|
|
110
|
+
})}
|
|
111
|
+
</tr>
|
|
112
|
+
</>
|
|
113
|
+
);
|
|
114
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { FC, ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
export type WfoTruncateCellProps = {
|
|
4
|
+
children?: ReactElement | string | null;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const WfoTruncateCell: FC<WfoTruncateCellProps> = ({ children }) => {
|
|
8
|
+
if (!children) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<p
|
|
14
|
+
css={{
|
|
15
|
+
textOverflow: 'ellipsis',
|
|
16
|
+
overflow: 'ellipsis',
|
|
17
|
+
whiteSpace: 'nowrap',
|
|
18
|
+
}}
|
|
19
|
+
>
|
|
20
|
+
{children}
|
|
21
|
+
</p>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TABLE_ROW_HEIGHT = '40px';
|