@griddo/ax 11.15.7 → 11.15.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.atoms.test.tsx +409 -0
- package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.helpers.test.tsx +418 -0
- package/src/__tests__/components/Fields/Wysiwyg/Wysiwyg.test.tsx +776 -29
- package/src/__tests__/components/FieldsBehavior/FieldsBehavior.test.tsx +368 -11
- package/src/__tests__/modules/Users/UserList/UserList.test.tsx +6 -6
- package/src/components/Fields/IntegrationsField/IntegrationItem/atoms.tsx +14 -5
- package/src/components/Fields/IntegrationsField/IntegrationItem/index.tsx +1 -8
- package/src/components/Fields/UrlField/index.tsx +5 -4
- package/src/components/Fields/Wysiwyg/atoms.tsx +140 -0
- package/src/components/Fields/Wysiwyg/config.tsx +190 -9
- package/src/components/Fields/Wysiwyg/helpers.tsx +54 -1
- package/src/components/Fields/Wysiwyg/index.tsx +210 -61
- package/src/components/Fields/Wysiwyg/style.tsx +32 -1
- package/src/components/Fields/Wysiwyg/vendors.tsx +0 -1
- package/src/components/FieldsBehavior/index.tsx +66 -31
- package/src/components/Icon/components/Sync.js +16 -0
- package/src/components/Icon/svgs/Sync.svg +3 -0
- package/src/components/RestoreModal/index.tsx +1 -3
- package/src/components/ScheduleModal/index.tsx +3 -3
- package/src/components/TableList/index.tsx +5 -3
- package/src/containers/FileDrive/actions.tsx +5 -5
- package/src/containers/Forms/actions.tsx +40 -38
- package/src/containers/Gallery/actions.tsx +27 -27
- package/src/containers/Integrations/actions.tsx +2 -2
- package/src/containers/Navigation/Defaults/actions.tsx +1 -1
- package/src/containers/PageEditor/actions.tsx +3 -5
- package/src/containers/Redirects/actions.tsx +2 -2
- package/src/containers/Sites/actions.tsx +15 -8
- package/src/containers/StructuredData/actions.tsx +5 -5
- package/src/containers/Users/actions.tsx +2 -2
- package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +36 -43
- package/src/modules/Categories/CategoriesList/CategoryPanel/index.tsx +15 -11
- package/src/modules/Categories/CategoriesList/atoms.tsx +42 -12
- package/src/modules/Categories/CategoriesList/index.tsx +8 -30
- package/src/modules/Content/PageItem/index.tsx +6 -5
- package/src/modules/Content/atoms.tsx +7 -3
- package/src/modules/Content/index.tsx +8 -16
- package/src/modules/FileDrive/FileModal/DetailPanel/index.tsx +14 -14
- package/src/modules/FileDrive/FolderItem/index.tsx +46 -54
- package/src/modules/FileDrive/GridItem/index.tsx +32 -37
- package/src/modules/FileDrive/ListItem/index.tsx +31 -37
- package/src/modules/FileDrive/atoms.tsx +59 -12
- package/src/modules/FileDrive/index.tsx +88 -98
- package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +42 -34
- package/src/modules/Forms/FormCategoriesList/atoms.tsx +17 -6
- package/src/modules/Forms/FormCategoriesList/index.tsx +30 -34
- package/src/modules/Forms/FormEditor/index.tsx +14 -6
- package/src/modules/Forms/FormList/FormItem/index.tsx +5 -1
- package/src/modules/Forms/FormList/index.tsx +15 -9
- package/src/modules/Forms/atoms.tsx +7 -4
- package/src/modules/GlobalEditor/atoms.tsx +77 -0
- package/src/modules/GlobalEditor/index.tsx +24 -7
- package/src/modules/MediaGallery/FolderItem/index.tsx +36 -52
- package/src/modules/MediaGallery/GridItem/index.tsx +27 -38
- package/src/modules/MediaGallery/ImageModal/DetailPanel/index.tsx +13 -13
- package/src/modules/MediaGallery/ImageModal/index.tsx +2 -16
- package/src/modules/MediaGallery/ListItem/index.tsx +25 -37
- package/src/modules/MediaGallery/atoms.tsx +84 -15
- package/src/modules/MediaGallery/index.tsx +62 -122
- package/src/modules/Navigation/Defaults/Item/atoms.tsx +2 -4
- package/src/modules/Navigation/Defaults/Item/index.tsx +80 -94
- package/src/modules/Navigation/Defaults/atoms.tsx +179 -7
- package/src/modules/Navigation/Defaults/index.tsx +51 -18
- package/src/modules/Navigation/Defaults/style.tsx +10 -7
- package/src/modules/Navigation/Menus/List/Table/Item/atoms.tsx +33 -19
- package/src/modules/Navigation/Menus/List/Table/Item/index.tsx +18 -19
- package/src/modules/Navigation/Menus/List/Table/index.tsx +15 -13
- package/src/modules/Navigation/Menus/List/index.tsx +1 -1
- package/src/modules/PageEditor/atoms.tsx +14 -11
- package/src/modules/PageEditor/index.tsx +11 -16
- package/src/modules/Redirects/RedirectItem/index.tsx +37 -39
- package/src/modules/Redirects/atoms.tsx +58 -12
- package/src/modules/Redirects/index.tsx +30 -58
- package/src/modules/Settings/Integrations/IntegrationItem/CopyModal/index.tsx +1 -1
- package/src/modules/Settings/Integrations/IntegrationItem/index.tsx +57 -69
- package/src/modules/Settings/Integrations/atoms.tsx +72 -8
- package/src/modules/Settings/Integrations/index.tsx +34 -48
- package/src/modules/StructuredData/Form/index.tsx +25 -8
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/atoms.tsx +26 -75
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +15 -33
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +63 -41
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/style.tsx +13 -8
- package/src/modules/StructuredData/StructuredDataList/index.tsx +11 -16
- package/src/modules/StructuredData/{StructuredDataList/atoms.tsx → atoms.tsx} +25 -28
- package/src/modules/Users/UserList/UserItem/index.tsx +18 -35
- package/src/modules/Users/UserList/atoms.tsx +61 -0
- package/src/modules/Users/UserList/index.tsx +12 -32
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import type React from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
|
|
10
11
|
const NewFolderModal = (props: INewModalProps): JSX.Element => {
|
|
11
|
-
const { isOpen, toggleModal,
|
|
12
|
+
const { isOpen, toggleModal, form, setForm, onCreateFolder, isSaving } = props;
|
|
12
13
|
|
|
13
14
|
const setNameValue = (name: string) => setForm({ ...form, name });
|
|
14
15
|
const setFolder = (folderID: number | null) => setForm({ ...form, folderID });
|
|
15
16
|
|
|
16
17
|
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
17
18
|
if (e.key === "Enter") {
|
|
18
|
-
|
|
19
|
+
onCreateFolder?.();
|
|
19
20
|
}
|
|
20
21
|
};
|
|
21
22
|
|
|
23
|
+
const mainModalAction = {
|
|
24
|
+
title: isSaving ? "Saving..." : "Create New Folder",
|
|
25
|
+
onClick: onCreateFolder,
|
|
26
|
+
disabled: form.name.trim().length === 0 || isSaving,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
|
|
30
|
+
|
|
22
31
|
return (
|
|
23
32
|
<Modal
|
|
24
33
|
isOpen={isOpen}
|
|
@@ -47,8 +56,16 @@ const NewFolderModal = (props: INewModalProps): JSX.Element => {
|
|
|
47
56
|
);
|
|
48
57
|
};
|
|
49
58
|
|
|
50
|
-
const DeleteFolderModal = (props:
|
|
51
|
-
const { isOpen, toggleModal,
|
|
59
|
+
const DeleteFolderModal = (props: IDeleteFolderModalProps): JSX.Element => {
|
|
60
|
+
const { isOpen, toggleModal, title, onDelete, isDeleting = false } = props;
|
|
61
|
+
|
|
62
|
+
const mainModalAction = {
|
|
63
|
+
title: isDeleting ? "Deleting" : "Delete",
|
|
64
|
+
onClick: onDelete,
|
|
65
|
+
disabled: isDeleting,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
|
|
52
69
|
|
|
53
70
|
return (
|
|
54
71
|
<Modal
|
|
@@ -69,13 +86,21 @@ const DeleteFolderModal = (props: IDeleteModalProps): JSX.Element => {
|
|
|
69
86
|
};
|
|
70
87
|
|
|
71
88
|
const RenameFolderModal = (props: IRenameModalProps): JSX.Element => {
|
|
72
|
-
const { isOpen, toggleModal,
|
|
89
|
+
const { isOpen, toggleModal, value, setValue, onUpdateFolder, isUpdating = false, isNameEmpty = false } = props;
|
|
73
90
|
|
|
74
91
|
const setNameValue = (name: string) => setValue(name);
|
|
75
92
|
|
|
93
|
+
const mainModalAction = {
|
|
94
|
+
title: isUpdating ? "Updating..." : "Rename Folder",
|
|
95
|
+
onClick: onUpdateFolder,
|
|
96
|
+
disabled: isNameEmpty || isUpdating,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
|
|
100
|
+
|
|
76
101
|
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
77
102
|
if (e.key === "Enter") {
|
|
78
|
-
mainModalAction
|
|
103
|
+
mainModalAction.onClick();
|
|
79
104
|
}
|
|
80
105
|
};
|
|
81
106
|
|
|
@@ -87,7 +112,7 @@ const RenameFolderModal = (props: IRenameModalProps): JSX.Element => {
|
|
|
87
112
|
secondaryAction={secondaryModalAction}
|
|
88
113
|
mainAction={mainModalAction}
|
|
89
114
|
size="S"
|
|
90
|
-
height=
|
|
115
|
+
height="auto"
|
|
91
116
|
>
|
|
92
117
|
<S.ModalContent>
|
|
93
118
|
<S.NoMarginFieldsBehavior
|
|
@@ -106,7 +131,15 @@ const RenameFolderModal = (props: IRenameModalProps): JSX.Element => {
|
|
|
106
131
|
};
|
|
107
132
|
|
|
108
133
|
const DeleteFileModal = (props: IDeleteModalProps): JSX.Element => {
|
|
109
|
-
const { isOpen, toggleModal,
|
|
134
|
+
const { isOpen, toggleModal, title, isChild, onDelete, isDeleting = false } = props;
|
|
135
|
+
|
|
136
|
+
const mainModalAction = {
|
|
137
|
+
title: isDeleting ? "Deleting" : "Delete",
|
|
138
|
+
onClick: onDelete,
|
|
139
|
+
disabled: isDeleting,
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
|
|
110
143
|
|
|
111
144
|
return (
|
|
112
145
|
<Modal
|
|
@@ -128,10 +161,18 @@ const DeleteFileModal = (props: IDeleteModalProps): JSX.Element => {
|
|
|
128
161
|
};
|
|
129
162
|
|
|
130
163
|
const MoveItemModal = (props: IMoveModalProps): JSX.Element => {
|
|
131
|
-
const { isOpen, toggleModal,
|
|
164
|
+
const { isOpen, toggleModal, folder, setFolder, hidden, hideRoot, onMove = () => {}, isMoving = false } = props;
|
|
132
165
|
|
|
133
166
|
const handleSetFolder = (folderID: number) => setFolder(folderID);
|
|
134
167
|
|
|
168
|
+
const mainModalAction = {
|
|
169
|
+
title: isMoving ? "Moving" : "Move",
|
|
170
|
+
onClick: onMove,
|
|
171
|
+
disabled: isMoving,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
|
|
175
|
+
|
|
135
176
|
return (
|
|
136
177
|
<Modal
|
|
137
178
|
isOpen={isOpen}
|
|
@@ -149,8 +190,15 @@ const MoveItemModal = (props: IMoveModalProps): JSX.Element => {
|
|
|
149
190
|
);
|
|
150
191
|
};
|
|
151
192
|
|
|
152
|
-
const NotSavedModal = (props:
|
|
153
|
-
const { isOpen, toggleModal,
|
|
193
|
+
const NotSavedModal = (props: INotSavedModalProps): JSX.Element => {
|
|
194
|
+
const { isOpen, toggleModal, onDiscard } = props;
|
|
195
|
+
|
|
196
|
+
const mainModalAction = {
|
|
197
|
+
title: "Yes, discard changes",
|
|
198
|
+
onClick: onDiscard,
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const secondaryModalAction = { title: "Cancel", onClick: toggleModal };
|
|
154
202
|
|
|
155
203
|
return (
|
|
156
204
|
<Modal
|
|
@@ -161,6 +209,7 @@ const NotSavedModal = (props: IModal): JSX.Element => {
|
|
|
161
209
|
mainAction={mainModalAction}
|
|
162
210
|
secondaryAction={secondaryModalAction}
|
|
163
211
|
isChild={true}
|
|
212
|
+
height="auto"
|
|
164
213
|
>
|
|
165
214
|
{
|
|
166
215
|
<S.ModalContent>
|
|
@@ -175,15 +224,29 @@ const NotSavedModal = (props: IModal): JSX.Element => {
|
|
|
175
224
|
interface INewModalProps extends IModal {
|
|
176
225
|
form: IFolderFormState;
|
|
177
226
|
setForm(form: IFolderFormState): void;
|
|
227
|
+
onCreateFolder(): void;
|
|
228
|
+
isSaving: boolean;
|
|
178
229
|
}
|
|
179
230
|
|
|
180
231
|
interface IRenameModalProps extends IModal {
|
|
181
232
|
value: string;
|
|
182
233
|
setValue(value: string): void;
|
|
234
|
+
onUpdateFolder(): void | Promise<void>;
|
|
235
|
+
isUpdating?: boolean;
|
|
236
|
+
isNameEmpty?: boolean;
|
|
183
237
|
}
|
|
184
238
|
|
|
185
239
|
interface IDeleteModalProps extends IModal {
|
|
186
240
|
title: string;
|
|
241
|
+
onDelete(): void;
|
|
242
|
+
isDeleting?: boolean;
|
|
243
|
+
isChild?: boolean;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
interface IDeleteFolderModalProps extends IModal {
|
|
247
|
+
title: string;
|
|
248
|
+
onDelete(): void;
|
|
249
|
+
isDeleting?: boolean;
|
|
187
250
|
}
|
|
188
251
|
|
|
189
252
|
interface IMoveModalProps extends IModal {
|
|
@@ -191,6 +254,12 @@ interface IMoveModalProps extends IModal {
|
|
|
191
254
|
setFolder(folderID: number | null): void;
|
|
192
255
|
hidden?: number[];
|
|
193
256
|
hideRoot?: boolean;
|
|
257
|
+
onMove(): void;
|
|
258
|
+
isMoving?: boolean;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
interface INotSavedModalProps extends IModal {
|
|
262
|
+
onDiscard(): void;
|
|
194
263
|
}
|
|
195
264
|
|
|
196
265
|
export { NewFolderModal, DeleteFolderModal, DeleteFileModal, MoveItemModal, RenameFolderModal, NotSavedModal };
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
Tooltip,
|
|
22
22
|
} from "@ax/components";
|
|
23
23
|
import { galleryActions } from "@ax/containers/Gallery";
|
|
24
|
-
import { useBulkSelection, useIsDirty,
|
|
24
|
+
import { useBulkSelection, useIsDirty, useModals, usePermissions, useResizable, useToast } from "@ax/hooks";
|
|
25
25
|
import type {
|
|
26
26
|
IBulkAction,
|
|
27
27
|
IFolder,
|
|
@@ -86,7 +86,6 @@ const MediaGallery = (props: IProps) => {
|
|
|
86
86
|
const firstPage = 1;
|
|
87
87
|
const lastPage = Math.ceil(totalItems / itemsPerPage);
|
|
88
88
|
const [page, setPage] = useState(firstPage);
|
|
89
|
-
const [isBulkLoading, setIsBulkLoading] = useState(false);
|
|
90
89
|
const [isPanelOpen, setPanelOpen] = useState(false);
|
|
91
90
|
const [fileSelected, setFileSelected] = useState<IImage | null>(null);
|
|
92
91
|
const [selectedFolder, setSelectedFolder] = useState<number | null>(currentFolderID || null);
|
|
@@ -103,12 +102,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
103
102
|
const tableRef = useRef<HTMLDivElement>(null);
|
|
104
103
|
const contentRef = useRef<HTMLDivElement>(null);
|
|
105
104
|
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
106
|
-
const { isOpen
|
|
107
|
-
const { isOpen: isUploadOpen, toggleModal: toggleUploadModal } = useModal();
|
|
108
|
-
const { isOpen: isDeleteOpen, toggleModal: toggleDeleteModal } = useModal();
|
|
109
|
-
const { isOpen: isMoveOpen, toggleModal: toggleMoveModal } = useModal();
|
|
110
|
-
const { isOpen: isSaveOpen, toggleModal: toggleSaveModal } = useModal();
|
|
111
|
-
const { isOpen, toggleModal } = useModal();
|
|
105
|
+
const { isOpen, toggleModal } = useModals(["new", "upload", "delete", "move", "save", "imageModal"]);
|
|
112
106
|
const { isVisible, toggleToast, setIsVisible, state: toastState } = useToast();
|
|
113
107
|
const [ref] = useResizable();
|
|
114
108
|
|
|
@@ -130,35 +124,20 @@ const MediaGallery = (props: IProps) => {
|
|
|
130
124
|
const isRoot = !breadcrumb?.length;
|
|
131
125
|
const isGrid = displayMode === "grid";
|
|
132
126
|
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const allowedToEditFile = !isSiteView
|
|
148
|
-
? allowedToEditGlobalFile
|
|
149
|
-
: isTabGlobal
|
|
150
|
-
? allowedToEditGlobalFileFromSite
|
|
151
|
-
: allowedToEditSiteFile;
|
|
152
|
-
|
|
153
|
-
const allowedToDeleteSiteFile = usePermission("mediaGallery.deleteImages");
|
|
154
|
-
const allowedToDeleteGlobalFile = usePermission("global.mediaGallery.deleteGlobalImages");
|
|
155
|
-
const allowedToDeleteGlobalFileFromSite = false;
|
|
156
|
-
|
|
157
|
-
const allowedToDeleteFile = !isSiteView
|
|
158
|
-
? allowedToDeleteGlobalFile
|
|
159
|
-
: isTabGlobal
|
|
160
|
-
? allowedToDeleteGlobalFileFromSite
|
|
161
|
-
: allowedToDeleteSiteFile;
|
|
127
|
+
const allowedTo = usePermissions({
|
|
128
|
+
accessGlobalFromSite: "mediaGallery.accessToGlobalGalleryFromSite",
|
|
129
|
+
addSiteFile: "mediaGallery.addImages",
|
|
130
|
+
addGlobalFile: "global.mediaGallery.addGlobalImages",
|
|
131
|
+
editSiteFile: "mediaGallery.editImages",
|
|
132
|
+
editGlobalFile: "global.mediaGallery.editGlobalImages",
|
|
133
|
+
deleteSiteFile: "mediaGallery.deleteImages",
|
|
134
|
+
deleteGlobalFile: "global.mediaGallery.deleteGlobalImages",
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const allowedToAccessGlobalFromSite = allowedTo.accessGlobalFromSite;
|
|
138
|
+
const allowedToAddFile = !isSiteView ? allowedTo.addGlobalFile : isTabGlobal ? false : allowedTo.addSiteFile;
|
|
139
|
+
const allowedToEditFile = !isSiteView ? allowedTo.editGlobalFile : isTabGlobal ? false : allowedTo.editSiteFile;
|
|
140
|
+
const allowedToDeleteFile = !isSiteView ? allowedTo.deleteGlobalFile : isTabGlobal ? false : allowedTo.deleteSiteFile;
|
|
162
141
|
|
|
163
142
|
const getParams = useCallback(() => {
|
|
164
143
|
const params: IGetFolderParams = {
|
|
@@ -263,7 +242,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
263
242
|
|
|
264
243
|
const handleNewFolder = () => {
|
|
265
244
|
setFolderForm(initFolderState);
|
|
266
|
-
|
|
245
|
+
toggleModal("new");
|
|
267
246
|
};
|
|
268
247
|
|
|
269
248
|
const changeDisplayMode = (mode: "grid" | "list") => updateDisplayMode(mode);
|
|
@@ -291,7 +270,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
291
270
|
params,
|
|
292
271
|
);
|
|
293
272
|
if (isCreated) {
|
|
294
|
-
|
|
273
|
+
toggleModal("new");
|
|
295
274
|
toggleToast("1 new folder created");
|
|
296
275
|
}
|
|
297
276
|
};
|
|
@@ -306,13 +285,13 @@ const MediaGallery = (props: IProps) => {
|
|
|
306
285
|
|
|
307
286
|
const handleClick = (file: IImage) => {
|
|
308
287
|
setFileSelected(file);
|
|
309
|
-
toggleModal();
|
|
288
|
+
toggleModal("imageModal");
|
|
310
289
|
};
|
|
311
290
|
|
|
312
291
|
const handleUpload = async (files: IImage[]) => {
|
|
313
292
|
setFileSelected(files[0]);
|
|
314
|
-
|
|
315
|
-
toggleModal();
|
|
293
|
+
isOpen("upload") && toggleModal("upload");
|
|
294
|
+
toggleModal("imageModal");
|
|
316
295
|
const params = getParams();
|
|
317
296
|
await getFolderContent(params);
|
|
318
297
|
};
|
|
@@ -338,7 +317,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
338
317
|
};
|
|
339
318
|
|
|
340
319
|
const handleMultipleUpload = async (files: File[]) => {
|
|
341
|
-
|
|
320
|
+
isOpen("upload") && toggleModal("upload");
|
|
342
321
|
|
|
343
322
|
const initialProgress = files.map(() => 0);
|
|
344
323
|
setProgressItems({ tab: selectedTab, folder: currentFolderID, items: initialProgress });
|
|
@@ -356,7 +335,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
356
335
|
|
|
357
336
|
const handleCloseModal = () => {
|
|
358
337
|
if (isDirty) {
|
|
359
|
-
|
|
338
|
+
toggleModal("save");
|
|
360
339
|
} else {
|
|
361
340
|
resetFileModal();
|
|
362
341
|
}
|
|
@@ -367,7 +346,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
367
346
|
setGalleryItems(imagesIds);
|
|
368
347
|
setGalleryDelete(true);
|
|
369
348
|
resetDirty();
|
|
370
|
-
toggleModal();
|
|
349
|
+
toggleModal("imageModal");
|
|
371
350
|
};
|
|
372
351
|
|
|
373
352
|
const handleDeleteFile = async (imageID: number) => {
|
|
@@ -376,12 +355,11 @@ const MediaGallery = (props: IProps) => {
|
|
|
376
355
|
const isDeleted = await deleteImage(imageID, resetedParams);
|
|
377
356
|
if (isDeleted) {
|
|
378
357
|
toggleToast("1 Image deleted");
|
|
379
|
-
isOpen && handleCloseModal();
|
|
358
|
+
isOpen("imageModal") && handleCloseModal();
|
|
380
359
|
}
|
|
381
360
|
};
|
|
382
361
|
|
|
383
362
|
const handleBulkDeleteFile = async () => {
|
|
384
|
-
setIsBulkLoading(true);
|
|
385
363
|
const params = getParams();
|
|
386
364
|
const resetedParams = { ...params, page: firstPage, infinite: false, loading: true };
|
|
387
365
|
const isDeleted = await deleteImage(selectedItems.all, resetedParams);
|
|
@@ -389,33 +367,28 @@ const MediaGallery = (props: IProps) => {
|
|
|
389
367
|
toggleToast(`${selectedItems.all.length} Image${selectedItems.all.length > 1 ? "s" : ""} deleted`);
|
|
390
368
|
resetBulkSelection();
|
|
391
369
|
}
|
|
392
|
-
|
|
393
|
-
setIsBulkLoading(false);
|
|
370
|
+
toggleModal("delete");
|
|
394
371
|
};
|
|
395
372
|
|
|
396
373
|
const handleMoveImage = async (imageID: number, folderID: number | "root") => {
|
|
397
|
-
setIsBulkLoading(true);
|
|
398
374
|
const params = getParams();
|
|
399
375
|
const resetedParams = { ...params, page: firstPage, infinite: false, loading: true };
|
|
400
376
|
const isMoved = await moveImage(imageID, folderID, resetedParams);
|
|
401
377
|
if (isMoved) {
|
|
402
378
|
toggleToast("1 Image moved to a folder");
|
|
403
379
|
}
|
|
404
|
-
setIsBulkLoading(false);
|
|
405
380
|
};
|
|
406
381
|
|
|
407
382
|
const handleBulkMoveFile = async () => {
|
|
408
|
-
setIsBulkLoading(true);
|
|
409
383
|
const params = getParams();
|
|
410
384
|
const resetedParams = { ...params, page: firstPage, infinite: false, loading: true };
|
|
411
385
|
const isMoved = await moveImage(selectedItems.all, selectedFolder || "root", resetedParams);
|
|
412
386
|
if (isMoved) {
|
|
413
|
-
|
|
387
|
+
toggleModal("move");
|
|
414
388
|
toggleToast(`${selectedItems.all.length} Image${selectedItems.all.length > 1 ? "s" : ""} moved to a folder`);
|
|
415
389
|
setSelectedFolder(0);
|
|
416
390
|
resetBulkSelection();
|
|
417
391
|
}
|
|
418
|
-
setIsBulkLoading(false);
|
|
419
392
|
};
|
|
420
393
|
|
|
421
394
|
const handleBulkEditFile = () => {
|
|
@@ -424,13 +397,13 @@ const MediaGallery = (props: IProps) => {
|
|
|
424
397
|
setGalleryItems(selectedItems.all);
|
|
425
398
|
setFileSelected(currentFile);
|
|
426
399
|
setGalleryDelete(false);
|
|
427
|
-
toggleModal();
|
|
400
|
+
toggleModal("imageModal");
|
|
428
401
|
}
|
|
429
402
|
};
|
|
430
403
|
|
|
431
404
|
const handleModalClose = () => {
|
|
432
405
|
setSelectedFolder(0);
|
|
433
|
-
|
|
406
|
+
isOpen("move") && toggleModal("move");
|
|
434
407
|
};
|
|
435
408
|
|
|
436
409
|
const handleSelectFile = (id: number) => {
|
|
@@ -441,11 +414,9 @@ const MediaGallery = (props: IProps) => {
|
|
|
441
414
|
};
|
|
442
415
|
|
|
443
416
|
const handleDownloadBulk = async () => {
|
|
444
|
-
setIsBulkLoading(true);
|
|
445
417
|
const fileName = isSiteView ? `${currentSiteInfo.name}-images.zip` : "global-images.zip";
|
|
446
418
|
await downloadImages(selectedItems.all, true, fileName);
|
|
447
419
|
resetBulkSelection();
|
|
448
|
-
setIsBulkLoading(false);
|
|
449
420
|
};
|
|
450
421
|
|
|
451
422
|
const handleUpdateCurrentFolder = (folderID: number | null) => {
|
|
@@ -486,7 +457,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
486
457
|
{
|
|
487
458
|
icon: "change",
|
|
488
459
|
text: "Move to",
|
|
489
|
-
action:
|
|
460
|
+
action: () => toggleModal("move"),
|
|
490
461
|
},
|
|
491
462
|
];
|
|
492
463
|
}
|
|
@@ -506,7 +477,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
506
477
|
{
|
|
507
478
|
icon: "delete",
|
|
508
479
|
text: "delete",
|
|
509
|
-
action:
|
|
480
|
+
action: () => toggleModal("delete"),
|
|
510
481
|
},
|
|
511
482
|
];
|
|
512
483
|
}
|
|
@@ -521,7 +492,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
521
492
|
bulkActions={bulkActions}
|
|
522
493
|
setHoverCheck={setHoverCheck}
|
|
523
494
|
selectedItems={selectedItems}
|
|
524
|
-
isLoading={
|
|
495
|
+
isLoading={isSaving}
|
|
525
496
|
/>
|
|
526
497
|
);
|
|
527
498
|
|
|
@@ -548,6 +519,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
548
519
|
isAllowedToDelete={allowedToDeleteFile}
|
|
549
520
|
isAllowedToEdit={allowedToEditFile}
|
|
550
521
|
isAllowedToMove={!isRoot || (isRoot && (folders.length > 0 || isSearching))}
|
|
522
|
+
isSaving={isSaving}
|
|
551
523
|
/>
|
|
552
524
|
);
|
|
553
525
|
})}
|
|
@@ -590,6 +562,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
590
562
|
isAllowedToEdit={allowedToEditFile}
|
|
591
563
|
isAllowedToMove={!isRoot || (isRoot && (folders.length > 0 || isSearching))}
|
|
592
564
|
hoverCheck={checkState.hoverCheck}
|
|
565
|
+
isSaving={isSaving}
|
|
593
566
|
/>
|
|
594
567
|
);
|
|
595
568
|
})}
|
|
@@ -600,7 +573,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
600
573
|
const rightButtonProps = allowedToAddFile
|
|
601
574
|
? {
|
|
602
575
|
label: "Upload",
|
|
603
|
-
action: () =>
|
|
576
|
+
action: () => toggleModal("upload"),
|
|
604
577
|
disabled: isUploading,
|
|
605
578
|
}
|
|
606
579
|
: undefined;
|
|
@@ -616,7 +589,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
616
589
|
""
|
|
617
590
|
),
|
|
618
591
|
button: allowedToAddFile ? "Upload image" : undefined,
|
|
619
|
-
action: () =>
|
|
592
|
+
action: () => toggleModal("upload"),
|
|
620
593
|
};
|
|
621
594
|
|
|
622
595
|
const emptySearchStateProps = {
|
|
@@ -625,41 +598,6 @@ const MediaGallery = (props: IProps) => {
|
|
|
625
598
|
message: "We couldn’t find what you are looking for. Please, try another search.",
|
|
626
599
|
};
|
|
627
600
|
|
|
628
|
-
const mainNewModalAction = {
|
|
629
|
-
title: isSaving ? "Saving..." : "Create New Folder",
|
|
630
|
-
onClick: () => handleCreateNewFolder(),
|
|
631
|
-
disabled: folderForm.name.trim().length === 0 || isSaving,
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
const secondaryNewModalAction = { title: "Cancel", onClick: toggleNewModal };
|
|
635
|
-
|
|
636
|
-
const mainDeleteModalAction = {
|
|
637
|
-
title: isBulkLoading ? "Deleting" : "Delete",
|
|
638
|
-
onClick: () => handleBulkDeleteFile(),
|
|
639
|
-
disabled: isBulkLoading,
|
|
640
|
-
};
|
|
641
|
-
|
|
642
|
-
const secondaryDeleteModalAction = { title: "Cancel", onClick: toggleDeleteModal };
|
|
643
|
-
|
|
644
|
-
const mainMoveModalAction = {
|
|
645
|
-
title: "Move",
|
|
646
|
-
onClick: () => handleBulkMoveFile(),
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
const secondaryMoveModalAction = { title: "Cancel", onClick: handleModalClose };
|
|
650
|
-
|
|
651
|
-
const handleMainAction = () => {
|
|
652
|
-
toggleSaveModal();
|
|
653
|
-
resetFileModal();
|
|
654
|
-
};
|
|
655
|
-
|
|
656
|
-
const mainSaveModalAction = {
|
|
657
|
-
title: "Yes, discard changes",
|
|
658
|
-
onClick: () => handleMainAction(),
|
|
659
|
-
};
|
|
660
|
-
|
|
661
|
-
const secondarySaveModalAction = { title: "Cancel", onClick: toggleSaveModal };
|
|
662
|
-
|
|
663
601
|
const foldersIcon = isPanelOpen ? <Icon name="closePanel" size="24" /> : <Icon name="openPanel" size="24" />;
|
|
664
602
|
|
|
665
603
|
const tabs = ["site", "global"];
|
|
@@ -780,7 +718,7 @@ const MediaGallery = (props: IProps) => {
|
|
|
780
718
|
selectItems={selectItems}
|
|
781
719
|
bulkActions={bulkActions}
|
|
782
720
|
selectedItems={selectedItems}
|
|
783
|
-
isLoading={
|
|
721
|
+
isLoading={isSaving}
|
|
784
722
|
/>
|
|
785
723
|
)}
|
|
786
724
|
{!hasFolders && isRoot && !isSearching && <NewFolderButton />}
|
|
@@ -799,18 +737,18 @@ const MediaGallery = (props: IProps) => {
|
|
|
799
737
|
)}
|
|
800
738
|
</S.ContentWrapper>
|
|
801
739
|
</S.Wrapper>
|
|
802
|
-
{
|
|
740
|
+
{isOpen("new") && (
|
|
803
741
|
<NewFolderModal
|
|
804
|
-
isOpen={
|
|
805
|
-
toggleModal={
|
|
806
|
-
mainModalAction={mainNewModalAction}
|
|
807
|
-
secondaryModalAction={secondaryNewModalAction}
|
|
742
|
+
isOpen={isOpen("new")}
|
|
743
|
+
toggleModal={() => toggleModal("new")}
|
|
808
744
|
form={folderForm}
|
|
809
745
|
setForm={setFolderForm}
|
|
746
|
+
onCreateFolder={handleCreateNewFolder}
|
|
747
|
+
isSaving={isSaving}
|
|
810
748
|
/>
|
|
811
749
|
)}
|
|
812
|
-
<Modal isOpen={
|
|
813
|
-
{
|
|
750
|
+
<Modal isOpen={isOpen("upload")} hide={() => toggleModal("upload")} size="XL" title="Upload media">
|
|
751
|
+
{isOpen("upload") && (
|
|
814
752
|
<ImageDragAndDrop
|
|
815
753
|
folderID={currentFolderID}
|
|
816
754
|
handleUpload={handleUpload}
|
|
@@ -820,8 +758,8 @@ const MediaGallery = (props: IProps) => {
|
|
|
820
758
|
/>
|
|
821
759
|
)}
|
|
822
760
|
</Modal>
|
|
823
|
-
<Modal isOpen={isOpen} hide={handleCloseModal} size="XL" title="Image details">
|
|
824
|
-
{isOpen && fileSelected && (
|
|
761
|
+
<Modal isOpen={isOpen("imageModal")} hide={handleCloseModal} size="XL" title="Image details">
|
|
762
|
+
{isOpen("imageModal") && fileSelected && (
|
|
825
763
|
<ImageModal
|
|
826
764
|
image={fileSelected}
|
|
827
765
|
onDelete={handleDeleteFile}
|
|
@@ -839,31 +777,33 @@ const MediaGallery = (props: IProps) => {
|
|
|
839
777
|
/>
|
|
840
778
|
)}
|
|
841
779
|
</Modal>
|
|
842
|
-
{
|
|
780
|
+
{isOpen("delete") && (
|
|
843
781
|
<DeleteFileModal
|
|
844
|
-
isOpen={
|
|
845
|
-
toggleModal={
|
|
846
|
-
mainModalAction={mainDeleteModalAction}
|
|
847
|
-
secondaryModalAction={secondaryDeleteModalAction}
|
|
782
|
+
isOpen={isOpen("delete")}
|
|
783
|
+
toggleModal={() => toggleModal("delete")}
|
|
848
784
|
title="these images"
|
|
785
|
+
onDelete={handleBulkDeleteFile}
|
|
786
|
+
isDeleting={isSaving}
|
|
849
787
|
/>
|
|
850
788
|
)}
|
|
851
|
-
{
|
|
789
|
+
{isOpen("move") && (
|
|
852
790
|
<MoveItemModal
|
|
853
|
-
isOpen={
|
|
791
|
+
isOpen={isOpen("move")}
|
|
854
792
|
toggleModal={handleModalClose}
|
|
855
|
-
mainModalAction={mainMoveModalAction}
|
|
856
|
-
secondaryModalAction={secondaryMoveModalAction}
|
|
857
793
|
folder={selectedFolder}
|
|
858
794
|
setFolder={setSelectedFolder}
|
|
795
|
+
onMove={handleBulkMoveFile}
|
|
796
|
+
isMoving={isSaving}
|
|
859
797
|
/>
|
|
860
798
|
)}
|
|
861
|
-
{
|
|
799
|
+
{isOpen("save") && (
|
|
862
800
|
<NotSavedModal
|
|
863
|
-
isOpen={
|
|
864
|
-
toggleModal={
|
|
865
|
-
|
|
866
|
-
|
|
801
|
+
isOpen={isOpen("save")}
|
|
802
|
+
toggleModal={() => toggleModal("save")}
|
|
803
|
+
onDiscard={() => {
|
|
804
|
+
toggleModal("save");
|
|
805
|
+
resetFileModal();
|
|
806
|
+
}}
|
|
867
807
|
/>
|
|
868
808
|
)}
|
|
869
809
|
{isVisible && <Toast setIsVisible={setIsVisible} message={toastState} />}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { FloatingMenu, Flag, LanguageMenu } from "@ax/components";
|
|
1
|
+
import { Flag, FloatingMenu, LanguageMenu } from "@ax/components";
|
|
2
|
+
import type { ILanguage } from "@ax/types";
|
|
4
3
|
|
|
5
4
|
import * as S from "./style";
|
|
6
|
-
import { ILanguage } from "@ax/types";
|
|
7
5
|
|
|
8
6
|
const LangMenu = (props: IProps) => {
|
|
9
7
|
const { currentLanguages, locale, languages, handleLanguage } = props;
|