@orchestrator-ui/orchestrator-ui-components 1.38.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/.turbo/turbo-lint.log +5 -2
  3. package/.turbo/turbo-test.log +11 -11
  4. package/CHANGELOG.md +25 -0
  5. package/dist/index.d.ts +252 -170
  6. package/dist/index.js +4355 -3498
  7. package/package.json +1 -1
  8. package/src/components/WfoForms/formFields/SubscriptionSummaryField.tsx +6 -5
  9. package/src/components/WfoPageTemplate/WfoPageHeader/WfoPageHeader.tsx +3 -1
  10. package/src/components/WfoPageTemplate/WfoSidebar/WfoCopyright.tsx +1 -1
  11. package/src/components/WfoProcessList/WfoProcessesList.tsx +52 -51
  12. package/src/components/WfoRadioDropdown/WfoRadioDropdown.tsx +88 -0
  13. package/src/components/WfoRadioDropdown/index.ts +1 -0
  14. package/src/components/WfoStartButton/WfoStartButtonComboBox.tsx +4 -0
  15. package/src/components/WfoStartButton/WfoStartTaskComboBox.tsx +1 -0
  16. package/src/components/WfoStartButton/WfoStartWorkflowComboBox.tsx +1 -0
  17. package/src/components/WfoStartButton/styles.ts +0 -4
  18. package/src/components/WfoSubscription/WfoInSyncField.tsx +13 -9
  19. package/src/components/WfoSubscription/WfoInUseByRelations.tsx +4 -2
  20. package/src/components/WfoSubscription/WfoProcessesTimeline.tsx +76 -29
  21. package/src/components/WfoSubscription/WfoRelatedSubscriptions.tsx +50 -56
  22. package/src/components/WfoSubscription/WfoSubscriptionDetailTree.tsx +17 -9
  23. package/src/components/WfoSubscription/WfoSubscriptionGeneral.tsx +29 -160
  24. package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionDetailSection.tsx +113 -0
  25. package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionFixedInputSection.tsx +28 -0
  26. package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionMetadataSection.tsx +29 -0
  27. package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionProductInfoSection.tsx +55 -0
  28. package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/index.ts +4 -0
  29. package/src/components/WfoSubscription/index.ts +3 -0
  30. package/src/components/WfoSubscription/overrides/index.ts +1 -0
  31. package/src/components/WfoSubscription/styles.ts +4 -1
  32. package/src/components/WfoSubscription/utils/utils.spec.ts +0 -13
  33. package/src/components/WfoSubscription/utils/utils.ts +18 -5
  34. package/src/components/WfoSubscriptionsList/WfoSubscriptionsList.tsx +105 -100
  35. package/src/components/WfoTable/{WfoTableWithFilter/WfoTableWithFilter.tsx → WfoAdvancedTable/WfoAdvancedTable.tsx} +65 -123
  36. package/src/components/WfoTable/WfoAdvancedTable/getRowDetailData.tsx +55 -0
  37. package/src/components/WfoTable/WfoAdvancedTable/index.ts +4 -0
  38. package/src/components/WfoTable/WfoAdvancedTable/toSortedTableColumnConfig.ts +12 -0
  39. package/src/components/WfoTable/WfoAdvancedTable/types.ts +23 -0
  40. package/src/components/WfoTable/WfoStatusColorField/WfoStatusColorField.tsx +16 -0
  41. package/src/components/WfoTable/WfoStatusColorField/index.ts +1 -0
  42. package/src/components/WfoTable/WfoStatusColorField/styles.ts +20 -0
  43. package/src/components/WfoTable/WfoTable/WfoExpandedRow.tsx +33 -0
  44. package/src/components/WfoTable/WfoTable/WfoGroupedTable/WfoExpandableRow.tsx +48 -0
  45. package/src/components/WfoTable/WfoTable/WfoGroupedTable/WfoExpandedGroupRow.tsx +71 -0
  46. package/src/components/WfoTable/WfoTable/WfoGroupedTable/WfoGroupedTable.tsx +100 -0
  47. package/src/components/WfoTable/WfoTable/WfoGroupedTable/WfoGroupedTableGroups.tsx +74 -0
  48. package/src/components/WfoTable/WfoTable/WfoGroupedTable/styles.ts +39 -0
  49. package/src/components/WfoTable/WfoTable/WfoGroupedTable/useGroupedTableConfig.tsx +184 -0
  50. package/src/components/WfoTable/WfoTable/WfoGroupedTable/utils.spec.ts +133 -0
  51. package/src/components/WfoTable/WfoTable/WfoGroupedTable/utils.ts +41 -0
  52. package/src/components/WfoTable/WfoTable/WfoMultilineCell.tsx +13 -0
  53. package/src/components/WfoTable/WfoTable/WfoTable.tsx +201 -0
  54. package/src/components/WfoTable/WfoTable/WfoTableDataRows.tsx +112 -0
  55. package/src/components/WfoTable/{WfoBasicTable → WfoTable/WfoTableHeaderCell}/WfoSortDirectionIcon.tsx +3 -3
  56. package/src/components/WfoTable/{WfoBasicTable → WfoTable/WfoTableHeaderCell}/WfoTableHeaderCell.tsx +4 -3
  57. package/src/components/WfoTable/WfoTable/WfoTableHeaderCell/index.ts +2 -0
  58. package/src/components/WfoTable/WfoTable/WfoTableHeaderRow.tsx +114 -0
  59. package/src/components/WfoTable/WfoTable/WfoTruncateCell.tsx +23 -0
  60. package/src/components/WfoTable/WfoTable/constants.ts +1 -0
  61. package/src/components/WfoTable/WfoTable/index.ts +14 -0
  62. package/src/components/WfoTable/WfoTable/styles.ts +117 -0
  63. package/src/components/WfoTable/WfoTable/utils.spec.ts +79 -0
  64. package/src/components/WfoTable/WfoTable/utils.ts +78 -0
  65. package/src/components/WfoTable/WfoTableSettingsModal/WfoTableSettingsModal.tsx +13 -12
  66. package/src/components/WfoTable/WfoTableWithFilter/index.ts +1 -1
  67. package/src/components/WfoTable/index.ts +4 -5
  68. package/src/components/WfoTable/utils/columns.ts +1 -48
  69. package/src/components/WfoTable/utils/tableUtils.ts +13 -10
  70. package/src/components/WfoTree/WfoTreeBranch.tsx +10 -1
  71. package/src/components/WfoTree/WfoTreeNode.tsx +8 -57
  72. package/src/components/WfoTree/WfoTreeNodeListItem.tsx +65 -0
  73. package/src/components/WfoTree/styles.ts +28 -4
  74. package/src/components/index.ts +1 -0
  75. package/src/configuration/policy-resources.ts +1 -0
  76. package/src/configuration/version.ts +1 -1
  77. package/src/icons/WfoXMarkSmall.tsx +29 -0
  78. package/src/messages/en-GB.json +4 -0
  79. package/src/messages/nl-NL.json +4 -0
  80. package/src/pages/metadata/WfoProductBlocksPage.tsx +42 -59
  81. package/src/pages/metadata/WfoProductsPage.tsx +41 -47
  82. package/src/pages/metadata/WfoResourceTypesPage.tsx +26 -35
  83. package/src/pages/metadata/WfoTasksPage.tsx +35 -33
  84. package/src/pages/metadata/WfoWorkflowsPage.tsx +33 -29
  85. package/src/pages/tasks/WfoTasksListPage.tsx +25 -19
  86. package/src/utils/getObjectKeys.ts +3 -0
  87. package/src/utils/index.ts +5 -3
  88. package/src/components/WfoTable/WfoBasicTable/WfoBasicTable.tsx +0 -194
  89. package/src/components/WfoTable/WfoBasicTable/WfoStatusColorField.tsx +0 -21
  90. package/src/components/WfoTable/WfoBasicTable/index.ts +0 -5
  91. package/src/components/WfoTable/WfoDataGridTable/WfoDataGridTable.stories.tsx +0 -136
  92. package/src/components/WfoTable/WfoDataGridTable/WfoDataGridTable.tsx +0 -146
  93. package/src/components/WfoTable/WfoDataGridTable/WfodataGridColumns.spec.ts +0 -113
  94. package/src/components/WfoTable/WfoDataGridTable/WfodataGridColumns.ts +0 -81
  95. package/src/components/WfoTable/utils/mapSortableAndFilterableValuesToTableColumnConfig.spec.ts +0 -52
  96. package/src/components/WfoTable/utils/mapSortableAndFilterableValuesToTableColumnConfig.ts +0 -23
  97. /package/src/components/WfoTable/{WfoBasicTable → WfoTable/WfoTableHeaderCell}/styles.ts +0 -0
