@orchestrator-ui/orchestrator-ui-components 0.5.0 → 0.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orchestrator-ui/orchestrator-ui-components",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -1,9 +1,10 @@
1
1
  import React, { FC } from 'react';
2
2
 
3
3
  import {
4
+ getDate,
4
5
  parseDateOrTimeRelativeToToday,
5
6
  parseDateToLocaleDateTimeString,
6
- } from '../../utils';
7
+ } from '@/utils';
7
8
 
8
9
  export type WfoDateTimeProps = {
9
10
  dateOrIsoString: Date | string | null;
@@ -18,11 +19,3 @@ export const WfoDateTime: FC<WfoDateTimeProps> = ({ dateOrIsoString }) => {
18
19
  </span>
19
20
  );
20
21
  };
21
-
22
- function getDate(date: Date | string | null) {
23
- if (typeof date === 'string') {
24
- return new Date(date);
25
- }
26
-
27
- return date;
28
- }
@@ -0,0 +1,45 @@
1
+ import React, { ErrorInfo, ReactNode } from 'react';
2
+
3
+ type ErrorBoundaryProps = {
4
+ fallback?: ReactNode;
5
+ children: ReactNode;
6
+ };
7
+
8
+ type ErrorBoundaryState = {
9
+ hasError: boolean;
10
+ };
11
+
12
+ export class WfoErrorBoundary extends React.Component<
13
+ ErrorBoundaryProps,
14
+ ErrorBoundaryState
15
+ > {
16
+ constructor(props: ErrorBoundaryProps) {
17
+ super(props);
18
+ this.state = { hasError: false };
19
+ }
20
+
21
+ static getDerivedStateFromError() {
22
+ return { hasError: true };
23
+ }
24
+
25
+ componentDidCatch(error: Error, info: ErrorInfo) {
26
+ console.error(error, info.componentStack);
27
+ }
28
+
29
+ render() {
30
+ if (this.state.hasError) {
31
+ if (this.props.fallback) {
32
+ return this.props.fallback;
33
+ }
34
+
35
+ return (
36
+ <p>
37
+ An unexpected error occurred, try to go back to the{' '}
38
+ <a href="/">home page</a>
39
+ </p>
40
+ );
41
+ }
42
+
43
+ return this.props.children;
44
+ }
45
+ }
@@ -0,0 +1 @@
1
+ export * from './WfoErrorBoundary';
@@ -4,7 +4,9 @@ import { useTranslations } from 'next-intl';
4
4
 
5
5
  import { EuiFlexGrid, EuiFlexItem } from '@elastic/eui';
6
6
 
