@orchestrator-ui/orchestrator-ui-components 1.3.1 → 1.5.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 +5 -5
  2. package/.turbo/turbo-lint.log +7 -1
  3. package/.turbo/turbo-test.log +7 -7
  4. package/CHANGELOG.md +31 -2
  5. package/LICENSE.txt +202 -0
  6. package/README.md +22 -0
  7. package/dist/index.d.ts +531 -314
  8. package/dist/index.js +5120 -7384
  9. package/package.json +21 -4
  10. package/src/api/index.ts +4 -3
  11. package/src/api/types.ts +53 -0
  12. package/src/components/WfoDropdownButton/WfoDropdownButton.tsx +2 -0
  13. package/src/components/WfoForms/AutoFieldLoader.tsx +6 -6
  14. package/src/components/WfoForms/formFields/AcceptField.tsx +2 -1
  15. package/src/components/WfoForms/formFields/BoolField.tsx +2 -1
  16. package/src/components/WfoForms/formFields/DividerField.tsx +1 -1
  17. package/src/components/WfoForms/formFields/ErrorField.tsx +1 -1
  18. package/src/components/WfoForms/formFields/LabelField.tsx +1 -1
  19. package/src/components/WfoForms/formFields/ListAddField.tsx +2 -1
  20. package/src/components/WfoForms/formFields/ListDelField.tsx +2 -1
  21. package/src/components/WfoForms/formFields/LongTextField.tsx +1 -1
  22. package/src/components/WfoForms/formFields/NumField.tsx +1 -1
  23. package/src/components/WfoForms/formFields/ProductField.tsx +8 -7
  24. package/src/components/WfoForms/formFields/RadioField.tsx +1 -1
  25. package/src/components/WfoForms/formFields/SelectField.tsx +4 -2
  26. package/src/components/WfoForms/formFields/SubmitField.tsx +1 -1
  27. package/src/components/WfoForms/formFields/SubscriptionField.tsx +5 -4
  28. package/src/components/WfoForms/formFields/SubscriptionSummaryField.tsx +11 -15
  29. package/src/components/WfoForms/formFields/TextField.tsx +1 -1
  30. package/src/components/WfoForms/formFields/{ContactPersonAutocomplete.tsx → deprecated/ContactPersonAutocomplete.tsx} +4 -3
  31. package/src/components/WfoForms/formFields/{ContactPersonNameField.tsx → deprecated/ContactPersonNameField.tsx} +3 -2
  32. package/src/components/WfoForms/formFields/{ImsNodeIdField.tsx → deprecated/ImsNodeIdField.tsx} +4 -3
  33. package/src/components/WfoForms/formFields/{ImsPortIdField.tsx → deprecated/ImsPortIdField.tsx} +7 -4
  34. package/src/components/WfoForms/formFields/{IpNetworkField.tsx → deprecated/IpNetworkField.tsx} +4 -3
  35. package/src/components/WfoForms/formFields/{IpPrefixTableField.tsx → deprecated/IpPrefixTableField.tsx} +5 -4
  36. package/src/components/WfoForms/formFields/{SplitPrefix.tsx → deprecated/SplitPrefix.tsx} +3 -2
  37. package/src/components/WfoForms/formFields/{TimestampField.tsx → deprecated/TimestampField.tsx} +1 -1
  38. package/src/components/WfoForms/formFields/{VlanField.tsx → deprecated/VlanField.tsx} +5 -4
  39. package/src/components/WfoForms/formFields/deprecated/index.ts +13 -0
  40. package/src/components/WfoForms/formFields/{surf → deprecated}/types.ts +1 -1
  41. package/src/components/WfoForms/formFields/index.ts +1 -6
  42. package/src/components/WfoForms/formFields/utils.spec.ts +1 -1
  43. package/src/components/WfoForms/formFields/utils.ts +3 -2
  44. package/src/components/WfoPageTemplate/WfoSidebar/WfoSidebar.tsx +2 -2
  45. package/src/components/WfoProcessList/WfoProcessesList.tsx +16 -9
  46. package/src/components/WfoProcessList/processListObjectMappers.ts +6 -10
  47. package/src/components/WfoSettings/WfoModifySettings.tsx +29 -13
  48. package/src/components/WfoSettings/WfoResetTextSearchIndexButton.tsx +22 -0
  49. package/src/components/WfoSettings/index.ts +1 -0
  50. package/src/components/{WfoButtonComboBox/WfoButtonComboBox.tsx → WfoStartButton/WfoStartButtonComboBox.tsx} +11 -17
  51. package/src/components/WfoStartButton/WfoStartTaskComboBox.tsx +47 -0
  52. package/src/components/WfoStartButton/WfoStartWorkflowComboBox.tsx +49 -0
  53. package/src/components/WfoStartButton/index.ts +2 -0
  54. package/src/components/WfoSubscription/WfoRelatedSubscriptions.tsx +30 -36
  55. package/src/components/WfoSubscription/WfoSubscription.tsx +17 -20
  56. package/src/components/WfoSubscription/index.ts +6 -4
  57. package/src/components/WfoSubscriptionsList/WfoSubscriptionsList.tsx +12 -16
  58. package/src/components/WfoSubscriptionsList/subscriptionResultMappers.ts +10 -12
  59. package/src/components/index.ts +2 -1
  60. package/src/configuration/constants.ts +3 -0
  61. package/src/hooks/{surf → deprecated}/useGetSubscriptionDropdownOptions.ts +6 -13
  62. package/src/hooks/{surf → deprecated}/useIsTaggedPort.ts +6 -9
  63. package/src/hooks/index.ts +0 -1
  64. package/src/index.ts +0 -1
  65. package/src/messages/en-GB.json +3 -1
  66. package/src/messages/nl-NL.json +3 -1
  67. package/src/pages/metadata/WfoProductBlocksPage.tsx +27 -37
  68. package/src/pages/metadata/WfoProductsPage.tsx +11 -16
  69. package/src/pages/metadata/WfoResourceTypesPage.tsx +33 -35
  70. package/src/pages/metadata/WfoWorkflowsPage.tsx +42 -40
  71. package/src/pages/metadata/workflowListObjectMapper.ts +4 -7
  72. package/src/pages/processes/WfoStartProcessPage.tsx +0 -6
  73. package/src/pages/startPage/WfoStartPage.tsx +56 -68
  74. package/src/pages/subscriptions/WfoSubscriptionsListPage.tsx +6 -7
  75. package/src/rtk/api.ts +11 -3
  76. package/src/rtk/endpoints/index.ts +11 -2
  77. package/src/rtk/endpoints/metadata/index.ts +3 -0
  78. package/src/rtk/endpoints/metadata/productBlocks.ts +88 -0
  79. package/src/rtk/endpoints/metadata/resourceTypes.ts +78 -0
  80. package/src/rtk/endpoints/metadata/workflows.ts +73 -0
  81. package/src/rtk/endpoints/processList.ts +2 -1
  82. package/src/rtk/endpoints/processListSummary.ts +70 -0
  83. package/src/rtk/endpoints/products.ts +76 -0
  84. package/src/rtk/endpoints/productsSummary.ts +62 -0
  85. package/src/rtk/endpoints/relatedSubscriptions.ts +99 -0
  86. package/src/rtk/endpoints/settings.ts +10 -0
  87. package/src/rtk/endpoints/startOptions.ts +99 -0
  88. package/src/{graphqlQueries/subscriptionDetailQuery.ts → rtk/endpoints/subscriptionDetail.ts} +45 -11
  89. package/src/rtk/endpoints/subscriptionList.ts +86 -0
  90. package/src/rtk/endpoints/subscriptionListSummary.ts +70 -0
  91. package/src/rtk/endpoints/subscriptionsDropdownOptions.ts +72 -0
  92. package/src/types/types.ts +20 -0
  93. package/src/utils/index.ts +1 -0
  94. package/src/components/WfoPageTemplate/WfoSidebar/WfoStartCreateWorkflowButtonComboBox.tsx +0 -61
  95. package/src/components/WfoStartTaskButtonComboBox/WfoStartTaskButtonComboBox.tsx +0 -54
  96. package/src/components/WfoStartTaskButtonComboBox/index.ts +0 -1
  97. package/src/graphqlQueries/index.ts +0 -7
  98. package/src/graphqlQueries/processListQuery.ts +0 -101
  99. package/src/graphqlQueries/productBlocksQuery.ts +0 -59
  100. package/src/graphqlQueries/productsQuery.ts +0 -85
  101. package/src/graphqlQueries/relatedSubscriptionsQuery.ts +0 -65
  102. package/src/graphqlQueries/resourceTypesQuery.ts +0 -52
  103. package/src/graphqlQueries/subscriptionsDropdownOptionsQuery.ts +0 -48
  104. package/src/graphqlQueries/subscriptionsListQuery.ts +0 -101
  105. package/src/graphqlQueries/workflows/workflowsQuery.ts +0 -48
  106. package/src/graphqlQueries/workflows/workflowsQueryForDropdownList.ts +0 -38
  107. package/src/hooks/useQueryWithGraphql.ts +0 -72
  108. /package/src/components/WfoForms/formFields/{ContactPersonAutocompleteStyles.ts → deprecated/ContactPersonAutocompleteStyles.ts} +0 -0
  109. /package/src/components/WfoForms/formFields/{ImsPortIdFieldStyling.ts → deprecated/ImsPortIdFieldStyling.ts} +0 -0
  110. /package/src/components/WfoForms/formFields/{IpPrefixTableFieldStyling.ts → deprecated/IpPrefixTableFieldStyling.ts} +0 -0
  111. /package/src/components/WfoForms/formFields/{SplitPrefixStyling.ts → deprecated/SplitPrefixStyling.ts} +0 -0
  112. /package/src/components/WfoForms/formFields/{surf → deprecated}/utils.ts +0 -0
  113. /package/src/components/{WfoButtonComboBox → WfoStartButton}/styles.ts +0 -0
