@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.
Files changed (113) hide show
  1. package/.turbo/turbo-build.log +11 -9
  2. package/.turbo/turbo-lint.log +5 -2
  3. package/.turbo/turbo-test.log +14 -14
  4. package/CHANGELOG.md +30 -0
  5. package/dist/index.d.ts +329 -172
  6. package/dist/index.js +6152 -5545
  7. package/dist/index.js.map +1 -0
  8. package/package.json +2 -2
  9. package/src/components/WfoContentHeader/WfoContentHeader.tsx +55 -0
  10. package/src/components/WfoContentHeader/index.ts +1 -0
  11. package/src/components/WfoForms/formFields/SubscriptionSummaryField.tsx +6 -5
  12. package/src/components/WfoInlineNoteEdit/WfoInlineNoteEdit.tsx +105 -0
  13. package/src/components/WfoInlineNoteEdit/index.ts +1 -0
  14. package/src/components/WfoPageTemplate/WfoPageHeader/WfoPageHeader.tsx +3 -1
  15. package/src/components/WfoPageTemplate/WfoSidebar/WfoCopyright.tsx +1 -1
  16. package/src/components/WfoPageTemplate/WfoSidebar/WfoSidebar.tsx +6 -6
  17. package/src/components/WfoProcessList/WfoProcessesList.tsx +52 -51
  18. package/src/components/WfoRadioDropdown/WfoRadioDropdown.tsx +88 -0
  19. package/src/components/WfoRadioDropdown/index.ts +1 -0
  20. package/src/components/WfoRenderElementOrString/WfoRenderElementOrString.tsx +16 -0
  21. package/src/components/WfoRenderElementOrString/index.ts +1 -0
  22. package/src/components/WfoSubscription/WfoInSyncField.tsx +13 -9
  23. package/src/components/WfoSubscription/WfoInUseByRelations.tsx +4 -2
  24. package/src/components/WfoSubscription/WfoProcessesTimeline.tsx +76 -29
  25. package/src/components/WfoSubscription/WfoRelatedSubscriptions.tsx +92 -84
  26. package/src/components/WfoSubscription/WfoSubscription.tsx +19 -37
  27. package/src/components/WfoSubscription/WfoSubscriptionDetailTree.tsx +17 -9
  28. package/src/components/WfoSubscription/WfoSubscriptionGeneral.tsx +18 -156
  29. package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionDetailSection.tsx +119 -0
  30. package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionFixedInputSection.tsx +28 -0
  31. package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionMetadataSection.tsx +29 -0
  32. package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/WfoSubscriptionProductInfoSection.tsx +55 -0
  33. package/src/components/WfoSubscription/WfoSubscriptionGeneralSections/index.ts +4 -0
  34. package/src/components/WfoSubscription/index.ts +3 -0
  35. package/src/components/WfoSubscription/overrides/index.ts +1 -0
  36. package/src/components/WfoSubscription/styles.ts +4 -1
  37. package/src/components/WfoSubscription/utils/relatedSubscriptionsListItemsObjectMappers.ts +62 -0
  38. package/src/components/WfoSubscription/utils/utils.spec.ts +0 -13
  39. package/src/components/WfoSubscription/utils/utils.ts +18 -5
  40. package/src/components/WfoSubscriptionsList/WfoSubscriptionsList.tsx +105 -100
  41. package/src/components/WfoTable/{WfoTableWithFilter/WfoTableWithFilter.tsx → WfoAdvancedTable/WfoAdvancedTable.tsx} +65 -123
  42. package/src/components/WfoTable/WfoAdvancedTable/getRowDetailData.tsx +55 -0
  43. package/src/components/WfoTable/WfoAdvancedTable/index.ts +4 -0
  44. package/src/components/WfoTable/WfoAdvancedTable/toSortedTableColumnConfig.ts +12 -0
  45. package/src/components/WfoTable/WfoAdvancedTable/types.ts +23 -0
  46. package/src/components/WfoTable/WfoStatusColorField/WfoStatusColorField.tsx +16 -0
  47. package/src/components/WfoTable/WfoStatusColorField/index.ts +1 -0
  48. package/src/components/WfoTable/WfoStatusColorField/styles.ts +20 -0
  49. package/src/components/WfoTable/WfoTable/WfoExpandedRow.tsx +33 -0
  50. package/src/components/WfoTable/WfoTable/WfoGroupedTable/WfoExpandableRow.tsx +48 -0
  51. package/src/components/WfoTable/WfoTable/WfoGroupedTable/WfoExpandedGroupRow.tsx +71 -0
  52. package/src/components/WfoTable/WfoTable/WfoGroupedTable/WfoGroupedTable.tsx +100 -0
  53. package/src/components/WfoTable/WfoTable/WfoGroupedTable/WfoGroupedTableGroups.tsx +74 -0
  54. package/src/components/WfoTable/WfoTable/WfoGroupedTable/styles.ts +39 -0
  55. package/src/components/WfoTable/WfoTable/WfoGroupedTable/useGroupedTableConfig.tsx +184 -0
  56. package/src/components/WfoTable/WfoTable/WfoGroupedTable/utils.spec.ts +133 -0
  57. package/src/components/WfoTable/WfoTable/WfoGroupedTable/utils.ts +41 -0
  58. package/src/components/WfoTable/WfoTable/WfoMultilineCell.tsx +13 -0
  59. package/src/components/WfoTable/WfoTable/WfoTable.tsx +201 -0
  60. package/src/components/WfoTable/WfoTable/WfoTableDataRows.tsx +112 -0
  61. package/src/components/WfoTable/{WfoBasicTable → WfoTable/WfoTableHeaderCell}/WfoSortDirectionIcon.tsx +3 -3
  62. package/src/components/WfoTable/{WfoBasicTable → WfoTable/WfoTableHeaderCell}/WfoTableHeaderCell.tsx +4 -3
  63. package/src/components/WfoTable/WfoTable/WfoTableHeaderCell/index.ts +2 -0
  64. package/src/components/WfoTable/WfoTable/WfoTableHeaderRow.tsx +114 -0
  65. package/src/components/WfoTable/WfoTable/WfoTruncateCell.tsx +23 -0
  66. package/src/components/WfoTable/WfoTable/constants.ts +1 -0
  67. package/src/components/WfoTable/WfoTable/index.ts +14 -0
  68. package/src/components/WfoTable/WfoTable/styles.ts +117 -0
  69. package/src/components/WfoTable/WfoTable/utils.spec.ts +79 -0
  70. package/src/components/WfoTable/WfoTable/utils.ts +78 -0
  71. package/src/components/WfoTable/WfoTableSettingsModal/WfoTableSettingsModal.tsx +13 -12
  72. package/src/components/WfoTable/WfoTableWithFilter/index.ts +1 -1
  73. package/src/components/WfoTable/index.ts +4 -5
  74. package/src/components/WfoTable/utils/columns.ts +1 -48
  75. package/src/components/WfoTable/utils/tableUtils.ts +13 -10
  76. package/src/components/WfoTree/WfoTreeBranch.tsx +10 -1
  77. package/src/components/WfoTree/WfoTreeNode.tsx +8 -57
  78. package/src/components/WfoTree/WfoTreeNodeListItem.tsx +65 -0
  79. package/src/components/WfoTree/styles.ts +28 -4
  80. package/src/components/index.ts +4 -0
  81. package/src/configuration/policy-resources.ts +1 -0
  82. package/src/configuration/version.ts +1 -1
  83. package/src/icons/WfoXMarkSmall.tsx +29 -0
  84. package/src/messages/en-GB.json +4 -0
  85. package/src/messages/nl-NL.json +4 -0
  86. package/src/pages/metadata/WfoMetadataPageLayout.tsx +4 -4
  87. package/src/pages/metadata/WfoProductBlocksPage.tsx +42 -59
  88. package/src/pages/metadata/WfoProductsPage.tsx +41 -47
  89. package/src/pages/metadata/WfoResourceTypesPage.tsx +26 -35
  90. package/src/pages/metadata/WfoTasksPage.tsx +35 -33
  91. package/src/pages/metadata/WfoWorkflowsPage.tsx +33 -29
  92. package/src/pages/processes/WfoProcessDetail.tsx +47 -55
  93. package/src/pages/settings/WfoSettingsPage.tsx +9 -4
  94. package/src/pages/startPage/WfoStartPage.tsx +17 -1
  95. package/src/pages/subscriptions/WfoSubscriptionsListPage.tsx +4 -5
  96. package/src/pages/tasks/WfoTasksListPage.tsx +44 -52
  97. package/src/pages/workflows/WfoWorkflowsListPage.tsx +4 -5
  98. package/src/rtk/endpoints/index.ts +1 -0
  99. package/src/rtk/endpoints/relatedSubscriptions.ts +5 -4
  100. package/src/rtk/endpoints/subscriptionActions.ts +11 -1
  101. package/src/utils/getObjectKeys.ts +3 -0
  102. package/src/utils/index.ts +5 -3
  103. package/tsup.config.ts +10 -0
  104. package/src/components/WfoTable/WfoBasicTable/WfoBasicTable.tsx +0 -194
  105. package/src/components/WfoTable/WfoBasicTable/WfoStatusColorField.tsx +0 -21
  106. package/src/components/WfoTable/WfoBasicTable/index.ts +0 -5
  107. package/src/components/WfoTable/WfoDataGridTable/WfoDataGridTable.stories.tsx +0 -136
  108. package/src/components/WfoTable/WfoDataGridTable/WfoDataGridTable.tsx +0 -146
  109. package/src/components/WfoTable/WfoDataGridTable/WfodataGridColumns.spec.ts +0 -113
  110. package/src/components/WfoTable/WfoDataGridTable/WfodataGridColumns.ts +0 -81
  111. package/src/components/WfoTable/utils/mapSortableAndFilterableValuesToTableColumnConfig.spec.ts +0 -52
  112. package/src/components/WfoTable/utils/mapSortableAndFilterableValuesToTableColumnConfig.ts +0 -23
  113. /package/src/components/WfoTable/{WfoBasicTable → WfoTable/WfoTableHeaderCell}/styles.ts +0 -0
