@leav/ui 1.6.0-4c30ab85 → 1.6.0-4fe8c6ba

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 (23) hide show
  1. package/dist/_gqlTypes/index.d.ts +49 -0
  2. package/dist/_gqlTypes/index.js +46 -0
  3. package/dist/_gqlTypes/index.js.map +1 -1
  4. package/dist/components/Explorer/Explorer.js +2 -2
  5. package/dist/components/Explorer/Explorer.js.map +1 -1
  6. package/dist/components/Explorer/actions-mass/export/ExportProfileSelectionModal.d.ts +10 -0
  7. package/dist/components/Explorer/actions-mass/export/ExportProfileSelectionModal.js +46 -0
  8. package/dist/components/Explorer/actions-mass/export/ExportProfileSelectionModal.js.map +1 -0
  9. package/dist/components/Explorer/actions-mass/export/content/NoProfiles.d.ts +1 -0
  10. package/dist/components/Explorer/actions-mass/export/content/NoProfiles.js +17 -0
  11. package/dist/components/Explorer/actions-mass/export/content/NoProfiles.js.map +1 -0
  12. package/dist/components/Explorer/actions-mass/export/content/ProfilesSelection.d.ts +8 -0
  13. package/dist/components/Explorer/actions-mass/export/content/ProfilesSelection.js +49 -0
  14. package/dist/components/Explorer/actions-mass/export/content/ProfilesSelection.js.map +1 -0
  15. package/dist/components/Explorer/actions-mass/export/useGetLibraryExportProfiles.d.ts +27 -0
  16. package/dist/components/Explorer/actions-mass/export/useGetLibraryExportProfiles.js +48 -0
  17. package/dist/components/Explorer/actions-mass/export/useGetLibraryExportProfiles.js.map +1 -0
  18. package/dist/components/Explorer/actions-mass/useExportMassAction.d.ts +7 -4
  19. package/dist/components/Explorer/actions-mass/useExportMassAction.js +76 -71
  20. package/dist/components/Explorer/actions-mass/useExportMassAction.js.map +1 -1
  21. package/dist/locales/en/shared.json +11 -0
  22. package/dist/locales/fr/shared.json +11 -0
  23. package/package.json +2 -2
@@ -2,13 +2,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
3
3
  // This file is released under LGPL V3
4
4
  // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
- import { useMemo } from 'react';
5
+ import { useCallback, useMemo, useState } from 'react';
6
6
  import { FaFileExport } from 'react-icons/fa';
7
- import { KitAlert, KitModal, KitNotification } from 'aristid-ds';
7
+ import { KitAlert, KitNotification } from 'aristid-ds';
8
8
  import { useExportLazyQuery } from '../../../_gqlTypes';
9
9
  import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
10
- import { BREAK_TWO_LINES, MASS_SELECTION_ALL } from '../_constants';
10
+ import { MASS_SELECTION_ALL } from '../_constants';
11
11
  import { ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION } from '../../../constants';
