@griddo/ax 11.4.24 → 11.5.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.
- package/package.json +2 -2
- package/src/__tests__/components/Fields/ImageField/ImageField.test.tsx +52 -34
- package/src/api/folders.tsx +62 -0
- package/src/api/images.tsx +159 -1
- package/src/api/index.tsx +2 -0
- package/src/api/sites.tsx +1 -1
- package/src/components/Fields/ImageField/index.tsx +7 -6
- package/src/components/Fields/Wysiwyg/index.tsx +5 -3
- package/src/components/FileGallery/index.tsx +22 -16
- package/src/components/FileGallery/style.tsx +18 -4
- package/src/components/Gallery/FolderItem/index.tsx +39 -0
- package/src/components/Gallery/FolderItem/style.tsx +31 -0
- package/src/components/Gallery/GalleryPanel/DetailPanel/index.tsx +112 -237
- package/src/components/Gallery/GalleryPanel/DetailPanel/style.tsx +77 -61
- package/src/components/Gallery/GalleryPanel/index.tsx +37 -32
- package/src/components/Gallery/GalleryPanel/style.tsx +1 -0
- package/src/components/Gallery/index.tsx +267 -163
- package/src/components/Gallery/style.tsx +200 -135
- package/src/components/Loading/index.tsx +7 -2
- package/src/components/Loading/style.tsx +2 -2
- package/src/components/TableFilters/StateFilter/index.tsx +1 -1
- package/src/containers/FileDrive/actions.tsx +1 -2
- package/src/containers/FileDrive/interfaces.tsx +3 -3
- package/src/containers/Gallery/actions.tsx +359 -13
- package/src/containers/Gallery/constants.tsx +12 -0
- package/src/containers/Gallery/interfaces.tsx +44 -1
- package/src/containers/Gallery/reducer.tsx +27 -3
- package/src/containers/Sites/actions.tsx +2 -2
- package/src/containers/Users/actions.tsx +9 -6
- package/src/helpers/files.tsx +37 -1
- package/src/helpers/index.tsx +3 -1
- package/src/modules/App/Routing/NavMenu/NavItem/NavSubItem/style.tsx +7 -2
- package/src/modules/App/Routing/NavMenu/index.tsx +2 -1
- package/src/modules/FileDrive/FileFilters/SortBy/style.tsx +3 -0
- package/src/modules/FileDrive/FileModal/DetailPanel/UsageContent/index.tsx +1 -1
- package/src/modules/FileDrive/FolderTree/MenuItem/index.tsx +14 -10
- package/src/modules/FileDrive/FolderTree/MenuItem/style.tsx +8 -1
- package/src/modules/FileDrive/FolderTree/MenuList/index.tsx +9 -2
- package/src/modules/FileDrive/index.tsx +45 -28
- package/src/modules/FileDrive/style.tsx +7 -6
- package/src/modules/GlobalEditor/index.tsx +1 -1
- package/src/modules/MediaGallery/Breadcrumb/index.tsx +42 -0
- package/src/modules/MediaGallery/Breadcrumb/style.tsx +18 -0
- package/src/modules/MediaGallery/BulkGridHeader/GridHeader/index.tsx +37 -0
- package/src/modules/MediaGallery/BulkGridHeader/GridHeader/style.tsx +19 -0
- package/src/modules/MediaGallery/BulkGridHeader/index.tsx +35 -0
- package/src/modules/MediaGallery/BulkGridHeader/style.tsx +17 -0
- package/src/modules/MediaGallery/BulkListHeader/TableHeader/index.tsx +46 -0
- package/src/modules/MediaGallery/BulkListHeader/TableHeader/style.tsx +53 -0
- package/src/modules/MediaGallery/BulkListHeader/index.tsx +42 -0
- package/src/modules/MediaGallery/BulkListHeader/style.tsx +17 -0
- package/src/modules/MediaGallery/FolderItem/index.tsx +191 -0
- package/src/modules/MediaGallery/FolderItem/style.tsx +39 -0
- package/src/modules/MediaGallery/FolderTree/MenuItem/index.tsx +87 -0
- package/src/modules/MediaGallery/FolderTree/MenuItem/style.tsx +76 -0
- package/src/modules/MediaGallery/FolderTree/MenuList/index.tsx +34 -0
- package/src/modules/MediaGallery/FolderTree/index.tsx +62 -0
- package/src/modules/MediaGallery/FolderTree/style.tsx +49 -0
- package/src/modules/MediaGallery/GridItem/index.tsx +149 -0
- package/src/modules/MediaGallery/GridItem/style.tsx +74 -0
- package/src/modules/MediaGallery/ImageDragAndDrop/index.tsx +299 -0
- package/src/{components/Gallery/GalleryPanel/GalleryDragAndDrop → modules/MediaGallery/ImageDragAndDrop}/style.tsx +114 -33
- package/src/{components/Gallery/GalleryFilters → modules/MediaGallery/ImageFilters}/Orientation/style.tsx +2 -1
- package/src/{components/Gallery/GalleryFilters → modules/MediaGallery/ImageFilters}/SortBy/style.tsx +3 -0
- package/src/{components/Gallery/GalleryFilters → modules/MediaGallery/ImageFilters}/Type/style.tsx +1 -0
- package/src/modules/MediaGallery/ImageFilters/Usage/index.tsx +75 -0
- package/src/modules/MediaGallery/ImageFilters/Usage/style.tsx +30 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/Item/index.tsx +35 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/Item/style.tsx +43 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/ItemGroup/index.tsx +44 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/ItemGroup/style.tsx +34 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/index.tsx +233 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/UsageContent/style.tsx +21 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/index.tsx +209 -0
- package/src/modules/MediaGallery/ImageModal/DetailPanel/style.tsx +81 -0
- package/src/modules/MediaGallery/ImageModal/index.tsx +168 -0
- package/src/modules/MediaGallery/ImageModal/style.tsx +106 -0
- package/src/modules/MediaGallery/ListItem/index.tsx +181 -0
- package/src/modules/MediaGallery/ListItem/style.tsx +100 -0
- package/src/modules/MediaGallery/UploadItem/index.tsx +32 -0
- package/src/modules/MediaGallery/UploadItem/style.tsx +42 -0
- package/src/modules/MediaGallery/atoms.tsx +196 -0
- package/src/{components/Gallery → modules/MediaGallery}/hooks.tsx +10 -4
- package/src/modules/MediaGallery/index.tsx +892 -0
- package/src/modules/MediaGallery/style.tsx +216 -0
- package/src/{components/Gallery → modules/MediaGallery}/utils.tsx +1 -1
- package/src/modules/StructuredData/Form/index.tsx +2 -2
- package/src/routes/multisite.tsx +24 -4
- package/src/routes/site.tsx +24 -4
- package/src/types/files.tsx +98 -0
- package/src/types/index.tsx +33 -91
- package/src/__tests__/components/Gallery/Gallery.test.tsx +0 -559
- package/src/__tests__/components/Gallery/GalleryFilters/Orientation/Orientation.test.tsx +0 -54
- package/src/__tests__/components/Gallery/GalleryFilters/SortBy/SortBy.test.tsx +0 -118
- package/src/__tests__/components/Gallery/GalleryFilters/Type/Type.test.tsx +0 -54
- package/src/__tests__/components/Gallery/GalleryPanel/DetailPanel/DetailPanel.test.tsx +0 -869
- package/src/__tests__/components/Gallery/GalleryPanel/GalleryDragAndDrop/GalleryDragAndDrop.test.tsx +0 -249
- package/src/__tests__/components/Gallery/GalleryPanel/GalleryPanel.test.tsx +0 -55
- package/src/components/Gallery/GalleryPanel/GalleryDragAndDrop/index.tsx +0 -239
- package/src/containers/FileDrive/utils.tsx +0 -37
- /package/src/{components/Gallery/GalleryFilters → modules/MediaGallery/ImageFilters}/Orientation/index.tsx +0 -0
- /package/src/{components/Gallery/GalleryFilters → modules/MediaGallery/ImageFilters}/SortBy/index.tsx +0 -0
- /package/src/{components/Gallery/GalleryFilters → modules/MediaGallery/ImageFilters}/Type/index.tsx +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "11.
|
|
4
|
+
"version": "11.5.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Diego M. Béjar <diego.bejar@secuoyas.com>",
|
|
@@ -224,5 +224,5 @@
|
|
|
224
224
|
"publishConfig": {
|
|
225
225
|
"access": "public"
|
|
226
226
|
},
|
|
227
|
-
"gitHead": "
|
|
227
|
+
"gitHead": "cf3db6035618b29bb1bf2a0b650e8be3199605ad"
|
|
228
228
|
}
|
|
@@ -6,7 +6,7 @@ import { ThemeProvider } from "styled-components";
|
|
|
6
6
|
import { mock } from "jest-mock-extended";
|
|
7
7
|
import thunk from "redux-thunk";
|
|
8
8
|
|
|
9
|
-
import { render, screen, cleanup, fireEvent } from "../../../../../config/jest/test-utils";
|
|
9
|
+
import { render, screen, cleanup, fireEvent, act } from "../../../../../config/jest/test-utils";
|
|
10
10
|
|
|
11
11
|
import ImageField, { IImageFieldProps } from "@ax/components/Fields/ImageField";
|
|
12
12
|
import { parseTheme } from "@ax/helpers";
|
|
@@ -35,13 +35,6 @@ const defaultProps = mock<IImageFieldProps>();
|
|
|
35
35
|
const initialStore = {
|
|
36
36
|
...defaultStore,
|
|
37
37
|
gallery: {
|
|
38
|
-
data: {
|
|
39
|
-
items: [],
|
|
40
|
-
isImageSelected: false,
|
|
41
|
-
imageSelected: null,
|
|
42
|
-
page: 1,
|
|
43
|
-
isFinished: false,
|
|
44
|
-
},
|
|
45
38
|
isLoading: {
|
|
46
39
|
init: false,
|
|
47
40
|
more: false,
|
|
@@ -55,6 +48,12 @@ const initialStore = {
|
|
|
55
48
|
isSuccess: false,
|
|
56
49
|
isError: false,
|
|
57
50
|
errorMsg: "",
|
|
51
|
+
currentFolderContent: null,
|
|
52
|
+
currentFolderID: null,
|
|
53
|
+
breadcrumb: [],
|
|
54
|
+
foldersTree: [],
|
|
55
|
+
displayMode: "grid",
|
|
56
|
+
selectedTab: "site",
|
|
58
57
|
},
|
|
59
58
|
};
|
|
60
59
|
|
|
@@ -93,7 +92,8 @@ describe("ImageField component rendering", () => {
|
|
|
93
92
|
width: 1444,
|
|
94
93
|
height: 640,
|
|
95
94
|
orientation: "L",
|
|
96
|
-
site:
|
|
95
|
+
site: null,
|
|
96
|
+
folderId: null,
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
defaultProps.selectedContent = {
|
|
@@ -120,6 +120,7 @@ describe("ImageField component rendering", () => {
|
|
|
120
120
|
height: 353,
|
|
121
121
|
orientation: "L",
|
|
122
122
|
site: 113,
|
|
123
|
+
folderId: null,
|
|
123
124
|
},
|
|
124
125
|
};
|
|
125
126
|
|
|
@@ -137,7 +138,7 @@ describe("ImageField component rendering", () => {
|
|
|
137
138
|
expect(screen.getByTestId("previewDiv")).toBeVisible();
|
|
138
139
|
});
|
|
139
140
|
|
|
140
|
-
it("should render the component with image with no url attr", () => {
|
|
141
|
+
it("should render the component with image with no url attr", async () => {
|
|
141
142
|
defaultProps.value = "image.png";
|
|
142
143
|
|
|
143
144
|
defaultProps.selectedContent = {
|
|
@@ -164,14 +165,17 @@ describe("ImageField component rendering", () => {
|
|
|
164
165
|
height: 353,
|
|
165
166
|
orientation: "L",
|
|
166
167
|
site: 113,
|
|
168
|
+
folderId: null,
|
|
167
169
|
},
|
|
168
170
|
};
|
|
169
171
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
<
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
await act(async () =>
|
|
173
|
+
render(
|
|
174
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
175
|
+
<ImageField {...defaultProps} />
|
|
176
|
+
</ThemeProvider>,
|
|
177
|
+
{ store }
|
|
178
|
+
)
|
|
175
179
|
);
|
|
176
180
|
|
|
177
181
|
expect(screen.getByTestId("fieldWrapper")).toBeTruthy();
|
|
@@ -179,7 +183,7 @@ describe("ImageField component rendering", () => {
|
|
|
179
183
|
expect(screen.getByTestId("previewDiv")).toBeVisible();
|
|
180
184
|
});
|
|
181
185
|
|
|
182
|
-
it("should render the component with no image", () => {
|
|
186
|
+
it("should render the component with no image", async () => {
|
|
183
187
|
defaultProps.value = null;
|
|
184
188
|
|
|
185
189
|
defaultProps.selectedContent = {
|
|
@@ -206,14 +210,17 @@ describe("ImageField component rendering", () => {
|
|
|
206
210
|
height: 353,
|
|
207
211
|
orientation: "L",
|
|
208
212
|
site: 113,
|
|
213
|
+
folderId: null,
|
|
209
214
|
},
|
|
210
215
|
};
|
|
211
216
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
<
|
|
215
|
-
|
|
216
|
-
|
|
217
|
+
await act(async () =>
|
|
218
|
+
render(
|
|
219
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
220
|
+
<ImageField {...defaultProps} />
|
|
221
|
+
</ThemeProvider>,
|
|
222
|
+
{ store }
|
|
223
|
+
)
|
|
217
224
|
);
|
|
218
225
|
|
|
219
226
|
expect(screen.getByTestId("fieldWrapper")).toBeTruthy();
|
|
@@ -221,7 +228,7 @@ describe("ImageField component rendering", () => {
|
|
|
221
228
|
expect(screen.getByTestId("previewDiv")).not.toBeVisible();
|
|
222
229
|
});
|
|
223
230
|
|
|
224
|
-
it("should render the component with image with undefined", () => {
|
|
231
|
+
it("should render the component with image with undefined", async () => {
|
|
225
232
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
226
233
|
// @ts-ignore
|
|
227
234
|
defaultProps.value = undefined;
|
|
@@ -250,14 +257,17 @@ describe("ImageField component rendering", () => {
|
|
|
250
257
|
height: 353,
|
|
251
258
|
orientation: "L",
|
|
252
259
|
site: 113,
|
|
260
|
+
folderId: null,
|
|
253
261
|
},
|
|
254
262
|
};
|
|
255
263
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
<
|
|
259
|
-
|
|
260
|
-
|
|
264
|
+
await act(async () =>
|
|
265
|
+
render(
|
|
266
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
267
|
+
<ImageField {...defaultProps} />
|
|
268
|
+
</ThemeProvider>,
|
|
269
|
+
{ store }
|
|
270
|
+
)
|
|
261
271
|
);
|
|
262
272
|
|
|
263
273
|
expect(screen.getByTestId("fieldWrapper")).toBeTruthy();
|
|
@@ -267,7 +277,7 @@ describe("ImageField component rendering", () => {
|
|
|
267
277
|
});
|
|
268
278
|
|
|
269
279
|
describe("ImageField triggers", () => {
|
|
270
|
-
it("should handle the onClick", () => {
|
|
280
|
+
it("should handle the onClick", async () => {
|
|
271
281
|
defaultProps.value = {
|
|
272
282
|
id: 857,
|
|
273
283
|
name: ".png",
|
|
@@ -284,7 +294,8 @@ describe("ImageField triggers", () => {
|
|
|
284
294
|
width: 1444,
|
|
285
295
|
height: 640,
|
|
286
296
|
orientation: "L",
|
|
287
|
-
site:
|
|
297
|
+
site: null,
|
|
298
|
+
folderId: null,
|
|
288
299
|
};
|
|
289
300
|
|
|
290
301
|
defaultProps.selectedContent = {
|
|
@@ -311,10 +322,12 @@ describe("ImageField triggers", () => {
|
|
|
311
322
|
height: 353,
|
|
312
323
|
orientation: "L",
|
|
313
324
|
site: 113,
|
|
325
|
+
folderId: null,
|
|
314
326
|
},
|
|
315
327
|
};
|
|
316
328
|
const setIsGalleryMock = defaultProps.setIsGalleryOpened as jest.MockedFunction<() => void>;
|
|
317
329
|
defaultProps.disabled = false;
|
|
330
|
+
|
|
318
331
|
render(
|
|
319
332
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
320
333
|
<ImageField {...defaultProps} />
|
|
@@ -325,7 +338,8 @@ describe("ImageField triggers", () => {
|
|
|
325
338
|
const fieldWrapperAction = screen.getByTestId("fieldWrapper");
|
|
326
339
|
expect(fieldWrapperAction).toBeTruthy();
|
|
327
340
|
|
|
328
|
-
fireEvent.click(fieldWrapperAction);
|
|
341
|
+
await act(async () => fireEvent.click(fieldWrapperAction));
|
|
342
|
+
|
|
329
343
|
expect(setIsGalleryMock).toBeCalled();
|
|
330
344
|
});
|
|
331
345
|
|
|
@@ -346,7 +360,8 @@ describe("ImageField triggers", () => {
|
|
|
346
360
|
width: 1444,
|
|
347
361
|
height: 640,
|
|
348
362
|
orientation: "L",
|
|
349
|
-
site:
|
|
363
|
+
site: null,
|
|
364
|
+
folderId: null,
|
|
350
365
|
};
|
|
351
366
|
|
|
352
367
|
defaultProps.selectedContent = {
|
|
@@ -373,6 +388,7 @@ describe("ImageField triggers", () => {
|
|
|
373
388
|
height: 353,
|
|
374
389
|
orientation: "L",
|
|
375
390
|
site: 113,
|
|
391
|
+
folderId: null,
|
|
376
392
|
},
|
|
377
393
|
};
|
|
378
394
|
const onChangeMock = defaultProps.onChange as jest.MockedFunction<(value: any) => void>;
|
|
@@ -401,7 +417,7 @@ describe("ImageField triggers", () => {
|
|
|
401
417
|
expect(previewDiv).not.toBeVisible();
|
|
402
418
|
});
|
|
403
419
|
|
|
404
|
-
it("should handle the change action", () => {
|
|
420
|
+
it("should handle the change action", async () => {
|
|
405
421
|
defaultProps.value = {
|
|
406
422
|
id: 857,
|
|
407
423
|
name: ".png",
|
|
@@ -418,7 +434,8 @@ describe("ImageField triggers", () => {
|
|
|
418
434
|
width: 1444,
|
|
419
435
|
height: 640,
|
|
420
436
|
orientation: "L",
|
|
421
|
-
site:
|
|
437
|
+
site: null,
|
|
438
|
+
folderId: null,
|
|
422
439
|
};
|
|
423
440
|
|
|
424
441
|
defaultProps.selectedContent = {
|
|
@@ -445,6 +462,7 @@ describe("ImageField triggers", () => {
|
|
|
445
462
|
height: 353,
|
|
446
463
|
orientation: "L",
|
|
447
464
|
site: 113,
|
|
465
|
+
folderId: null,
|
|
448
466
|
},
|
|
449
467
|
};
|
|
450
468
|
const setIsGalleryMock = defaultProps.setIsGalleryOpened as jest.MockedFunction<() => void>;
|
|
@@ -459,7 +477,7 @@ describe("ImageField triggers", () => {
|
|
|
459
477
|
const iconActions = screen.getAllByTestId("icon-action-component");
|
|
460
478
|
expect(iconActions).toHaveLength(2);
|
|
461
479
|
|
|
462
|
-
fireEvent.click(iconActions[0]);
|
|
480
|
+
await act(async () => fireEvent.click(iconActions[0]));
|
|
463
481
|
expect(setIsGalleryMock).toBeCalled();
|
|
464
482
|
|
|
465
483
|
rerender(
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { template } from "./config";
|
|
2
|
+
import { IServiceConfig, sendRequest } from "./utils";
|
|
3
|
+
|
|
4
|
+
const SERVICES: { [key: string]: IServiceConfig } = {
|
|
5
|
+
CREATE_FOLDER: {
|
|
6
|
+
...template,
|
|
7
|
+
endpoint: "/folders",
|
|
8
|
+
method: "POST",
|
|
9
|
+
},
|
|
10
|
+
UPDATE_FOLDER: {
|
|
11
|
+
...template,
|
|
12
|
+
endpoint: "/folders/",
|
|
13
|
+
method: "PUT",
|
|
14
|
+
},
|
|
15
|
+
DELETE_FOLDER: {
|
|
16
|
+
...template,
|
|
17
|
+
endpoint: ["/folders/", "/type/"],
|
|
18
|
+
method: "DELETE",
|
|
19
|
+
},
|
|
20
|
+
DELETE_FOLDER_BULK: {
|
|
21
|
+
...template,
|
|
22
|
+
endpoint: "/folders/bulk",
|
|
23
|
+
method: "DELETE",
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const createFolder = async (data: {
|
|
28
|
+
type: "images" | "files";
|
|
29
|
+
folderName: string;
|
|
30
|
+
site: number | null;
|
|
31
|
+
parentId: number | null;
|
|
32
|
+
}) => {
|
|
33
|
+
return sendRequest(SERVICES.CREATE_FOLDER, data);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const updateFolder = async (folderID: number, data: { parentId: number; folderName: string }) => {
|
|
37
|
+
const { host, endpoint } = SERVICES.UPDATE_FOLDER;
|
|
38
|
+
SERVICES.UPDATE_FOLDER.dynamicUrl = `${host}${endpoint}${folderID}`;
|
|
39
|
+
|
|
40
|
+
return sendRequest(SERVICES.UPDATE_FOLDER, data);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const deleteFolder = async (folderID: number, type: "images" | "files") => {
|
|
44
|
+
const {
|
|
45
|
+
host,
|
|
46
|
+
endpoint: [prefix, suffix],
|
|
47
|
+
} = SERVICES.DELETE_FOLDER;
|
|
48
|
+
SERVICES.DELETE_FOLDER.dynamicUrl = `${host}${prefix}${folderID}${suffix}${type}`;
|
|
49
|
+
|
|
50
|
+
return sendRequest(SERVICES.DELETE_FOLDER);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const deleteFolderBulk = async (ids: number[]) => {
|
|
54
|
+
return sendRequest(SERVICES.DELETE_FOLDER_BULK, { ids });
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
createFolder,
|
|
59
|
+
updateFolder,
|
|
60
|
+
deleteFolder,
|
|
61
|
+
deleteFolderBulk,
|
|
62
|
+
};
|
package/src/api/images.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { encodeData } from "@ax/helpers";
|
|
1
2
|
import { template } from "./config";
|
|
2
3
|
import { IServiceConfig, sendRequest, sendUploadRequest } from "./utils";
|
|
4
|
+
import { IGetFolderParams } from "@ax/types";
|
|
3
5
|
|
|
4
6
|
const SERVICES: { [key: string]: IServiceConfig } = {
|
|
5
7
|
CREATE_IMAGE: {
|
|
@@ -22,11 +24,52 @@ const SERVICES: { [key: string]: IServiceConfig } = {
|
|
|
22
24
|
endpoint: "/image/",
|
|
23
25
|
method: "DELETE",
|
|
24
26
|
},
|
|
27
|
+
DELETE_IMAGE_BULK: {
|
|
28
|
+
...template,
|
|
29
|
+
endpoint: "/image/bulk",
|
|
30
|
+
method: "DELETE",
|
|
31
|
+
},
|
|
25
32
|
CREATE_THUMBNAIL: {
|
|
26
33
|
...template,
|
|
27
34
|
endpoint: ["/thumbnail/contentId/", "/contentType/"],
|
|
28
35
|
method: "POST",
|
|
29
36
|
},
|
|
37
|
+
GET_IMAGES_FOLDER: {
|
|
38
|
+
...template,
|
|
39
|
+
endpoint: ["/images/site/", "/folder"],
|
|
40
|
+
method: "GET",
|
|
41
|
+
},
|
|
42
|
+
GET_IMAGES_FOLDER_TREE: {
|
|
43
|
+
...template,
|
|
44
|
+
endpoint: ["/images/site/", "/folder/tree"],
|
|
45
|
+
method: "GET",
|
|
46
|
+
},
|
|
47
|
+
MOVE_IMAGE: {
|
|
48
|
+
...template,
|
|
49
|
+
endpoint: ["/image/", "/folder/"],
|
|
50
|
+
method: "PUT",
|
|
51
|
+
},
|
|
52
|
+
MOVE_IMAGE_BULK: {
|
|
53
|
+
...template,
|
|
54
|
+
endpoint: "/image/bulk/folder/",
|
|
55
|
+
method: "PUT",
|
|
56
|
+
},
|
|
57
|
+
DOWNLOAD_IMAGES: {
|
|
58
|
+
...template,
|
|
59
|
+
endpoint: "/image/downloads/",
|
|
60
|
+
method: "POST",
|
|
61
|
+
responseType: "blob",
|
|
62
|
+
},
|
|
63
|
+
IMAGE_IN_USE: {
|
|
64
|
+
...template,
|
|
65
|
+
endpoint: ["/image/", "/inuse/"],
|
|
66
|
+
method: "GET",
|
|
67
|
+
},
|
|
68
|
+
IMAGE_REPLACE: {
|
|
69
|
+
...template,
|
|
70
|
+
endpoint: ["/image/", "/replace"],
|
|
71
|
+
method: "PUT",
|
|
72
|
+
},
|
|
30
73
|
};
|
|
31
74
|
|
|
32
75
|
const createImage = async (data: FormData, setProgress?: (progress: number) => void) => {
|
|
@@ -54,6 +97,8 @@ const deleteImage = async (imageID: number) => {
|
|
|
54
97
|
return sendRequest(SERVICES.DELETE_IMAGE);
|
|
55
98
|
};
|
|
56
99
|
|
|
100
|
+
const deleteImageBulk = async (ids: number[]) => sendRequest(SERVICES.DELETE_IMAGE_BULK, { ids });
|
|
101
|
+
|
|
57
102
|
const createThumbnail = async (contentID: number, contentType: "form" | "navigation", data: FormData) => {
|
|
58
103
|
const {
|
|
59
104
|
host,
|
|
@@ -64,4 +109,117 @@ const createThumbnail = async (contentID: number, contentType: "form" | "navigat
|
|
|
64
109
|
return sendRequest(SERVICES.CREATE_THUMBNAIL, data);
|
|
65
110
|
};
|
|
66
111
|
|
|
67
|
-
|
|
112
|
+
const getImagesFolderContent = async (params: IGetFolderParams) => {
|
|
113
|
+
const {
|
|
114
|
+
host,
|
|
115
|
+
endpoint: [prefix, suffix],
|
|
116
|
+
} = SERVICES.GET_IMAGES_FOLDER;
|
|
117
|
+
|
|
118
|
+
const {
|
|
119
|
+
siteID,
|
|
120
|
+
folderID,
|
|
121
|
+
search,
|
|
122
|
+
thumbHeight = 188,
|
|
123
|
+
thumbWidth,
|
|
124
|
+
pagination,
|
|
125
|
+
page,
|
|
126
|
+
itemsPerPage,
|
|
127
|
+
query: filters = "",
|
|
128
|
+
} = params;
|
|
129
|
+
|
|
130
|
+
const data = {
|
|
131
|
+
...(folderID && { folder: folderID }),
|
|
132
|
+
...(search && { search }),
|
|
133
|
+
...(thumbWidth && { thumbWidth }),
|
|
134
|
+
...(thumbHeight && { thumbHeight }),
|
|
135
|
+
...(pagination && { pagination }),
|
|
136
|
+
...(page && { page }),
|
|
137
|
+
...(itemsPerPage && { itemsPerPage }),
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const queryParams = encodeData(data);
|
|
141
|
+
const queryFilters = filters.length ? `${queryParams}&${filters}` : queryParams;
|
|
142
|
+
const query = queryFilters.length ? `?${queryFilters}` : "";
|
|
143
|
+
|
|
144
|
+
SERVICES.GET_IMAGES_FOLDER.dynamicUrl = `${host}${prefix}${siteID}${suffix}${query}`;
|
|
145
|
+
|
|
146
|
+
return sendRequest(SERVICES.GET_IMAGES_FOLDER);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const getFoldersTree = async (siteID: number | "global") => {
|
|
150
|
+
const {
|
|
151
|
+
host,
|
|
152
|
+
endpoint: [prefix, suffix],
|
|
153
|
+
} = SERVICES.GET_IMAGES_FOLDER_TREE;
|
|
154
|
+
|
|
155
|
+
SERVICES.GET_IMAGES_FOLDER_TREE.dynamicUrl = `${host}${prefix}${siteID}${suffix}`;
|
|
156
|
+
|
|
157
|
+
return sendRequest(SERVICES.GET_IMAGES_FOLDER_TREE);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const moveImage = async (imageID: number, folderID: number | "root") => {
|
|
161
|
+
const {
|
|
162
|
+
host,
|
|
163
|
+
endpoint: [prefix, suffix],
|
|
164
|
+
} = SERVICES.MOVE_IMAGE;
|
|
165
|
+
|
|
166
|
+
SERVICES.MOVE_IMAGE.dynamicUrl = `${host}${prefix}${imageID}${suffix}${folderID}`;
|
|
167
|
+
|
|
168
|
+
return sendRequest(SERVICES.MOVE_IMAGE);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const moveImageBulk = async (ids: number[], folderID: number | "root") => {
|
|
172
|
+
const { host, endpoint } = SERVICES.MOVE_IMAGE_BULK;
|
|
173
|
+
|
|
174
|
+
SERVICES.MOVE_IMAGE_BULK.dynamicUrl = `${host}${endpoint}${folderID}`;
|
|
175
|
+
|
|
176
|
+
return sendRequest(SERVICES.MOVE_IMAGE_BULK, { ids });
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const downloadImages = async (imageID: number | number[], zip: boolean) => {
|
|
180
|
+
const { host, endpoint } = SERVICES.DOWNLOAD_IMAGES;
|
|
181
|
+
|
|
182
|
+
const query = zip ? "?zip=on" : "";
|
|
183
|
+
|
|
184
|
+
SERVICES.DOWNLOAD_IMAGES.dynamicUrl = `${host}${endpoint}${imageID}${query}`;
|
|
185
|
+
|
|
186
|
+
return sendRequest(SERVICES.DOWNLOAD_IMAGES);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const getImageInUse = async (imageID: number) => {
|
|
190
|
+
const {
|
|
191
|
+
host,
|
|
192
|
+
endpoint: [prefix, suffix],
|
|
193
|
+
} = SERVICES.IMAGE_IN_USE;
|
|
194
|
+
|
|
195
|
+
SERVICES.IMAGE_IN_USE.dynamicUrl = `${host}${prefix}${imageID}${suffix}`;
|
|
196
|
+
|
|
197
|
+
return sendRequest(SERVICES.IMAGE_IN_USE);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const replaceImage = async (data: FormData, imageID: number, setProgress?: (progress: number) => void) => {
|
|
201
|
+
const {
|
|
202
|
+
host,
|
|
203
|
+
endpoint: [prefix, suffix],
|
|
204
|
+
} = SERVICES.IMAGE_REPLACE;
|
|
205
|
+
|
|
206
|
+
SERVICES.IMAGE_REPLACE.dynamicUrl = `${host}${prefix}${imageID}${suffix}`;
|
|
207
|
+
|
|
208
|
+
return sendUploadRequest(SERVICES.IMAGE_REPLACE, data, setProgress);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export default {
|
|
212
|
+
createImage,
|
|
213
|
+
getImageInfo,
|
|
214
|
+
updateImage,
|
|
215
|
+
deleteImage,
|
|
216
|
+
deleteImageBulk,
|
|
217
|
+
createThumbnail,
|
|
218
|
+
getImagesFolderContent,
|
|
219
|
+
getFoldersTree,
|
|
220
|
+
moveImage,
|
|
221
|
+
moveImageBulk,
|
|
222
|
+
downloadImages,
|
|
223
|
+
getImageInUse,
|
|
224
|
+
replaceImage,
|
|
225
|
+
};
|
package/src/api/index.tsx
CHANGED
|
@@ -19,6 +19,7 @@ import analytics from "./analytics";
|
|
|
19
19
|
import roles from "./roles";
|
|
20
20
|
import integrations from "./integrations";
|
|
21
21
|
import forms from "./forms";
|
|
22
|
+
import folders from "./folders";
|
|
22
23
|
|
|
23
24
|
export {
|
|
24
25
|
sites,
|
|
@@ -42,4 +43,5 @@ export {
|
|
|
42
43
|
roles,
|
|
43
44
|
integrations,
|
|
44
45
|
forms,
|
|
46
|
+
folders,
|
|
45
47
|
};
|
package/src/api/sites.tsx
CHANGED
|
@@ -304,7 +304,7 @@ const getSitePagesLight = async (params: IGetSitePagesParams): Promise<AxiosResp
|
|
|
304
304
|
};
|
|
305
305
|
|
|
306
306
|
const getSiteImages = async (
|
|
307
|
-
site: number |
|
|
307
|
+
site: number | "global",
|
|
308
308
|
page: number,
|
|
309
309
|
itemsPerPage: number | null,
|
|
310
310
|
thumbWidth?: number,
|
|
@@ -4,7 +4,7 @@ import { Icon, IconAction, Gallery, Modal, Image, FieldsBehavior } from "@ax/com
|
|
|
4
4
|
import { formatBytes, getFormattedDateWithTimezone } from "@ax/helpers";
|
|
5
5
|
import { IImage, ISite } from "@ax/types";
|
|
6
6
|
import { useModal } from "@ax/hooks";
|
|
7
|
-
import
|
|
7
|
+
import ImageDragAndDrop from "@ax/modules/MediaGallery/ImageDragAndDrop";
|
|
8
8
|
|
|
9
9
|
import * as S from "./style";
|
|
10
10
|
|
|
@@ -111,6 +111,8 @@ const ImageField = (props: IImageFieldProps) => {
|
|
|
111
111
|
isImage(value) && onChange({ ...value, alt: altValue });
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
+
const handleUpload = (file: IImage[]) => getImageSelected(file[0]);
|
|
115
|
+
|
|
114
116
|
return (
|
|
115
117
|
<>
|
|
116
118
|
<S.FieldWrapper
|
|
@@ -179,12 +181,11 @@ const ImageField = (props: IImageFieldProps) => {
|
|
|
179
181
|
<Gallery getImageSelected={getImageSelected} toggleModal={toggleModal} site={site} />
|
|
180
182
|
</Modal>
|
|
181
183
|
<Modal isOpen={isOpenDD} hide={toggleModalDD} size="M" title="Upload Media">
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
allowUpload={true}
|
|
186
|
-
selectImage={getImageSelected}
|
|
184
|
+
<ImageDragAndDrop
|
|
185
|
+
siteID={site ? site.id : "global"}
|
|
186
|
+
isAllowedToUpload={true}
|
|
187
187
|
validFormats={validFormats}
|
|
188
|
+
handleUpload={handleUpload}
|
|
188
189
|
visible={false}
|
|
189
190
|
/>
|
|
190
191
|
</Modal>
|
|
@@ -57,8 +57,10 @@ const Wysiwyg = (props: IWysiwygProps): JSX.Element => {
|
|
|
57
57
|
"image.beforeUpload": async function (images: FileList) {
|
|
58
58
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
59
59
|
const editor: any = this;
|
|
60
|
-
const
|
|
61
|
-
|
|
60
|
+
const result = await uploadImage(images[0], imageSite);
|
|
61
|
+
if (result) {
|
|
62
|
+
editor.image.insert(result.url, true, null, editor.image.get(), null);
|
|
63
|
+
}
|
|
62
64
|
return false;
|
|
63
65
|
},
|
|
64
66
|
blur: function () {
|
|
@@ -100,7 +102,7 @@ const mapStateToProps = (state: IRootState) => ({
|
|
|
100
102
|
});
|
|
101
103
|
|
|
102
104
|
interface IDispatchProps {
|
|
103
|
-
uploadImage: (imageFile: File, site: number | string) => Promise<IImage>;
|
|
105
|
+
uploadImage: (imageFile: File, site: number | string) => Promise<IImage | null>;
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
const mapDispatchToProps = {
|
|
@@ -79,20 +79,20 @@ const FileGallery = (props: IProps): JSX.Element => {
|
|
|
79
79
|
const allowedToAddSiteFile = usePermission("mediaGallery.addFiles");
|
|
80
80
|
const allowedToAddGlobalFile = usePermission("global.mediaGallery.addGlobalFiles");
|
|
81
81
|
const allowedToAddGlobalFileFromSite = usePermission("mediaGallery.addGlobalFilesFromSite");
|
|
82
|
-
const allowedToAddFile =
|
|
83
|
-
?
|
|
84
|
-
:
|
|
85
|
-
?
|
|
86
|
-
:
|
|
82
|
+
const allowedToAddFile = !isSiteView
|
|
83
|
+
? allowedToAddGlobalFile
|
|
84
|
+
: isTabGlobal
|
|
85
|
+
? allowedToAddGlobalFileFromSite
|
|
86
|
+
: allowedToAddSiteFile;
|
|
87
87
|
|
|
88
88
|
const allowedToEditSiteFile = usePermission("mediaGallery.editFilesss");
|
|
89
89
|
const allowedToEditGlobalFile = usePermission("global.mediaGallery.editGlobalFiles");
|
|
90
90
|
const allowedToEditGlobalFileFromSite = usePermission("mediaGallery.editGlobalFilesInSite");
|
|
91
|
-
const allowedToEditFile =
|
|
92
|
-
?
|
|
93
|
-
:
|
|
94
|
-
?
|
|
95
|
-
:
|
|
91
|
+
const allowedToEditFile = !isSiteView
|
|
92
|
+
? allowedToEditGlobalFile
|
|
93
|
+
: isTabGlobal
|
|
94
|
+
? allowedToEditGlobalFileFromSite
|
|
95
|
+
: allowedToEditSiteFile;
|
|
96
96
|
|
|
97
97
|
const tabs: string[] = [];
|
|
98
98
|
if (isSiteView && allowedToAccessGlobalFromSite) {
|
|
@@ -109,12 +109,13 @@ const FileGallery = (props: IProps): JSX.Element => {
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
return params;
|
|
112
|
-
}, [currentFolderID, searchQuery,
|
|
112
|
+
}, [currentFolderID, searchQuery, filterQuery, siteID]);
|
|
113
113
|
|
|
114
114
|
useLayoutEffect(() => {
|
|
115
115
|
return () => {
|
|
116
116
|
updateCurrentFolder(null);
|
|
117
117
|
};
|
|
118
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
118
119
|
}, []);
|
|
119
120
|
|
|
120
121
|
useEffect(() => {
|
|
@@ -126,7 +127,7 @@ const FileGallery = (props: IProps): JSX.Element => {
|
|
|
126
127
|
};
|
|
127
128
|
handleGetContent();
|
|
128
129
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
|
-
}, [getParams]);
|
|
130
|
+
}, [getParams, selectedTab]);
|
|
130
131
|
|
|
131
132
|
useEffect(() => {
|
|
132
133
|
const handleGetTree = async () => await getFoldersTree(siteID);
|
|
@@ -192,6 +193,13 @@ const FileGallery = (props: IProps): JSX.Element => {
|
|
|
192
193
|
message: "No documents found in this folder.",
|
|
193
194
|
};
|
|
194
195
|
|
|
196
|
+
const filters = (
|
|
197
|
+
<>
|
|
198
|
+
<Type filterItems={filterItems} value={filterValues["filterType"]} />
|
|
199
|
+
<SortBy sortItems={sortItems} sortedState={sortedListStatus} />
|
|
200
|
+
</>
|
|
201
|
+
);
|
|
202
|
+
|
|
195
203
|
return (
|
|
196
204
|
<S.Wrapper data-testid="file-gallery-wrapper">
|
|
197
205
|
<S.FolderPanel isOpen={isPanelOpen} ref={ref}>
|
|
@@ -208,13 +216,11 @@ const FileGallery = (props: IProps): JSX.Element => {
|
|
|
208
216
|
<Tabs tabs={tabs} active={selectedTab} setSelectedTab={handleSelectedTab} noMargins />
|
|
209
217
|
</S.TabsWrapper>
|
|
210
218
|
)}
|
|
211
|
-
<S.Filters>
|
|
212
|
-
<Type filterItems={filterItems} value={filterValues["filterType"]} />
|
|
213
|
-
<SortBy sortItems={sortItems} sortedState={sortedListStatus} />
|
|
214
|
-
</S.Filters>
|
|
219
|
+
<S.Filters>{filters}</S.Filters>
|
|
215
220
|
</S.Header>
|
|
216
221
|
)}
|
|
217
222
|
<S.Search>
|
|
223
|
+
{!isSiteView && <S.FiltersGlobal>{filters}</S.FiltersGlobal>}
|
|
218
224
|
<SearchField
|
|
219
225
|
onChange={setSearchQuery}
|
|
220
226
|
value={searchQuery}
|