@@ -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';
@@ -1,54 +1,7 @@
1
- import { ReactNode } from 'react';
2
-
3
- import { EuiBasicTableColumn } from '@elastic/eui';
4
-
5
- import { SortOrder } from '../../../types';
6
-
7
- // Todo need to Pick a few more props from EuiBasicTableColumn to prevent none-functioning props (truncateText)
8
- // https://github.com/workfloworchestrator/orchestrator-ui/issues/130
9
- export type WfoEuiBasicTableColumn<T extends object> = Omit<
10
- EuiBasicTableColumn<T>,
11
- 'render'
12
- >;
13
-
14
- export type WfoTableDataColumnConfig<
15
- T extends object,
16
- Property,
17
- > = WfoEuiBasicTableColumn<T> & {
18
- field: Property;
19
- name: string;
20
- sortable?: boolean;
21
- filterable?: boolean;
22
- truncateText?: boolean;
23
- };
1
+ import { SortOrder } from '@/types';
24
2
 
25
3
  export const WFO_STATUS_COLOR_FIELD = 'statusColorField';
26
4
 
27
- // Todo need to Pick a few props from EuiBasicTableColumn to prevent none-functioning props (truncateText)
28
- export type WfoTableColumnsWithExtraNonDataFields<T extends object> =
29
- WfoTableColumns<T> & {
30
- [key: string]: EuiBasicTableColumn<T> & {
31
- field: string;
32
- name?: string;
33
- };
34
- };
35
-
36
- export type WfoTableColumns<T extends object> = {
37
- [Property in keyof T]: WfoTableDataColumnConfig<T, Property> & {
38
- render?: (cellValue: T[Property], row: T) => ReactNode;
39
- renderDetails?: (cellValue: T[Property], row: T) => ReactNode;
40
- clipboardText?: (cellValue: T[Property], row: T) => string;
41
- };
42
- };
43
-
44
- export type WfoTableControlColumnConfig<T extends object> = {
45
- [key: string]: WfoEuiBasicTableColumn<T> & {
46
- field: string;
47
- name?: string;
48
- render: (cellValue: never, row: T) => ReactNode;
49
- };
50
- };
51
-
52
5
  export type TableColumnKeys<T> = Array<keyof T>;