12
+ import { ExportProfileSelectionModal } from './export/ExportProfileSelectionModal';
12
13
  /**
13
14
  * Hook that provides a mass action configuration for exporting selected or all items
14
15
  * from a view/data set
@@ -16,81 +17,85 @@ import { ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION } from '../../../const
16
17
  export const useExportMassAction = ({ isEnabled, store: { view, dispatch }, totalCount, onExport, }) => {
17
18
  const { t } = useSharedTranslation();
18
19
  const [exportQuery] = useExportLazyQuery();
20
+ const [isModalOpen, setIsModalOpen] = useState(false);
21
+ const [isExporting, setIsExporting] = useState(false);
22
+ const [massSelectionFilter, setMassSelectionFilter] = useState();
23
+ const _handleConfirmExport = useCallback(async (profileLabel) => {
24
+ if (!massSelectionFilter) {
25
+ return;
26
+ }
27
+ const total = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;
28
+ setIsExporting(true);
29
+ try {
30
+ const { data, error } = await exportQuery({
31
+ variables: {
32
+ library: view.libraryId,
33
+ filters: massSelectionFilter,
34
+ profile: profileLabel,
35
+ },
36
+ });
37
+ if (error) {
38
+ // Preserve the extensions property which contains the error code
39
+ const graphQLError = error.graphQLErrors?.[0];
40
+ const errorWithExtensions = new Error(error.message);
41
+ errorWithExtensions.extensions = graphQLError?.extensions;
42
+ throw errorWithExtensions;
43
+ }
44
+ KitNotification.info({
45
+ message: t('explorer.massAction.export_message'),
46
+ description: t('explorer.massAction.export_description', {
47
+ count: total,
48
+ total,
49
+ }),
50
+ duration: INFO_NOTIFICATION_DURATION,
51
+ closable: true,
52
+ });
53
+ onExport?.(massSelectionFilter, view.massSelection);
54
+ setIsModalOpen(false);
55
+ }
56
+ catch (e) {
57
+ if (e.extensions?.code === 'CUSTOM_CONFIG_ERROR') {
58
+ KitAlert.error({
59
+ showIcon: true,
60
+ duration: ERROR_ALERT_DURATION,
61
+ message: t('error.error_occurred', { count: total }),
62
+ description: t('explorer.massAction.export_config_error_description', {
63
+ library: view.libraryId,
64
+ }),
65
+ closable: true,
66
+ });
67
+ }
68
+ else {
69
+ KitAlert.error({
70
+ showIcon: true,
71
+ duration: ERROR_ALERT_DURATION,
72
+ message: t('error.error_occurred'),
73
+ description: t('explorer.massAction.export_error_description', { count: total }),
74
+ closable: true,
75
+ });
76
+ }
77
+ }
78
+ finally {
79
+ setIsExporting(false);
80
+ }
81
+ }, [exportQuery, view.libraryId, view.massSelection, totalCount, massSelectionFilter, onExport, t]);
82
+ const _handleCloseModal = useCallback(() => {
83
+ setIsModalOpen(false);
84
+ setMassSelectionFilter(undefined);
85
+ }, []);
19
86
  const _exportMassAction = useMemo(() => ({
20
87
  label: t('explorer.massAction.export'),
21
88
  icon: _jsx(FaFileExport, {}),
22
89
  deselectAll: false,
23
- callback: massSelectionFilter => {
24
- KitModal.confirm({
25
- width: '100%',
26
- style: { content: { width: '90vw', maxWidth: '656px' } },
27
- icon: false,
28
- type: 'confirm',
29
- title: t('explorer.export_item', {
30
- count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,
31
- }) ?? undefined,
32
- content: t('explorer.export_item_description', {
33
- count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,
34
- }) +
35
- BREAK_TWO_LINES +
36
- t('global.are_you_sure'),
37
- okText: t('global.confirm') ?? undefined,
38
- cancelText: t('global.cancel') ?? undefined,
39
- onOk: async () => {
40
- const total = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;
41
- try {
42
- const { error } = await exportQuery({
43
- fetchPolicy: 'no-cache',
44
- variables: {
45
- library: view.libraryId,
46
- filters: massSelectionFilter,
47
- profile: 'default', // Set 'default' by default, it'll change when we can select a profile from the UI
48
- },
49
- });
50
- if (error) {
51
- // Preserve the extensions property which contains the error code
52
- const graphQLError = error.graphQLErrors?.[0];
53
- const errorWithExtensions = new Error(error.message);
54
- errorWithExtensions.extensions = graphQLError?.extensions;
55
- throw errorWithExtensions;
56
- }
57
- KitNotification.info({
58
- message: t('explorer.massAction.export_message'),
59
- description: t('explorer.massAction.export_description', {
60
- count: total,
61
- total,
62
- }),
63
- duration: INFO_NOTIFICATION_DURATION,
64
- closable: true,
65
- });
66
- onExport?.(massSelectionFilter, view.massSelection);
67
- }
68
- catch (e) {
69
- if (e.extensions?.code === 'CUSTOM_CONFIG_ERROR') {
70
- KitAlert.error({
71
- showIcon: true,
72
- duration: ERROR_ALERT_DURATION,
73
- message: t('explorer.massAction.export_config_error_message'),
74
- description: t('explorer.massAction.export_config_error_description'),
75
- closable: true,
76
- });
77
- }
78
- else {
79
- KitAlert.error({
80
- showIcon: true,
81
- duration: ERROR_ALERT_DURATION,
82
- message: t('explorer.massAction.export_error_message'),
83
- description: t('explorer.massAction.export_error_description', { count: total }),
84
- closable: true,
85
- });
86
- }
87
- }
88
- },
89
- });
90
+ callback: filter => {
91
+ setMassSelectionFilter(filter);
92
+ setIsModalOpen(true);
90
93
  },
91
- }), [t, exportQuery, view.massSelection, dispatch, view.libraryId]);
94
+ }), [t]);
95
+ const exportModal = isEnabled ? (_jsx(ExportProfileSelectionModal, { open: isModalOpen, libraryId: view.libraryId, isLoading: isExporting, onClose: _handleCloseModal, onConfirm: _handleConfirmExport })) : null;
92
96
  return {
93
97
  exportMassAction: isEnabled ? _exportMassAction : null,
98
+ ExportModal: exportModal,
94
99
  };
95
100
  };
96
101
  //# sourceMappingURL=useExportMassAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useExportMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useExportMassAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAgB,OAAO,EAAC,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAClE,OAAO,EAAC,oBAAoB,EAAE,0BAA0B,EAAC,MAAM,eAAe,CAAC;AAE/E;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAChC,SAAS,EACT,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EACvB,UAAU,EACV,QAAQ,GAQV,EAAE,EAAE;IACF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,CAAC,WAAW,CAAC,GAAG,kBAAkB,EAAE,CAAC;IAE3C,MAAM,iBAAiB,GAAiB,OAAO,CAC3C,GAAG,EAAE,CAAC,CAAC;QACH,KAAK,EAAE,CAAC,CAAC,4BAA4B,CAAC;QACtC,IAAI,EAAE,KAAC,YAAY,KAAG;QACtB,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE,mBAAmB,CAAC,EAAE;YAC5B,QAAQ,CAAC,OAAO,CAAC;gBACb,KAAK,EAAE,MAAM;gBACb,KAAK,EAAE,EAAC,OAAO,EAAE,EAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,O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,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;KACzD,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type Dispatch, useMemo} from 'react';\nimport {FaFileExport} from 'react-icons/fa';\nimport {KitAlert, KitModal, KitNotification} from 'aristid-ds';\nimport {useExportLazyQuery} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type FeatureHook, type IMassActions} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState} from '../manage-view-settings';\nimport {BREAK_TWO_LINES, MASS_SELECTION_ALL} from '../_constants';\nimport {ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION} from '_ui/constants';\n\n/**\n * Hook that provides a mass action configuration for exporting selected or all items\n * from a view/data set\n */\nexport const useExportMassAction = ({\n isEnabled,\n store: {view, dispatch},\n totalCount,\n onExport,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n totalCount: number;\n onExport?: IMassActions['callback'];\n}>) => {\n const {t} = useSharedTranslation();\n\n const [exportQuery] = useExportLazyQuery();\n\n const _exportMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.export'),\n icon: <FaFileExport />,\n deselectAll: false,\n callback: massSelectionFilter => {\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n icon: false,\n type: 'confirm',\n title:\n t('explorer.export_item', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) ?? undefined,\n content:\n t('explorer.export_item_description', {\n count: view.massSelection === MASS_SELECTION_ALL ? Infinity : view.massSelection.length,\n }) +\n BREAK_TWO_LINES +\n t('global.are_you_sure'),\n okText: t('global.confirm') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk: async () => {\n const total =\n view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;\n try {\n const {error} = await exportQuery({\n fetchPolicy: 'no-cache',\n variables: {\n library: view.libraryId,\n filters: massSelectionFilter,\n profile: 'default', // Set 'default' by default, it'll change when we can select a profile from the UI\n },\n });\n if (error) {\n // Preserve the extensions property which contains the error code\n const graphQLError = error.graphQLErrors?.[0];\n const errorWithExtensions = new Error(error.message);\n (errorWithExtensions as any).extensions = graphQLError?.extensions;\n throw errorWithExtensions;\n }\n\n KitNotification.info({\n message: t('explorer.massAction.export_message'),\n description: t('explorer.massAction.export_description', {\n count: total,\n total,\n }),\n duration: INFO_NOTIFICATION_DURATION,\n closable: true,\n });\n\n onExport?.(massSelectionFilter, view.massSelection);\n } catch (e) {\n if (e.extensions?.code === 'CUSTOM_CONFIG_ERROR') {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('explorer.massAction.export_config_error_message'),\n description: t('explorer.massAction.export_config_error_description'),\n closable: true,\n });\n } else {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('explorer.massAction.export_error_message'),\n description: t('explorer.massAction.export_error_description', {count: total}),\n closable: true,\n });\n }\n }\n },\n });\n },\n }),\n [t, exportQuery, view.massSelection, dispatch, view.libraryId],\n );\n\n return {\n exportMassAction: isEnabled ? _exportMassAction : null,\n };\n};\n"]}
1
+ {"version":3,"file":"useExportMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useExportMassAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAmC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvF,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AACrD,O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AAC,CAAC,IAAI;QACtD,WAAW,EAAE,WAAW;KAC3B,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type Dispatch, type ReactElement, useCallback, useMemo, useState} from 'react';\nimport {FaFileExport} from 'react-icons/fa';\nimport {KitAlert, KitNotification} from 'aristid-ds';\nimport {useExportLazyQuery, type RecordFilterInput} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type FeatureHook, type IMassActions} from '../_types';\nimport {type IViewSettingsAction, type IViewSettingsState} from '../manage-view-settings';\nimport {MASS_SELECTION_ALL} from '../_constants';\nimport {ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION} from '_ui/constants';\nimport {ExportProfileSelectionModal} from './export/ExportProfileSelectionModal';\n\ninterface IUseExportMassActionReturn {\n exportMassAction: IMassActions | null;\n ExportModal: ReactElement | null;\n}\n\n/**\n * Hook that provides a mass action configuration for exporting selected or all items\n * from a view/data set\n */\nexport const useExportMassAction = ({\n isEnabled,\n store: {view, dispatch},\n totalCount,\n onExport,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n dispatch: Dispatch<IViewSettingsAction>;\n };\n totalCount: number;\n onExport?: IMassActions['callback'];\n}>): IUseExportMassActionReturn => {\n const {t} = useSharedTranslation();\n\n const [exportQuery] = useExportLazyQuery();\n\n const [isModalOpen, setIsModalOpen] = useState(false);\n const [isExporting, setIsExporting] = useState(false);\n const [massSelectionFilter, setMassSelectionFilter] = useState<RecordFilterInput[] | undefined>();\n\n const _handleConfirmExport = useCallback(\n async (profileLabel: string) => {\n if (!massSelectionFilter) {\n return;\n }\n\n const total = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;\n setIsExporting(true);\n\n try {\n const {data, error} = await exportQuery({\n variables: {\n library: view.libraryId,\n filters: massSelectionFilter,\n profile: profileLabel,\n },\n });\n\n if (error) {\n // Preserve the extensions property which contains the error code\n const graphQLError = error.graphQLErrors?.[0];\n const errorWithExtensions = new Error(error.message);\n (errorWithExtensions as any).extensions = graphQLError?.extensions;\n throw errorWithExtensions;\n }\n\n KitNotification.info({\n message: t('explorer.massAction.export_message'),\n description: t('explorer.massAction.export_description', {\n count: total,\n total,\n }),\n duration: INFO_NOTIFICATION_DURATION,\n closable: true,\n });\n\n onExport?.(massSelectionFilter, view.massSelection);\n setIsModalOpen(false);\n } catch (e) {\n if (e.extensions?.code === 'CUSTOM_CONFIG_ERROR') {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred', {count: total}),\n description: t('explorer.massAction.export_config_error_description', {\n library: view.libraryId,\n }),\n closable: true,\n });\n } else {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred'),\n description: t('explorer.massAction.export_error_description', {count: total}),\n closable: true,\n });\n }\n } finally {\n setIsExporting(false);\n }\n },\n [exportQuery, view.libraryId, view.massSelection, totalCount, massSelectionFilter, onExport, t],\n );\n\n const _handleCloseModal = useCallback(() => {\n setIsModalOpen(false);\n setMassSelectionFilter(undefined);\n }, []);\n\n const _exportMassAction: IMassActions = useMemo(\n () => ({\n label: t('explorer.massAction.export'),\n icon: <FaFileExport />,\n deselectAll: false,\n callback: filter => {\n setMassSelectionFilter(filter);\n setIsModalOpen(true);\n },\n }),\n [t],\n );\n\n const exportModal = isEnabled ? (\n <ExportProfileSelectionModal\n open={isModalOpen}\n libraryId={view.libraryId}\n isLoading={isExporting}\n onClose={_handleCloseModal}\n onConfirm={_handleConfirmExport}\n />\n ) : null;\n\n return {\n exportMassAction: isEnabled ? _exportMassAction : null,\n ExportModal: exportModal,\n };\n};\n"]}
@@ -776,6 +776,17 @@
776
776
  "deselect_all": "Deselect all items"
