@griddo/ax 11.15.7 → 11.15.8-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/package.json +2 -2
  2. package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.atoms.test.tsx +409 -0
  3. package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.helpers.test.tsx +418 -0
  4. package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.test.tsx +776 -29
  5. package/src/__tests__/components/FieldsBehavior/FieldsBehavior.test.tsx +368 -11
  6. package/src/__tests__/modules/Users/UserList/UserList.test.tsx +6 -6
  7. package/src/components/Fields/IntegrationsField/IntegrationItem/atoms.tsx +14 -5
  8. package/src/components/Fields/IntegrationsField/IntegrationItem/index.tsx +1 -8
  9. package/src/components/Fields/UrlField/index.tsx +5 -4
  10. package/src/components/Fields/Wysiwyg/atoms.tsx +140 -0
  11. package/src/components/Fields/Wysiwyg/config.tsx +190 -9
  12. package/src/components/Fields/Wysiwyg/helpers.tsx +54 -1
  13. package/src/components/Fields/Wysiwyg/index.tsx +210 -61
  14. package/src/components/Fields/Wysiwyg/style.tsx +32 -1
  15. package/src/components/Fields/Wysiwyg/vendors.tsx +0 -1
  16. package/src/components/FieldsBehavior/index.tsx +66 -31
  17. package/src/components/Icon/components/Sync.js +16 -0
  18. package/src/components/Icon/svgs/Sync.svg +3 -0
  19. package/src/components/RestoreModal/index.tsx +1 -3
  20. package/src/components/ScheduleModal/index.tsx +3 -3
  21. package/src/components/TableList/index.tsx +5 -3
  22. package/src/containers/FileDrive/actions.tsx +5 -5
  23. package/src/containers/Forms/actions.tsx +40 -38
  24. package/src/containers/Gallery/actions.tsx +27 -27
  25. package/src/containers/Integrations/actions.tsx +2 -2
  26. package/src/containers/Navigation/Defaults/actions.tsx +1 -1
  27. package/src/containers/PageEditor/actions.tsx +3 -5
  28. package/src/containers/Redirects/actions.tsx +2 -2
  29. package/src/containers/Sites/actions.tsx +15 -8
  30. package/src/containers/StructuredData/actions.tsx +5 -5
  31. package/src/containers/Users/actions.tsx +2 -2
  32. package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +36 -43
  33. package/src/modules/Categories/CategoriesList/CategoryPanel/index.tsx +15 -11
  34. package/src/modules/Categories/CategoriesList/atoms.tsx +42 -12
  35. package/src/modules/Categories/CategoriesList/index.tsx +8 -30
  36. package/src/modules/Content/PageItem/index.tsx +6 -5
  37. package/src/modules/Content/atoms.tsx +7 -3
  38. package/src/modules/Content/index.tsx +8 -16
  39. package/src/modules/FileDrive/FileModal/DetailPanel/index.tsx +14 -14
  40. package/src/modules/FileDrive/FolderItem/index.tsx +46 -54
  41. package/src/modules/FileDrive/GridItem/index.tsx +32 -37
  42. package/src/modules/FileDrive/ListItem/index.tsx +31 -37
  43. package/src/modules/FileDrive/atoms.tsx +59 -12
  44. package/src/modules/FileDrive/index.tsx +88 -98
  45. package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +42 -34
  46. package/src/modules/Forms/FormCategoriesList/atoms.tsx +17 -6
  47. package/src/modules/Forms/FormCategoriesList/index.tsx +30 -34
  48. package/src/modules/Forms/FormEditor/index.tsx +14 -6
  49. package/src/modules/Forms/FormList/FormItem/index.tsx +5 -1
  50. package/src/modules/Forms/FormList/index.tsx +15 -9
  51. package/src/modules/Forms/atoms.tsx +7 -4
  52. package/src/modules/GlobalEditor/atoms.tsx +77 -0
  53. package/src/modules/GlobalEditor/index.tsx +24 -7
  54. package/src/modules/MediaGallery/FolderItem/index.tsx +36 -52
  55. package/src/modules/MediaGallery/GridItem/index.tsx +27 -38
  56. package/src/modules/MediaGallery/ImageModal/DetailPanel/index.tsx +13 -13
  57. package/src/modules/MediaGallery/ImageModal/index.tsx +2 -16
  58. package/src/modules/MediaGallery/ListItem/index.tsx +25 -37
  59. package/src/modules/MediaGallery/atoms.tsx +84 -15
  60. package/src/modules/MediaGallery/index.tsx +62 -122
  61. package/src/modules/Navigation/Defaults/Item/atoms.tsx +2 -4
  62. package/src/modules/Navigation/Defaults/Item/index.tsx +80 -94
  63. package/src/modules/Navigation/Defaults/atoms.tsx +179 -7
  64. package/src/modules/Navigation/Defaults/index.tsx +51 -18
  65. package/src/modules/Navigation/Defaults/style.tsx +10 -7
  66. package/src/modules/Navigation/Menus/List/Table/Item/atoms.tsx +33 -19
  67. package/src/modules/Navigation/Menus/List/Table/Item/index.tsx +18 -19
  68. package/src/modules/Navigation/Menus/List/Table/index.tsx +15 -13
  69. package/src/modules/Navigation/Menus/List/index.tsx +1 -1
  70. package/src/modules/PageEditor/atoms.tsx +14 -11
  71. package/src/modules/PageEditor/index.tsx +11 -16
  72. package/src/modules/Redirects/RedirectItem/index.tsx +37 -39
  73. package/src/modules/Redirects/atoms.tsx +58 -12
  74. package/src/modules/Redirects/index.tsx +30 -58
  75. package/src/modules/Settings/Integrations/IntegrationItem/CopyModal/index.tsx +1 -1
  76. package/src/modules/Settings/Integrations/IntegrationItem/index.tsx +57 -69
  77. package/src/modules/Settings/Integrations/atoms.tsx +72 -8
  78. package/src/modules/Settings/Integrations/index.tsx +34 -48
  79. package/src/modules/StructuredData/Form/index.tsx +25 -8
  80. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/atoms.tsx +26 -75
  81. package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +15 -33
  82. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +63 -41
  83. package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/style.tsx +13 -8
  84. package/src/modules/StructuredData/StructuredDataList/index.tsx +11 -16
  85. package/src/modules/StructuredData/{StructuredDataList/atoms.tsx → atoms.tsx} +25 -28
  86. package/src/modules/Users/UserList/UserItem/index.tsx +18 -35
  87. package/src/modules/Users/UserList/atoms.tsx +61 -0
  88. package/src/modules/Users/UserList/index.tsx +12 -32