@@ -0,0 +1,62 @@
1
+ import { orchestratorApi } from '@/rtk';
2
+ import {
3
+ BaseGraphQlResult,
4
+ GraphqlQueryVariables,
5
+ ProductDefinitionsResult,
6
+ ProductsSummary,
7
+ } from '@/types';
8
+
9
+ export const productsSummary = `
10
+ query MetadataProducts(
11
+ $first: Int!
12
+ $after: Int!
13
+ $sortBy: [GraphqlSort!]
14
+ ) {
15
+ products(first: $first, after: $after, sortBy: $sortBy) {
16
+ page {
17
+ name
18
+ subscriptions {
19
+ pageInfo {
20
+ totalItems
21
+ }
22
+ }
23
+ }
24
+ pageInfo {
25
+ totalItems
26
+ startCursor
27
+ endCursor
28
+ }
29
+ }
30
+ }
31
+ `;
32
+
33
+ export type ProductsSummaryResponse = {
34
+ products: ProductsSummary[];
35
+ } & BaseGraphQlResult;
36
+
37
+ const productsSummaryApi = orchestratorApi.injectEndpoints({
38
+ endpoints: (builder) => ({
39
+ getProductsSummary: builder.query<
40
+ ProductsSummaryResponse,
41
+ GraphqlQueryVariables<ProductsSummary>
42
+ >({
43
+ query: (variables) => ({
44
+ document: productsSummary,
45
+ variables,
46
+ }),
47
+ transformResponse: (
48
+ response: ProductDefinitionsResult<ProductsSummary>,
49
+ ): ProductsSummaryResponse => {
50
+ const products = response.products.page || [];
51
+ const pageInfo = response.products.pageInfo || {};
52
+
53
+ return {
54
+ products,
55
+ pageInfo,
56
+ };
57
+ },
58
+ }),
59
+ }),
60
+ });
61
+
62
+ export const { useGetProductsSummaryQuery } = productsSummaryApi;
@@ -0,0 +1,99 @@
1
+ import {
2
+ BaseGraphQlResult,
3
+ GraphqlFilter,
4
+ GraphqlQueryVariables,
5
+ RelatedSubscription,
6
+ RelatedSubscriptionsResult,
7
+ Subscription,
8
+ } from '@/types';
9
+
10
+ import { orchestratorApi } from '../api';
11
+
12
+ export const RelatedSubscriptionsQuery = `
13
+ query RelatedSubscriptions(
14
+ $subscriptionId: String!
15
+ $first: Int!
16
+ $after: Int!
17
+ $sortBy: [GraphqlSort!]
18
+ $terminatedSubscriptionFilter: [GraphqlFilter!]
19
+ ) {
20
+ subscriptions(
21
+ filterBy: { value: $subscriptionId, field: "subscriptionId" }
22
+ ) {
23
+ page {
24
+ subscriptionId
25
+ inUseBySubscriptions(
26
+ first: $first
27
+ after: $after
28
+ sortBy: $sortBy
29
+ filterBy: $terminatedSubscriptionFilter
30
+ ) {
31
+ page {
32
+ subscriptionId
33
+ customer {
34
+ fullname
35
+ }
36
+ description
37
+ insync
38
+ startDate
39
+ status
40
+ product {
41
+ tag
42
+ }
43
+ }
44
+ pageInfo {
45
+ endCursor
46
+ hasNextPage
47
+ hasPreviousPage
48
+ startCursor
49
+ totalItems
50
+ sortFields
51
+ filterFields
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+ `;
58
+
59
+ export type RelatedSubscriptionsResponse = {
60
+ relatedSubscriptions: RelatedSubscription[];
61
+ } & BaseGraphQlResult;
62
+
63
+ type RelatedSubscriptionVariables = GraphqlQueryVariables<RelatedSubscription> &
64
+ Pick<Subscription, 'subscriptionId'> & {
65
+ terminatedSubscriptionFilter?: GraphqlFilter<RelatedSubscription>;
66
+ };
67
+
68
+ const relatedSubscriptionsApi = orchestratorApi.injectEndpoints({
69
+ endpoints: (build) => ({
70
+ getRelatedSubscriptions: build.query<
71
+ RelatedSubscriptionsResponse,
72
+ RelatedSubscriptionVariables
73
+ >({
74
+ query: (variables) => ({
75
+ document: RelatedSubscriptionsQuery,
76
+ variables,
77
+ }),
78
+ transformResponse: (
79
+ result: RelatedSubscriptionsResult,
80
+ ): RelatedSubscriptionsResponse => {
81
+ const relatedSubscriptionResultForSubscription =
82
+ result.subscriptions.page[0] || [];
83
+ const relatedSubscriptions =
84
+ relatedSubscriptionResultForSubscription
85
+ .inUseBySubscriptions.page || [];
86
+ const pageInfo =
87
+ relatedSubscriptionResultForSubscription
88
+ .inUseBySubscriptions.pageInfo || {};
89
+
90
+ return {
91
+ relatedSubscriptions,
92
+ pageInfo,
93
+ };
94
+ },
95
+ }),
96
+ }),
97
+ });
98
+
99
+ export const { useGetRelatedSubscriptionsQuery } = relatedSubscriptionsApi;
@@ -46,6 +46,15 @@ const statusApi = orchestratorApi.injectEndpoints({
46
46
  baseQueryType: BaseQueryTypes.fetch,
47
47
  },
48
48
  }),