777
777
  }
778
778
  },
779
+ "export_profile_modal": {
780
+ "title": "Export",
781
+ "profile_label": "Choose an export profile",
782
+ "preview_label": "Preview of exported attributes",
783
+ "search_placeholder": "Search...",
784
+ "no_profiles": "No export profiles configured for this library",
785
+ "contact_admin": "Please contact an administrator to configure export profiles.",
786
+ "empty_columns": "(empty column)",
787
+ "export_button": "Export",
788
+ "error_title": "Export profile error"
789
+ },
779
790
  "add-existing-item": "Add existing item",
780
791
  "activate_item_one": "Activate this item?",
781
792
  "activate_item_other": "Activate these items?",
@@ -776,6 +776,17 @@
776
776
  "deselect_all": "Tout désélectionner"
777
777
  }
778
778
  },
779
+ "export_profile_modal": {
780
+ "title": "Export",
781
+ "profile_label": "Choisir un profil d'export",
782
+ "preview_label": "Aperçu des attributs exportés",
783
+ "search_placeholder": "Rechercher...",
784
+ "no_profiles": "Aucun profil d'export configuré pour cette librairie",
785
+ "contact_admin": "Veuillez contacter un administrateur pour configurer les profils d'export.",
786
+ "empty_columns": "(colonne vide)",
787
+ "export_button": "Exporter",
788
+ "error_title": "Erreur de profil d'export"
789
+ },
779
790
  "add-existing-item": "Ajouter un élément existant",
780
791
  "activate_item_one": "Activer cet élément ?",
781
792
  "activate_item_other": "Activer ces éléments ?",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leav/ui",
3
- "version": "1.6.0-4c30ab85",
3
+ "version": "1.6.0-4fe8c6ba",
4
4
  "description": "Shared React components and hooks",
5
5
  "scripts": {
6
6
  "prepublishOnly": "yarn build",
@@ -49,7 +49,7 @@
49
49
  "i18next": "22.5.1",
50
50
  "jest": "29.0.3",
51
51
  "jest-environment-jsdom": "29.3.1",
52
- "jest-styled-components": "7.1.1",
52
+ "jest-styled-components": "7.2.0",
53
53
  "react": "18.2.0",
54
54
  "react-dom": "18.2.0",
55
55
  "react-i18next": "12",