@openmrs/esm-openconceptlab-app 3.0.1-pre.7 → 3.0.1-pre.72

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 (78) hide show
  1. package/.turbo/turbo-build.log +33 -36
  2. package/dist/130.js +2 -0
  3. package/dist/130.js.LICENSE.txt +5 -0
  4. package/dist/130.js.map +1 -0
  5. package/dist/316.js +1 -1
  6. package/dist/316.js.map +1 -0
  7. package/dist/392.js +1 -0
  8. package/dist/392.js.map +1 -0
  9. package/dist/553.js +1 -0
  10. package/dist/553.js.map +1 -0
  11. package/dist/574.js +1 -1
  12. package/dist/608.js +2 -0
  13. package/dist/608.js.LICENSE.txt +15 -0
  14. package/dist/608.js.map +1 -0
  15. package/dist/784.js +1 -1
  16. package/dist/784.js.map +1 -0
  17. package/dist/842.js +1 -0
  18. package/dist/842.js.map +1 -0
  19. package/dist/853.js +1 -0
  20. package/dist/853.js.map +1 -0
  21. package/dist/912.js +2 -0
  22. package/dist/912.js.LICENSE.txt +9 -0
  23. package/dist/912.js.map +1 -0
  24. package/dist/main.js +1 -1
  25. package/dist/main.js.map +1 -0
  26. package/dist/openmrs-esm-openconceptlab-app.js +1 -1
  27. package/dist/openmrs-esm-openconceptlab-app.js.buildmanifest.json +143 -54
  28. package/dist/openmrs-esm-openconceptlab-app.js.map +1 -0
  29. package/dist/routes.json +1 -0
  30. package/jest.config.js +3 -0
  31. package/package.json +7 -5
  32. package/src/admin-ocl-card-link.component.tsx +23 -0
  33. package/src/declarations.d.tsx +2 -0
  34. package/src/import/import.component.tsx +38 -21
  35. package/src/import/import.resource.ts +1 -1
  36. package/src/import/import.scss +26 -0
  37. package/src/import/import.test.tsx +13 -15
  38. package/src/index.ts +9 -51
  39. package/src/previous-imports/import-overview/import-items.component.tsx +23 -20
  40. package/src/previous-imports/import-overview/import-items.resource.ts +1 -1
  41. package/src/previous-imports/import-overview/import-items.scss +23 -0
  42. package/src/previous-imports/import-overview/import-items.test.tsx +7 -14
  43. package/src/previous-imports/import-overview/import-overview.component.tsx +2 -2
  44. package/src/previous-imports/import-overview/import-overview.scss +10 -0
  45. package/src/previous-imports/import-overview/import-overview.test.tsx +1 -2
  46. package/src/previous-imports/previous-imports.component.tsx +4 -4
  47. package/src/previous-imports/previous-imports.resource.ts +1 -1
  48. package/src/previous-imports/previous-imports.scss +39 -0
  49. package/src/previous-imports/previous-imports.test.tsx +1 -2
  50. package/src/root.component.tsx +8 -8
  51. package/src/root.scss +23 -0
  52. package/src/root.test.tsx +4 -4
  53. package/src/routes.json +20 -0
  54. package/src/subscription/subscription.component.tsx +58 -24
  55. package/src/subscription/subscription.resource.ts +1 -1
  56. package/src/subscription/subscription.scss +26 -0
  57. package/src/subscription/subscription.test.tsx +22 -20
  58. package/src/utils.ts +27 -0
  59. package/translations/en.json +42 -40
  60. package/tsconfig.json +1 -19
  61. package/webpack.config.js +1 -1
  62. package/dist/452.js +0 -1
  63. package/dist/645.js +0 -2
  64. package/dist/645.js.LICENSE.txt +0 -20
  65. package/dist/709.js +0 -1
  66. package/dist/858.js +0 -2
  67. package/dist/858.js.LICENSE.txt +0 -1
  68. package/dist/862.js +0 -1
  69. package/dist/openmrs-esm-openconceptlab-app.old +0 -1
  70. package/locales/en/translation.json +0 -35
  71. package/locales/fr/translation.json +0 -35
  72. package/src/import/import.component.scss +0 -27
  73. package/src/previous-imports/import-overview/import-items.component.scss +0 -24
  74. package/src/previous-imports/import-overview/import-overview.component.scss +0 -11
  75. package/src/previous-imports/previous-imports.component.scss +0 -39
  76. package/src/root.component.scss +0 -23
  77. package/src/setup-tests.ts +0 -1
  78. package/src/subscription/subscription.component.scss +0 -27
@@ -1,4 +1,5 @@
1
- import { showNotification } from '@openmrs/esm-framework';
1
+ import React, { useCallback, useEffect, useState } from 'react';
2
+ import { useSWRConfig } from 'swr';
2
3
  import {
3
4
  Button,
4
5
  ButtonSkeleton,
@@ -13,11 +14,11 @@ import {
13
14
  TextInput,
14
15
  TextInputSkeleton,
15
16
  } from '@carbon/react';
16
- import React, { useCallback, useEffect, useState } from 'react';
17
17
  import { useTranslation } from 'react-i18next';
18
+ import { showNotification } from '@openmrs/esm-framework';
18
19
  import { deleteSubscription, updateSubscription, useSubscription } from './subscription.resource';
19
- import styles from './subscription.component.scss';
20
- import { useSWRConfig } from 'swr';
20
+ import { isVersionDefinedInUrl } from '../utils';
21
+ import styles from './subscription.scss';
21
22
 
22
23
  const Subscription: React.FC = () => {
23
24
  const { t } = useTranslation();
@@ -26,6 +27,7 @@ const Subscription: React.FC = () => {
26
27
  const [token, setToken] = useState('');
27
28
  const [isSubscribedToSnapshot, setIsSubscribedToSnapshot] = useState(false);
28
29
  const [validationType, setValidationType] = useState<'NONE' | 'FULL'>('FULL');
30
+ const [isSnapshotOptionDisabled, setIsSnapshotOptionDisabled] = useState(false);
29
31
 
30
32
  const { data: subscription, isLoading, isError } = useSubscription();
31
33
 
@@ -35,22 +37,29 @@ const Subscription: React.FC = () => {
35
37
  setToken(subscription?.token || '');
36
38
  setIsSubscribedToSnapshot(subscription?.subscribedToSnapshot || false);
37
39
  setValidationType(subscription?.validationType || 'FULL');
40
+ setIsSnapshotOptionDisabled(subscription ? isVersionDefinedInUrl(subscription.url) : false);
38
41
  }
39
42
  }, [isLoading, isError, subscription]);
40
43
 
41
44
  const handleChangeSubscriptionUrl = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
42
45
  setSubscriptionUrl(event.target.value);
46
+ if (isVersionDefinedInUrl(event.target.value)) {
47
+ setIsSnapshotOptionDisabled(true);
48
+ setIsSubscribedToSnapshot(false);
49
+ } else {
50
+ setIsSnapshotOptionDisabled(false);
51
+ }
43
52
  }, []);
44
53
 
45
54
  const handleChangeToken = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {
46
55
  setToken(event.target.value);
47
56
  }, []);
48
57
 