49
+ resetTextSearchIndex: build.mutation<void, null>({
50
+ query: () => ({
51
+ url: `/settings/search-index/reset`,
52
+ method: 'POST',
53
+ }),
54
+ extraOptions: {
55
+ baseQueryType: BaseQueryTypes.fetch,
56
+ },
57
+ }),
49
58
  setEngineStatus: build.mutation<EngineStatusReturnValue, boolean>({
50
59
  query: (globalStatus) => ({
51
60
  url: `/settings/status`,
@@ -68,5 +77,6 @@ const statusApi = orchestratorApi.injectEndpoints({
68
77
  export const {
69
78
  useGetEngineStatusQuery,
70
79
  useClearCacheMutation,
80
+ useResetTextSearchIndexMutation,
71
81
  useSetEngineStatusMutation,
72
82
  } = statusApi;
@@ -0,0 +1,99 @@
1
+ import {
2
+ ProductDefinition,
3
+ StartOptionsResult,
4
+ WorkflowDefinition,
5
+ WorkflowTarget,
6
+ } from '@/types';
7
+
8
+ import { orchestratorApi } from '../api';
9
+
10
+ const workflowOptionsQuery = `
11
+ query StartOptions {
12
+ workflows(first: 1000000, after: 0, filterBy: [{ field: "target", value: "${WorkflowTarget.CREATE}"}]) {
13
+ page {
14
+ name
15
+ products {
16
+ productId
17
+ name
18
+ }
19
+ }
20
+ }
21
+ }
22
+ `;
23
+
24
+ const taskOptionsQuery = `
25
+ query StartOptions {
26
+ workflows(first: 1000000, after: 0, filterBy: [{ field: "target", value: "${WorkflowTarget.SYSTEM}"}]) {
27
+ page {
28
+ name
29
+ description
30
+ }
31
+ }
32
+ }
33
+ `;
34
+
35
+ type WorkflowOption = {
36
+ workflowName: WorkflowDefinition['name'];
37
+ productName: ProductDefinition['name'];
38
+ productId: ProductDefinition['productId'];
39
+ };
40
+
41
+ type WorkflowOptionsResult = StartOptionsResult<{
42
+ name: WorkflowDefinition['name'];
43
+ products: {
44
+ name: ProductDefinition['name'];
45
+ productId: ProductDefinition['productId'];
46
+ }[];
47
+ }>;
48
+
49
+ export type StartOptionsResponse<StartOption> = {
50
+ startOptions: StartOption[];
51
+ };
52
+
53
+ type TaskOption = Pick<WorkflowDefinition, 'name' | 'description'>;
54
+ type TaskOptionsResult = StartOptionsResult<TaskOption>;
55
+
56
+ const startButtonOptionsApi = orchestratorApi.injectEndpoints({
57
+ endpoints: (build) => ({
58
+ getWorkflowOptions: build.query<
59
+ StartOptionsResponse<WorkflowOption>,
60
+ void
61
+ >({
62
+ query: () => ({
63
+ document: workflowOptionsQuery,
64
+ }),
65
+ transformResponse: (response: WorkflowOptionsResult) => {
66
+ const startOptions: WorkflowOption[] = [];
67
+ const workflows = response.workflows?.page || [];
68
+ workflows.forEach((workflow) => {
69
+ const workflowName = workflow.name;
70
+ workflow.products.forEach((product) => {
71
+ startOptions.push({
72
+ workflowName,
73
+ productName: product.name,
74
+ productId: product.productId,
75
+ });
76
+ });
77
+ });
78
+
79
+ return { startOptions };
80
+ },
81
+ }),
82
+ getTaskOptions: build.query<StartOptionsResponse<TaskOption>, void>({
83
+ query: () => ({
84
+ document: taskOptionsQuery,
85
+ }),
86
+ transformResponse: (response: TaskOptionsResult) => {
87
+ return {
88
+ startOptions: response.workflows.page.map((option) => ({
89
+ name: option.name,
90
+ description: option.description,
91
+ })),
92
+ };
93
+ },
94
+ }),
95
+ }),
96
+ });
97
+
98
+ export const { useGetWorkflowOptionsQuery, useGetTaskOptionsQuery } =
99
+ startButtonOptionsApi;
@@ -1,14 +1,11 @@
1
- import { parse } from 'graphql';
2
- import { gql } from 'graphql-request';
3
-
4
- import { TypedDocumentNode } from '@graphql-typed-document-node/core';
5
-
6
- import { SubscriptionDetailResult } from '../types';
7
-
8
- export const GET_SUBSCRIPTION_DETAIL_GRAPHQL_QUERY: TypedDocumentNode<
1
+ import { CacheTags, orchestratorApi } from '@/rtk';
2
+ import {
3
+ BaseGraphQlResult,
4
+ SubscriptionDetail,
9
5
  SubscriptionDetailResult,
10
- { subscriptionId: string }
11
- > = parse(gql`
6
+ } from '@/types';
7
+
8
+ export const subscriptionDetailQuery = `
12
9
  query SubscriptionDetail($subscriptionId: String!) {
13
10
  subscriptions(
14
11
  filterBy: { value: $subscriptionId, field: "subscriptionId" }
@@ -60,4 +57,41 @@ export const GET_SUBSCRIPTION_DETAIL_GRAPHQL_QUERY: TypedDocumentNode<
60
57
  }
61
58
  }
62
59
  }
63
- `);
60
+ `;
61
+
62
+ export type SubscriptionDetailResponse = {
63
+ subscription: SubscriptionDetail;
64
+ } & BaseGraphQlResult;
65
+
66
+ const subscriptionDetailApi = orchestratorApi.injectEndpoints({
67
+ endpoints: (builder) => ({
68
+ getSubscriptionDetail: builder.query<
69
+ SubscriptionDetailResponse,
70
+ { subscriptionId: string }
71
+ >({
72
+ query: (variables) => ({
73
+ document: subscriptionDetailQuery,
74
+ variables,
75
+ }),
76
+ transformResponse: (
77
+ response: SubscriptionDetailResult,
78
+ ): SubscriptionDetailResponse => {
79
+ const subscription = response.subscriptions.page[0] || [];
80
+ const pageInfo = response.subscriptions.pageInfo || {};
81
+
82
+ return {
83
+ subscription,
84
+ pageInfo,
85
+ };
86
+ },
87
+ providesTags: (result, error, arg) => [
88
+ {
89
+ type: CacheTags.subscription,
90
+ id: arg.subscriptionId,
91
+ },
92
+ ],
93
+ }),
94
+ }),
95
+ });
96
+
97
+ export const { useGetSubscriptionDetailQuery } = subscriptionDetailApi;
@@ -0,0 +1,86 @@
1
+ import { SubscriptionListItem } from '@/components/WfoSubscriptionsList';
2
+ import { CacheTags, orchestratorApi } from '@/rtk';
3
+ import {
4
+ BaseGraphQlResult,
5
+ GraphqlQueryVariables,
6
+ Subscription,
7
+ SubscriptionsResult,
8
+ } from '@/types';
9
+
10
+ export const subscriptionListQuery = `query SubscriptionsList(
11
+ $first: Int!
12
+ $after: Int!
13
+ $sortBy: [GraphqlSort!]
14
+ $filterBy: [GraphqlFilter!]
15
+ $query: String
16
+ ) {
17
+ subscriptions(
18
+ first: $first
19
+ after: $after
20
+ sortBy: $sortBy
21
+ filterBy: $filterBy
22
+ query: $query
23
+ ) {
24
+ page {
25
+ note
26
+ startDate
27
+ endDate
28
+ description
29
+ insync
30
+ status
31
+ subscriptionId
32
+ product {
33
+ name
34
+ tag
35
+ productType
36
+ }
37
+ customer {
38
+ fullname
39
+ shortcode
40
+ }
41
+ }
42
+ pageInfo {
43
+ totalItems
44
+ startCursor
45
+ hasPreviousPage
46
+ hasNextPage
47
+ endCursor
48
+ sortFields
49
+ filterFields
50
+ }
51
+ }
52
+ }
53
+ `;
54
+
55
+ export type SubscriptionListResponse = {
56
+ subscriptions: Subscription[];
57
+ } & BaseGraphQlResult;
58
+
59
+ const subscriptionListApi = orchestratorApi.injectEndpoints({
60
+ endpoints: (builder) => ({
61
+ getSubscriptionList: builder.query<
62
+ SubscriptionListResponse,
63
+ GraphqlQueryVariables<SubscriptionListItem>
64
+ >({
65
+ query: (variables) => ({
66
+ document: subscriptionListQuery,
67
+ variables,
68
+ }),
69
+ transformResponse: (
70
+ response: SubscriptionsResult,
71
+ ): SubscriptionListResponse => {
72
+ const subscriptions = response.subscriptions.page || [];
73
+ const pageInfo = response.subscriptions.pageInfo || {};
74
+
75
+ return {
76
+ subscriptions,
77
+ pageInfo,
78
+ };
79
+ },
80
+ providesTags: [CacheTags.subscriptionList],
81
+ }),
82
+ }),
83
+ });
84
+
85
+ export const { useGetSubscriptionListQuery, useLazyGetSubscriptionListQuery } =
86
+ subscriptionListApi;
@@ -0,0 +1,70 @@
1
+ import { CacheTags, orchestratorApi } from '@/rtk';
2
+ import {
3
+ BaseGraphQlResult,
4
+ GraphqlQueryVariables,
5
+ Subscription,
6
+ SubscriptionSummary,
7
+ SubscriptionsResult,
8
+ } from '@/types';
9
+
10
+ export const subscriptionListSummaryQuery = `
11
+ query SubscriptionsList(
12
+ $first: Int!
13
+ $after: Int!
14
+ $sortBy: [GraphqlSort!]
15
+ $filterBy: [GraphqlFilter!]
16
+ $query: String
17
+ ) {
18
+ subscriptions(
19
+ first: $first
20
+ after: $after
21
+ sortBy: $sortBy
22
+ filterBy: $filterBy
23
+ query: $query
24
+ ) {
25
+ page {
26
+ startDate
27
+ description
28
+ subscriptionId
29
+ }
30
+ pageInfo {
31
+ totalItems
32
+ startCursor
33
+ endCursor
34
+ }
35
+ }
36
+ }
37
+ `;
38
+
39
+ export type SubscriptionListSummaryResponse = {
40
+ subscriptions: SubscriptionSummary[];
41
+ } & BaseGraphQlResult;
42
+
43
+ const subscriptionListSummaryApi = orchestratorApi.injectEndpoints({
44
+ endpoints: (builder) => ({
45
+ getSubscriptionSummaryList: builder.query<
46
+ SubscriptionListSummaryResponse,
47
+ GraphqlQueryVariables<Subscription>
48
+ >({
49
+ query: (variables) => ({
50
+ document: subscriptionListSummaryQuery,
51
+ variables,
52
+ }),
53
+ transformResponse: (
54
+ response: SubscriptionsResult<SubscriptionSummary>,
55
+ ): SubscriptionListSummaryResponse => {
56
+ const subscriptions = response.subscriptions.page || [];
57
+ const pageInfo = response.subscriptions.pageInfo || {};
58
+
59
+ return {
60
+ subscriptions,
61
+ pageInfo,
62
+ };
63
+ },
64
+ providesTags: [CacheTags.subscriptionList],
65
+ }),
66
+ }),
67
+ });
68
+
69
+ export const { useGetSubscriptionSummaryListQuery } =
70
+ subscriptionListSummaryApi;
@@ -0,0 +1,72 @@
1
+ import { NUMBER_OF_ITEMS_REPRESENTING_ALL_ITEMS } from '@/configuration';
2
+ import { orchestratorApi } from '@/rtk';
3
+ import {
4
+ GraphqlQueryVariables,
5
+ SubscriptionDropdownOption,
6
+ SubscriptionDropdownOptionsResult,
7
+ } from '@/types';
8
+
9
+ export const subscriptionsDropdownOptionsQuery = `
10
+ query SubscriptionDropdownOptions(
11
+ $filterBy: [GraphqlFilter!]
12
+ $first: Int!
13
+ ) {
14
+ subscriptions(filterBy: $filterBy, first: $first, after: 0) {
15
+ page {
16
+ description
17
+ subscriptionId
18
+ product {
19
+ tag
20
+ productId
21
+ }
22
+ customer {
23
+ fullname
24
+ customerId
25
+ }
26
+ productBlockInstances {
27
+ id
28
+ ownerSubscriptionId
29
+ parent
30
+ productBlockInstanceValues
31
+ subscriptionInstanceId
32
+ inUseByRelations
33
+ }
34
+ fixedInputs
35
+ }
36
+ }
37
+ }
38
+ `;
39
+
40
+ export type SubscriptionDropdownOptionsResponse = {
41
+ subscriptionDropdownOptions: SubscriptionDropdownOption[];
42
+ };
43
+
44
+ const subscriptionsDropdownOptionsApi = orchestratorApi.injectEndpoints({
45
+ endpoints: (builder) => ({
46
+ getSubscriptionsDropdownOptions: builder.query<
47
+ SubscriptionDropdownOptionsResponse,
48
+ GraphqlQueryVariables<SubscriptionDropdownOption>
49
+ >({
50
+ query: (variables) => ({
51
+ document: subscriptionsDropdownOptionsQuery,
52
+ variables: {
53
+ ...variables,
54
+ first: NUMBER_OF_ITEMS_REPRESENTING_ALL_ITEMS,
55
+ },
56
+ }),
57
+ transformResponse: (
58
+ response: SubscriptionDropdownOptionsResult,
59
+ ): SubscriptionDropdownOptionsResponse => {
60
+ const subscriptionDropdownOptions =
61
+ response.subscriptions.page || [];
62
+
63
+ return {
64
+ subscriptionDropdownOptions,
65
+ };
66
+ },
67
+ }),
68
+ }),
69
+ });
70
+
71
+ export const { useGetSubscriptionsDropdownOptionsQuery } =
72
+ subscriptionsDropdownOptionsApi;
@@ -109,6 +109,9 @@ export interface ProductDefinition {
109
109
  fixedInputs: Pick<FixedInputDefinition, 'name' | 'value'>[];
110
110
  }
111
111
 
112
+ export type ProductsSummary = Pick<ProductDefinition, 'name'> &
113
+ SubscriptionsResult<never>;
114
+
112
115
  export enum WorkflowTarget {
113
116
  CREATE = 'create',
114
117
  MODIFY = 'modify',
@@ -333,6 +336,10 @@ export interface WorkflowDefinitionsResult<T = WorkflowDefinition> {
333
336
  workflows: GraphQlResultPage<T>;
334
337
  }
335
338
 
339
+ export interface StartOptionsResult<T> {
340
+ workflows: GraphQlSinglePage<T>;
341
+ }
342
+
336
343
  export interface RelatedSubscriptionsResult {
337
344
  subscriptions: GraphQlSinglePage<
338
345
  Pick<Subscription, 'subscriptionId'> & {
@@ -341,6 +348,14 @@ export interface RelatedSubscriptionsResult {
341
348
  >;
342
349
  }
343
350
 
351
+ export type StartComboBoxOption = {
352
+ data: {
353
+ workflowName: string;
354
+ productId?: string;
355
+ };
356
+ label: string;
357
+ };
358
+
344
359
  interface GraphQlResultPage<T> {
345
360
  page: T[];
346
361
  pageInfo: GraphQLPageInfo;
@@ -382,6 +397,11 @@ export type Subscription = {
382
397
  customer: Pick<Customer, 'fullname' | 'shortcode'>;
383
398
  };
384
399
 
400
+ export type SubscriptionSummary = Pick<
401
+ Subscription,
402
+ 'subscriptionId' | 'description' | 'startDate'
403
+ >;
404
+
385
405
  export type SubscriptionDropdownOption = {
386
406
  description: Subscription['description'];
387
407
  subscriptionId: Subscription['subscriptionId'];
@@ -1,3 +1,4 @@
1
+ export * from './csvDownload';
1
2
  export * from './date';
2
3
  export * from './environmentVariables';
3
4
  export * from './getStatusBadgeColor';
@@ -1,61 +0,0 @@
1
- import React from 'react';
2
-
3
- import { useTranslations } from 'next-intl';
4
- import { useRouter } from 'next/router';
5
-
6
- import { GET_WORKFLOWS_FOR_DROPDOWN_LIST_GRAPHQL_QUERY } from '@/graphqlQueries/workflows/workflowsQueryForDropdownList';
7
- import { useCheckEngineStatus, useQueryWithGraphql } from '@/hooks';
8
-
9
- import {
10
- WfoButtonComboBox,
11
- WorkflowComboBoxOption,
12
- } from '../../WfoButtonComboBox/WfoButtonComboBox';
13
- import { PATH_START_NEW_WORKFLOW } from '../paths';
14
-
15
- export const WfoStartCreateWorkflowButtonComboBox = () => {
16
- const router = useRouter();
17
- const t = useTranslations('common');
18
- const { isEngineRunningNow } = useCheckEngineStatus();
19
-
20
- const { data } = useQueryWithGraphql(
21
- GET_WORKFLOWS_FOR_DROPDOWN_LIST_GRAPHQL_QUERY,
22
- {
23
- filterBy: [{ field: 'target', value: 'CREATE' }],
24
- },
25
- 'createWorkflows',
26
- );
27
-
28
- const productList: WorkflowComboBoxOption[] =
29
- data?.workflows.page
30
- .flatMap(({ name: workflowName, products }) =>
31
- products.map(({ productId, name: productName }) => ({
32
- label: productName,
33
- data: {
34
- workflowName,
35
- productId,
36
- },
37
- })),
38
- )
39
- .sort((a, b) => a.label.localeCompare(b.label)) ?? [];
40
-
41
- const handleOptionChange = async (
42
- selectedProduct: WorkflowComboBoxOption,
43
- ) => {
44
- if (await isEngineRunningNow()) {
45
- const { workflowName, productId } = selectedProduct.data;
46
- router.push({
47
- pathname: `${PATH_START_NEW_WORKFLOW}/${workflowName}`,
48
- query: { productId },
49
- });
50
- }
51
- };
52
-
53
- return (
54
- <WfoButtonComboBox
55
- buttonText={t('newSubscription')}
56
- options={productList}
57
- onOptionChange={handleOptionChange}
58
- isProcess
59
- />
60
- );
61
- };