53
6
 
54
7
  export type WfoDataSorting<T> = {
@@ -1,7 +1,6 @@
1
- import type { Criteria } from '@elastic/eui';
1
+ import type { DataDisplayReturnValues } from '@/hooks';
2
+ import { SortOrder } from '@/types';
2
3
 
3
- import type { DataDisplayReturnValues } from '../../../hooks';
4
- import { SortOrder } from '../../../types';
5
4
  import { WfoDataSorting } from './columns';
6
5
 
7
6
  export const determinePageIndex = (pageIndex: number, pageSize: number) =>
@@ -32,16 +31,20 @@ export const getDataSortHandler =
32
31
  });
33
32
  };
34
33
 
35
- export const getPageChangeHandler =
34
+ export const getPageSizeChangeHandler =
36
35
  <Type>(
37
36
  setDataDisplayParam: DataDisplayReturnValues<Type>['setDataDisplayParam'],
38
37
  ) =>
39
- (page: Criteria<Type>['page']) => {
40
- if (page) {
41
- const { index, size } = page;
42
- setDataDisplayParam('pageSize', size);
43
- setDataDisplayParam('pageIndex', index);
44
- }
38
+ (pageSize: number) => {
39
+ setDataDisplayParam('pageSize', pageSize);
40
+ };
41
+
42
+ export const getPageIndexChangeHandler =
43
+ <Type>(
44
+ setDataDisplayParam: DataDisplayReturnValues<Type>['setDataDisplayParam'],
45
+ ) =>
46
+ (pageIndex: number) => {
47
+ setDataDisplayParam('pageIndex', pageIndex);
45
48
  };
46
49
 
47
50
  export const getQueryStringHandler =
@@ -2,7 +2,9 @@ import React, { FC } from 'react';
2
2
 
3
3
  import { EuiListGroup } from '@elastic/eui';
4
4
 
5
+ import { getSubscriptionDetailStyles } from '@/components/WfoSubscription/styles';
5
6
  import { TreeContext, TreeContextType } from '@/contexts';
7
+ import { useWithOrchestratorTheme } from '@/hooks';
6
8
  import { TreeBlock } from '@/types';
7
9
 
8
10
  import { WfoTreeNode } from './WfoTreeNode';
@@ -15,6 +17,9 @@ type WfoTreeBranchProps = {
15
17
  export const WfoTreeBranch: FC<WfoTreeBranchProps> = ({ item, level }) => {
16
18
  const { expandedIds } = React.useContext(TreeContext) as TreeContextType;
17
19
  const selected = expandedIds.includes(item.id);
20
+ const { productBlockTreeWidth } = useWithOrchestratorTheme(
21
+ getSubscriptionDetailStyles,
22
+ );
18
23
 
19
24
  const hasChildren = item.children && item.children.length !== 0;
20
25
 
@@ -32,7 +37,11 @@ export const WfoTreeBranch: FC<WfoTreeBranchProps> = ({ item, level }) => {
32
37
 
33
38
  return (
34
39
  <>
35
- <EuiListGroup flush={true} color="primary" maxWidth={455}>
40
+ <EuiListGroup
41
+ flush={true}
42
+ color="primary"
43
+ maxWidth={productBlockTreeWidth}
44
+ >
36
45
  <WfoTreeNode
37
46
  item={item}
38
47
  hasChildren={hasChildren}
@@ -1,15 +1,8 @@
1
1
  import React, { FC } from 'react';
2
2
 
3
- import { useTranslations } from 'next-intl';
4
-
5
- import {
6
- EuiFlexGroup,
7
- EuiFlexItem,
8
- EuiIcon,
9
- EuiListGroupItem,
10
- EuiToken,
11
- } from '@elastic/eui';
3
+ import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiToken } from '@elastic/eui';
12
4
 
5
+ import { WfoTreeNodeListItem } from '@/components/WfoTree/WfoTreeNodeListItem';
13
6
  import { TreeContext, TreeContextType } from '@/contexts';
14
7
  import { useOrchestratorTheme, useWithOrchestratorTheme } from '@/hooks';
15
8
  import { TreeBlock } from '@/types';
@@ -28,19 +21,10 @@ export const WfoTreeNode: FC<WfoTreeNodeProps> = ({
28
21
  level,
29
22
  }) => {
30
23
  const { theme } = useOrchestratorTheme();
31
- const {
32
- expandIconContainerStyle,
33
- treeContainerStyle,
34
- treeItemOtherSubscriptionStyle,
35
- } = useWithOrchestratorTheme(getStyles);
36
- const t = useTranslations('common');
37
- const {
38
- expandedIds,
39
- collapseNode,
40
- expandNode,
41
- selectedIds,
42
- toggleSelectedId,
43
- } = React.useContext(TreeContext) as TreeContextType;
24
+ const { expandIconContainerStyle, treeContainerStyle } =
25
+ useWithOrchestratorTheme(getStyles);
26
+ const { expandedIds, collapseNode, expandNode, selectedIds } =
27
+ React.useContext(TreeContext) as TreeContextType;
44
28
  const expanded = expandedIds.includes(item.id);
45
29
  const selected = selectedIds.includes(item.id);
46
30
 
@@ -65,41 +49,8 @@ export const WfoTreeNode: FC<WfoTreeNodeProps> = ({
65
49
  <EuiToken iconType={item.icon} />
66
50
  )}
67
51
  </EuiFlexItem>
68
- <EuiFlexItem grow={true}>
69
- {selected ? (
70
- <EuiListGroupItem
71
- onClick={() => toggleSelectedId(item.id)}
72
- label={item.label}
73
- isActive={selected}
74
- color={'primary'}
75
- style={{ borderRadius: 6 }}
76
- extraAction={{
77
- color: 'primary',
78
- onClick: () => toggleSelectedId(item.id),
79
- iconType: 'error',
80
- iconSize: 's',
81
- 'aria-label': t('deselect'),
82
- alwaysShow: true,
83
- }}
84
- css={
85
- item.isOutsideCurrentSubscription &&
86
- treeItemOtherSubscriptionStyle
87
- }
88
- />
89
- ) : (
90
- <EuiListGroupItem
91
- onClick={() => toggleSelectedId(item.id)}
92
- label={item.label}
93
- isActive={selected}
94
- style={{
95
- borderRadius: 6,
96
- }}
97
- css={
98
- item.isOutsideCurrentSubscription &&
99
- treeItemOtherSubscriptionStyle
100
- }
101
- />
102
- )}
52
+ <EuiFlexItem>
53
+ <WfoTreeNodeListItem item={item} selected={selected} />
103
54
  </EuiFlexItem>
104
55
  </EuiFlexGroup>
105
56
  </div>
@@ -0,0 +1,65 @@
1
+ import React, { useContext } from 'react';
2
+
3
+ import { useTranslations } from 'next-intl';
4
+
5
+ import {
6
+ EuiButtonIcon,
7
+ EuiFlexGroup,
8
+ EuiFlexItem,
9
+ EuiText,
10
+ EuiTextTruncate,
11
+ } from '@elastic/eui';
12
+
13
+ import { getStyles } from '@/components/WfoTree/styles';
14
+ import { TreeContext, TreeContextType } from '@/contexts';
15
+ import { useOrchestratorTheme, useWithOrchestratorTheme } from '@/hooks';
16
+ import { WfoXMarkSmall } from '@/icons/WfoXMarkSmall';
17
+ import { TreeBlock } from '@/types';
18
+
19
+ interface WfoTreeNodeListItemProps {
20
+ item: TreeBlock;
21
+ selected: boolean;
22
+ }
23
+
24
+ export const WfoTreeNodeListItem = ({
25
+ item,
26
+ selected,
27
+ }: WfoTreeNodeListItemProps) => {
28
+ const t = useTranslations('common');
29
+ const { toggleSelectedId } = useContext(TreeContext) as TreeContextType;
30
+ const { theme } = useOrchestratorTheme();
31
+ const { selectedTreeItemStyle, treeItemStyle } =
32
+ useWithOrchestratorTheme(getStyles);
33
+
34
+ const { isOutsideCurrentSubscription, id, label } = item;
35
+ const textLabel = label.toString();
36
+
37
+ return (
38
+ <EuiFlexGroup
39
+ alignItems="center"
40
+ css={
41
+ selected
42
+ ? selectedTreeItemStyle(isOutsideCurrentSubscription)
43
+ : treeItemStyle(isOutsideCurrentSubscription)
44
+ }
45
+ onClick={() => toggleSelectedId(id)}
46
+ gutterSize="xs"
47
+ justifyContent="spaceBetween"
48
+ >
49
+ <EuiFlexItem>
50
+ <EuiText title={textLabel}>
51
+ <EuiTextTruncate text={textLabel} />
52
+ </EuiText>
53
+ </EuiFlexItem>
54
+ <EuiFlexItem css={{ maxWidth: theme.size.l }}>
55
+ <EuiButtonIcon
56
+ color="primary"
57
+ iconType={() => <WfoXMarkSmall color="currentColor" />}
58
+ size="xs"
59
+ aria-label={t('deselect')}
60
+ css={{ display: selected ? 'block' : 'none' }}
61
+ />
62
+ </EuiFlexItem>
63
+ </EuiFlexGroup>
64
+ );
65
+ };