49
- const handleChangeValidationType = useCallback((checked: boolean) => {
58
+ const handleChangeValidationType = useCallback((event, { checked, id }) => {
50
59
  setValidationType(checked ? 'NONE' : 'FULL');
51
60
  }, []);
52
61
 
53
- const handleChangeSubscriptionType = useCallback((checked: boolean) => {
62
+ const handleChangeSubscriptionType = useCallback((event, { checked, id }) => {
54
63
  setIsSubscribedToSnapshot(checked);
55
64
  }, []);
56
65
 
@@ -59,6 +68,17 @@ const Subscription: React.FC = () => {
59
68
  evt.preventDefault();
60
69
  evt.stopPropagation();
61
70
 
71
+ if (isSnapshotOptionDisabled && isSubscribedToSnapshot) {
72
+ showNotification({
73
+ kind: 'error',
74
+ description: t(
75
+ 'snapshotDisabledError',
76
+ "You cannot subscribe to a SNAPSHOT if you've provided the collection version",
77
+ ),
78
+ });
79
+ return;
80
+ }
81
+
62
82
  const abortController = new AbortController();
63
83
 
64
84
  const updatedSubscription = {
@@ -76,11 +96,14 @@ const Subscription: React.FC = () => {
76
96
  if (response.ok) {
77
97
  showNotification({
78
98
  kind: 'success',
79
- description: t(response.status === 201 ? 'subscriptionCreated' : 'subscriptionUpdated'),
99
+ description: t(
100
+ response.status === 201 ? 'subscriptionCreated' : 'subscriptionUpdated',
101
+ response.status === 201 ? 'Subscription created successfully' : 'Subscription updated successfully',
102
+ ),
80
103
  });
81
104
  } else {
82
105
  showNotification({
83
- title: t('errorSavingSubscription'),
106
+ title: t('errorSavingSubscription', 'Error occured while saving the subscription'),
84
107
  kind: 'error',
85
108
  critical: true,
86
109
  description: JSON.stringify(response.data),
@@ -89,7 +112,7 @@ const Subscription: React.FC = () => {
89
112
 
90
113
  return () => abortController.abort();
91
114
  },
92
- [subscriptionUrl, token, validationType, isSubscribedToSnapshot, t, subscription, mutate],
115
+ [subscriptionUrl, token, validationType, isSubscribedToSnapshot, isSnapshotOptionDisabled, subscription, t, mutate],
93
116
  );
94
117
 
95
118
  const handleCancel = useCallback(() => {
@@ -97,10 +120,11 @@ const Subscription: React.FC = () => {
97
120
  setToken(subscription?.token || '');
98
121
  setIsSubscribedToSnapshot(subscription?.subscribedToSnapshot || false);
99
122
  setValidationType(subscription?.validationType || 'FULL');
123
+ setIsSnapshotOptionDisabled(subscription ? isVersionDefinedInUrl(subscription.url) : false);
100
124
 
101
125
  showNotification({
102
126
  kind: 'info',
103
- description: t('cancelledChanges'),
127
+ description: t('cancelledChanges', 'Cancelled changes successfully'),
104
128
  });
105
129
  }, [subscription, t]);
106
130
 
@@ -118,13 +142,14 @@ const Subscription: React.FC = () => {
118
142
  setToken('');
119
143
  setIsSubscribedToSnapshot(false);
120
144
  setValidationType('FULL');
145
+ setIsSnapshotOptionDisabled(false);
121
146
  showNotification({
122
147
  kind: 'success',
123
- description: t('subscriptionDeleted'),
148
+ description: t('subscriptionDeleted', 'Successfully unsubscribed'),
124
149
  });
125
150
  } else {
126
151
  showNotification({
127
- title: t('errorDeletingSubscription'),
152
+ title: t('errorDeletingSubscription', 'Error occured while deleting the subscription'),
128
153
  kind: 'error',
129
154
  critical: true,
130
155
  description: JSON.stringify(response.data),
@@ -166,7 +191,7 @@ const Subscription: React.FC = () => {
166
191
  if (isError) {
167
192
  showNotification({
168
193
  kind: 'error',
169
- description: t('subscriptionError'),
194
+ description: t('subscriptionError', 'Error occured while fetching the subscription'),
170
195
  });
171
196
  }
172
197
 
@@ -174,12 +199,12 @@ const Subscription: React.FC = () => {
174
199
  <Grid className={styles.grid}>
175
200
  <Column sm={4} md={8} lg={10}>
176
201
  <Form onSubmit={handleSubmit}>
177
- <h3 className={styles.productiveHeading03}>{t('setupSubscription')}</h3>
202
+ <h3 className={styles.productiveHeading03}>{t('setupSubscription', 'Setup Subscription')}</h3>
178
203
  <Stack gap={5}>
179
204
  <TextInput
180
205
  id="subscriptionUrl"
181
206
  type="url"
182
- labelText={t('subscriptionUrl')}
207
+ labelText={t('subscriptionUrl', 'Subscription URL')}
183
208
  placeholder="https://api.openconceptlab.org/orgs/organization-name/collections/dictionary-name"
184
209
  value={subscriptionUrl}
185
210
  onChange={handleChangeSubscriptionUrl}
@@ -190,39 +215,48 @@ const Subscription: React.FC = () => {
190
215
  id="apiToken"
191
216
  type="password"
192
217
  placeholder="••••••••••••••••••••••••••••••••••••••••••••••••"
193
- labelText={t('apiToken')}
218
+ labelText={t('apiToken', 'Token')}
194
219
  value={token}
195
220
  onChange={handleChangeToken}
196
221
  light={true}
197
222
  required
198
223
  />
199
- <FormGroup legendText={t('advancedOptions')} className={styles.formGroup}>
224
+ <FormGroup legendText={t('advancedOptions', 'Advanced Options')} className={styles.formGroup}>
200
225
  <Checkbox
201
226
  checked={isSubscribedToSnapshot}
202
227
  onChange={handleChangeSubscriptionType}
203
- labelText={t('subscribeToSnapshotText')}
228
+ labelText={t('subscribeToSnapshotText', 'Subscribe to SNAPSHOT versions (not recommended)')}
204
229
  id="isSubscribedToSnapshot"
230
+ disabled={isSnapshotOptionDisabled}
205
231
  />
206
232
  <Checkbox
207
233
  checked={validationType === 'NONE'}
208
234
  onChange={handleChangeValidationType}
209
- labelText={t('disableValidationText')}
235
+ labelText={t(
236
+ 'disableValidationText',
237
+ 'Disable validation (should be used with care for well curated collections or sources)',
238
+ )}
210
239
  id="isValidationDisabled"
211
240
  />
212
241
  </FormGroup>
213
242
  </Stack>
214
243
  <Button kind="secondary" onClick={handleCancel}>
215
- {t('cancelButton')}
244
+ {t('cancelButton', 'Cancel changes')}
216
245
  </Button>
217
246
  <Button kind="primary" type="submit">
218
- {t('subscribeButton')}
247
+ {t('subscribeButton', 'Save changes')}
219
248
  </Button>
220
249
  </Form>
221
250
  <Form onSubmit={handleUnsubscribe} className={styles.unsubscribeForm}>
222
- <h3 className={styles.productiveHeading03}>{t('unsubscribe')}</h3>
223
- <p className={styles.unsubscribeText}>{t('unsubscribeInfo')}</p>
251
+ <h3 className={styles.productiveHeading03}>{t('unsubscribe', 'Unsubscribe')}</h3>
252
+ <p className={styles.unsubscribeText}>
253
+ {t(
254
+ 'unsubscribeInfo',
255
+ 'If you unsubscribe, no concepts will be deleted nor changed. All information about subscription will be deleted from your system.',
256
+ )}
257
+ </p>
224
258
  <Button kind="danger" type="submit" disabled={!subscription}>
225
- {t('unsubscribeButton')}
259
+ {t('unsubscribeButton', 'Unsubscribe')}
226
260
  </Button>
227
261
  </Form>
228
262
  </Column>
@@ -1,7 +1,7 @@
1
1
  import { openmrsFetch } from '@openmrs/esm-framework';
2
2
  import useSWR from 'swr';
3
- import { Subscription } from '../types';
4
3
  import isNil from 'lodash-es/isNil';
4
+ import type { Subscription } from '../types';
5
5
 
6
6
  export function useSubscription() {
7
7
  const { data, error, isValidating } = useSWR<{ data: { results: Subscription[] } }, Error>(
@@ -0,0 +1,26 @@
1
+ @use "@carbon/layout";
2
+ @use "@carbon/type";
3
+
4
+ .grid {
5
+ margin-left: 0;
6
+ margin-right: 0;
7
+ padding-left: 0;
8
+ padding-right: 0;
9
+ }
10
+
11
+ .productiveHeading03 {
12
+ @include type.type-style('heading-03');
13
+ margin-bottom: layout.$spacing-03;
14
+ }
15
+
16
+ .formGroup {
17
+ margin-bottom: layout.$spacing-05;
18
+ }
19
+
20
+ .unsubscribeText {
21
+ padding-bottom: layout.$spacing-05;
22
+ }
23
+
24
+ .unsubscribeForm {
25
+ margin-top: layout.$spacing-05;
26
+ }
@@ -47,9 +47,9 @@ describe(`Subscription component`, () => {
47
47
  renderSubscriptionComponent();
48
48
  await waitForLoadingToFinish();
49
49
 
50
- expect(screen.getByText('setupSubscription')).toBeVisible();
51
- expect(screen.getByText('unsubscribe')).toBeVisible();
52
- expect(screen.getByText('unsubscribeButton')).toBeDisabled();
50
+ expect(screen.getByText('Setup Subscription')).toBeVisible();
51
+ expect(screen.getByRole('heading', { name: 'Unsubscribe' })).toBeVisible();
52
+ expect(screen.getByRole('button', { name: 'danger Unsubscribe' })).toBeDisabled();
53
53
  });
54
54
 
55
55
  it(`renders the subscription if a subscription exists`, async () => {
@@ -58,11 +58,13 @@ describe(`Subscription component`, () => {
58
58
  await waitForLoadingToFinish();
59
59
  await waitForLoadingSubscription();
60
60
 
61
- expect(screen.getByLabelText('subscriptionUrl')).toHaveValue(mockSubscription.url);
62
- expect(screen.getByLabelText('apiToken')).toHaveValue(mockSubscription.token);
63
- expect(screen.getByLabelText('subscribeToSnapshotText')).not.toBeChecked();
64
- expect(screen.getByLabelText('disableValidationText')).not.toBeChecked();
65
- expect(screen.getByText('unsubscribeButton')).toBeEnabled();
61
+ expect(screen.getByLabelText('Subscription URL')).toHaveValue(mockSubscription.url);
62
+ expect(screen.getByLabelText('Token')).toHaveValue(mockSubscription.token);
63
+ expect(screen.getByLabelText('Subscribe to SNAPSHOT versions (not recommended)')).not.toBeChecked();
64
+ expect(
65
+ screen.getByLabelText('Disable validation (should be used with care for well curated collections or sources)'),
66
+ ).not.toBeChecked();
67
+ expect(screen.getByRole('button', { name: 'danger Unsubscribe' })).toBeEnabled();
66
68
  });
67
69
 
68
70
  it(`allows adding a new subscription`, async () => {
@@ -70,9 +72,9 @@ describe(`Subscription component`, () => {
70
72
  renderSubscriptionComponent();
71
73
  await waitForLoadingToFinish();
72
74
 
73
- const urlInputField = screen.getByLabelText('subscriptionUrl');
74
- const tokenInputField = screen.getByLabelText('apiToken');
75
- const saveButton = screen.getByText('subscribeButton');
75
+ const urlInputField = screen.getByLabelText('Subscription URL');
76
+ const tokenInputField = screen.getByLabelText('Token');
77
+ const saveButton = screen.getByRole('button', { name: 'Save changes' });
76
78
 
77
79
  mockUpdateSubscription.mockReturnValueOnce({ status: 201, ok: true });
78
80
 
@@ -88,7 +90,7 @@ describe(`Subscription component`, () => {
88
90
 
89
91
  expect(mockShowNotification).toHaveBeenCalledWith(
90
92
  expect.objectContaining({
91
- description: 'subscriptionCreated',
93
+ description: 'Subscription created successfully',
92
94
  kind: 'success',
93
95
  }),
94
96
  );
@@ -101,9 +103,9 @@ describe(`Subscription component`, () => {
101
103
  await waitForLoadingToFinish();
102
104
  await waitForLoadingSubscription();
103
105
 
104
- const urlInputField = screen.getByLabelText('subscriptionUrl');
105
- const tokenInputField = screen.getByLabelText('apiToken');
106
- const saveButton = screen.getByText('subscribeButton');
106
+ const urlInputField = screen.getByLabelText('Subscription URL');
107
+ const tokenInputField = screen.getByLabelText('Token');
108
+ const saveButton = screen.getByRole('button', { name: 'Save changes' });
107
109
 
108
110
  mockUpdateSubscription.mockReturnValueOnce({ status: 200, ok: true });
109
111
 
@@ -127,7 +129,7 @@ describe(`Subscription component`, () => {
127
129
 
128
130
  expect(mockShowNotification).toHaveBeenCalledWith(
129
131
  expect.objectContaining({
130
- description: 'subscriptionUpdated',
132
+ description: 'Subscription updated successfully',
131
133
  kind: 'success',
132
134
  }),
133
135
  );
@@ -140,7 +142,7 @@ describe(`Subscription component`, () => {
140
142
  await waitForLoadingToFinish();
141
143
  await waitForLoadingSubscription();
142
144
 
143
- const unsubscribeButton = screen.getByText('unsubscribeButton');
145
+ const unsubscribeButton = screen.getByRole('button', { name: 'danger Unsubscribe' });
144
146
 
145
147
  mockDeleteSubscription.mockReturnValueOnce({ status: 204 });
146
148
 
@@ -154,7 +156,7 @@ describe(`Subscription component`, () => {
154
156
 
155
157
  expect(mockShowNotification).toHaveBeenCalledWith(
156
158
  expect.objectContaining({
157
- description: 'subscriptionDeleted',
159
+ description: 'Successfully unsubscribed',
158
160
  kind: 'success',
159
161
  }),
160
162
  );
@@ -168,12 +170,12 @@ function renderSubscriptionComponent() {
168
170
 
169
171
  function waitForLoadingToFinish() {
170
172
  return waitFor(() => {
171
- expect(screen.getByText('setupSubscription')).toBeVisible(), { timeout: 2000 };
173
+ expect(screen.getByText('Setup Subscription')).toBeVisible(), { timeout: 2000 };
172
174
  });
173
175
  }
174
176
 
175
177
  function waitForLoadingSubscription() {
176
178
  return waitFor(() => {
177
- expect(screen.getByLabelText('subscriptionUrl')).not.toHaveValue(''), { timeout: 2000 };
179
+ expect(screen.getByLabelText('Subscription URL')).not.toHaveValue(''), { timeout: 2000 };
178
180
  });
179
181
  }
package/src/utils.ts ADDED
@@ -0,0 +1,27 @@
1
+ const NUMBER_OF_SLASHES_AFTER_BASE_URL = 5;
2
+
3
+ /*
4
+ * This checks if collection version has been passed to subscription url by checking number of forward slashes after base url
5
+ * If the number is 5, such as with https://api.openconceptlab.org/users/username/collections/collectionname/v1.0
6
+ * that means collection version was passed and isVersionDefinedInUrl() will return true
7
+ * Also returns false if the string is not a valid URL
8
+ */
9
+ export const isVersionDefinedInUrl = (subscriptionUrl: string) => {
10
+ if (subscriptionUrl.endsWith('/')) {
11
+ subscriptionUrl = subscriptionUrl.substring(0, subscriptionUrl.lastIndexOf('/'));
12
+ }
13
+
14
+ let url;
15
+ try {
16
+ url = new URL(subscriptionUrl);
17
+ } catch (e) {
18
+ return false;
19
+ }
20
+
21
+ let count = url.pathname.match(/\//g)?.length ?? 0;
22
+ if (count == NUMBER_OF_SLASHES_AFTER_BASE_URL) {
23
+ return true;
24
+ } else {
25
+ return false;
26
+ }
27
+ };
@@ -1,53 +1,55 @@
1
1
  {
2
- "moduleTitle": "OCL Subscription Module",
3
- "subscription": "Subscription",
4
- "import": "Import",
5
- "previousImports": "Previous Imports",
6
- "setupSubscription": "Setup Subscription",
7
- "subscriptionUrl": "Subscription URL",
8
- "apiToken": "Token",
9
2
  "advancedOptions": "Advanced Options",
10
- "subscribeToSnapshotText": "Subscribe to SNAPSHOT versions (not recommended)",
11
- "disableValidationText": "Disable validation (should be used with care for well curated collections or sources)",
12
- "subscribeButton": "Save changes",
3
+ "apiToken": "Token",
13
4
  "cancelButton": "Cancel changes",
14
- "unsubscribe": "Unsubscribe",
15
- "unsubscribeButton": "Unsubscribe",
16
- "unsubscribeInfo": "If you unsubscribe, no concepts will be deleted nor changed. All information about subscription will be deleted from your system.",
17
- "subscriptionCreated": "Subscription created successfully",
18
- "subscriptionUpdated": "Subscription updated successfully",
19
- "errorSavingSubscription": "Error occured while saving the subscription",
20
- "subscriptionDeleted": "Successfully unsubscribed",
21
- "errorDeletingSubscription": "Error occured while deleting the subscription",
22
5
  "cancelledChanges": "Cancelled changes successfully",
6
+ "completedOn": "Completed on",
7
+ "conceptOrMapping": "Concept/Mapping",
8
+ "conceptsAdded": "concepts added",
9
+ "conceptsRetired": "concepts retired",
10
+ "conceptsUpdated": "concepts updated",
11
+ "conceptsUpToDate": "concepts up to date",
12
+ "dateAndTime": "Date and Time",
13
+ "disableValidationText": "Disable validation (should be used with care for well curated collections or sources)",
14
+ "duration": "Duration",
15
+ "errorDeletingSubscription": "Error occured while deleting the subscription",
16
+ "errorSavingSubscription": "Error occured while saving the subscription",
17
+ "errorsFound": "errors found",
18
+ "errorsIgnored": "errors ignored",
19
+ "fileAdded": "File Added",
20
+ "fileFormatError": "Only .zip files are allowed",
21
+ "import": "Import",
23
22
  "importConcepts": "Import Concepts",
24
- "importInstructions": "Avoid importing during data entry hours, because the operation may significantly slow down the system. You can either use the subscription or a zip file to import concepts.",
25
- "importFromSubscription": "Import from Subscription",
23
+ "importFailed": "Import failed",
24
+ "importFromFile": "Import from file",
25
+ "importFromFileDragInfo": "Drag and drop file here or click to upload",
26
26
  "importFromFileHeading": "Import from file (Offline)",
27
27
  "importFromFileInfo": "You can import data without setting up a subscription by using this option.",
28
- "fileAdded":"File Added",
29
- "importFromFileDragInfo": "Drag and drop file here or click to upload",
30
- "importFromFile": "Import from file",
28
+ "importFromSubscription": "Import from Subscription",
29
+ "importInstructions": "Avoid importing during data entry hours, because the operation may significantly slow down the system. You can either use the subscription or a zip file to import concepts.",
30
+ "importItemsFetchError": "Error occured while fetching the import items",
31
31
  "importSuccess": "Import started successfully",
32
- "importFailed": "Import failed",
32
+ "manageConcepts": "Manage Concepts",
33
+ "message": "Message",
34
+ "moduleTitle": "OCL Subscription Module",
33
35
  "noFileSelected": "No file selected",
34
36
  "noSubscriptionError": "No saved subscription",
35
- "fileFormatError": "Only .zip files are allowed",
36
- "subscriptionError": "Error occured while fetching the subscription",
37
+ "openConceptLab": "Open Concept Lab",
38
+ "previousImports": "Previous Imports",
37
39
  "previousImportsFetchError": "Error occured while fetching the imports",
38
- "dateAndTime": "Date and Time",
39
- "duration": "Duration",
40
- "status": "Status",
41
- "startedOn": "Started on",
42
- "completedOn": "Completed on",
43
40
  "result": "Result:",
44
- "conceptsUpToDate": "concepts up to date",
45
- "conceptsAdded": "concepts added",
46
- "conceptsUpdated": "concepts updated",
47
- "conceptsRetired": "concepts retired",
48
- "errorsFound": "errors found",
49
- "errorsIgnored": "errors ignored",
50
- "importItemsFetchError": "Error occured while fetching the import items",
51
- "conceptOrMapping": "Concept/Mapping",
52
- "message": "Message"
41
+ "setupSubscription": "Setup Subscription",
42
+ "snapshotDisabledError": "You cannot subscribe to a SNAPSHOT if you've provided the collection version",
43
+ "startedOn": "Started on",
44
+ "status": "Status",
45
+ "subscribeButton": "Save changes",
46
+ "subscribeToSnapshotText": "Subscribe to SNAPSHOT versions (not recommended)",
47
+ "subscription": "Subscription",
48
+ "subscriptionDeleted": "Successfully unsubscribed",
49
+ "subscriptionError": "Error occured while fetching the subscription",
50
+ "subscriptionUrl": "Subscription URL",
51
+ "unsubscribe": "Unsubscribe",
52
+ "unsubscribeButton": "Unsubscribe",
53
+ "unsubscribeInfo": "If you unsubscribe, no concepts will be deleted nor changed. All information about subscription will be deleted from your system.",
54
+ "uploading": "Uploading..."
53
55
  }
package/tsconfig.json CHANGED
@@ -1,23 +1,5 @@
1
1
  {
2
- "compilerOptions": {
3
- "esModuleInterop": true,
4
- "module": "esnext",
5
- "allowSyntheticDefaultImports": true,
6
- "jsx": "react",
7
- "moduleResolution": "node",
8
- "resolveJsonModule": true,
9
- "lib": [
10
- "dom",
11
- "es5",
12
- "scripthost",
13
- "es2015",
14
- "es2015.promise",
15
- "es2016.array.include",
16
- "es2018",
17
- "es2020"
18
- ],
19
- "noEmit": true
20
- },
2
+ "extends": "../../tsconfig.json",
21
3
  "include": ["src/**/*"],
22
4
  "exclude": ["src/**/*.test.tsx", "src/**/*.outdated.tsx"]
23
5
  }
package/webpack.config.js CHANGED
@@ -1 +1 @@
1
- module.exports = require("openmrs/default-webpack-config");
1
+ module.exports = require('openmrs/default-webpack-config');
package/dist/452.js DELETED
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_openmrs_esm_openconceptlab_app=self.webpackChunk_openmrs_esm_openconceptlab_app||[]).push([[452],{7564:(e,t,n)=>{n.r(t),n.d(t,{default:()=>Se});var r=n(7730),o=n(268),a=n.n(o),i=n(4924),c=n(9857),l=n(5047),s=n.n(l),u=n(906),p=n(9140);function m(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,o)}function d(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){m(a,r,o,i,c,"next",e)}function c(e){m(a,r,o,i,c,"throw",e)}i(void 0)}))}}function b(e,t){return _.apply(this,arguments)}function _(){return(_=d(s().mark((function e(t,n){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=(0,p.Z)(t.uuid)?"/ws/rest/v1/openconceptlab/subscription":"/ws/rest/v1/openconceptlab/subscription/".concat(t.uuid),e.abrupt("return",(0,u.openmrsFetch)(r,{method:"POST",body:t,headers:{"Content-Type":"application/json"},signal:null==n?void 0:n.signal}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function f(e,t){return g.apply(this,arguments)}function g(){return(g=d(s().mark((function e(t,n){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/ws/rest/v1/openconceptlab/subscription/".concat(t.uuid),e.abrupt("return",(0,u.openmrsFetch)(r,{method:"DELETE",signal:null==n?void 0:n.signal}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var v=n(6062),h=n.n(v),y=n(4036),E=n.n(y),w=n(6793),k=n.n(w),N=n(7892),S=n.n(N),x=n(1173),T=n.n(x),C=n(2464),O=n.n(C),P=n(7542),D={};D.styleTagTransform=O(),D.setAttributes=S(),D.insert=k().bind(null,"head"),D.domAPI=E(),D.insertStyleElement=T(),h()(P.Z,D);const A=P.Z&&P.Z.locals?P.Z.locals:void 0;function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,o)}function Z(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){j(a,r,o,i,c,"next",e)}function c(e){j(a,r,o,i,c,"throw",e)}i(void 0)}))}}function H(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function I(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){H(e,t,n[t])}))}return e}function z(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}function B(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return F(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?F(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const L=function(){var e=(0,i.useTranslation)().t,t=(0,c.kY)().mutate,n=B((0,o.useState)(""),2),l=n[0],p=n[1],m=B((0,o.useState)(""),2),d=m[0],_=m[1],g=B((0,o.useState)(!1),2),v=g[0],h=g[1],y=B((0,o.useState)("FULL"),2),E=y[0],w=y[1],k=function(){var e,t=(0,c.ZP)("/ws/rest/v1/openconceptlab/subscription?v=full",u.openmrsFetch),n=t.data,r=t.error,o=t.isValidating;return{data:null==n||null===(e=n.data)||void 0===e?void 0:e.results[0],isLoading:!n&&!r,isError:r,isValidating:o}}(),N=k.data,S=k.isLoading,x=k.isError;(0,o.useEffect)((function(){S||x||(p((null==N?void 0:N.url)||""),_((null==N?void 0:N.token)||""),h((null==N?void 0:N.subscribedToSnapshot)||!1),w((null==N?void 0:N.validationType)||"FULL"))}),[S,x,N]);var T,C=(0,o.useCallback)((function(e){p(e.target.value)}),[]),O=(0,o.useCallback)((function(e){_(e.target.value)}),[]),P=(0,o.useCallback)((function(e){w(e?"NONE":"FULL")}),[]),D=(0,o.useCallback)((function(e){h(e)}),[]),F=(0,o.useCallback)((T=Z(s().mark((function n(r){var o,a,i;return s().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r.preventDefault(),r.stopPropagation(),o=new AbortController,a=z(I({},N),{url:l,token:d,validationType:E,subscribedToSnapshot:v}),t("/ws/rest/v1/openconceptlab/subscription?v=full",a,!1),n.next=7,b(a,o);case 7:return i=n.sent,t("/ws/rest/v1/openconceptlab/subscription?v=full"),i.ok?(0,u.showNotification)({kind:"success",description:e(201===i.status?"subscriptionCreated":"subscriptionUpdated")}):(0,u.showNotification)({title:e("errorSavingSubscription"),kind:"error",critical:!0,description:JSON.stringify(i.data)}),n.abrupt("return",(function(){return o.abort()}));case 11:case"end":return n.stop()}}),n)}))),function(e){return T.apply(this,arguments)}),[l,d,E,v,e,N,t]),j=(0,o.useCallback)((function(){p((null==N?void 0:N.url)||""),_((null==N?void 0:N.token)||""),h((null==N?void 0:N.subscribedToSnapshot)||!1),w((null==N?void 0:N.validationType)||"FULL"),(0,u.showNotification)({kind:"info",description:e("cancelledChanges")})}),[N,e]),H=(0,o.useCallback)(function(){var n=Z(s().mark((function n(r){var o,a;return s().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r.preventDefault(),r.stopPropagation(),o=new AbortController,n.next=5,f(N,o);case 5:return a=n.sent,t("/ws/rest/v1/openconceptlab/subscription?v=full"),204===a.status?(p(""),_(""),h(!1),w("FULL"),(0,u.showNotification)({kind:"success",description:e("subscriptionDeleted")})):(0,u.showNotification)({title:e("errorDeletingSubscription"),kind:"error",critical:!0,description:JSON.stringify(a.data)}),n.abrupt("return",(function(){return o.abort()}));case 9:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}(),[N,e,t]);return S?a().createElement(r.rjZ,{className:A.grid},a().createElement(r.sgG,{sm:4,md:8,lg:10},a().createElement(r.l09,null,a().createElement(r.N2B,{className:A.productiveHeading03}),a().createElement(r.Kqy,{gap:5},a().createElement(r.znL,null),a().createElement(r.znL,null),a().createElement(r.cwH,{legendText:a().createElement(r.N2B,{width:"75px"}),className:A.formGroup},a().createElement(r.jJq,null),a().createElement(r.jJq,null))),a().createElement(r.Db,null),a().createElement(r.Db,null)),a().createElement(r.l09,{className:A.unsubscribeForm},a().createElement(r.N2B,{className:A.productiveHeading03}),a().createElement(r.N2B,{className:A.unsubscribeText}),a().createElement(r.Db,null)))):(x&&(0,u.showNotification)({kind:"error",description:e("subscriptionError")}),a().createElement(r.rjZ,{className:A.grid},a().createElement(r.sgG,{sm:4,md:8,lg:10},a().createElement(r.l09,{onSubmit:F},a().createElement("h3",{className:A.productiveHeading03},e("setupSubscription")),a().createElement(r.Kqy,{gap:5},a().createElement(r.oil,{id:"subscriptionUrl",type:"url",labelText:e("subscriptionUrl"),placeholder:"https://api.openconceptlab.org/orgs/organization-name/collections/dictionary-name",value:l,onChange:C,light:!0,required:!0}),a().createElement(r.oil,{id:"apiToken",type:"password",placeholder:"••••••••••••••••••••••••••••••••••••••••••••••••",labelText:e("apiToken"),value:d,onChange:O,light:!0,required:!0}),a().createElement(r.cwH,{legendText:e("advancedOptions"),className:A.formGroup},a().createElement(r.XZJ,{checked:v,onChange:D,labelText:e("subscribeToSnapshotText"),id:"isSubscribedToSnapshot"}),a().createElement(r.XZJ,{checked:"NONE"===E,onChange:P,labelText:e("disableValidationText"),id:"isValidationDisabled"}))),a().createElement(r.zxk,{kind:"secondary",onClick:j},e("cancelButton")),a().createElement(r.zxk,{kind:"primary",type:"submit"},e("subscribeButton"))),a().createElement(r.l09,{onSubmit:H,className:A.unsubscribeForm},a().createElement("h3",{className:A.productiveHeading03},e("unsubscribe")),a().createElement("p",{className:A.unsubscribeText},e("unsubscribeInfo")),a().createElement(r.zxk,{kind:"danger",type:"submit",disabled:!N},e("unsubscribeButton"))))))};var R=n(302),U={};U.styleTagTransform=O(),U.setAttributes=S(),U.insert=k().bind(null,"head"),U.domAPI=E(),U.insertStyleElement=T(),h()(R.Z,U);const G=R.Z&&R.Z.locals?R.Z.locals:void 0;var M=n(3111),V={};V.styleTagTransform=O(),V.setAttributes=S(),V.insert=k().bind(null,"head"),V.domAPI=E(),V.insertStyleElement=T(),h()(M.Z,V);const K=M.Z&&M.Z.locals?M.Z.locals:void 0;function J(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,o)}function X(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){J(a,r,o,i,c,"next",e)}function c(e){J(a,r,o,i,c,"throw",e)}i(void 0)}))}}function q(e){return W.apply(this,arguments)}function W(){return(W=X(s().mark((function e(t){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,u.openmrsFetch)("/ws/rest/v1/openconceptlab/import",{method:"POST",body:{},headers:{"Content-Type":"application/json"},signal:null==t?void 0:t.signal}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $(e,t){return Q.apply(this,arguments)}function Q(){return(Q=X(s().mark((function e(t,n){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new FormData).append("file",t),e.abrupt("return",(0,u.openmrsFetch)("/ws/rest/v1/openconceptlab/import",{method:"POST",body:r,signal:null==n?void 0:n.signal}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ee(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,o)}function te(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){ee(a,r,o,i,c,"next",e)}function c(e){ee(a,r,o,i,c,"throw",e)}i(void 0)}))}}function ne(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Y(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const re=function(){var e=(0,i.useTranslation)().t,t=ne((0,o.useState)(!1),2),n=t[0],l=t[1],p=ne((0,o.useState)(),2),m=p[0],d=p[1],b=function(){var e,t=(0,c.ZP)("/ws/rest/v1/openconceptlab/subscription?v=full",u.openmrsFetch),n=t.data,r=t.error,o=t.isValidating;return{data:null==n||null===(e=n.data)||void 0===e?void 0:e.results[0],isLoading:!n&&!r,isError:r,isValidating:o}}(),_=b.data,f=b.isLoading,g=b.isError;(0,o.useEffect)((function(){f||g||l(!!_)}),[f,g,_]);var v,h=(0,o.useCallback)((function(t,n){var r=n.addedFiles[0];"application/zip"!==r.type?(0,u.showNotification)({kind:"error",description:e("fileFormatError")}):d(r)}),[e]),y=(0,o.useCallback)((function(){d(null)}),[]),E=(0,o.useCallback)((v=te(s().mark((function t(r){var o;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r.preventDefault(),r.stopPropagation(),n){t.next=5;break}return(0,u.showNotification)({kind:"error",description:e("noSubscriptionError")}),t.abrupt("return");case 5:return o=new AbortController,t.next=8,q(o);case 8:201===t.sent.status?(0,u.showNotification)({kind:"success",description:e("importSuccess")}):(0,u.showNotification)({kind:"error",description:e("importFailed")});case 10:case"end":return t.stop()}}),t)}))),function(e){return v.apply(this,arguments)}),[n,e]),w=(0,o.useCallback)(function(){var t=te(s().mark((function t(n){var r;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n.preventDefault(),n.stopPropagation(),m){t.next=5;break}return(0,u.showNotification)({kind:"error",description:e("noFileSelected")}),t.abrupt("return");case 5:return r=new AbortController,t.next=8,$(m,r);case 8:201===t.sent.status?(d(null),(0,u.showNotification)({kind:"success",description:e("importSuccess")})):(0,u.showNotification)({kind:"error",description:e("importFailed")});case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[m,e]);return f?a().createElement(r.rjZ,{className:K.grid},a().createElement(r.sgG,{sm:4,md:8,lg:10},a().createElement(r.l09,null,a().createElement(r.N2B,{className:K.productiveHeading03,heading:!0}),a().createElement(r.N2B,{className:K.formText,paragraph:!0,lineCount:2}),a().createElement(r.Db,null)),a().createElement(r.l09,{className:K.form},a().createElement(r.N2B,{className:K.productiveHeading03,heading:!0}),a().createElement(r.N2B,{className:K.formText}),a().createElement(r.rhD,{style:{marginBottom:"1.5rem"}}),a().createElement(r.Db,null)))):(g&&(0,u.showNotification)({kind:"error",description:e("subscriptionError")}),a().createElement(r.rjZ,{className:K.grid},a().createElement(r.sgG,{sm:4,md:8,lg:10},a().createElement(r.l09,{onSubmit:E},a().createElement("h3",{className:K.productiveHeading03},e("importConcepts")),a().createElement("p",{className:K.formText},e("importInstructions")),a().createElement(r.zxk,{kind:"primary",type:"submit",disabled:!n},e("importFromSubscription"))),a().createElement(r.l09,{className:K.form,onSubmit:w},a().createElement("h3",{className:K.productiveHeading03},e("importFromFileHeading")),a().createElement("p",{className:K.formText},e("importFromFileInfo")),m?a().createElement(r.Py3,{key:m.name,name:m.name,size:"default",status:"edit",iconDescription:e("fileAdded"),onDelete:y,style:{backgroundColor:"#e0e0e0"}}):a().createElement(r.awp,{accept:["application/zip"],multiple:!0,labelText:e("importFromFileDragInfo"),onAddFiles:h,style:{marginBottom:"1.5rem"}}),a().createElement(r.zxk,{kind:"primary",type:"submit"},e("importFromFile"))))))};var oe=n(2258),ae={};ae.styleTagTransform=O(),ae.setAttributes=S(),ae.insert=k().bind(null,"head"),ae.domAPI=E(),ae.insertStyleElement=T(),h()(oe.Z,ae);const ie=oe.Z&&oe.Z.locals?oe.Z.locals:void 0;var ce=n(385),le={};le.styleTagTransform=O(),le.setAttributes=S(),le.insert=k().bind(null,"head"),le.domAPI=E(),le.insertStyleElement=T(),h()(ce.Z,le);const se=ce.Z&&ce.Z.locals?ce.Z.locals:void 0;function ue(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,o)}function pe(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function i(e){ue(a,r,o,i,c,"next",e)}function c(e){ue(a,r,o,i,c,"throw",e)}i(void 0)}))}}function me(e,t){return de.apply(this,arguments)}function de(){return(de=pe(s().mark((function e(t,n){var r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/ws/rest/v1/openconceptlab/import/".concat(t,"/item?state=ERROR&v=full"),e.abrupt("return",(0,u.openmrsFetch)(r,{method:"GET",signal:null==n?void 0:n.signal}));case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var be=n(8850),_e={};_e.styleTagTransform=O(),_e.setAttributes=S(),_e.insert=k().bind(null,"head"),_e.domAPI=E(),_e.insertStyleElement=T(),h()(be.Z,_e);const fe=be.Z&&be.Z.locals?be.Z.locals:void 0;function ge(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ve(e,t,n,r,o,a,i){try{var c=e[a](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,o)}function he(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ge(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ge(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const ye=function(e){var t,n,c=e.importUuid,l=(0,i.useTranslation)().t,p=he((0,o.useState)(),2),m=p[0],d=p[1],b=he((0,o.useState)(5),2),_=b[0],f=b[1],g=he((0,o.useState)([]),2),v=g[0],h=g[1],y=(0,u.usePagination)(v,_),E=y.results,w=y.currentPage,k=y.goTo,N=(0,o.useCallback)((t=s().mark((function e(t){var n,r;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d(!0),n=new AbortController,e.next=4,me(t,n);case 4:return(r=e.sent).ok?h(r.data.results):(0,u.showNotification)({title:l("importItemsFetchError","Error occured while fetching the import items"),kind:"error",critical:!0,description:JSON.stringify(r.data)}),d(!1),e.abrupt("return",(function(){return n.abort()}));case 8:case"end":return e.stop()}}),e)})),n=function(){var e=this,n=arguments;return new Promise((function(r,o){var a=t.apply(e,n);function i(e){ve(a,r,o,i,c,"next",e)}function c(e){ve(a,r,o,i,c,"throw",e)}i(void 0)}))},function(e){return n.apply(this,arguments)}),[]);if((0,o.useEffect)((function(){N(c)}),[]),m)return a().createElement("div",null,a().createElement(r.gqd,{showHeader:!1,showToolbar:!1,columnCount:2}),a().createElement(r.F3O,null));var S=[{header:l("conceptOrMapping","Concept/Mapping"),key:"uuid"},{header:l("message","Message"),key:"errorMessage"}];return!m&&a().createElement("div",null,a().createElement(r.iA_,{size:"sm",className:fe.tableBordered},a().createElement(r.ssF,null,a().createElement(r.SCH,{className:fe.tableHeaderRow},S.map((function(e,t){return a().createElement(r.xDH,{key:t,isSortable:!0},e.header)})))),a().createElement(r.RMI,null,null==E?void 0:E.map((function(e){return a().createElement(o.Fragment,{key:e.uuid},a().createElement(r.SCH,{className:fe.tableDataRow},a().createElement(r.pj1,null,a().createElement(r.rUS,{href:e.versionUrl},e.type," ",e.uuid)),a().createElement(r.pj1,null,e.errorMessage)))})))),a().createElement(r.tlE,{className:fe.pagination,size:"sm",page:w,pageSize:_,pageSizes:[5,10,20,50,100],totalItems:null==v?void 0:v.length,onChange:function(e){var t=e.page,n=e.pageSize;k(t),f(n)}}))},Ee=function(e){var t=e.selectedImportObject,n=(0,i.useTranslation)().t;return a().createElement("div",null,a().createElement("span",{className:se.heading01},n("startedOn","Started on")," "),a().createElement("span",{className:"body"},(0,u.formatDatetime)(new Date(t.localDateStarted))),a().createElement("br",null),a().createElement("span",{className:se.heading01},n("completedOn","Completed on")," "),a().createElement("span",{className:"body"},(0,u.formatDatetime)(new Date(t.localDateStopped))),a().createElement("br",null),a().createElement("span",{className:se.heading01},n("duration","Duration")," "),a().createElement("span",{className:"body"},t.importTime),a().createElement("br",null),a().createElement("br",null),a().createElement("span",{className:se.heading01},n("result","Result:")," "),a().createElement("br",null),a().createElement("div",{className:"body ".concat(se.indentedContent)},a().createElement("span",null,t.upToDateItemsCount," ",n("conceptsUpToDate","concepts up to date")),a().createElement("br",null),a().createElement("span",null,t.addedItemsCount," ",n("conceptsAdded","concepts added")),a().createElement("br",null),a().createElement("span",null,t.updatedItemsCount," ",n("conceptsUpdated","concepts updated")),a().createElement("br",null),a().createElement("span",null,t.retiredItemsCount," ",n("conceptsRetired","concepts retired")),a().createElement("br",null),a().createElement("span",null,t.errorItemsCount," ",n("errorsFound","errors found")),a().createElement("br",null),a().createElement("span",null,t.ignoredErrorsCount," ",n("errorsIgnored","errors ignored")),a().createElement("br",null)),a().createElement("br",null),0!=t.errorItemsCount&&a().createElement(ye,{importUuid:t.uuid}))};function we(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ke(){return ke=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ke.apply(this,arguments)}const Ne=function(){var e,t,n=(0,i.useTranslation)().t,l=(e=(0,o.useState)(10),t=2,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return we(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?we(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=l[0],p=l[1],m=function(){var e,t=(0,c.ZP)("/ws/rest/v1/openconceptlab/import?v=full",u.openmrsFetch),n=t.data,r=t.error,o=t.isValidating;return{data:null==n||null===(e=n.data)||void 0===e?void 0:e.results,isLoading:!n&&!r,isError:r,isValidating:o}}(),d=m.data,b=m.isLoading,_=m.isError,f=(0,u.usePagination)(d,s),g=f.results,v=f.currentPage,h=f.goTo;if(b)return a().createElement(r.rjZ,{className:ie.grid},a().createElement(r.sgG,{sm:4,md:8,lg:10},a().createElement(r.N2B,{className:ie.productiveHeading03}),a().createElement(r.gqd,{showHeader:!1,showToolbar:!1,rowCount:10,columnCount:3}),a().createElement(r.F3O,null)));_&&(0,u.showNotification)({kind:"error",description:n("previousImportsFetchError","Error occured while fetching the imports")});var y=[{header:n("dateAndTime","Date and Time"),key:"localDateStarted"},{header:n("duration","Duration"),key:"importTime"},{header:n("status","Status"),key:"status"}],E=null==g?void 0:g.map((function(e){return{id:e.uuid,localDateStarted:(0,u.formatDatetime)(new Date(e.localDateStarted)),importTime:e.importTime,status:e.status}}));return!b&&!_&&a().createElement(r.rjZ,{className:ie.grid},a().createElement(r.sgG,{sm:4,md:8,lg:10},a().createElement("h3",{className:ie.productiveHeading03},n("previousImports","Previous Imports")),a().createElement(r.wQF,{rows:E,headers:y,size:"sm"},(function(e){var t=e.rows,n=e.headers,i=e.getHeaderProps,c=e.getRowProps,l=e.getTableProps;return a().createElement(r.iA_,ke({},l(),{className:ie.tableBordered}),a().createElement(r.ssF,null,a().createElement(r.SCH,null,a().createElement(r.MOD,null),n.map((function(e,t){return a().createElement(r.xDH,ke({key:t},i({header:e})),e.header)})))),a().createElement(r.RMI,null,t.map((function(e){return a().createElement(o.Fragment,{key:e.id},a().createElement(r.RcE,ke({},c({row:e}),{className:ie.tableRow}),e.cells.map((function(e){return a().createElement(r.pj1,{key:e.id},e.value)}))),e.isExpanded&&a().createElement(r.WdL,{colSpan:n.length+1,className:ie.tableExpandedRow},a().createElement(Ee,{selectedImportObject:d.find((function(t){return t.uuid===e.id}))})))}))))})),a().createElement(r.tlE,{className:ie.pagination,size:"sm",page:v,pageSize:s,pageSizes:[10,20,50,100],totalItems:d.length,onChange:function(e){var t=e.page,n=e.pageSize;h(t),p(n)}})))},Se=function(){var e=(0,i.useTranslation)().t;return a().createElement(c.J$,null,a().createElement("main",{className:"omrs-main-content ".concat(G.main)},a().createElement("h3",{className:G.moduleHeader},e("moduleTitle")),a().createElement(r.mQc,null,a().createElement(r.tdY,{className:G.tabList,contained:!0},a().createElement(r.OK9,null,e("subscription")," "),a().createElement(r.OK9,null,e("import")," "),a().createElement(r.OK9,null,e("previousImports")," ")),a().createElement(r.nPR,null,a().createElement(r.x45,{className:G.tabPanel},a().createElement(L,null)),a().createElement(r.x45,{className:G.tabPanel},a().createElement(re,null)),a().createElement(r.x45,{className:G.tabPanel},a().createElement(Ne,null))))))}},3111:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(2609),o=n.n(r)()((function(e){return e[1]}));o.push([e.id,":root{--brand-01: #005d5d;--brand-02: #004144;--brand-03: #007d79}.-esm-openconceptlab__import-component__grid___5wW0H{margin-left:0;margin-right:0;padding-left:0;padding-right:0}.-esm-openconceptlab__import-component__productiveHeading03___m6cC7{font-size:var(--cds-productive-heading-03-font-size, 1.25rem);font-weight:var(--cds-productive-heading-03-font-weight, 400);line-height:var(--cds-productive-heading-03-line-height, 1.4);letter-spacing:var(--cds-productive-heading-03-letter-spacing, 0);margin-bottom:.5rem}.-esm-openconceptlab__import-component__form___BAtOz{margin-top:2rem}.-esm-openconceptlab__import-component__formText___-LFNS{padding-bottom:1rem}.-esm-openconceptlab__import-component__fileUploaderDropContainer___u9wb\\+{margin-bottom:1.5rem}",""]),o.locals={grid:"-esm-openconceptlab__import-component__grid___5wW0H",productiveHeading03:"-esm-openconceptlab__import-component__productiveHeading03___m6cC7",form:"-esm-openconceptlab__import-component__form___BAtOz",formText:"-esm-openconceptlab__import-component__formText___-LFNS",fileUploaderDropContainer:"-esm-openconceptlab__import-component__fileUploaderDropContainer___u9wb+"};const a=o},8850:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(2609),o=n.n(r)()((function(e){return e[1]}));o.push([e.id,":root{--brand-01: #005d5d;--brand-02: #004144;--brand-03: #007d79}.-esm-openconceptlab__import-items-component__pagination___UFodW{font-size:var(--cds-body-short-01-font-size, 0.875rem);font-weight:var(--cds-body-short-01-font-weight, 400);line-height:var(--cds-body-short-01-line-height, 1.28572);letter-spacing:var(--cds-body-short-01-letter-spacing, 0.16px);background-color:#fff;color:#525252;border:1px solid #e0e0e0;display:flex}.-esm-openconceptlab__import-items-component__tableBordered___agwp-{border:1px solid #e0e0e0}.-esm-openconceptlab__import-items-component__tableDataRow___BdXBZ>td{padding-left:1rem !important;background-color:#fff !important}.-esm-openconceptlab__import-items-component__tableHeaderRow___rp03z>th{background-color:#e0e0e0 !important}",""]),o.locals={pagination:"-esm-openconceptlab__import-items-component__pagination___UFodW",tableBordered:"-esm-openconceptlab__import-items-component__tableBordered___agwp-",tableDataRow:"-esm-openconceptlab__import-items-component__tableDataRow___BdXBZ",tableHeaderRow:"-esm-openconceptlab__import-items-component__tableHeaderRow___rp03z"};const a=o},385:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(2609),o=n.n(r)()((function(e){return e[1]}));o.push([e.id,":root{--brand-01: #005d5d;--brand-02: #004144;--brand-03: #007d79}.-esm-openconceptlab__import-overview-component__heading01___wV6-M{font-size:var(--cds-heading-01-font-size, 0.875rem);font-weight:var(--cds-heading-01-font-weight, 600);line-height:var(--cds-heading-01-line-height, 1.42857);letter-spacing:var(--cds-heading-01-letter-spacing, 0.16px)}.-esm-openconceptlab__import-overview-component__indentedContent___kMG5X{margin-left:2rem}",""]),o.locals={heading01:"-esm-openconceptlab__import-overview-component__heading01___wV6-M",indentedContent:"-esm-openconceptlab__import-overview-component__indentedContent___kMG5X"};const a=o},2258:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(2609),o=n.n(r)()((function(e){return e[1]}));o.push([e.id,":root{--brand-01: #005d5d;--brand-02: #004144;--brand-03: #007d79}.-esm-openconceptlab__previous-imports-component__grid___VG\\+Rw{margin-left:0;margin-right:0;padding-left:0;padding-right:0}.-esm-openconceptlab__previous-imports-component__productiveHeading03___-O6sL{font-size:var(--cds-productive-heading-03-font-size, 1.25rem);font-weight:var(--cds-productive-heading-03-font-weight, 400);line-height:var(--cds-productive-heading-03-line-height, 1.4);letter-spacing:var(--cds-productive-heading-03-letter-spacing, 0);margin-bottom:.5rem}.-esm-openconceptlab__previous-imports-component__pagination___JXNSt{font-size:var(--cds-body-short-01-font-size, 0.875rem);font-weight:var(--cds-body-short-01-font-weight, 400);line-height:var(--cds-body-short-01-line-height, 1.28572);letter-spacing:var(--cds-body-short-01-letter-spacing, 0.16px);background-color:#fff;color:#525252;border:1px solid #e0e0e0;display:flex}.-esm-openconceptlab__previous-imports-component__tableBordered___440s3{border:1px solid #e0e0e0}.-esm-openconceptlab__previous-imports-component__tableRow___tM2aj>td{background-color:#fff;border-bottom:1px solid #e0e0e0 !important}.-esm-openconceptlab__previous-imports-component__tableExpandedRow___fQwKD>td{padding-left:3rem !important;padding-right:3rem;padding-top:1rem;padding-bottom:1rem}",""]),o.locals={grid:"-esm-openconceptlab__previous-imports-component__grid___VG+Rw",productiveHeading03:"-esm-openconceptlab__previous-imports-component__productiveHeading03___-O6sL",pagination:"-esm-openconceptlab__previous-imports-component__pagination___JXNSt",tableBordered:"-esm-openconceptlab__previous-imports-component__tableBordered___440s3",tableRow:"-esm-openconceptlab__previous-imports-component__tableRow___tM2aj",tableExpandedRow:"-esm-openconceptlab__previous-imports-component__tableExpandedRow___fQwKD"};const a=o},302:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(2609),o=n.n(r)()((function(e){return e[1]}));o.push([e.id,":root{--brand-01: #005d5d;--brand-02: #004144;--brand-03: #007d79}.-esm-openconceptlab__root-component__main___G0\\+lN{background-color:#fff}.-esm-openconceptlab__root-component__moduleHeader___yB-PY{font-size:var(--cds-productive-heading-03-font-size, 1.25rem);font-weight:var(--cds-productive-heading-03-font-weight, 400);line-height:var(--cds-productive-heading-03-line-height, 1.4);letter-spacing:var(--cds-productive-heading-03-letter-spacing, 0);padding-left:1rem;padding-top:1rem;padding-bottom:1rem}.-esm-openconceptlab__root-component__tabList___aXyg4{padding:0 1rem}.-esm-openconceptlab__root-component__tabPanel___2e0wL{height:100%;background-color:#f4f4f4}",""]),o.locals={main:"-esm-openconceptlab__root-component__main___G0+lN",moduleHeader:"-esm-openconceptlab__root-component__moduleHeader___yB-PY",tabList:"-esm-openconceptlab__root-component__tabList___aXyg4",tabPanel:"-esm-openconceptlab__root-component__tabPanel___2e0wL"};const a=o},7542:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(2609),o=n.n(r)()((function(e){return e[1]}));o.push([e.id,":root{--brand-01: #005d5d;--brand-02: #004144;--brand-03: #007d79}.-esm-openconceptlab__subscription-component__grid___Kwugy{margin-left:0;margin-right:0;padding-left:0;padding-right:0}.-esm-openconceptlab__subscription-component__productiveHeading03___xgZur{font-size:var(--cds-productive-heading-03-font-size, 1.25rem);font-weight:var(--cds-productive-heading-03-font-weight, 400);line-height:var(--cds-productive-heading-03-line-height, 1.4);letter-spacing:var(--cds-productive-heading-03-letter-spacing, 0);margin-bottom:.5rem}.-esm-openconceptlab__subscription-component__formGroup___GmK5h{margin-bottom:1rem}.-esm-openconceptlab__subscription-component__unsubscribeText___B9jCa{padding-bottom:1rem}.-esm-openconceptlab__subscription-component__unsubscribeForm___dMi0v{margin-top:1rem}",""]),o.locals={grid:"-esm-openconceptlab__subscription-component__grid___Kwugy",productiveHeading03:"-esm-openconceptlab__subscription-component__productiveHeading03___xgZur",formGroup:"-esm-openconceptlab__subscription-component__formGroup___GmK5h",unsubscribeText:"-esm-openconceptlab__subscription-component__unsubscribeText___B9jCa",unsubscribeForm:"-esm-openconceptlab__subscription-component__unsubscribeForm___dMi0v"};const a=o}}]);