7
- import { SubscriptionDetail } from '../../types';
7
+ import { SubscriptionDetail } from '@/types';
8
+ import { formatDate } from '@/utils';
9
+
8
10
  import {
9
11
  WfoProductStatusBadge,
10
12
  WfoSubscriptionStatusBadge,
@@ -33,18 +35,17 @@ export const WfoSubscriptionGeneral = ({
33
35
  key: t('productName'),
34
36
  value: subscriptionDetail.product.name,
35
37
  },
36
-
37
38
  {
38
39
  key: t('description'),
39
40
  value: subscriptionDetail.description,
40
41
  },
41
42
  {
42
43
  key: t('startDate'),
43
- value: subscriptionDetail.startDate,
44
+ value: formatDate(subscriptionDetail.startDate),
44
45
  },
45
46
  {
46
47
  key: t('endDate'),
47
- value: subscriptionDetail.endDate,
48
+ value: formatDate(subscriptionDetail.endDate),
48
49
  },
49
50
  {
50
51
  key: t('status'),
@@ -71,6 +72,7 @@ export const WfoSubscriptionGeneral = ({
71
72
  subscriptionDetail && subscriptionDetail.customer
72
73
  ? `${subscriptionDetail.customer?.customerId}`
73
74
  : '-',
75
+ textToCopy: subscriptionDetail.customer?.customerId,
74
76
  },
75
77
  {
76
78
  key: t('note'),
@@ -111,11 +113,11 @@ export const WfoSubscriptionGeneral = ({
111
113
  },
112
114
  {
113
115
  key: t('created'),
114
- value: product.createdAt,
116
+ value: formatDate(product.createdAt),
115
117
  },
116
118
  {
117
119
  key: t('endDate'),
118
- value: product.endDate,
120
+ value: formatDate(product.endDate),
119
121
  },
120
122
  ];
121
123
  };
@@ -155,7 +155,7 @@ export const WfoSubscriptionsList: FC<WfoSubscriptionsListProps> = ({
155
155
  filterBy: alwaysOnFilters,
156
156
  query: queryString || undefined,
157
157
  };
158
- const { data, isError, isLoading } = useQueryWithGraphql(
158
+ const { data, isError, isFetching } = useQueryWithGraphql(
159
159
  getSubscriptionsListGraphQlQuery<SubscriptionListItem>(),
160
160
  graphqlQueryVariables,
161
161
  ['subscriptions', 'listPage'],
@@ -205,7 +205,7 @@ export const WfoSubscriptionsList: FC<WfoSubscriptionsListProps> = ({
205
205
  defaultHiddenColumns={hiddenColumns}
206
206
  dataSorting={dataSorting}
207
207
  pagination={pagination}
208
- isLoading={isLoading}
208
+ isLoading={isFetching}
209
209
  localStorageKey={SUBSCRIPTIONS_TABLE_LOCAL_STORAGE_KEY}
210
210
  detailModalTitle={'Details - Subscription'}
211
211
  onUpdatePage={getPageChangeHandler<SubscriptionListItem>(
@@ -1,5 +1,7 @@
1
1
  import React, { ReactNode } from 'react';
2
2
 
3
+ import { useTranslations } from 'next-intl';
4
+
3
5
  import { EuiBasicTable, EuiBasicTableColumn, Pagination } from '@elastic/eui';
4
6
  import { Criteria } from '@elastic/eui/src/components/basic_table/basic_table';
5
7
  import { SerializedStyles } from '@emotion/react';
@@ -68,6 +70,8 @@ export const WfoBasicTable = <T extends object>({
68
70
  const { theme } = useOrchestratorTheme();
69
71
  const { basicTableStyle } = getWfoBasicTableStyles(theme);
70
72
 
73
+ const t = useTranslations('common');
74
+
71
75
  const statusColorColumn: WfoTableControlColumnConfig<T> = {
72
76
  statusColorField: {
73
77
  field: WFO_STATUS_COLOR_FIELD,
@@ -94,6 +98,7 @@ export const WfoBasicTable = <T extends object>({
94
98
  <EuiBasicTable
95
99
  css={tableStyling}
96
100
  items={data}
101
+ noItemsMessage={isLoading ? t('loading') : t('noItemsFound')}
97
102
  columns={mapWfoTableColumnsToEuiColumns(
98
103
  allTableColumns,
99
104
  hiddenColumns,
@@ -23,4 +23,5 @@ export * from './WfoDiff';
23
23
  export * from './WfoSettings';
24
24
  export * from './WfoInsyncIcon';
25
25
  export * from './WfoError';
26
+ export * from './WfoErrorBoundary';
26
27
  export * from './WfoWorkflowSteps';
@@ -71,6 +71,7 @@ export const GET_SUBSCRIPTIONS_LIST_SUMMARY_GRAPHQL_QUERY = parse(gql`
71
71
  query: $query
72
72
  ) {
73
73
  page {
74
+ startDate
74
75
  description
75
76
  subscriptionId
76
77
  }
@@ -93,6 +94,8 @@ export const getSubscriptionsListGraphQlQuery = <
93
94
  export const getSubscriptionsListSummaryGraphQlQuery = <
94
95
  QueryVariablesType = Subscription,
95
96
  >(): TypedDocumentNode<
96
- SubscriptionsResult<Pick<Subscription, 'subscriptionId' | 'description'>>,
97
+ SubscriptionsResult<
98
+ Pick<Subscription, 'subscriptionId' | 'description' | 'startDate'>
99
+ >,
97
100
  GraphqlQueryVariables<QueryVariablesType>
98
101
  > => GET_SUBSCRIPTIONS_LIST_SUMMARY_GRAPHQL_QUERY;
@@ -19,9 +19,11 @@
19
19
  "deselect": "Deselect",
20
20
  "close": "Close",
21
21
  "editColumns": "Edit columns",
22
+ "loading": "Loading",
22
23
  "newSubscription": "New subscription",
23
24
  "newTask": "New task",
24
25
  "noFailedTasks": "No failed tasks!",
26
+ "noItemsFound": "No items found",
25
27
  "search": "Search",
26
28
  "errorMessage": "An error occurred",
27
29
  "export": "Export"
@@ -19,9 +19,11 @@
19
19
  "deselect": "Deselecteer",
20
20
  "close": "Sluiten",
21
21
  "editColumns": "Wijzig kolommen",
22
+ "loading": "Laden",
22
23
  "newSubscription": "Nieuwe subscription",
23
24
  "newTask": "Nieuwe task",
24
25
  "noFailedTasks": "Geen gefaalde taken!",
26
+ "noItemsFound": "Geen items gevonden",
25
27
  "search": "Zoeken",
26
28
  "errorMessage": "Er is een fout opgetreden",
27
29
  "export": "Exporteren"
@@ -201,7 +201,7 @@ export const WfoProductBlocksPage = () => {
201
201
  sortBy: sortBy,
202
202
  query: queryString || undefined,
203
203
  };
204
- const { data, isLoading, isError } = useQueryWithGraphql(
204
+ const { data, isFetching, isError } = useQueryWithGraphql(
205
205
  GET_PRODUCTS_BLOCKS_GRAPHQL_QUERY,
206
206
  graphqlQueryVariables,
207
207
  ['productBlocks', 'listPage'],
@@ -249,7 +249,7 @@ export const WfoProductBlocksPage = () => {
249
249
  setDataDisplayParam,
250
250
  )}
251
251
  pagination={pagination}
252
- isLoading={isLoading}
252
+ isLoading={isFetching}
253
253
  hasError={isError}
254
254
  queryString={queryString}
255
255
  localStorageKey={
@@ -170,7 +170,7 @@ export const WfoProductsPage = () => {
170
170
  sortBy: sortBy,
171
171
  query: queryString || undefined,
172
172
  };
173
- const { data, isLoading, isError } = useQueryWithGraphql(
173
+ const { data, isFetching, isError } = useQueryWithGraphql(
174
174
  getProductsQuery(),
175
175
  graphqlQueryVariables,
176
176
  ['products', 'listPage'],
@@ -218,7 +218,7 @@ export const WfoProductsPage = () => {
218
218
  setDataDisplayParam,
219
219
  )}
220
220
  pagination={pagination}
221
- isLoading={isLoading}
221
+ isLoading={isFetching}
222
222
  hasError={isError}
223
223
  queryString={queryString}
224
224
  localStorageKey={METADATA_PRODUCT_TABLE_LOCAL_STORAGE_KEY}
@@ -144,7 +144,7 @@ export const WfoResourceTypesPage = () => {
144
144
  sortBy: sortBy,
145
145
  query: queryString || undefined,
146
146
  };
147
- const { data, isLoading, isError } = useQueryWithGraphql(
147
+ const { data, isFetching, isError } = useQueryWithGraphql(
148
148
  GET_RESOURCE_TYPES_GRAPHQL_QUERY,
149
149
  graphqlQueryVariables,
150
150
  ['resourceTypes', 'listPage'],
@@ -192,7 +192,7 @@ export const WfoResourceTypesPage = () => {
192
192
  setDataDisplayParam,
193
193
  )}
194
194
  pagination={pagination}
195
- isLoading={isLoading}
195
+ isLoading={isFetching}
196
196
  hasError={isError}
197
197
  queryString={queryString}
198
198
  localStorageKey={
@@ -156,7 +156,7 @@ export const WfoWorkflowsPage = () => {
156
156
  sortBy: graphQlWorkflowListMapper(sortBy),
157
157
  query: queryString || undefined,
158
158
  };
159
- const { data, isLoading, isError } = useQueryWithGraphql(
159
+ const { data, isFetching, isError } = useQueryWithGraphql(
160
160
  GET_WORKFLOWS_GRAPHQL_QUERY,
161
161
  graphqlQueryVariables,
162
162
  ['workflows', 'listPage'],
@@ -204,7 +204,7 @@ export const WfoWorkflowsPage = () => {
204
204
  setDataDisplayParam,
205
205
  )}
206
206
  pagination={pagination}
207
- isLoading={isLoading}
207
+ isLoading={isFetching}
208
208
  hasError={isError}
209
209
  queryString={queryString}
210
210
  localStorageKey={METADATA_WORKFLOWS_TABLE_LOCAL_STORAGE_KEY}
@@ -23,7 +23,7 @@ import {
23
23
  SortOrder,
24
24
  Subscription,
25
25
  } from '@/types';
26
- import { getFirstUuidPart } from '@/utils';
26
+ import { formatDate } from '@/utils';
27
27
 
28
28
  export const WfoStartPage = () => {
29
29
  const t = useTranslations('startPage');
@@ -71,7 +71,7 @@ export const WfoStartPage = () => {
71
71
  subscriptionsSummaryResult?.subscriptions.page.map(
72
72
  (subscription) => ({
73
73
  title: subscription.description,
74
- value: getFirstUuidPart(subscription.subscriptionId),
74
+ value: formatDate(subscription.startDate),
75
75
  url: `${PATH_SUBSCRIPTIONS}/${subscription.subscriptionId}`,
76
76
  }),
77
77
  ) ?? [],
@@ -90,7 +90,7 @@ export const WfoStartPage = () => {
90
90
  listItems:
91
91
  processesSummaryResult?.processes.page.map((workflow) => ({
92
92
  title: workflow.workflowName,
93
- value: workflow.startedAt,
93
+ value: formatDate(workflow?.startedAt),
94
94
  url: `${PATH_WORKFLOWS}/${workflow.processId}`,
95
95
  })) ?? [],
96
96
  button: {
@@ -109,7 +109,7 @@ export const WfoStartPage = () => {
109
109
  listItems:
110
110
  failedTasksSummaryResult?.processes.page.map((task) => ({
111
111
  title: task.workflowName,
112
- value: task.startedAt,
112
+ value: formatDate(task?.startedAt),
113
113
  url: `${PATH_TASKS}/${task.processId}`,
114
114
  })) ?? [],
115
115
  button: {
@@ -154,9 +154,9 @@ export const WfoStartPage = () => {
154
154
  <EuiFlexItem>
155
155
  <WfoSummaryCards
156
156
  summaryCards={[
157
- latestActiveSubscriptionsSummaryCard,
158
- latestWorkflowsSummaryCard,
159
157
  failedTasksSummaryCard,
158
+ latestWorkflowsSummaryCard,
159
+ latestActiveSubscriptionsSummaryCard,
160
160
  productsSummaryCard,
161
161
  ]}
162
162
  />
package/src/utils/date.ts CHANGED
@@ -112,3 +112,11 @@ export const formatDateCetWithUtc = (
112
112
 
113
113
  return `${formattedDateCET} (${formattedDateUTC})`;
114
114
  };
115
+
116
+ export const getDate = (date: Date | string | null) => {
117
+ if (typeof date === 'string') {
118
+ return new Date(date);
119
+ }
120
+
121
+ return date;
122
+ };