@orchestrator-ui/orchestrator-ui-components 1.6.0 → 1.6.1

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.
@@ -11,12 +11,12 @@ import {
11
11
  } from '@/components';
12
12
  import { WfoFilterTabs } from '@/components';
13
13
  import { StoredTableConfig } from '@/components';
14
+ import type { SubscriptionListItem } from '@/components';
14
15
  import {
15
16
  WfoSubscriptionListTab,
16
17
  WfoSubscriptionsList,
17
18
  subscriptionListTabs,
18
19
  } from '@/components/WfoSubscriptionsList';
19
- import { SubscriptionListItem } from '@/components/WfoSubscriptionsList';
20
20
  import { useDataDisplayParams, useStoredTableConfig } from '@/hooks';
21
21
  import { SortOrder } from '@/types';
22
22
 
@@ -1 +1,3 @@
1
1
  export * from './WfoWorkflowsListPage';
2
+ export * from './tabConfig';
3
+ export * from './getWorkflowsListTabTypeFromString';
@@ -357,12 +357,12 @@ export type StartComboBoxOption = {
357
357
  label: string;
358
358
  };
359
359
 
360
- interface GraphQlResultPage<T> {
360
+ export interface GraphQlResultPage<T> {
361
361
  page: T[];
362
362
  pageInfo: GraphQLPageInfo;
363
363
  }
364
364
 
365
- interface GraphQlSinglePage<T> {
365
+ export interface GraphQlSinglePage<T> {
366
366
  page: T[];
367
367
  }
368
368
 
@@ -8,3 +8,4 @@ export * from './strings';
8
8
  export * from './getProductNamesFromProcess';
9
9
  export * from './getQueryVariablesForExport';
10
10
  export * from './onlyUnique';
11
+ export * from './resultFlattener';
@@ -0,0 +1,51 @@
1
+ import {
2
+ getConcatenatedPagedResult,
3
+ getConcatenatedResult,
4
+ } from './resultFlattener';
5
+
6
+ describe('pagedResultFlattener', () => {
7
+ it('returns an empty string when the paged result is empty', () => {
8
+ const pagedResult = { page: [] };
9
+ const fields = ['name', 'age'];
10
+
11
+ const result = getConcatenatedPagedResult(pagedResult, fields);
12
+
13
+ expect(result).toBe('');
14
+ });
15
+ });
16
+
17
+ describe('resultFlattener', () => {
18
+ it('returns a flattened string of the specified fields', () => {
19
+ type TestItem = {
20
+ name: string;
21
+ age: number;
22
+ };
23
+ const results = [
24
+ { name: 'John', age: 25 },
25
+ { name: 'Jane', age: 30 },
26
+ { name: 'Bob', age: 40 },
27
+ ];
28
+ const fields: Array<keyof TestItem> = ['name', 'age'];
29
+ const result = getConcatenatedResult<TestItem>(results, fields);
30
+ expect(result).toBe('John: 25 - Jane: 30 - Bob: 40');
31
+ });
32
+
33
+ it('returns a flattened string with selected fields only', () => {
34
+ type TestItem = {
35
+ name: string;
36
+ age: number;
37
+ city: string;
38
+ };
39
+ const results: TestItem[] = [
40
+ { name: 'John', age: 25, city: 'New York' },
41
+ { name: 'Jane', age: 30, city: 'London' },
42
+ { name: 'Bob', age: 40, city: 'Paris' },
43
+ ];
44
+
45
+ const fields: Array<keyof TestItem> = ['name', 'city'];
46
+
47
+ const result = getConcatenatedResult(results, fields);
48
+
49
+ expect(result).toBe('John: New York - Jane: London - Bob: Paris');
50
+ });
51
+ });
@@ -0,0 +1,25 @@
1
+ import { GraphQlSinglePage } from '@/types';
2
+
3
+ export const getConcatenatedPagedResult = <T>(
4
+ pagedResult: GraphQlSinglePage<T>,
5
+ fields: Array<keyof T>,
6
+ ): string => {
7
+ const results = pagedResult.page || [];
8
+ return getConcatenatedResult(results, fields);
9
+ };
10
+
11
+ export const getConcatenatedResult = <T>(
12
+ results: T[],
13
+ fields: Array<keyof T>,
14
+ ): string => {
15
+ return results.reduce((accumulator, result, index) => {
16
+ const resultFields = fields.reduce((accumulator, field, index) => {
17
+ return (
18
+ accumulator +
19
+ `${result[field]}${index !== fields.length - 1 ? ': ' : ''}`
20
+ );
21
+ }, '');
22
+
23
+ return `${accumulator}${resultFields}${index !== results.length - 1 ? ' - ' : ''}`;
24
+ }, '');
25
+ };