@@ -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 '../../../hooks';
4
- import { WfoArrowNarrowDown, WfoArrowNarrowUp } from '../../../icons';
5
- import { SortOrder } from '../../../types';
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;
@@ -10,9 +10,10 @@ import {
10
10
  useGeneratedHtmlId,
11
11
  } from '@elastic/eui';
12
12
 
13
- import { useWithOrchestratorTheme } from '../../../hooks';
14
- import { SortOrder } from '../../../types';
15
- import { WfoSortButtons } from '../WfoSortButtons';
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,2 @@
1
+ export * from './WfoSortDirectionIcon';
2
+ export * from './WfoTableHeaderCell';
@@ -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';
@@ -0,0 +1,14 @@
1
+ export * from './WfoTable';
2
+ export * from './constants';
3
+ export * from './styles';
4
+
5
+ export * from './WfoGroupedTable/WfoGroupedTable';
6
+ export * from './WfoGroupedTable/utils';
7
+ export * from './WfoGroupedTable/styles';
8
+
9
+ export * from './WfoMultilineCell';
10
+
11
+ export * from './WfoTable';
12
+ export * from './WfoTableHeaderCell';
13
+
14
+ export * from './WfoTruncateCell';
@@ -0,0 +1,117 @@
1
+ import { CSSProperties } from 'react';
2
+
3
+ import { css, keyframes } from '@emotion/react';
4
+
5
+ import { TABLE_ROW_HEIGHT } from '@/components/WfoTable';
6
+ import { WfoTheme } from '@/hooks';
7
+
8
+ export const getWfoTableStyles = ({ theme }: WfoTheme) => {
9
+ const radius = theme.border.radius.medium;
10
+
11
+ const tableLoadingLineKeyframes = keyframes({
12
+ from: {
13
+ left: 0,
14
+ width: 0,
15
+ },
16
+ '20%': {
17
+ left: 0,
18
+ width: '40%',
19
+ },
20
+ '80%': {
21
+ left: '60%',
22
+ width: '40%',
23
+ },
24
+ '100%': {
25
+ left: '100%',
26
+ width: 0,
27
+ },
28
+ });
29
+
30
+ const tableContainerStyle = css({
31
+ overflowX: 'auto',
32
+ });
33
+
34
+ const tableStyle = css({
35
+ width: '100%',
36
+ });
37
+
38
+ const headerStyle = css({
39
+ backgroundColor: theme.colors.lightShade,
40
+ fontSize: theme.size.m,
41
+ textAlign: 'left',
42
+ 'tr>:first-child': {
43
+ borderTopLeftRadius: radius,
44
+ },
45
+ 'tr>:last-child': {
46
+ borderTopRightRadius: radius,
47
+ },
48
+ });
49
+
50
+ const bodyLoadingStyle = css({
51
+ position: 'relative',
52
+ overflow: 'hidden',
53
+
54
+ '&::before': {
55
+ position: 'absolute',
56
+ content: '""',
57
+ height: theme.border.width.thick,
58
+ backgroundColor: theme.colors.primary,
59
+ animation: `${tableLoadingLineKeyframes} 1s linear infinite`,
60
+ },
61
+ });
62
+
63
+ const rowStyle = css({
64
+ height: TABLE_ROW_HEIGHT,
65
+ borderStyle: 'solid',
66
+ borderWidth: '0 0 1px 0',
67
+ borderColor: theme.colors.lightShade,
68
+ });
69
+
70
+ const dataRowStyle = css({
71
+ '&:hover': {
72
+ backgroundColor: theme.colors.lightestShade,
73
+ },
74
+ });
75
+
76
+ const expandedRowStyle = css({
77
+ backgroundColor: theme.colors.lightestShade,
78
+ });
79
+
80
+ const cellStyle = css({
81
+ paddingLeft: theme.size.m,
82
+ paddingRight: theme.size.m,
83
+ whiteSpace: 'nowrap',
84
+ verticalAlign: 'middle',
85
+ });
86
+
87
+ const emptyTableMessageStyle = css({
88
+ textAlign: 'center',
89
+ });
90
+
91
+ const clickableStyle = css({
92
+ cursor: 'pointer',
93
+ });
94
+
95
+ const setWidth = (width?: CSSProperties['width']) =>
96
+ width !== undefined &&
97
+ css({
98
+ width: width,
99
+ minWidth: width,
100
+ maxWidth: width,
101
+ overflow: 'hidden',
102
+ });
103
+
104
+ return {
105
+ tableContainerStyle,
106
+ tableStyle,
107
+ headerStyle,
108
+ bodyLoadingStyle,
109
+ rowStyle,
110
+ dataRowStyle,
111
+ expandedRowStyle,
112
+ cellStyle,
113
+ emptyTableMessageStyle,
114
+ clickableStyle,
115
+ setWidth,
116
+ };
117
+ };
@@ -0,0 +1,79 @@
1
+ import {
2
+ ColumnType,
3
+ WfoTableColumnConfig,
4
+ } from '@/components/WfoTable/WfoTable/WfoTable';
5
+
6
+ import { mapSortableAndFilterableValuesToTableColumnConfig } from './utils';
7
+
8
+ type TestObject = {
9
+ name: string;
10
+ age: number;
11
+ };
12
+
13
+ const tableColumnConfig: WfoTableColumnConfig<TestObject> = {
14
+ name: {
15
+ columnType: ColumnType.DATA,
16
+ label: 'tesName',
17
+ },
18
+ age: {
19
+ columnType: ColumnType.DATA,
20
+ label: 'testAge',
21
+ },
22
+ };
23
+
24
+ describe('mapSortableAndFilterableValuesToTableColumnConfig', () => {
25
+ it('sets the sortable and filterable properties for the columnConfig object to true when the colum name is specified in the list', () => {
26
+ // Given
27
+ const sortableFieldNames = ['name', 'age', 'nonExistingFieldName'];
28
+ const filterableFieldNames = ['name', 'age', 'nonExistingFieldName'];
29
+
30
+ // When
31
+ const result =
32
+ mapSortableAndFilterableValuesToTableColumnConfig<TestObject>(
33
+ tableColumnConfig,
34
+ sortableFieldNames,
35
+ filterableFieldNames,
36
+ );
37
+
38
+ // Then
39
+ if (
40
+ result.name?.columnType === ColumnType.DATA &&
41
+ result.age?.columnType === ColumnType.DATA
42
+ ) {
43
+ expect(result.name.isSortable).toEqual(true);
44
+ expect(result.name.isFilterable).toEqual(true);
45
+ expect(result.age.isSortable).toEqual(true);
46
+ expect(result.age.isFilterable).toEqual(true);
47
+ } else {
48
+ // Preventing silently skipping above expects
49
+ throw Error('Some of the fields are not data fields');
50
+ }
51
+ });
52
+ it('sets the sortable and filterable properties for the columnConfig object to false when the colum name is not specified in the list', () => {
53
+ // Given
54
+ const sortableFieldNames = ['nonExistingFieldName'];
55
+ const filterableFieldNames: string[] = [];
56
+
57
+ // When
58
+ const result =
59
+ mapSortableAndFilterableValuesToTableColumnConfig<TestObject>(
60
+ tableColumnConfig,
61
+ sortableFieldNames,
62
+ filterableFieldNames,
63
+ );
64
+
65
+ // Then
66
+ if (
67
+ result.name?.columnType === ColumnType.DATA &&
68
+ result.age?.columnType === ColumnType.DATA
69
+ ) {
70
+ expect(result.name.isSortable).toEqual(false);
71
+ expect(result.name.isFilterable).toEqual(false);
72
+ expect(result.age.isSortable).toEqual(false);
73
+ expect(result.age.isFilterable).toEqual(false);
74
+ } else {
75
+ // Preventing silently skipping above expects
76
+ throw Error('Some of the fields are not data fields');
77
+ }
78
+ });
79
+ });
@@ -0,0 +1,78 @@
1
+ import { TableColumnKeys } from '@/components';
2
+ import { toObjectWithSortedKeys } from '@/utils';
3
+
4
+ import {
5
+ ColumnType,
6
+ WfoTableColumnConfig,
7
+ WfoTableControlColumnConfigItem,
8
+ WfoTableDataColumnConfigItem,
9
+ } from './WfoTable';
10
+
11
+ export const getSortedVisibleColumns = <T extends object>(
12
+ columnConfig: WfoTableColumnConfig<T>,
13
+ columnOrder: TableColumnKeys<T>,
14
+ hiddenColumns: TableColumnKeys<T>,
15
+ ) => {
16
+ const tableHeadersEntries: Array<
17
+ [
18
+ string,
19
+ (
20
+ | WfoTableControlColumnConfigItem<T>
21
+ | WfoTableDataColumnConfigItem<T, keyof T>
22
+ ),
23
+ ]
24
+ > = Object.entries(
25
+ toObjectWithSortedKeys(
26
+ columnConfig,
27
+ columnOrder.map((value) => value.toString()),
28
+ ),
29
+ );
30
+
31
+ return tableHeadersEntries.filter(
32
+ ([columnId]) => !hiddenColumns.includes(columnId as keyof T),
33
+ );
34
+ };
35
+
36
+ /**
37
+ * Maps from WfoTableColumnConfig to WfoTableColumnConfig.
38
+ * A generic type must be provided to prevent type errors
39
+ * @param tableColumnConfig
40
+ * @param sortableFieldNames
41
+ * @param filterableFieldNames
42
+ *
43
+ * @returns updated WfoTableColumnConfig with isSortable and isFilterable set
44
+ */
45
+ export function mapSortableAndFilterableValuesToTableColumnConfig<
46
+ T extends object,
47
+ >(
48
+ tableColumnConfig: WfoTableColumnConfig<T>,
49
+ sortableFieldNames: string[] = [],
50
+ filterableFieldNames: string[] = [],
51
+ ): WfoTableColumnConfig<T> {
52
+ const tableColumnConfigEntries: [
53
+ string,
54
+ (
55
+ | WfoTableControlColumnConfigItem<T>
56
+ | WfoTableDataColumnConfigItem<T, keyof T>
57
+ ),
58
+ ][] = Object.entries(tableColumnConfig);
59
+
60
+ const tableColumnConfigUpdatedEntries = tableColumnConfigEntries.map(
61
+ ([key, value]) => {
62
+ if (value.columnType === ColumnType.DATA) {
63
+ return [
64
+ key,
65
+ {
66
+ ...value,
67
+ isSortable: sortableFieldNames.includes(key),
68
+ isFilterable: filterableFieldNames.includes(key),
69
+ },
70
+ ];
71
+ }
72
+
73
+ return [key, value];
74
+ },
75
+ );
76
+
77
+ return Object.fromEntries(tableColumnConfigUpdatedEntries);
78
+ }
@@ -15,22 +15,22 @@ import { WfoSettingsModal } from '@/components';
15
15
  import { getWfoTableSettingsModalStyles } from '@/components/WfoTable/WfoTableSettingsModal/styles';