@@ -1,9 +1,10 @@
1
- import React from "react";
1
+ import type React from "react";
2
2
 
3
- import { IModal } from "@ax/types";
4
- import { Modal, FieldsBehavior } from "@ax/components";
3
+ import { FieldsBehavior, Modal } from "@ax/components";
4
+ import type { IModal } from "@ax/types";
5
+
6
+ import type { IFolderFormState } from ".";
5
7
  import FolderTree from "./FolderTree";
6
- import { IFolderFormState } from ".";
7
8
 
8
9
  import * as S from "./style";
9
10
 
@@ -47,8 +48,16 @@ const NewFolderModal = (props: INewModalProps): JSX.Element => {
47
48
  );
48
49
  };
49
50
 
50
- const DeleteFolderModal = (props: IDeleteModalProps): JSX.Element => {
51
- const { isOpen, toggleModal, mainModalAction, secondaryModalAction, title } = props;
51
+ const DeleteFolderModal = (props: IDeleteFolderModalProps): JSX.Element => {
52
+ const { isOpen, toggleModal, title, onDelete, isDeleting = false } = props;
53
+
54
+ const mainModalAction = {
55
+ title: isDeleting ? "Deleting" : "Delete",
56
+ onClick: onDelete,
57
+ disabled: isDeleting,
58
+ };
59
+
60
+ const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
52
61
 
53
62
  return (
54
63
  <Modal
@@ -69,13 +78,21 @@ const DeleteFolderModal = (props: IDeleteModalProps): JSX.Element => {
69
78
  };
70
79
 
71
80
  const RenameFolderModal = (props: IRenameModalProps): JSX.Element => {
72
- const { isOpen, toggleModal, mainModalAction, secondaryModalAction, value, setValue } = props;
81
+ const { isOpen, toggleModal, value, setValue, onUpdateFolder, isUpdating = false, isNameEmpty = false } = props;
73
82
 
74
83
  const setNameValue = (name: string) => setValue(name);
75
84
 
85
+ const mainModalAction = {
86
+ title: isUpdating ? "Updating..." : "Rename Folder",
87
+ onClick: onUpdateFolder,
88
+ disabled: isNameEmpty || isUpdating,
89
+ };
90
+
91
+ const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
92
+
76
93
  const handleKeyDown = (e: React.KeyboardEvent) => {
77
94
  if (e.key === "Enter") {
78
- mainModalAction?.onClick();
95
+ mainModalAction.onClick();
79
96
  }
80
97
  };
81
98
 
@@ -87,7 +104,7 @@ const RenameFolderModal = (props: IRenameModalProps): JSX.Element => {
87
104
  secondaryAction={secondaryModalAction}
88
105
  mainAction={mainModalAction}
89
106
  size="S"
90
- height={244}
107
+ height="auto"
91
108
  >
92
109
  <S.ModalContent>
93
110
  <S.NoMarginFieldsBehavior
@@ -106,7 +123,15 @@ const RenameFolderModal = (props: IRenameModalProps): JSX.Element => {
106
123
  };
107
124
 
108
125
  const DeleteFileModal = (props: IDeleteModalProps): JSX.Element => {
109
- const { isOpen, toggleModal, mainModalAction, secondaryModalAction, title, isChild } = props;
126
+ const { isOpen, toggleModal, title, isChild, onDelete, isDeleting = false } = props;
127
+
128
+ const mainModalAction = {
129
+ title: isDeleting ? "Deleting" : "Delete",
130
+ onClick: onDelete,
131
+ disabled: isDeleting,
132
+ };
133
+
134
+ const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
110
135
 
111
136
  return (
112
137
  <Modal
@@ -116,7 +141,7 @@ const DeleteFileModal = (props: IDeleteModalProps): JSX.Element => {
116
141
  secondaryAction={secondaryModalAction}
117
142
  mainAction={mainModalAction}
118
143
  size="S"
119
- height={240}
144
+ height="auto"
120
145
  isChild={isChild}
121
146
  >
122
147
  <S.ModalContent>
@@ -128,10 +153,18 @@ const DeleteFileModal = (props: IDeleteModalProps): JSX.Element => {
128
153
  };
129
154
 
130
155
  const MoveItemModal = (props: IMoveModalProps): JSX.Element => {
131
- const { isOpen, toggleModal, mainModalAction, secondaryModalAction, folder, setFolder, hidden, hideRoot } = props;
156
+ const { isOpen, toggleModal, folder, setFolder, hidden, hideRoot, onMove = () => {}, isMoving = false } = props;
132
157
 
133
158
  const handleSetFolder = (folderID: number) => setFolder(folderID);
134
159
 
160
+ const mainModalAction = {
161
+ title: isMoving ? "Moving" : "Move",
162
+ onClick: onMove,
163
+ disabled: isMoving,
164
+ };
165
+
166
+ const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
167
+
135
168
  return (
136
169
  <Modal
137
170
  isOpen={isOpen}
@@ -180,10 +213,22 @@ interface INewModalProps extends IModal {
180
213
  interface IRenameModalProps extends IModal {
181
214
  value: string;
182
215
  setValue(value: string): void;
216
+ onUpdateFolder(): void | Promise<void>;
217
+ isUpdating?: boolean;
218
+ isNameEmpty?: boolean;
183
219
  }
184
220
 
185
221
  interface IDeleteModalProps extends IModal {
186
222
  title: string;
223
+ onDelete(): void;
224
+ isDeleting?: boolean;
225
+ isChild?: boolean;
226
+ }
227
+
228
+ interface IDeleteFolderModalProps extends IModal {
229
+ title: string;
230
+ onDelete(): void;
231
+ isDeleting?: boolean;
187
232
  }
188
233
 
189
234
  interface IMoveModalProps extends IModal {
@@ -191,6 +236,8 @@ interface IMoveModalProps extends IModal {
191
236
  setFolder(folderID: number): void;
192
237
  hidden?: number[];
193
238
  hideRoot?: boolean;
239
+ onMove(): void;
240
+ isMoving?: boolean;
194
241
  }
195
242
 
196
243
  export { NewFolderModal, DeleteFolderModal, DeleteFileModal, MoveItemModal, RenameFolderModal, NotSavedModal };
@@ -19,9 +19,8 @@ import {
19
19
  Toast,
20
20
  Tooltip,
21
21
  } from "@ax/components";
22
- import { VALID_FILE_FORMATS } from "@ax/constants";
23
22
  import { fileDriveActions } from "@ax/containers/FileDrive";
24
- import { useBulkSelection, useIsDirty, useModal, usePermission, useResizable, useToast } from "@ax/hooks";
23
+ import { useBulkSelection, useIsDirty, useModals, usePermissions, useResizable, useToast } from "@ax/hooks";
25
24
  import type {
26
25
  IBulkAction,
27
26
  IFile,
@@ -79,7 +78,6 @@ const FileDrive = (props: IProps) => {
79
78
  folders,
80
79
  } = currentFolderContent || { files: { totalItems: 0, items: [] }, folders: [] };
81
80
 
82
- const [isBulkLoading, setIsBulkLoading] = useState(false);
83
81
  const [isPanelOpen, setPanelOpen] = useState(false);
84
82
  const [fileSelected, setFileSelected] = useState<IFile | null>(null);
85
83
  const [selectedFolder, setSelectedFolder] = useState<number>(currentFolderID || 0);
@@ -91,12 +89,7 @@ const FileDrive = (props: IProps) => {
91
89
  const [wrapperWidth, setWrapperWidth] = useState<number>();
92
90
  const tableRef = useRef<HTMLDivElement>(null);
93
91
  const wrapperRef = useRef<HTMLDivElement>(null);
94
- const { isOpen: isNewOpen, toggleModal: toggleNewModal } = useModal();
95
- const { isOpen: isUploadOpen, toggleModal: toggleUploadModal } = useModal();
96
- const { isOpen: isDeleteOpen, toggleModal: toggleDeleteModal } = useModal();
97
- const { isOpen: isMoveOpen, toggleModal: toggleMoveModal } = useModal();
98
- const { isOpen: isSaveOpen, toggleModal: toggleSaveModal } = useModal();
99
- const { isOpen, toggleModal } = useModal();
92
+ const { isOpen, toggleModal } = useModals(["new", "upload", "delete", "move", "save", "file"]);
100
93
  const { isVisible, toggleToast, setIsVisible } = useToast();
101
94
  const { isVisible: isNewVisible, toggleToast: toggleNewToast, setIsVisible: setIsNewVisible } = useToast();
102
95
  const { isVisible: isDeleteVisible, toggleToast: toggleDeleteToast, setIsVisible: setIsDeleteVisible } = useToast();
@@ -127,34 +120,50 @@ const FileDrive = (props: IProps) => {
127
120
  const isRoot = !breadcrumb.length;
128
121
  const isGrid = displayMode === "grid";
129
122
 
130
- const allowedToAccessGlobalFromSite = usePermission("mediaGallery.accessToGlobalFileDriveFromSite");
131
-
132
- const allowedToAddSiteFile = usePermission("mediaGallery.addFiles");
133
- const allowedToAddGlobalFile = usePermission("global.mediaGallery.addGlobalFiles");
134
- const allowedToAddGlobalFileFromSite = usePermission("mediaGallery.addGlobalFilesFromSite");
135
- const allowedToAddFile = !isSiteView
136
- ? allowedToAddGlobalFile
137
- : isTabGlobal
138
- ? allowedToAddGlobalFileFromSite
139
- : allowedToAddSiteFile;
140
-
141
- const allowedToEditSiteFile = usePermission("mediaGallery.editFiles");
142
- const allowedToEditGlobalFile = usePermission("global.mediaGallery.editGlobalFiles");
143
- const allowedToEditGlobalFileFromSite = usePermission("mediaGallery.editGlobalFilesInSite");
144
- const allowedToEditFile = !isSiteView
145
- ? allowedToEditGlobalFile
146
- : isTabGlobal
147
- ? allowedToEditGlobalFileFromSite
148
- : allowedToEditSiteFile;
149
-
150
- const allowedToDeleteSiteFile = usePermission("mediaGallery.deleteFiles");
151
- const allowedToDeleteGlobalFile = usePermission("global.mediaGallery.deleteGlobalFiles");
152
- const allowedToDeleteGlobalFileFromSite = usePermission("mediaGallery.deleteGlobalFilesInSite");
153
- const allowedToDeleteFile = !isSiteView
154
- ? allowedToDeleteGlobalFile
155
- : isTabGlobal
156
- ? allowedToDeleteGlobalFileFromSite
157
- : allowedToDeleteSiteFile;
123
+ const {
124
+ allowedToAccessGlobalFromSite,
125
+ allowedToAddSiteFile,
126
+ allowedToAddGlobalFile,
127
+ allowedToAddGlobalFileFromSite,
128
+ allowedToEditSiteFile,
129
+ allowedToEditGlobalFile,
130
+ allowedToEditGlobalFileFromSite,
131
+ allowedToDeleteSiteFile,
132
+ allowedToDeleteGlobalFile,
133
+ allowedToDeleteGlobalFileFromSite,
134
+ } = usePermissions({
135
+ allowedToAccessGlobalFromSite: "mediaGallery.accessToGlobalFileDriveFromSite",
136
+ allowedToAddSiteFile: "mediaGallery.addFiles",
137
+ allowedToAddGlobalFile: "global.mediaGallery.addGlobalFiles",
138
+ allowedToAddGlobalFileFromSite: "mediaGallery.addGlobalFilesFromSite",
139
+ allowedToEditSiteFile: "mediaGallery.editFiles",
140
+ allowedToEditGlobalFile: "global.mediaGallery.editGlobalFiles",
141
+ allowedToEditGlobalFileFromSite: "mediaGallery.editGlobalFilesInSite",
142
+ allowedToDeleteSiteFile: "mediaGallery.deleteFiles",
143
+ allowedToDeleteGlobalFile: "global.mediaGallery.deleteGlobalFiles",
144
+ allowedToDeleteGlobalFileFromSite: "mediaGallery.deleteGlobalFilesInSite",
145
+ });
146
+
147
+ const selectPermission = (site: boolean, global: boolean, fromSite: boolean) =>
148
+ !isSiteView ? global : isTabGlobal ? fromSite : site;
149
+
150
+ const allowedToAddFile = selectPermission(
151
+ allowedToAddSiteFile,
152
+ allowedToAddGlobalFile,
153
+ allowedToAddGlobalFileFromSite,
154
+ );
155
+
156
+ const allowedToEditFile = selectPermission(
157
+ allowedToEditSiteFile,
158
+ allowedToEditGlobalFile,
159
+ allowedToEditGlobalFileFromSite,
160
+ );
161
+
162
+ const allowedToDeleteFile = selectPermission(
163
+ allowedToDeleteSiteFile,
164
+ allowedToDeleteGlobalFile,
165
+ allowedToDeleteGlobalFileFromSite,
166
+ );
158
167
 
159
168
  const getParams = useCallback(() => {
160
169
  const params = {
@@ -226,7 +235,7 @@ const FileDrive = (props: IProps) => {
226
235
 
227
236
  const handleNewFolder = () => {
228
237
  setFolderForm(initFolderState);
229
- !isNewOpen && toggleNewModal();
238
+ !isOpen("new") && toggleModal("new");
230
239
  };
231
240
 
232
241
  const changeDisplayMode = (mode: "grid" | "list") => updateDisplayMode(mode);
@@ -247,7 +256,7 @@ const FileDrive = (props: IProps) => {
247
256
  parentId: folderForm.folderID || undefined,
248
257
  });
249
258
  if (isCreated) {
250
- isNewOpen && toggleNewModal();
259
+ isOpen("new") && toggleModal("new");
251
260
  toggleNewToast();
252
261
  }
253
262
  };
@@ -261,13 +270,13 @@ const FileDrive = (props: IProps) => {
261
270
 
262
271
  const handleClick = (file: IFile) => {
263
272
  setFileSelected(file);
264
- toggleModal();
273
+ toggleModal("file");
265
274
  };
266
275
 
267
276
  const handleUpload = async (files: IFile[]) => {
268
277
  setFileSelected(files[0]);
269
- isUploadOpen && toggleUploadModal();
270
- toggleModal();
278
+ isOpen("upload") && toggleModal("upload");
279
+ toggleModal("file");
271
280
  const params = getParams();
272
281
  await getFolderContent(params);
273
282
  };
@@ -290,7 +299,7 @@ const FileDrive = (props: IProps) => {
290
299
  };
291
300
 
292
301
  const handleMultipleUpload = async (files: File[]) => {
293
- isUploadOpen && toggleUploadModal();
302
+ isOpen("upload") && toggleModal("upload");
294
303
 
295
304
  const initialProgress = files.map(() => 0);
296
305
  setProgressItems(initialProgress);
@@ -304,7 +313,7 @@ const FileDrive = (props: IProps) => {
304
313
 
305
314
  const handleCloseModal = () => {
306
315
  if (isDirty) {
307
- toggleSaveModal();
316
+ toggleModal("save");
308
317
  } else {
309
318
  resetFileModal();
310
319
  }
@@ -315,7 +324,7 @@ const FileDrive = (props: IProps) => {
315
324
  setGalleryItems(filesIds);
316
325
  setGalleryDelete(true);
317
326
  resetDirty();
318
- toggleModal();
327
+ toggleModal("file");
319
328
  };
320
329
 
321
330
  const handleDeleteFile = async (fileID: number) => {
@@ -327,15 +336,13 @@ const FileDrive = (props: IProps) => {
327
336
  };
328
337
 
329
338
  const handleBulkDeleteFile = async () => {
330
- setIsBulkLoading(true);
331
339
  const isDeleted = await deleteFile(selectedItems.all, siteID);
332
340
  if (isDeleted) {
333
341
  setNumDocs(selectedItems.all.length);
334
- toggleDeleteModal();
342
+ toggleModal("delete");
335
343
  toggleDeleteToast();
336
344
  resetBulkSelection();
337
345
  }
338
- setIsBulkLoading(false);
339
346
  };
340
347
 
341
348
  const handleMoveFile = async (fileID: number, folderID: number) => {
@@ -347,16 +354,14 @@ const FileDrive = (props: IProps) => {
347
354
  };
348
355
 
349
356
  const handleBulkMoveFile = async () => {
350
- setIsBulkLoading(true);
351
357
  const isMoved = await moveFile(selectedItems.all, selectedFolder, siteID);
352
358
  if (isMoved) {
353
359
  setNumDocs(selectedItems.all.length);
354
- toggleMoveModal();
360
+ toggleModal("move");
355
361
  toggleMoveToast();
356
362
  setSelectedFolder(0);
357
363
  resetBulkSelection();
358
364
  }
359
- setIsBulkLoading(false);
360
365
  };
361
366
 
362
367
  const handleBulkEditFile = () => {
@@ -365,13 +370,13 @@ const FileDrive = (props: IProps) => {
365
370
  setGalleryItems(selectedItems.all);
366
371
  setFileSelected(currentFile);
367
372
  setGalleryDelete(false);
368
- toggleModal();
373
+ toggleModal("file");
369
374
  }
370
375
  };
371
376
 
372
377
  const handleModalClose = () => {
373
378
  setSelectedFolder(0);
374
- isMoveOpen && toggleMoveModal();
379
+ isOpen("move") && toggleModal("move");
375
380
  };
376
381
 
377
382
  const handleSelectFile = (id: number) => {
@@ -382,10 +387,8 @@ const FileDrive = (props: IProps) => {
382
387
  };
383
388
 
384
389
  const handleDownloadBulk = async () => {
385
- setIsBulkLoading(true);
386
390
  await downloadFiles(selectedItems.all, true);
387
391
  resetBulkSelection();
388
- setIsBulkLoading(false);
389
392
  };
390
393
 
391
394
  const handleUpdateCurrentFolder = (folderID: number | null) => {
@@ -416,7 +419,7 @@ const FileDrive = (props: IProps) => {
416
419
  {
417
420
  icon: "change",
418
421
  text: "Move to",
419
- action: toggleMoveModal,
422
+ action: () => toggleModal("move"),
420
423
  },
421
424
  ];
422
425
  }
@@ -436,7 +439,7 @@ const FileDrive = (props: IProps) => {
436
439
  {
437
440
  icon: "delete",
438
441
  text: "delete",
439
- action: toggleDeleteModal,
442
+ action: () => toggleModal("delete"),
440
443
  },
441
444
  ];
442
445
  }
@@ -452,7 +455,7 @@ const FileDrive = (props: IProps) => {
452
455
  isSearching={isSearching}
453
456
  setHoverCheck={setHoverCheck}
454
457
  selectedItems={selectedItems}
455
- isLoading={isBulkLoading}
458
+ isLoading={isSaving}
456
459
  />
457
460
  );
458
461
 
@@ -477,6 +480,7 @@ const FileDrive = (props: IProps) => {
477
480
  isAllowedToEdit={allowedToEditFile}
478
481
  isAllowedToMove={!isRoot || (isRoot && (folders.length > 0 || isSearching))}
479
482
  isSearching={isSearching}
483
+ isSaving={isSaving}
480
484
  />
481
485
  );
482
486
  })}
@@ -506,6 +510,7 @@ const FileDrive = (props: IProps) => {
506
510
  isAllowedToMove={!isRoot || (isRoot && (folders.length > 0 || isSearching))}
507
511
  isSearching={isSearching}
508
512
  hoverCheck={checkState.hoverCheck}
513
+ isSaving={isSaving}
509
514
  />
510
515
  );
511
516
  })}
@@ -541,14 +546,14 @@ const FileDrive = (props: IProps) => {
541
546
  const rightButtonProps = allowedToAddFile
542
547
  ? {
543
548
  label: "Upload",
544
- action: () => toggleUploadModal(),
549
+ action: () => toggleModal("upload"),
545
550
  }
546
551
  : undefined;
547
552
 
548
553
  const emptyProps = {
549
554
  message: allowedToAddFile ? "To start using files in your site, upload as many documents as you need" : "",
550
555
  button: allowedToAddFile ? "Upload file" : undefined,
551
- action: () => toggleUploadModal(),
556
+ action: () => toggleModal("upload"),
552
557
  };
553
558
 
554
559
  const emptySearchStateProps = {
@@ -563,25 +568,10 @@ const FileDrive = (props: IProps) => {
563
568
  disabled: folderForm.name.trim().length === 0 || isSaving,
564
569
  };
565
570
 
566
- const secondaryNewModalAction = { title: "Cancel", onClick: toggleNewModal };
567
-
568
- const mainDeleteModalAction = {
569
- title: isBulkLoading ? "Deleting" : "Delete",
570
- onClick: () => handleBulkDeleteFile(),
571
- disabled: isBulkLoading,
572
- };
573
-
574
- const secondaryDeleteModalAction = { title: "Cancel", onClick: toggleDeleteModal };
575
-
576
- const mainMoveModalAction = {
577
- title: "Move",
578
- onClick: () => handleBulkMoveFile(),
579
- };
580
-
581
- const secondaryMoveModalAction = { title: "Cancel", onClick: handleModalClose };
571
+ const secondaryNewModalAction = { title: "Cancel", onClick: () => toggleModal("new") };
582
572
 
583
573
  const handleMainAction = () => {
584
- toggleSaveModal();
574
+ toggleModal("save");
585
575
  resetFileModal();
586
576
  };
587
577
 
@@ -590,7 +580,7 @@ const FileDrive = (props: IProps) => {
590
580
  onClick: () => handleMainAction(),
591
581
  };
592
582
 
593
- const secondarySaveModalAction = { title: "Cancel", onClick: toggleSaveModal };
583
+ const secondarySaveModalAction = { title: "Cancel", onClick: () => toggleModal("save") };
594
584
 
595
585
  const foldersIcon = isPanelOpen ? <Icon name="closePanel" size="24" /> : <Icon name="openPanel" size="24" />;
596
586
 
@@ -707,7 +697,7 @@ const FileDrive = (props: IProps) => {
707
697
  selectItems={selectItems}
708
698
  bulkActions={bulkActions}
709
699
  selectedItems={selectedItems}
710
- isLoading={isBulkLoading}
700
+ isLoading={isSaving}
711
701
  />
712
702
  )}
713
703
  {!hasFolders && isRoot && !isSearching && <NewFolderButton />}
@@ -723,18 +713,18 @@ const FileDrive = (props: IProps) => {
723
713
  )}
724
714
  </S.ContentWrapper>
725
715
  </S.Wrapper>
726
- {isNewOpen && (
716
+ {isOpen("new") && (
727
717
  <NewFolderModal
728
- isOpen={isNewOpen}
729
- toggleModal={toggleNewModal}
718
+ isOpen={isOpen("new")}
719
+ toggleModal={() => toggleModal("new")}
730
720
  mainModalAction={mainNewModalAction}
731
721
  secondaryModalAction={secondaryNewModalAction}
732
722
  form={folderForm}
733
723
  setForm={setFolderForm}
734
724
  />
735
725
  )}
736
- <Modal isOpen={isUploadOpen} hide={toggleUploadModal} size="XL" title="Upload file">
737
- {isUploadOpen && (
726
+ <Modal isOpen={isOpen("upload")} hide={() => toggleModal("upload")} size="XL" title="Upload file">
727
+ {isOpen("upload") && (
738
728
  <FileDragAndDrop
739
729
  folderID={currentFolderID}
740
730
  handleUpload={handleUpload}
@@ -743,8 +733,8 @@ const FileDrive = (props: IProps) => {
743
733
  />
744
734
  )}
745
735
  </Modal>
746
- <Modal isOpen={isOpen} hide={handleCloseModal} size="XL" title="Document details">
747
- {isOpen && fileSelected && (
736
+ <Modal isOpen={isOpen("file")} hide={handleCloseModal} size="XL" title="Document details">
737
+ {isOpen("file") && fileSelected && (
748
738
  <FileModal
749
739
  file={fileSelected}
750
740
  toggleModal={handleCloseModal}
@@ -762,29 +752,29 @@ const FileDrive = (props: IProps) => {
762
752
  />
763
753
  )}
764
754
  </Modal>
765
- {isDeleteOpen && (
755
+ {isOpen("delete") && (
766
756
  <DeleteFileModal
767
- isOpen={isDeleteOpen}
768
- toggleModal={toggleDeleteModal}
769
- mainModalAction={mainDeleteModalAction}
770
- secondaryModalAction={secondaryDeleteModalAction}
757
+ isOpen={isOpen("delete")}
758
+ toggleModal={() => toggleModal("delete")}
771
759
  title="these documents"
760
+ onDelete={handleBulkDeleteFile}
761
+ isDeleting={isSaving}
772
762
  />
773
763
  )}
774
- {isMoveOpen && (
764
+ {isOpen("move") && (
775
765
  <MoveItemModal
776
- isOpen={isMoveOpen}
766
+ isOpen={isOpen("move")}
777
767
  toggleModal={handleModalClose}
778
- mainModalAction={mainMoveModalAction}
779
- secondaryModalAction={secondaryMoveModalAction}
780
768
  folder={selectedFolder}
781
769
  setFolder={setSelectedFolder}
770
+ onMove={handleBulkMoveFile}
771
+ isMoving={isSaving}
782
772
  />
783
773
  )}
784
- {isSaveOpen && (
774
+ {isOpen("save") && (
785
775
  <NotSavedModal
786
- isOpen={isSaveOpen}
787
- toggleModal={toggleSaveModal}
776
+ isOpen={isOpen("save")}
777
+ toggleModal={() => toggleModal("save")}
788
778
  mainModalAction={mainSaveModalAction}
789
779
  secondaryModalAction={secondarySaveModalAction}
790
780
  />