16
16
  import { useWithOrchestratorTheme } from '@/hooks';
17
17
 
18
- export type ColumnConfig<T> = {
18
+ export type TableSettingsColumnConfig<T> = {
19
19
  field: keyof T;
20
20
  name: string;
21
21
  isVisible: boolean;
22
22
  };
23
23
 
24
- export type TableConfig<T> = {
25
- columns: ColumnConfig<T>[];
24
+ export type TableSettingsConfig<T> = {
25
+ columns: TableSettingsColumnConfig<T>[];
26
26
  selectedPageSize: number;
27
27
  };
28
28
 
29
29
  export type TableSettingsModalProps<T> = {
30
- tableConfig: TableConfig<T>;
30
+ tableConfig: TableSettingsConfig<T>;
31
31
  pageSizeOptions: number[];
32
32
  onClose: () => void;
33
- onUpdateTableConfig: (updatedTableConfig: TableConfig<T>) => void;
33
+ onUpdateTableConfig: (updatedTableConfig: TableSettingsConfig<T>) => void;
34
34
  onResetToDefaults: () => void;
35
35
  };
36
36
 
@@ -57,13 +57,14 @@ export const TableSettingsModal = <T,>({
57
57
  }));
58
58
 
59
59
  const handleUpdateColumnVisibility = (field: keyof T) => {
60
- const updatedColumns: ColumnConfig<T>[] = columns.map((column) =>
61
- column.field === field
62
- ? {
63
- ...column,
64
- isVisible: !column.isVisible,
65
- }
66
- : column,
60
+ const updatedColumns: TableSettingsColumnConfig<T>[] = columns.map(
61
+ (column) =>
62
+ column.field === field
63
+ ? {
64
+ ...column,
65
+ isVisible: !column.isVisible,
66
+ }
67
+ : column,
67
68
  );
68
69
  setColumns(updatedColumns);
69
70
  };
@@ -1 +1 @@
1
- export * from './WfoTableWithFilter';
1
+ export * from './updateQueryString';
@@ -1,18 +1,17 @@
1
- export * from './WfoDataGridTable/WfoDataGridTable';
2
- export * from './WfoDataGridTable/WfodataGridColumns';
3
-
4
1
  export * from './WfoTableSettingsModal';
5
2
 
6
3
  export * from './utils/columns';
7
4
  export * from './utils/constants';
8
- export * from './utils/mapSortableAndFilterableValuesToTableColumnConfig';
9
5
 
10
6
  export * from './utils/tableConfigPersistence';
11
7
  export * from './utils/tableUtils';
12
8
 
13
- export * from './WfoBasicTable';
9
+ export * from './WfoStatusColorField';
14
10
  export * from './WfoTableWithFilter';
15
11
 
16
12
  export * from './WfoSortButtons';
17
13
  export * from './WfoFirstPartUUID';
18
14
  export * from './WfoInlineJson';
15
+
16
+ export * from './WfoAdvancedTable';
17
+ export * from './WfoTable';