@strapi/upload 5.2.0 → 5.4.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/dist/_chunks/{index-Bi33Km2i.mjs → App-D1ayH-QS.mjs} +112 -106
- package/dist/_chunks/App-D1ayH-QS.mjs.map +1 -0
- package/dist/_chunks/{index-DlRn6eNH.js → App-Dqqn78jO.js} +112 -106
- package/dist/_chunks/App-Dqqn78jO.js.map +1 -0
- package/dist/_chunks/{index-KSVkjErL.mjs → ConfigureTheView-B2Syy3q5.mjs} +24 -23
- package/dist/_chunks/ConfigureTheView-B2Syy3q5.mjs.map +1 -0
- package/dist/_chunks/{index-l4hbqJYu.js → ConfigureTheView-fwDgErsi.js} +42 -23
- package/dist/_chunks/ConfigureTheView-fwDgErsi.js.map +1 -0
- package/dist/_chunks/{index-GpFGwMho.mjs → SettingsPage-BYC3ism8.mjs} +45 -43
- package/dist/_chunks/SettingsPage-BYC3ism8.mjs.map +1 -0
- package/dist/_chunks/{index-D7YMYvKK.js → SettingsPage-oDEVs3XV.js} +61 -41
- package/dist/_chunks/SettingsPage-oDEVs3XV.js.map +1 -0
- package/dist/_chunks/{index-BHcSb0I3.js → index-B7NW5XiM.js} +1065 -1677
- package/dist/_chunks/index-B7NW5XiM.js.map +1 -0
- package/dist/_chunks/{index-BjvAmZvH.mjs → index-Clesg6BA.mjs} +1108 -1719
- package/dist/_chunks/index-Clesg6BA.mjs.map +1 -0
- package/dist/admin/index.js +2 -2
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/src/components/AssetCard/AssetCard.d.ts +18 -0
- package/dist/admin/src/components/AssetCard/AssetCardBase.d.ts +14 -0
- package/dist/admin/src/components/AssetCard/AudioAssetCard.d.ts +7 -0
- package/dist/admin/src/components/AssetCard/AudioPreview.d.ts +6 -0
- package/dist/admin/src/components/AssetCard/DocAssetCard.d.ts +7 -0
- package/dist/admin/src/components/AssetCard/ImageAssetCard.d.ts +12 -0
- package/dist/admin/src/components/AssetCard/UploadingAssetCard.d.ts +17 -0
- package/dist/admin/src/components/AssetCard/VideoAssetCard.d.ts +8 -0
- package/dist/admin/src/components/AssetCard/VideoPreview.d.ts +9 -0
- package/dist/admin/src/components/AssetDialog/AssetDialog.d.ts +39 -0
- package/dist/admin/src/components/AssetDialog/BrowseStep/BrowseStep.d.ts +63 -0
- package/dist/admin/src/components/AssetDialog/BrowseStep/Filters.d.ts +23 -0
- package/dist/admin/src/components/AssetDialog/BrowseStep/PageSize.d.ts +6 -0
- package/dist/admin/src/components/AssetDialog/BrowseStep/PaginationFooter/Pagination.d.ts +13 -0
- package/dist/admin/src/components/AssetDialog/BrowseStep/PaginationFooter/PaginationFooter.d.ts +9 -0
- package/dist/admin/src/components/AssetDialog/BrowseStep/SearchAsset/SearchAsset.d.ts +7 -0
- package/dist/admin/src/components/AssetDialog/BrowseStep/utils/isSelectable.d.ts +1 -0
- package/dist/admin/src/components/AssetDialog/DialogFooter.d.ts +6 -0
- package/dist/admin/src/components/AssetDialog/SelectedStep/SelectedStep.d.ts +8 -0
- package/dist/admin/src/components/AssetGridList/AssetGridList.d.ts +13 -0
- package/dist/admin/src/components/AssetGridList/Draggable.d.ts +9 -0
- package/dist/admin/src/components/Breadcrumbs/Breadcrumbs.d.ts +14 -0
- package/dist/admin/src/components/Breadcrumbs/CrumbSimpleMenuAsync.d.ts +7 -0
- package/dist/admin/src/components/BulkMoveDialog/BulkMoveDialog.d.ts +15 -0
- package/dist/admin/src/components/ContextInfo/ContextInfo.d.ts +8 -0
- package/dist/admin/src/components/CopyLinkButton/CopyLinkButton.d.ts +3 -0
- package/dist/admin/src/components/EditAssetDialog/DialogHeader.d.ts +1 -0
- package/dist/admin/src/components/EditAssetDialog/EditAssetContent.d.ts +28 -0
- package/dist/admin/src/components/EditAssetDialog/PreviewBox/AssetPreview.d.ts +9 -0
- package/dist/admin/src/components/EditAssetDialog/PreviewBox/CroppingActions.d.ts +7 -0
- package/dist/admin/src/components/EditAssetDialog/PreviewBox/PreviewBox.d.ts +23 -0
- package/dist/admin/src/components/EditAssetDialog/PreviewBox/PreviewComponents.d.ts +17 -0
- package/dist/admin/src/components/EditAssetDialog/RemoveAssetDialog.d.ts +8 -0
- package/dist/admin/src/components/EditAssetDialog/ReplaceMediaButton.d.ts +8 -0
- package/dist/admin/src/components/EditFolderDialog/EditFolderDialog.d.ts +12 -0
- package/dist/admin/src/components/EditFolderDialog/ModalHeader/ModalHeader.d.ts +5 -0
- package/dist/admin/src/components/EditFolderDialog/RemoveFolderDialog.d.ts +7 -0
- package/dist/admin/src/components/EmptyAssets/EmptyAssetGrid.d.ts +6 -0
- package/dist/admin/src/components/EmptyAssets/EmptyAssets.d.ts +10 -0
- package/dist/admin/src/components/FilterList/FilterList.d.ts +33 -0
- package/dist/admin/src/components/FilterList/FilterTag.d.ts +23 -0
- package/dist/admin/src/components/FilterPopover/FilterPopover.d.ts +31 -0
- package/dist/admin/src/components/FilterPopover/FilterValueInput.d.ts +12 -0
- package/dist/admin/src/components/FilterPopover/utils/getFilterList.d.ts +21 -0
- package/dist/admin/src/components/FolderCard/FolderCard/FolderCard.d.ts +13 -0
- package/dist/admin/src/components/FolderCard/FolderCardBody/FolderCardBody.d.ts +2 -0
- package/dist/admin/src/components/FolderCard/FolderCardBodyAction/FolderCardBodyAction.d.ts +7 -0
- package/dist/admin/src/components/FolderCard/FolderCardCheckbox/FolderCardCheckbox.d.ts +2 -0
- package/dist/admin/src/components/FolderCard/contexts/FolderCard.d.ts +7 -0
- package/dist/admin/src/components/FolderGridList/FolderGridList.d.ts +6 -0
- package/dist/admin/src/components/MediaLibraryDialog/MediaLibraryDialog.d.ts +8 -0
- package/dist/admin/src/components/MediaLibraryInput/Carousel/CarouselAsset.d.ts +4 -0
- package/dist/admin/src/components/MediaLibraryInput/Carousel/CarouselAssetActions.d.ts +9 -0
- package/dist/admin/src/components/MediaLibraryInput/Carousel/CarouselAssets.d.ts +22 -0
- package/dist/admin/src/components/MediaLibraryInput/Carousel/EmptyStateAsset.d.ts +10 -0
- package/dist/admin/src/components/MediaLibraryInput/MediaLibraryInput.d.ts +17 -0
- package/dist/admin/src/components/SelectTree/Option.d.ts +16 -0
- package/dist/admin/src/components/SelectTree/SelectTree.d.ts +22 -0
- package/dist/admin/src/components/SelectTree/utils/flattenTree.d.ts +1 -1
- package/dist/admin/src/components/SelectTree/utils/getOpenValues.d.ts +9 -0
- package/dist/admin/src/components/SelectTree/utils/getValuesToClose.d.ts +6 -0
- package/dist/admin/src/components/SortPicker/SortPicker.d.ts +7 -0
- package/dist/admin/src/components/TableList/CellContent.d.ts +8 -0
- package/dist/admin/src/components/TableList/PreviewCell.d.ts +7 -0
- package/dist/admin/src/components/TableList/TableList.d.ts +31 -0
- package/dist/admin/src/components/TableList/TableRows.d.ts +22 -0
- package/dist/admin/src/components/UploadAssetDialog/AddAssetStep/AddAssetStep.d.ts +13 -0
- package/dist/admin/src/components/UploadAssetDialog/AddAssetStep/FromComputerForm.d.ts +8 -0
- package/dist/admin/src/components/UploadAssetDialog/AddAssetStep/FromUrlForm.d.ts +8 -0
- package/dist/admin/src/components/UploadAssetDialog/PendingAssetStep/PendingAssetStep.d.ts +22 -0
- package/dist/admin/src/components/UploadAssetDialog/UploadAssetDialog.d.ts +21 -0
- package/dist/admin/src/components/UploadProgress/UploadProgress.d.ts +7 -0
- package/dist/admin/src/{newConstants.d.ts → constants.d.ts} +25 -0
- package/dist/admin/src/hooks/useBulkMove.d.ts +5 -5
- package/dist/admin/src/hooks/useBulkRemove.d.ts +17 -20
- package/dist/admin/src/hooks/useFolder.d.ts +1 -1
- package/dist/admin/src/hooks/useFolderStructure.d.ts +7 -1
- package/dist/admin/src/hooks/useMediaLibraryPermissions.d.ts +5 -1
- package/dist/admin/src/hooks/useModalQueryParams.d.ts +2 -3
- package/dist/admin/src/hooks/useSelectionState.d.ts +1 -1
- package/dist/admin/src/hooks/useUpload.d.ts +6 -3
- package/dist/admin/src/index.d.ts +3 -0
- package/dist/admin/src/pages/App/App.d.ts +1 -0
- package/dist/admin/src/pages/App/ConfigureTheView/ConfigureTheView.d.ts +6 -0
- package/dist/admin/src/pages/App/ConfigureTheView/components/Settings.d.ts +13 -0
- package/dist/admin/src/pages/App/ConfigureTheView/state/actionTypes.d.ts +2 -0
- package/dist/admin/src/pages/App/ConfigureTheView/state/actions.d.ts +12 -0
- package/dist/admin/src/pages/App/ConfigureTheView/state/init.d.ts +8 -0
- package/dist/admin/src/pages/App/ConfigureTheView/state/reducer.d.ts +15 -0
- package/dist/admin/src/pages/App/MediaLibrary/MediaLibrary.d.ts +1 -0
- package/dist/admin/src/pages/App/MediaLibrary/components/BulkActions.d.ts +15 -0
- package/dist/admin/src/pages/App/MediaLibrary/components/BulkDeleteButton.d.ts +7 -0
- package/dist/admin/src/pages/App/MediaLibrary/components/BulkMoveButton.d.ts +15 -0
- package/dist/admin/src/pages/App/MediaLibrary/components/EmptyOrNoPermissions.d.ts +7 -0
- package/dist/admin/src/pages/App/MediaLibrary/components/Filters.d.ts +1 -0
- package/dist/admin/src/pages/App/MediaLibrary/components/Header.d.ts +22 -0
- package/dist/admin/src/pages/App/components/BulkActions.d.ts +15 -0
- package/dist/admin/src/pages/App/components/BulkDeleteButton.d.ts +10 -0
- package/dist/admin/src/pages/App/components/BulkMoveButton.d.ts +15 -0
- package/dist/admin/src/pages/App/components/EmptyOrNoPermissions.d.ts +8 -0
- package/dist/admin/src/pages/App/components/Filters.d.ts +1 -0
- package/dist/admin/src/pages/App/components/Header.d.ts +13 -0
- package/dist/admin/src/pages/SettingsPage/SettingsPage.d.ts +2 -0
- package/dist/admin/src/pages/SettingsPage/init.d.ts +2 -0
- package/dist/admin/src/pages/SettingsPage/reducer.d.ts +27 -0
- package/dist/admin/src/pluginId.d.ts +0 -1
- package/dist/admin/src/utils/findRecursiveFolderByValue.d.ts +3 -2
- package/dist/admin/src/utils/getAllowedFiles.d.ts +1 -2
- package/dist/admin/src/utils/getBreadcrumbDataCM.d.ts +1 -1
- package/dist/admin/src/utils/getBreadcrumbDataML.d.ts +1 -1
- package/dist/admin/src/utils/getFolderParents.d.ts +4 -3
- package/dist/admin/src/utils/moveElement.d.ts +1 -1
- package/dist/admin/src/utils/rawFileToAsset.d.ts +2 -2
- package/dist/admin/src/utils/toSingularTypes.d.ts +0 -1
- package/dist/admin/src/utils/typeFromMime.d.ts +1 -1
- package/dist/admin/src/utils/urlsToAssets.d.ts +3 -3
- package/dist/shared/contracts/files.d.ts +10 -6
- package/dist/shared/contracts/folders.d.ts +23 -2
- package/dist/shared/contracts/settings.d.ts +3 -2
- package/package.json +10 -10
- package/dist/_chunks/index-BHcSb0I3.js.map +0 -1
- package/dist/_chunks/index-Bi33Km2i.mjs.map +0 -1
- package/dist/_chunks/index-BjvAmZvH.mjs.map +0 -1
- package/dist/_chunks/index-D7YMYvKK.js.map +0 -1
- package/dist/_chunks/index-DlRn6eNH.js.map +0 -1
- package/dist/_chunks/index-GpFGwMho.mjs.map +0 -1
- package/dist/_chunks/index-KSVkjErL.mjs.map +0 -1
- package/dist/_chunks/index-l4hbqJYu.js.map +0 -1
- /package/dist/admin/src/hooks/utils/{rename-keys.d.ts → renameKeys.d.ts} +0 -0
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { ChevronUp, ChevronDown, Cross, CaretDown, Link, FilePdf, File as File$1, Check, Trash, Download, Crop, Pencil, Folder, Eye, CaretUp, Plus, Filter, ChevronLeft, ChevronRight, Search, List, GridFour, PlusCircle, Images } from "@strapi/icons";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { translatedErrors, useNotification, useFetchClient, useRBAC, useTracking, useClipboard, ConfirmDialog, useQueryParams, Layouts, Page, useField } from "@strapi/admin/strapi-admin";
|
|
4
|
+
import { useState, useEffect, createContext, useContext } from "react";
|
|
5
|
+
import { useNotification, useFetchClient, translatedErrors, useRBAC, useTracking, useClipboard, ConfirmDialog, useQueryParams, Layouts, Page, useField } from "@strapi/admin/strapi-admin";
|
|
7
6
|
import { useNotifyAT, Box, Grid, Flex, Typography, Modal, IconButton, ProgressBar, Dialog, Badge, Menu, FocusTrap, Button, VisuallyHidden, Loader, Field, TextInput, CardAction, Card as Card$1, CardHeader, CardCheckbox, CardBody, CardContent, CardTitle, CardSubtitle, CardBadge, CardAsset as CardAsset$2, CardTimer, KeyboardNavigable, CrumbSimpleMenu, MenuItem, Breadcrumbs as Breadcrumbs$1, CrumbLink, Crumb, SingleSelect, SingleSelectOption, Avatar, Tbody, Tr, Td, Checkbox, Table, Thead, Th, Tooltip, Tag, DateTimePicker, Popover, SearchForm, Searchbar, Divider, Tabs, Textarea, CarouselActions, CarouselInput, CarouselSlide } from "@strapi/design-system";
|
|
8
7
|
import { useIntl } from "react-intl";
|
|
9
|
-
import { styled, useTheme } from "styled-components";
|
|
8
|
+
import { styled, useTheme, css } from "styled-components";
|
|
9
|
+
import { useQuery, useMutation, useQueryClient } from "react-query";
|
|
10
|
+
import { stringify } from "qs";
|
|
10
11
|
import byteSize from "byte-size";
|
|
11
12
|
import { intervalToDuration } from "date-fns";
|
|
12
|
-
import { stringify } from "qs";
|
|
13
13
|
import * as yup from "yup";
|
|
14
|
-
import { useQuery, useMutation, useQueryClient } from "react-query";
|
|
15
14
|
import { Formik, Form } from "formik";
|
|
16
15
|
import isEqual from "lodash/isEqual";
|
|
17
16
|
import ReactSelect, { components } from "react-select";
|
|
@@ -19,7 +18,7 @@ import Cropper from "cropperjs";
|
|
|
19
18
|
import "cropperjs/dist/cropper.css";
|
|
20
19
|
import isEmpty from "lodash/isEmpty";
|
|
21
20
|
import { useDrop, useDrag } from "react-dnd";
|
|
22
|
-
import { useLocation,
|
|
21
|
+
import { useLocation, Link as Link$1, NavLink } from "react-router-dom";
|
|
23
22
|
import { EmptyDocuments } from "@strapi/icons/symbols";
|
|
24
23
|
import parseISO from "date-fns/parseISO";
|
|
25
24
|
const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
|
@@ -32,7 +31,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
|
|
32
31
|
});
|
|
33
32
|
};
|
|
34
33
|
const name$1 = "@strapi/upload";
|
|
35
|
-
const version = "5.
|
|
34
|
+
const version = "5.4.0";
|
|
36
35
|
const description = "Makes it easy to upload images and files to your Strapi Application.";
|
|
37
36
|
const license = "SEE LICENSE IN LICENSE";
|
|
38
37
|
const author = {
|
|
@@ -50,7 +49,7 @@ const maintainers = [
|
|
|
50
49
|
const exports = {
|
|
51
50
|
"./strapi-admin": {
|
|
52
51
|
types: "./dist/admin/src/index.d.ts",
|
|
53
|
-
source: "./admin/src/index.
|
|
52
|
+
source: "./admin/src/index.ts",
|
|
54
53
|
"import": "./dist/admin/index.mjs",
|
|
55
54
|
require: "./dist/admin/index.js",
|
|
56
55
|
"default": "./dist/admin/index.js"
|
|
@@ -88,10 +87,10 @@ const scripts = {
|
|
|
88
87
|
watch: "pack-up watch"
|
|
89
88
|
};
|
|
90
89
|
const dependencies = {
|
|
91
|
-
"@strapi/design-system": "2.0.0-rc.
|
|
92
|
-
"@strapi/icons": "2.0.0-rc.
|
|
93
|
-
"@strapi/provider-upload-local": "
|
|
94
|
-
"@strapi/utils": "
|
|
90
|
+
"@strapi/design-system": "2.0.0-rc.12",
|
|
91
|
+
"@strapi/icons": "2.0.0-rc.12",
|
|
92
|
+
"@strapi/provider-upload-local": "5.4.0",
|
|
93
|
+
"@strapi/utils": "5.4.0",
|
|
95
94
|
"byte-size": "8.1.1",
|
|
96
95
|
cropperjs: "1.6.1",
|
|
97
96
|
"date-fns": "2.30.0",
|
|
@@ -113,9 +112,9 @@ const dependencies = {
|
|
|
113
112
|
yup: "0.32.9"
|
|
114
113
|
};
|
|
115
114
|
const devDependencies = {
|
|
116
|
-
"@strapi/admin": "
|
|
115
|
+
"@strapi/admin": "5.4.0",
|
|
117
116
|
"@strapi/pack-up": "5.0.0",
|
|
118
|
-
"@strapi/types": "
|
|
117
|
+
"@strapi/types": "5.4.0",
|
|
119
118
|
"@testing-library/dom": "10.1.0",
|
|
120
119
|
"@testing-library/react": "15.0.7",
|
|
121
120
|
"@testing-library/user-event": "14.5.2",
|
|
@@ -134,7 +133,7 @@ const devDependencies = {
|
|
|
134
133
|
"styled-components": "6.1.8"
|
|
135
134
|
};
|
|
136
135
|
const peerDependencies = {
|
|
137
|
-
"@strapi/admin": "^5.0.0
|
|
136
|
+
"@strapi/admin": "^5.0.0",
|
|
138
137
|
react: "^17.0.0 || ^18.0.0",
|
|
139
138
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
140
139
|
"react-router-dom": "^6.0.0",
|
|
@@ -151,6 +150,7 @@ const strapi = {
|
|
|
151
150
|
required: true,
|
|
152
151
|
kind: "plugin"
|
|
153
152
|
};
|
|
153
|
+
const gitHead = "7d785703f52464577d077c4618cbe68b44f8a9cd";
|
|
154
154
|
const pluginPkg = {
|
|
155
155
|
name: name$1,
|
|
156
156
|
version,
|
|
@@ -165,7 +165,150 @@ const pluginPkg = {
|
|
|
165
165
|
devDependencies,
|
|
166
166
|
peerDependencies,
|
|
167
167
|
engines,
|
|
168
|
-
strapi
|
|
168
|
+
strapi,
|
|
169
|
+
gitHead
|
|
170
|
+
};
|
|
171
|
+
const pluginId = pluginPkg.name.replace(/^@strapi\//i, "");
|
|
172
|
+
const useAssets = ({ skipWhen = false, query = {} } = {}) => {
|
|
173
|
+
const { formatMessage } = useIntl();
|
|
174
|
+
const { toggleNotification } = useNotification();
|
|
175
|
+
const { notifyStatus } = useNotifyAT();
|
|
176
|
+
const { get } = useFetchClient();
|
|
177
|
+
const { folderPath, _q, ...paramsExceptFolderAndQ } = query;
|
|
178
|
+
let params;
|
|
179
|
+
if (_q) {
|
|
180
|
+
params = {
|
|
181
|
+
...paramsExceptFolderAndQ,
|
|
182
|
+
_q: encodeURIComponent(_q)
|
|
183
|
+
};
|
|
184
|
+
} else {
|
|
185
|
+
params = {
|
|
186
|
+
...paramsExceptFolderAndQ,
|
|
187
|
+
filters: {
|
|
188
|
+
$and: [
|
|
189
|
+
...paramsExceptFolderAndQ?.filters?.$and ?? [],
|
|
190
|
+
{
|
|
191
|
+
folderPath: { $eq: folderPath ?? "/" }
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const { data, error, isLoading } = useQuery(
|
|
198
|
+
[pluginId, "assets", params],
|
|
199
|
+
async () => {
|
|
200
|
+
const { data: data2 } = await get("/upload/files", { params });
|
|
201
|
+
return data2;
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
enabled: !skipWhen,
|
|
205
|
+
staleTime: 0,
|
|
206
|
+
cacheTime: 0,
|
|
207
|
+
select(data2) {
|
|
208
|
+
if (data2?.results && Array.isArray(data2.results)) {
|
|
209
|
+
return {
|
|
210
|
+
...data2,
|
|
211
|
+
results: data2.results.filter((asset) => asset.name).map((asset) => ({
|
|
212
|
+
...asset,
|
|
213
|
+
/**
|
|
214
|
+
* Mime and ext cannot be null in the front-end because
|
|
215
|
+
* we expect them to be strings and use the `includes` method.
|
|
216
|
+
*/
|
|
217
|
+
mime: asset.mime ?? "",
|
|
218
|
+
ext: asset.ext ?? ""
|
|
219
|
+
}))
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
return data2;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
React.useEffect(() => {
|
|
227
|
+
if (data) {
|
|
228
|
+
notifyStatus(
|
|
229
|
+
formatMessage({
|
|
230
|
+
id: "list.asset.at.finished",
|
|
231
|
+
defaultMessage: "The assets have finished loading."
|
|
232
|
+
})
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
}, [data, formatMessage, notifyStatus]);
|
|
236
|
+
React.useEffect(() => {
|
|
237
|
+
if (error) {
|
|
238
|
+
toggleNotification({
|
|
239
|
+
type: "danger",
|
|
240
|
+
message: formatMessage({ id: "notification.error" })
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}, [error, formatMessage, toggleNotification]);
|
|
244
|
+
return { data, error, isLoading };
|
|
245
|
+
};
|
|
246
|
+
const useFolders = ({ enabled = true, query = {} } = {}) => {
|
|
247
|
+
const { formatMessage } = useIntl();
|
|
248
|
+
const { toggleNotification } = useNotification();
|
|
249
|
+
const { notifyStatus } = useNotifyAT();
|
|
250
|
+
const { folder, _q, ...paramsExceptFolderAndQ } = query;
|
|
251
|
+
const { get } = useFetchClient();
|
|
252
|
+
let params;
|
|
253
|
+
if (_q) {
|
|
254
|
+
params = {
|
|
255
|
+
...paramsExceptFolderAndQ,
|
|
256
|
+
pagination: {
|
|
257
|
+
pageSize: -1
|
|
258
|
+
},
|
|
259
|
+
_q
|
|
260
|
+
};
|
|
261
|
+
} else {
|
|
262
|
+
params = {
|
|
263
|
+
...paramsExceptFolderAndQ,
|
|
264
|
+
pagination: {
|
|
265
|
+
pageSize: -1
|
|
266
|
+
},
|
|
267
|
+
filters: {
|
|
268
|
+
$and: [
|
|
269
|
+
...paramsExceptFolderAndQ?.filters?.$and ?? [],
|
|
270
|
+
{
|
|
271
|
+
parent: {
|
|
272
|
+
id: folder ?? {
|
|
273
|
+
$null: true
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
const { data, error, isLoading } = useQuery(
|
|
282
|
+
[pluginId, "folders", stringify(params)],
|
|
283
|
+
async () => {
|
|
284
|
+
const {
|
|
285
|
+
data: { data: data2 }
|
|
286
|
+
} = await get("/upload/folders", { params });
|
|
287
|
+
return data2;
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
enabled,
|
|
291
|
+
staleTime: 0,
|
|
292
|
+
cacheTime: 0,
|
|
293
|
+
onError() {
|
|
294
|
+
toggleNotification({
|
|
295
|
+
type: "danger",
|
|
296
|
+
message: formatMessage({ id: "notification.error" })
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
React.useEffect(() => {
|
|
302
|
+
if (data) {
|
|
303
|
+
notifyStatus(
|
|
304
|
+
formatMessage({
|
|
305
|
+
id: "list.asset.at.finished",
|
|
306
|
+
defaultMessage: "The folders have finished loading."
|
|
307
|
+
})
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
}, [data, formatMessage, notifyStatus]);
|
|
311
|
+
return { data, error, isLoading };
|
|
169
312
|
};
|
|
170
313
|
const appendSearchParamsToUrl = ({ url, params }) => {
|
|
171
314
|
if (url === void 0 || typeof params !== "object") {
|
|
@@ -336,10 +479,9 @@ function getAPIInnerErrors(error, { getTrad: getTrad2 }) {
|
|
|
336
479
|
}
|
|
337
480
|
return normalizedError?.defaultMessage;
|
|
338
481
|
}
|
|
339
|
-
const
|
|
340
|
-
const getTrad = (id2) => `${pluginId}.${id2}`;
|
|
482
|
+
const getTrad = (id) => `${pluginId}.${id}`;
|
|
341
483
|
const getBreadcrumbDataCM = (folder) => {
|
|
342
|
-
|
|
484
|
+
const data = [
|
|
343
485
|
{
|
|
344
486
|
id: null,
|
|
345
487
|
label: { id: getTrad("plugin.name"), defaultMessage: "Media Library" }
|
|
@@ -391,7 +533,7 @@ const getFolderParents = (folders, currentFolderId) => {
|
|
|
391
533
|
}
|
|
392
534
|
let { parent } = currentFolder;
|
|
393
535
|
while (parent !== void 0) {
|
|
394
|
-
|
|
536
|
+
const parentToStore = flatFolders.find(({ value }) => value === parent);
|
|
395
537
|
parents.push({ id: parentToStore?.value, label: parentToStore?.label });
|
|
396
538
|
parent = parentToStore?.parent;
|
|
397
539
|
}
|
|
@@ -404,9 +546,9 @@ const move = (array, oldIndex, newIndex) => {
|
|
|
404
546
|
array.splice(newIndex, 0, array.splice(oldIndex, 1)[0]);
|
|
405
547
|
return array;
|
|
406
548
|
};
|
|
407
|
-
const moveElement = (array,
|
|
408
|
-
const newIndex =
|
|
409
|
-
return move(array,
|
|
549
|
+
const moveElement = (array, index, offset) => {
|
|
550
|
+
const newIndex = index + offset;
|
|
551
|
+
return move(array, index, newIndex);
|
|
410
552
|
};
|
|
411
553
|
const prefixPluginTranslations = (trad, pluginId2) => {
|
|
412
554
|
if (!pluginId2) {
|
|
@@ -417,68 +559,17 @@ const prefixPluginTranslations = (trad, pluginId2) => {
|
|
|
417
559
|
return acc;
|
|
418
560
|
}, {});
|
|
419
561
|
};
|
|
420
|
-
var AssetType$1 = /* @__PURE__ */ ((AssetType2) => {
|
|
421
|
-
AssetType2["Video"] = "video";
|
|
422
|
-
AssetType2["Image"] = "image";
|
|
423
|
-
AssetType2["Document"] = "doc";
|
|
424
|
-
AssetType2["Audio"] = "audio";
|
|
425
|
-
return AssetType2;
|
|
426
|
-
})(AssetType$1 || {});
|
|
427
|
-
var AssetSource$1 = /* @__PURE__ */ ((AssetSource2) => {
|
|
428
|
-
AssetSource2["Url"] = "url";
|
|
429
|
-
AssetSource2["Computer"] = "computer";
|
|
430
|
-
return AssetSource2;
|
|
431
|
-
})(AssetSource$1 || {});
|
|
432
|
-
const PERMISSIONS$1 = {
|
|
433
|
-
// This permission regards the main component (App) and is used to tell
|
|
434
|
-
// If the plugin link should be displayed in the menu
|
|
435
|
-
// And also if the plugin is accessible. This use case is found when a user types the url of the
|
|
436
|
-
// plugin directly in the browser
|
|
437
|
-
main: [
|
|
438
|
-
{ action: "plugin::upload.read", subject: null },
|
|
439
|
-
{
|
|
440
|
-
action: "plugin::upload.assets.create",
|
|
441
|
-
subject: null
|
|
442
|
-
},
|
|
443
|
-
{
|
|
444
|
-
action: "plugin::upload.assets.update",
|
|
445
|
-
subject: null
|
|
446
|
-
}
|
|
447
|
-
],
|
|
448
|
-
copyLink: [
|
|
449
|
-
{
|
|
450
|
-
action: "plugin::upload.assets.copy-link",
|
|
451
|
-
subject: null
|
|
452
|
-
}
|
|
453
|
-
],
|
|
454
|
-
create: [
|
|
455
|
-
{
|
|
456
|
-
action: "plugin::upload.assets.create",
|
|
457
|
-
subject: null
|
|
458
|
-
}
|
|
459
|
-
],
|
|
460
|
-
download: [
|
|
461
|
-
{
|
|
462
|
-
action: "plugin::upload.assets.download",
|
|
463
|
-
subject: null
|
|
464
|
-
}
|
|
465
|
-
],
|
|
466
|
-
read: [{ action: "plugin::upload.read", subject: null }],
|
|
467
|
-
configureView: [{ action: "plugin::upload.configure-view", subject: null }],
|
|
468
|
-
settings: [{ action: "plugin::upload.settings.read", subject: null }],
|
|
469
|
-
update: [{ action: "plugin::upload.assets.update", subject: null, fields: null }]
|
|
470
|
-
};
|
|
471
562
|
const typeFromMime = (mime) => {
|
|
472
|
-
if (mime.includes(AssetType
|
|
473
|
-
return AssetType
|
|
563
|
+
if (mime.includes(AssetType.Image)) {
|
|
564
|
+
return AssetType.Image;
|
|
474
565
|
}
|
|
475
|
-
if (mime.includes(AssetType
|
|
476
|
-
return AssetType
|
|
566
|
+
if (mime.includes(AssetType.Video)) {
|
|
567
|
+
return AssetType.Video;
|
|
477
568
|
}
|
|
478
|
-
if (mime.includes(AssetType
|
|
479
|
-
return AssetType
|
|
569
|
+
if (mime.includes(AssetType.Audio)) {
|
|
570
|
+
return AssetType.Audio;
|
|
480
571
|
}
|
|
481
|
-
return AssetType
|
|
572
|
+
return AssetType.Document;
|
|
482
573
|
};
|
|
483
574
|
const rawFileToAsset = (rawFile, assetSource) => {
|
|
484
575
|
return {
|
|
@@ -514,12 +605,12 @@ const urlsToAssets = async (urls) => {
|
|
|
514
605
|
);
|
|
515
606
|
const assetsResults = await Promise.all(assetPromises);
|
|
516
607
|
const assets = assetsResults.map((fullFilledAsset) => ({
|
|
517
|
-
source: AssetSource
|
|
608
|
+
source: AssetSource.Url,
|
|
518
609
|
name: fullFilledAsset.name,
|
|
519
610
|
type: typeFromMime(fullFilledAsset.mime),
|
|
520
611
|
url: fullFilledAsset.url,
|
|
521
612
|
ext: fullFilledAsset.url.split(".").pop(),
|
|
522
|
-
mime: fullFilledAsset.mime,
|
|
613
|
+
mime: fullFilledAsset.mime ? fullFilledAsset.mime : void 0,
|
|
523
614
|
rawFile: fullFilledAsset.rawFile
|
|
524
615
|
}));
|
|
525
616
|
return assets;
|
|
@@ -551,355 +642,144 @@ const urlSchema = yup.object().shape({
|
|
|
551
642
|
return true;
|
|
552
643
|
}
|
|
553
644
|
});
|
|
554
|
-
const filteredLength = filtered.length;
|
|
555
|
-
if (filteredLength === 0) {
|
|
556
|
-
return true;
|
|
557
|
-
}
|
|
558
|
-
const errorMessage = filteredLength > 1 ? "form.upload-url.error.url.invalids" : "form.upload-url.error.url.invalid";
|
|
559
|
-
return this.createError({
|
|
560
|
-
path: this.path,
|
|
561
|
-
message: getTrad(errorMessage),
|
|
562
|
-
params: { number: filtered.length }
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
})
|
|
566
|
-
});
|
|
567
|
-
const AssetType = {
|
|
568
|
-
Video: "video",
|
|
569
|
-
Image: "image",
|
|
570
|
-
Document: "doc",
|
|
571
|
-
Audio: "audio"
|
|
572
|
-
};
|
|
573
|
-
const AssetSource = {
|
|
574
|
-
Url: "url",
|
|
575
|
-
Computer: "computer"
|
|
576
|
-
};
|
|
577
|
-
const ParentFolderShape = {
|
|
578
|
-
id: PropTypes.number.isRequired,
|
|
579
|
-
createdAt: PropTypes.string.isRequired,
|
|
580
|
-
name: PropTypes.string.isRequired,
|
|
581
|
-
updatedAt: PropTypes.string.isRequired,
|
|
582
|
-
pathId: PropTypes.number.isRequired,
|
|
583
|
-
path: PropTypes.string.isRequired
|
|
584
|
-
};
|
|
585
|
-
ParentFolderShape.parent = PropTypes.shape(ParentFolderShape);
|
|
586
|
-
const FolderShape = {
|
|
587
|
-
id: PropTypes.number,
|
|
588
|
-
children: PropTypes.shape({
|
|
589
|
-
count: PropTypes.number.isRequired
|
|
590
|
-
}),
|
|
591
|
-
createdAt: PropTypes.string,
|
|
592
|
-
createdBy: PropTypes.shape(),
|
|
593
|
-
files: PropTypes.shape({
|
|
594
|
-
count: PropTypes.number.isRequired
|
|
595
|
-
}),
|
|
596
|
-
name: PropTypes.string,
|
|
597
|
-
updatedAt: PropTypes.string,
|
|
598
|
-
updatedBy: PropTypes.shape(),
|
|
599
|
-
pathId: PropTypes.number,
|
|
600
|
-
path: PropTypes.string
|
|
601
|
-
};
|
|
602
|
-
FolderShape.parent = PropTypes.shape(ParentFolderShape);
|
|
603
|
-
const FolderDefinition = PropTypes.shape(FolderShape);
|
|
604
|
-
const FolderStructure = PropTypes.shape({
|
|
605
|
-
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
606
|
-
label: PropTypes.string.isRequired,
|
|
607
|
-
children: PropTypes.array
|
|
608
|
-
});
|
|
609
|
-
FolderStructure.children = PropTypes.arrayOf(PropTypes.shape(FolderStructure));
|
|
610
|
-
FolderStructure.defaultProps = {
|
|
611
|
-
children: void 0
|
|
612
|
-
};
|
|
613
|
-
PropTypes.arrayOf(FolderStructure);
|
|
614
|
-
const AssetDefinition = PropTypes.shape({
|
|
615
|
-
id: PropTypes.number,
|
|
616
|
-
height: PropTypes.number,
|
|
617
|
-
width: PropTypes.number,
|
|
618
|
-
size: PropTypes.number,
|
|
619
|
-
createdAt: PropTypes.string,
|
|
620
|
-
ext: PropTypes.string,
|
|
621
|
-
mime: PropTypes.string,
|
|
622
|
-
name: PropTypes.string,
|
|
623
|
-
url: PropTypes.string,
|
|
624
|
-
updatedAt: PropTypes.string,
|
|
625
|
-
alternativeText: PropTypes.string,
|
|
626
|
-
caption: PropTypes.string,
|
|
627
|
-
folder: PropTypes.shape(FolderDefinition),
|
|
628
|
-
formats: PropTypes.shape({
|
|
629
|
-
thumbnail: PropTypes.shape({
|
|
630
|
-
url: PropTypes.string
|
|
631
|
-
})
|
|
632
|
-
})
|
|
633
|
-
});
|
|
634
|
-
const CrumbDefinition = PropTypes.shape({
|
|
635
|
-
id: PropTypes.number,
|
|
636
|
-
label: PropTypes.oneOfType([
|
|
637
|
-
PropTypes.string,
|
|
638
|
-
PropTypes.shape({
|
|
639
|
-
id: PropTypes.string.isRequired,
|
|
640
|
-
defaultMessage: PropTypes.string.isRequired
|
|
641
|
-
})
|
|
642
|
-
]).isRequired,
|
|
643
|
-
href: PropTypes.string
|
|
644
|
-
});
|
|
645
|
-
const CrumbMenuDefinition = PropTypes.arrayOf(CrumbDefinition);
|
|
646
|
-
const BreadcrumbsDefinition = PropTypes.arrayOf(
|
|
647
|
-
PropTypes.oneOfType([CrumbDefinition, CrumbMenuDefinition])
|
|
648
|
-
);
|
|
649
|
-
const viewOptions = {
|
|
650
|
-
GRID: 0,
|
|
651
|
-
LIST: 1
|
|
652
|
-
};
|
|
653
|
-
const tableHeaders = [
|
|
654
|
-
{
|
|
655
|
-
name: "preview",
|
|
656
|
-
key: "preview",
|
|
657
|
-
metadatas: {
|
|
658
|
-
label: { id: getTrad("list.table.header.preview"), defaultMessage: "preview" },
|
|
659
|
-
isSortable: false
|
|
660
|
-
},
|
|
661
|
-
type: "image"
|
|
662
|
-
},
|
|
663
|
-
{
|
|
664
|
-
name: "name",
|
|
665
|
-
key: "name",
|
|
666
|
-
metadatas: {
|
|
667
|
-
label: { id: getTrad("list.table.header.name"), defaultMessage: "name" },
|
|
668
|
-
isSortable: true
|
|
669
|
-
},
|
|
670
|
-
type: "text"
|
|
671
|
-
},
|
|
672
|
-
{
|
|
673
|
-
name: "ext",
|
|
674
|
-
key: "extension",
|
|
675
|
-
metadatas: {
|
|
676
|
-
label: { id: getTrad("list.table.header.ext"), defaultMessage: "extension" },
|
|
677
|
-
isSortable: false
|
|
678
|
-
},
|
|
679
|
-
type: "ext"
|
|
680
|
-
},
|
|
681
|
-
{
|
|
682
|
-
name: "size",
|
|
683
|
-
key: "size",
|
|
684
|
-
metadatas: {
|
|
685
|
-
label: { id: getTrad("list.table.header.size"), defaultMessage: "size" },
|
|
686
|
-
isSortable: false
|
|
687
|
-
},
|
|
688
|
-
type: "size"
|
|
689
|
-
},
|
|
690
|
-
{
|
|
691
|
-
name: "createdAt",
|
|
692
|
-
key: "createdAt",
|
|
693
|
-
metadatas: {
|
|
694
|
-
label: { id: getTrad("list.table.header.createdAt"), defaultMessage: "created" },
|
|
695
|
-
isSortable: true
|
|
696
|
-
},
|
|
697
|
-
type: "date"
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
name: "updatedAt",
|
|
701
|
-
key: "updatedAt",
|
|
702
|
-
metadatas: {
|
|
703
|
-
label: { id: getTrad("list.table.header.updatedAt"), defaultMessage: "last update" },
|
|
704
|
-
isSortable: true
|
|
705
|
-
},
|
|
706
|
-
type: "date"
|
|
707
|
-
}
|
|
708
|
-
];
|
|
709
|
-
const pageSizes = [10, 20, 50, 100];
|
|
710
|
-
const sortOptions = [
|
|
711
|
-
{ key: "sort.created_at_desc", value: "createdAt:DESC" },
|
|
712
|
-
{ key: "sort.created_at_asc", value: "createdAt:ASC" },
|
|
713
|
-
{ key: "sort.name_asc", value: "name:ASC" },
|
|
714
|
-
{ key: "sort.name_desc", value: "name:DESC" },
|
|
715
|
-
{ key: "sort.updated_at_desc", value: "updatedAt:DESC" },
|
|
716
|
-
{ key: "sort.updated_at_asc", value: "updatedAt:ASC" }
|
|
717
|
-
];
|
|
718
|
-
const localStorageKeys = {
|
|
719
|
-
modalView: `STRAPI_UPLOAD_MODAL_VIEW`,
|
|
720
|
-
view: `STRAPI_UPLOAD_LIBRARY_VIEW`
|
|
721
|
-
};
|
|
722
|
-
const PERMISSIONS = {
|
|
723
|
-
// This permission regards the main component (App) and is used to tell
|
|
724
|
-
// If the plugin link should be displayed in the menu
|
|
725
|
-
// And also if the plugin is accessible. This use case is found when a user types the url of the
|
|
726
|
-
// plugin directly in the browser
|
|
727
|
-
main: [
|
|
728
|
-
{ action: "plugin::upload.read", subject: null },
|
|
729
|
-
{
|
|
730
|
-
action: "plugin::upload.assets.create",
|
|
731
|
-
subject: null
|
|
732
|
-
},
|
|
733
|
-
{
|
|
734
|
-
action: "plugin::upload.assets.update",
|
|
735
|
-
subject: null
|
|
736
|
-
}
|
|
737
|
-
],
|
|
738
|
-
copyLink: [
|
|
739
|
-
{
|
|
740
|
-
action: "plugin::upload.assets.copy-link",
|
|
741
|
-
subject: null
|
|
742
|
-
}
|
|
743
|
-
],
|
|
744
|
-
create: [
|
|
745
|
-
{
|
|
746
|
-
action: "plugin::upload.assets.create",
|
|
747
|
-
subject: null
|
|
748
|
-
}
|
|
749
|
-
],
|
|
750
|
-
download: [
|
|
751
|
-
{
|
|
752
|
-
action: "plugin::upload.assets.download",
|
|
753
|
-
subject: null
|
|
754
|
-
}
|
|
755
|
-
],
|
|
756
|
-
read: [{ action: "plugin::upload.read", subject: null }],
|
|
757
|
-
configureView: [{ action: "plugin::upload.configure-view", subject: null }],
|
|
758
|
-
settings: [{ action: "plugin::upload.settings.read", subject: null }],
|
|
759
|
-
update: [{ action: "plugin::upload.assets.update", subject: null, fields: null }]
|
|
760
|
-
};
|
|
761
|
-
const useAssets = ({ skipWhen = false, query = {} } = {}) => {
|
|
762
|
-
const { formatMessage } = useIntl();
|
|
763
|
-
const { toggleNotification } = useNotification();
|
|
764
|
-
const { notifyStatus } = useNotifyAT();
|
|
765
|
-
const { get } = useFetchClient();
|
|
766
|
-
const { folderPath, _q, ...paramsExceptFolderAndQ } = query;
|
|
767
|
-
let params;
|
|
768
|
-
if (_q) {
|
|
769
|
-
params = {
|
|
770
|
-
...paramsExceptFolderAndQ,
|
|
771
|
-
_q: encodeURIComponent(_q)
|
|
772
|
-
};
|
|
773
|
-
} else {
|
|
774
|
-
params = {
|
|
775
|
-
...paramsExceptFolderAndQ,
|
|
776
|
-
filters: {
|
|
777
|
-
$and: [
|
|
778
|
-
...paramsExceptFolderAndQ?.filters?.$and ?? [],
|
|
779
|
-
{
|
|
780
|
-
folderPath: { $eq: folderPath ?? "/" }
|
|
781
|
-
}
|
|
782
|
-
]
|
|
783
|
-
}
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
const { data, error, isLoading } = useQuery(
|
|
787
|
-
[pluginId, "assets", params],
|
|
788
|
-
async () => {
|
|
789
|
-
const { data: data2 } = await get("/upload/files", { params });
|
|
790
|
-
return data2;
|
|
791
|
-
},
|
|
792
|
-
{
|
|
793
|
-
enabled: !skipWhen,
|
|
794
|
-
staleTime: 0,
|
|
795
|
-
cacheTime: 0,
|
|
796
|
-
select(data2) {
|
|
797
|
-
if (data2?.results && Array.isArray(data2.results)) {
|
|
798
|
-
return {
|
|
799
|
-
...data2,
|
|
800
|
-
results: data2.results.filter((asset) => asset.name).map((asset) => ({
|
|
801
|
-
...asset,
|
|
802
|
-
/**
|
|
803
|
-
* Mime and ext cannot be null in the front-end because
|
|
804
|
-
* we expect them to be strings and use the `includes` method.
|
|
805
|
-
*/
|
|
806
|
-
mime: asset.mime ?? "",
|
|
807
|
-
ext: asset.ext ?? ""
|
|
808
|
-
}))
|
|
809
|
-
};
|
|
810
|
-
}
|
|
811
|
-
return data2;
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
);
|
|
815
|
-
React.useEffect(() => {
|
|
816
|
-
if (data) {
|
|
817
|
-
notifyStatus(
|
|
818
|
-
formatMessage({
|
|
819
|
-
id: "list.asset.at.finished",
|
|
820
|
-
defaultMessage: "The assets have finished loading."
|
|
821
|
-
})
|
|
822
|
-
);
|
|
823
|
-
}
|
|
824
|
-
}, [data, formatMessage, notifyStatus]);
|
|
825
|
-
React.useEffect(() => {
|
|
826
|
-
if (error) {
|
|
827
|
-
toggleNotification({
|
|
828
|
-
type: "danger",
|
|
829
|
-
message: formatMessage({ id: "notification.error" })
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
}, [error, formatMessage, toggleNotification]);
|
|
833
|
-
return { data, error, isLoading };
|
|
834
|
-
};
|
|
835
|
-
const useFolders = ({ enabled = true, query = {} } = {}) => {
|
|
836
|
-
const { formatMessage } = useIntl();
|
|
837
|
-
const { toggleNotification } = useNotification();
|
|
838
|
-
const { notifyStatus } = useNotifyAT();
|
|
839
|
-
const { folder, _q, ...paramsExceptFolderAndQ } = query;
|
|
840
|
-
const { get } = useFetchClient();
|
|
841
|
-
let params;
|
|
842
|
-
if (_q) {
|
|
843
|
-
params = {
|
|
844
|
-
...paramsExceptFolderAndQ,
|
|
845
|
-
pagination: {
|
|
846
|
-
pageSize: -1
|
|
847
|
-
},
|
|
848
|
-
_q
|
|
849
|
-
};
|
|
850
|
-
} else {
|
|
851
|
-
params = {
|
|
852
|
-
...paramsExceptFolderAndQ,
|
|
853
|
-
pagination: {
|
|
854
|
-
pageSize: -1
|
|
855
|
-
},
|
|
856
|
-
filters: {
|
|
857
|
-
$and: [
|
|
858
|
-
...paramsExceptFolderAndQ?.filters?.$and ?? [],
|
|
859
|
-
{
|
|
860
|
-
parent: {
|
|
861
|
-
id: folder ?? {
|
|
862
|
-
$null: true
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
]
|
|
645
|
+
const filteredLength = filtered.length;
|
|
646
|
+
if (filteredLength === 0) {
|
|
647
|
+
return true;
|
|
867
648
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
649
|
+
const errorMessage = filteredLength > 1 ? "form.upload-url.error.url.invalids" : "form.upload-url.error.url.invalid";
|
|
650
|
+
return this.createError({
|
|
651
|
+
path: this.path,
|
|
652
|
+
message: getTrad(errorMessage),
|
|
653
|
+
params: { number: filtered.length }
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
})
|
|
657
|
+
});
|
|
658
|
+
var AssetType = /* @__PURE__ */ ((AssetType2) => {
|
|
659
|
+
AssetType2["Video"] = "video";
|
|
660
|
+
AssetType2["Image"] = "image";
|
|
661
|
+
AssetType2["Document"] = "doc";
|
|
662
|
+
AssetType2["Audio"] = "audio";
|
|
663
|
+
return AssetType2;
|
|
664
|
+
})(AssetType || {});
|
|
665
|
+
var AssetSource = /* @__PURE__ */ ((AssetSource2) => {
|
|
666
|
+
AssetSource2["Url"] = "url";
|
|
667
|
+
AssetSource2["Computer"] = "computer";
|
|
668
|
+
return AssetSource2;
|
|
669
|
+
})(AssetSource || {});
|
|
670
|
+
const PERMISSIONS = {
|
|
671
|
+
// This permission regards the main component (App) and is used to tell
|
|
672
|
+
// If the plugin link should be displayed in the menu
|
|
673
|
+
// And also if the plugin is accessible. This use case is found when a user types the url of the
|
|
674
|
+
// plugin directly in the browser
|
|
675
|
+
main: [
|
|
676
|
+
{ action: "plugin::upload.read", subject: null },
|
|
677
|
+
{
|
|
678
|
+
action: "plugin::upload.assets.create",
|
|
679
|
+
subject: null
|
|
877
680
|
},
|
|
878
681
|
{
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
cacheTime: 0,
|
|
882
|
-
onError() {
|
|
883
|
-
toggleNotification({
|
|
884
|
-
type: "danger",
|
|
885
|
-
message: formatMessage({ id: "notification.error" })
|
|
886
|
-
});
|
|
887
|
-
}
|
|
682
|
+
action: "plugin::upload.assets.update",
|
|
683
|
+
subject: null
|
|
888
684
|
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
id: "list.asset.at.finished",
|
|
895
|
-
defaultMessage: "The folders have finished loading."
|
|
896
|
-
})
|
|
897
|
-
);
|
|
685
|
+
],
|
|
686
|
+
copyLink: [
|
|
687
|
+
{
|
|
688
|
+
action: "plugin::upload.assets.copy-link",
|
|
689
|
+
subject: null
|
|
898
690
|
}
|
|
899
|
-
|
|
900
|
-
|
|
691
|
+
],
|
|
692
|
+
create: [
|
|
693
|
+
{
|
|
694
|
+
action: "plugin::upload.assets.create",
|
|
695
|
+
subject: null
|
|
696
|
+
}
|
|
697
|
+
],
|
|
698
|
+
download: [
|
|
699
|
+
{
|
|
700
|
+
action: "plugin::upload.assets.download",
|
|
701
|
+
subject: null
|
|
702
|
+
}
|
|
703
|
+
],
|
|
704
|
+
read: [{ action: "plugin::upload.read", subject: null }],
|
|
705
|
+
configureView: [{ action: "plugin::upload.configure-view", subject: null }],
|
|
706
|
+
settings: [{ action: "plugin::upload.settings.read", subject: null }],
|
|
707
|
+
update: [{ action: "plugin::upload.assets.update", subject: null, fields: null }]
|
|
708
|
+
};
|
|
709
|
+
const tableHeaders = [
|
|
710
|
+
{
|
|
711
|
+
name: "preview",
|
|
712
|
+
key: "preview",
|
|
713
|
+
metadatas: {
|
|
714
|
+
label: { id: getTrad("list.table.header.preview"), defaultMessage: "preview" },
|
|
715
|
+
isSortable: false
|
|
716
|
+
},
|
|
717
|
+
type: "image"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
name: "name",
|
|
721
|
+
key: "name",
|
|
722
|
+
metadatas: {
|
|
723
|
+
label: { id: getTrad("list.table.header.name"), defaultMessage: "name" },
|
|
724
|
+
isSortable: true
|
|
725
|
+
},
|
|
726
|
+
type: "text"
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
name: "ext",
|
|
730
|
+
key: "extension",
|
|
731
|
+
metadatas: {
|
|
732
|
+
label: { id: getTrad("list.table.header.ext"), defaultMessage: "extension" },
|
|
733
|
+
isSortable: false
|
|
734
|
+
},
|
|
735
|
+
type: "ext"
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
name: "size",
|
|
739
|
+
key: "size",
|
|
740
|
+
metadatas: {
|
|
741
|
+
label: { id: getTrad("list.table.header.size"), defaultMessage: "size" },
|
|
742
|
+
isSortable: false
|
|
743
|
+
},
|
|
744
|
+
type: "size"
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
name: "createdAt",
|
|
748
|
+
key: "createdAt",
|
|
749
|
+
metadatas: {
|
|
750
|
+
label: { id: getTrad("list.table.header.createdAt"), defaultMessage: "created" },
|
|
751
|
+
isSortable: true
|
|
752
|
+
},
|
|
753
|
+
type: "date"
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
name: "updatedAt",
|
|
757
|
+
key: "updatedAt",
|
|
758
|
+
metadatas: {
|
|
759
|
+
label: { id: getTrad("list.table.header.updatedAt"), defaultMessage: "last update" },
|
|
760
|
+
isSortable: true
|
|
761
|
+
},
|
|
762
|
+
type: "date"
|
|
763
|
+
}
|
|
764
|
+
];
|
|
765
|
+
const sortOptions = [
|
|
766
|
+
{ key: "sort.created_at_desc", value: "createdAt:DESC" },
|
|
767
|
+
{ key: "sort.created_at_asc", value: "createdAt:ASC" },
|
|
768
|
+
{ key: "sort.name_asc", value: "name:ASC" },
|
|
769
|
+
{ key: "sort.name_desc", value: "name:DESC" },
|
|
770
|
+
{ key: "sort.updated_at_desc", value: "updatedAt:DESC" },
|
|
771
|
+
{ key: "sort.updated_at_asc", value: "updatedAt:ASC" }
|
|
772
|
+
];
|
|
773
|
+
const pageSizes = [10, 20, 50, 100];
|
|
774
|
+
const localStorageKeys = {
|
|
775
|
+
modalView: `STRAPI_UPLOAD_MODAL_VIEW`,
|
|
776
|
+
view: `STRAPI_UPLOAD_LIBRARY_VIEW`
|
|
901
777
|
};
|
|
902
|
-
const
|
|
778
|
+
const viewOptions = {
|
|
779
|
+
GRID: 0,
|
|
780
|
+
LIST: 1
|
|
781
|
+
};
|
|
782
|
+
const { main: _main, ...restPermissions } = PERMISSIONS;
|
|
903
783
|
const useMediaLibraryPermissions = () => {
|
|
904
784
|
const { allowedActions, isLoading } = useRBAC(restPermissions);
|
|
905
785
|
return { ...allowedActions, isLoading };
|
|
@@ -1034,13 +914,13 @@ const useModalQueryParams = (initialState) => {
|
|
|
1034
914
|
const useSelectionState = (keys, initialValue) => {
|
|
1035
915
|
const [selections, setSelections] = React.useState(initialValue);
|
|
1036
916
|
const selectOne = (selection) => {
|
|
1037
|
-
const
|
|
917
|
+
const index = selections.findIndex(
|
|
1038
918
|
(currentSelection) => keys.every((key) => currentSelection[key] === selection[key])
|
|
1039
919
|
);
|
|
1040
|
-
if (
|
|
920
|
+
if (index > -1) {
|
|
1041
921
|
setSelections((prevSelected) => [
|
|
1042
|
-
...prevSelected.slice(0,
|
|
1043
|
-
...prevSelected.slice(
|
|
922
|
+
...prevSelected.slice(0, index),
|
|
923
|
+
...prevSelected.slice(index + 1)
|
|
1044
924
|
]);
|
|
1045
925
|
} else {
|
|
1046
926
|
setSelections((prevSelected) => [...prevSelected, selection]);
|
|
@@ -1054,10 +934,10 @@ const useSelectionState = (keys, initialValue) => {
|
|
|
1054
934
|
}
|
|
1055
935
|
};
|
|
1056
936
|
const selectOnly = (nextSelection) => {
|
|
1057
|
-
const
|
|
937
|
+
const index = selections.findIndex(
|
|
1058
938
|
(currentSelection) => keys.every((key) => currentSelection[key] === nextSelection[key])
|
|
1059
939
|
);
|
|
1060
|
-
if (
|
|
940
|
+
if (index > -1) {
|
|
1061
941
|
setSelections([]);
|
|
1062
942
|
} else {
|
|
1063
943
|
setSelections([nextSelection]);
|
|
@@ -1197,14 +1077,6 @@ const ContextInfo = ({ blocks }) => {
|
|
|
1197
1077
|
}
|
|
1198
1078
|
);
|
|
1199
1079
|
};
|
|
1200
|
-
ContextInfo.propTypes = {
|
|
1201
|
-
blocks: PropTypes.arrayOf(
|
|
1202
|
-
PropTypes.shape({
|
|
1203
|
-
label: PropTypes.string,
|
|
1204
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
1205
|
-
})
|
|
1206
|
-
).isRequired
|
|
1207
|
-
};
|
|
1208
1080
|
const ToggleButton = styled(Flex)`
|
|
1209
1081
|
align-self: flex-end;
|
|
1210
1082
|
height: 2.2rem;
|
|
@@ -1221,9 +1093,9 @@ const Option = ({ children, data, selectProps, ...props }) => {
|
|
|
1221
1093
|
const { maxDisplayDepth, openValues, onOptionToggle } = selectProps;
|
|
1222
1094
|
const isOpen = openValues.includes(value);
|
|
1223
1095
|
const Icon = isOpen ? ChevronUp : ChevronDown;
|
|
1224
|
-
return /* @__PURE__ */ jsx(components.Option, { ...props, children: /* @__PURE__ */ jsxs(Flex, { alignItems: "start", children: [
|
|
1096
|
+
return /* @__PURE__ */ jsx(components.Option, { data, selectProps, ...props, children: /* @__PURE__ */ jsxs(Flex, { alignItems: "start", children: [
|
|
1225
1097
|
/* @__PURE__ */ jsx(Typography, { textColor: "neutral800", ellipsis: true, children: /* @__PURE__ */ jsx("span", { style: { paddingLeft: `${Math.min(depth, maxDisplayDepth) * 14}px` }, children }) }),
|
|
1226
|
-
options?.length > 0 && /* @__PURE__ */ jsx(
|
|
1098
|
+
options && options?.length > 0 && /* @__PURE__ */ jsx(
|
|
1227
1099
|
ToggleButton,
|
|
1228
1100
|
{
|
|
1229
1101
|
"aria-label": formatMessage({
|
|
@@ -1245,18 +1117,8 @@ const Option = ({ children, data, selectProps, ...props }) => {
|
|
|
1245
1117
|
)
|
|
1246
1118
|
] }) });
|
|
1247
1119
|
};
|
|
1248
|
-
Option.propTypes = {
|
|
1249
|
-
children: PropTypes.node.isRequired,
|
|
1250
|
-
data: PropTypes.object.isRequired,
|
|
1251
|
-
onToggle: PropTypes.func.isRequired,
|
|
1252
|
-
selectProps: PropTypes.shape({
|
|
1253
|
-
maxDisplayDepth: PropTypes.number,
|
|
1254
|
-
openValues: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
|
|
1255
|
-
onOptionToggle: PropTypes.func
|
|
1256
|
-
}).isRequired
|
|
1257
|
-
};
|
|
1258
1120
|
function getOpenValues(options, defaultValue = {}) {
|
|
1259
|
-
|
|
1121
|
+
const values = [];
|
|
1260
1122
|
const { value } = defaultValue;
|
|
1261
1123
|
const option = options.find((option2) => option2.value === value);
|
|
1262
1124
|
if (!option) {
|
|
@@ -1266,6 +1128,9 @@ function getOpenValues(options, defaultValue = {}) {
|
|
|
1266
1128
|
let { parent } = option;
|
|
1267
1129
|
while (parent !== void 0) {
|
|
1268
1130
|
const option2 = options.find(({ value: value2 }) => value2 === parent);
|
|
1131
|
+
if (!option2) {
|
|
1132
|
+
break;
|
|
1133
|
+
}
|
|
1269
1134
|
values.push(option2.value);
|
|
1270
1135
|
parent = option2.parent;
|
|
1271
1136
|
}
|
|
@@ -1273,15 +1138,28 @@ function getOpenValues(options, defaultValue = {}) {
|
|
|
1273
1138
|
}
|
|
1274
1139
|
function getValuesToClose(options, value) {
|
|
1275
1140
|
const optionForValue = options.find((option) => option.value === value);
|
|
1141
|
+
if (!optionForValue) {
|
|
1142
|
+
return [];
|
|
1143
|
+
}
|
|
1276
1144
|
return options.filter((option) => option.depth >= optionForValue.depth).map((option) => option.value);
|
|
1277
1145
|
}
|
|
1278
1146
|
const hasParent = (option) => !option.parent;
|
|
1279
|
-
const SelectTree = ({
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1147
|
+
const SelectTree = ({
|
|
1148
|
+
options: defaultOptions,
|
|
1149
|
+
maxDisplayDepth = 5,
|
|
1150
|
+
defaultValue,
|
|
1151
|
+
...props
|
|
1152
|
+
}) => {
|
|
1153
|
+
const flatDefaultOptions = React.useMemo(() => flattenTree(defaultOptions), [defaultOptions]);
|
|
1154
|
+
const optionsFiltered = React.useMemo(
|
|
1155
|
+
() => flatDefaultOptions.filter(hasParent),
|
|
1156
|
+
[flatDefaultOptions]
|
|
1157
|
+
);
|
|
1158
|
+
const [options, setOptions] = React.useState(optionsFiltered);
|
|
1159
|
+
const [openValues, setOpenValues] = React.useState(
|
|
1160
|
+
getOpenValues(flatDefaultOptions, defaultValue)
|
|
1161
|
+
);
|
|
1162
|
+
React.useEffect(() => {
|
|
1285
1163
|
if (openValues.length === 0) {
|
|
1286
1164
|
setOptions(flatDefaultOptions.filter((option) => option.parent === void 0));
|
|
1287
1165
|
} else {
|
|
@@ -1323,7 +1201,13 @@ const SelectTree = ({ options: defaultOptions, maxDisplayDepth, defaultValue, ..
|
|
|
1323
1201
|
}
|
|
1324
1202
|
);
|
|
1325
1203
|
};
|
|
1326
|
-
const Select = ({
|
|
1204
|
+
const Select = ({
|
|
1205
|
+
components: components2 = {},
|
|
1206
|
+
styles = {},
|
|
1207
|
+
error,
|
|
1208
|
+
ariaErrorMessage,
|
|
1209
|
+
...props
|
|
1210
|
+
}) => {
|
|
1327
1211
|
const theme = useTheme();
|
|
1328
1212
|
const customStyles = getSelectStyles(theme, error);
|
|
1329
1213
|
return /* @__PURE__ */ jsx(
|
|
@@ -1331,11 +1215,11 @@ const Select = ({ components: components2, styles, error, ariaErrorMessage, ...p
|
|
|
1331
1215
|
{
|
|
1332
1216
|
menuPosition: "fixed",
|
|
1333
1217
|
components: {
|
|
1218
|
+
...components2,
|
|
1334
1219
|
ClearIndicator,
|
|
1335
1220
|
DropdownIndicator,
|
|
1336
1221
|
IndicatorSeparator: () => null,
|
|
1337
|
-
LoadingIndicator: () => null
|
|
1338
|
-
...components2
|
|
1222
|
+
LoadingIndicator: () => null
|
|
1339
1223
|
},
|
|
1340
1224
|
"aria-errormessage": error && ariaErrorMessage,
|
|
1341
1225
|
"aria-invalid": !!error,
|
|
@@ -1344,18 +1228,6 @@ const Select = ({ components: components2, styles, error, ariaErrorMessage, ...p
|
|
|
1344
1228
|
}
|
|
1345
1229
|
);
|
|
1346
1230
|
};
|
|
1347
|
-
Select.defaultProps = {
|
|
1348
|
-
ariaErrorMessage: "",
|
|
1349
|
-
components: {},
|
|
1350
|
-
error: void 0,
|
|
1351
|
-
styles: {}
|
|
1352
|
-
};
|
|
1353
|
-
Select.propTypes = {
|
|
1354
|
-
components: PropTypes.object,
|
|
1355
|
-
styles: PropTypes.object,
|
|
1356
|
-
error: PropTypes.string,
|
|
1357
|
-
ariaErrorMessage: PropTypes.string
|
|
1358
|
-
};
|
|
1359
1231
|
const IconBox = styled(Box)`
|
|
1360
1232
|
background: transparent;
|
|
1361
1233
|
border: none;
|
|
@@ -1385,13 +1257,7 @@ const CarretBox = styled(IconBox)`
|
|
|
1385
1257
|
}
|
|
1386
1258
|
`;
|
|
1387
1259
|
const DropdownIndicator = ({ innerProps }) => {
|
|
1388
|
-
return (
|
|
1389
|
-
// @ts-expect-error – issue with the ref attached to `innerProps`
|
|
1390
|
-
/* @__PURE__ */ jsx(CarretBox, { paddingRight: 3, ...innerProps, children: /* @__PURE__ */ jsx(CaretDown, {}) })
|
|
1391
|
-
);
|
|
1392
|
-
};
|
|
1393
|
-
DropdownIndicator.propTypes = {
|
|
1394
|
-
innerProps: PropTypes.object.isRequired
|
|
1260
|
+
return /* @__PURE__ */ jsx(CarretBox, { paddingRight: 3, ...innerProps, children: /* @__PURE__ */ jsx(CaretDown, {}) });
|
|
1395
1261
|
};
|
|
1396
1262
|
const getSelectStyles = (theme, error) => {
|
|
1397
1263
|
return {
|
|
@@ -1403,8 +1269,8 @@ const getSelectStyles = (theme, error) => {
|
|
|
1403
1269
|
}),
|
|
1404
1270
|
control(base, state) {
|
|
1405
1271
|
let borderColor = theme.colors.neutral200;
|
|
1406
|
-
let boxShadowColor;
|
|
1407
|
-
let backgroundColor;
|
|
1272
|
+
let boxShadowColor = void 0;
|
|
1273
|
+
let backgroundColor = void 0;
|
|
1408
1274
|
if (state.isFocused) {
|
|
1409
1275
|
borderColor = theme.colors.primary600;
|
|
1410
1276
|
boxShadowColor = theme.colors.primary600;
|
|
@@ -1459,8 +1325,9 @@ const getSelectStyles = (theme, error) => {
|
|
|
1459
1325
|
paddingRight: theme.spaces[1],
|
|
1460
1326
|
paddingBottom: theme.spaces[1]
|
|
1461
1327
|
}),
|
|
1328
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1462
1329
|
option(base, state) {
|
|
1463
|
-
let backgroundColor = base
|
|
1330
|
+
let backgroundColor = base?.backgroundColor;
|
|
1464
1331
|
if (state.isFocused || state.isSelected) {
|
|
1465
1332
|
backgroundColor = theme.colors.primary100;
|
|
1466
1333
|
}
|
|
@@ -1501,26 +1368,6 @@ const getSelectStyles = (theme, error) => {
|
|
|
1501
1368
|
})
|
|
1502
1369
|
};
|
|
1503
1370
|
};
|
|
1504
|
-
const OptionShape = PropTypes.shape({
|
|
1505
|
-
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
1506
|
-
label: PropTypes.string.isRequired,
|
|
1507
|
-
children: PropTypes.array
|
|
1508
|
-
});
|
|
1509
|
-
OptionShape.children = PropTypes.arrayOf(PropTypes.shape(OptionShape));
|
|
1510
|
-
OptionShape.defaultProps = {
|
|
1511
|
-
children: void 0
|
|
1512
|
-
};
|
|
1513
|
-
SelectTree.defaultProps = {
|
|
1514
|
-
defaultValue: void 0,
|
|
1515
|
-
maxDisplayDepth: 5
|
|
1516
|
-
};
|
|
1517
|
-
SelectTree.propTypes = {
|
|
1518
|
-
defaultValue: PropTypes.shape({
|
|
1519
|
-
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
1520
|
-
}),
|
|
1521
|
-
maxDisplayDepth: PropTypes.number,
|
|
1522
|
-
options: PropTypes.arrayOf(OptionShape).isRequired
|
|
1523
|
-
};
|
|
1524
1371
|
const DialogHeader = () => {
|
|
1525
1372
|
const { formatMessage } = useIntl();
|
|
1526
1373
|
return /* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: formatMessage({ id: "global.details", defaultMessage: "Details" }) }) });
|
|
@@ -1634,6 +1481,7 @@ const useUpload = () => {
|
|
|
1634
1481
|
const cancel = () => abortController.abort();
|
|
1635
1482
|
return {
|
|
1636
1483
|
upload,
|
|
1484
|
+
isLoading: mutation.isLoading,
|
|
1637
1485
|
cancel,
|
|
1638
1486
|
error: mutation.error,
|
|
1639
1487
|
progress,
|
|
@@ -1668,9 +1516,6 @@ const CopyLinkButton = ({ url }) => {
|
|
|
1668
1516
|
}
|
|
1669
1517
|
);
|
|
1670
1518
|
};
|
|
1671
|
-
CopyLinkButton.propTypes = {
|
|
1672
|
-
url: PropTypes.string.isRequired
|
|
1673
|
-
};
|
|
1674
1519
|
const BoxWrapper = styled(Flex)`
|
|
1675
1520
|
border-radius: ${({ theme }) => `${theme.borderRadius} ${theme.borderRadius} 0 0`};
|
|
1676
1521
|
width: 100%;
|
|
@@ -1702,10 +1547,11 @@ const CancelButton = styled.button`
|
|
|
1702
1547
|
}
|
|
1703
1548
|
}
|
|
1704
1549
|
`;
|
|
1705
|
-
const UploadProgress = ({ onCancel, progress, error }) => {
|
|
1550
|
+
const UploadProgress = ({ onCancel, progress = 0, error }) => {
|
|
1706
1551
|
const { formatMessage } = useIntl();
|
|
1707
1552
|
return /* @__PURE__ */ jsx(BoxWrapper, { alignItems: "center", background: error ? "danger100" : "neutral150", error, children: error ? /* @__PURE__ */ jsx(Cross, { "aria-label": error?.message }) : /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 2, width: "100%", children: [
|
|
1708
|
-
/* @__PURE__ */ jsx(ProgressBar, { value: progress
|
|
1553
|
+
/* @__PURE__ */ jsx(ProgressBar, { value: progress }),
|
|
1554
|
+
/* @__PURE__ */ jsx(Typography, { children: `${progress}/100%` }),
|
|
1709
1555
|
/* @__PURE__ */ jsx(CancelButton, { type: "button", onClick: onCancel, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
1710
1556
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", tag: "span", textColor: "inherit", children: formatMessage({
|
|
1711
1557
|
id: "app.components.Button.cancel",
|
|
@@ -1715,15 +1561,6 @@ const UploadProgress = ({ onCancel, progress, error }) => {
|
|
|
1715
1561
|
] }) })
|
|
1716
1562
|
] }) });
|
|
1717
1563
|
};
|
|
1718
|
-
UploadProgress.defaultProps = {
|
|
1719
|
-
error: void 0,
|
|
1720
|
-
progress: 0
|
|
1721
|
-
};
|
|
1722
|
-
UploadProgress.propTypes = {
|
|
1723
|
-
error: PropTypes.instanceOf(Error),
|
|
1724
|
-
onCancel: PropTypes.func.isRequired,
|
|
1725
|
-
progress: PropTypes.number
|
|
1726
|
-
};
|
|
1727
1564
|
const useRemoveAsset = (onSuccess) => {
|
|
1728
1565
|
const { toggleNotification } = useNotification();
|
|
1729
1566
|
const { formatMessage } = useIntl();
|
|
@@ -1759,25 +1596,11 @@ const RemoveAssetDialog = ({ open, onClose, asset }) => {
|
|
|
1759
1596
|
onClose(null);
|
|
1760
1597
|
});
|
|
1761
1598
|
const handleConfirm = async (event) => {
|
|
1762
|
-
event
|
|
1599
|
+
event?.preventDefault();
|
|
1763
1600
|
await removeAsset(asset.id);
|
|
1764
1601
|
};
|
|
1765
1602
|
return /* @__PURE__ */ jsx(Dialog.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(ConfirmDialog, { onConfirm: handleConfirm }) });
|
|
1766
1603
|
};
|
|
1767
|
-
RemoveAssetDialog.propTypes = {
|
|
1768
|
-
onClose: PropTypes.func.isRequired,
|
|
1769
|
-
open: PropTypes.bool.isRequired,
|
|
1770
|
-
asset: PropTypes.shape({
|
|
1771
|
-
id: PropTypes.number,
|
|
1772
|
-
height: PropTypes.number,
|
|
1773
|
-
width: PropTypes.number,
|
|
1774
|
-
size: PropTypes.number,
|
|
1775
|
-
createdAt: PropTypes.string,
|
|
1776
|
-
ext: PropTypes.string,
|
|
1777
|
-
name: PropTypes.string,
|
|
1778
|
-
url: PropTypes.string
|
|
1779
|
-
}).isRequired
|
|
1780
|
-
};
|
|
1781
1604
|
const usePersistentState = (key, defaultValue) => {
|
|
1782
1605
|
const [value, setValue] = useState(() => {
|
|
1783
1606
|
const stickyValue = window.localStorage.getItem(key);
|
|
@@ -1799,7 +1622,7 @@ const CardAsset$1 = styled(Flex)`
|
|
|
1799
1622
|
border-radius: ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius} 0 0;
|
|
1800
1623
|
background: linear-gradient(180deg, #ffffff 0%, #f6f6f9 121.48%);
|
|
1801
1624
|
`;
|
|
1802
|
-
const AssetPreview = forwardRef(({ mime, url, name: name2, ...props }, ref) => {
|
|
1625
|
+
const AssetPreview = React.forwardRef(({ mime, url, name: name2, ...props }, ref) => {
|
|
1803
1626
|
const [lang] = usePersistentState("strapi-admin-language", "en");
|
|
1804
1627
|
if (mime.includes(AssetType.Image)) {
|
|
1805
1628
|
return /* @__PURE__ */ jsx("img", { ref, src: url, alt: name2, ...props });
|
|
@@ -1816,11 +1639,6 @@ const AssetPreview = forwardRef(({ mime, url, name: name2, ...props }, ref) => {
|
|
|
1816
1639
|
return /* @__PURE__ */ jsx(CardAsset$1, { justifyContent: "center", ...props, children: /* @__PURE__ */ jsx(File$1, { "aria-label": name2 }) });
|
|
1817
1640
|
});
|
|
1818
1641
|
AssetPreview.displayName = "AssetPreview";
|
|
1819
|
-
AssetPreview.propTypes = {
|
|
1820
|
-
mime: PropTypes.string.isRequired,
|
|
1821
|
-
name: PropTypes.string.isRequired,
|
|
1822
|
-
url: PropTypes.string.isRequired
|
|
1823
|
-
};
|
|
1824
1642
|
const RelativeBox = styled(Box)`
|
|
1825
1643
|
position: relative;
|
|
1826
1644
|
`;
|
|
@@ -1947,14 +1765,6 @@ const Trigger = styled(Menu.Trigger)`
|
|
|
1947
1765
|
}
|
|
1948
1766
|
}
|
|
1949
1767
|
`;
|
|
1950
|
-
CroppingActions.defaultProps = {
|
|
1951
|
-
onDuplicate: void 0
|
|
1952
|
-
};
|
|
1953
|
-
CroppingActions.propTypes = {
|
|
1954
|
-
onCancel: PropTypes.func.isRequired,
|
|
1955
|
-
onDuplicate: PropTypes.func,
|
|
1956
|
-
onValidate: PropTypes.func.isRequired
|
|
1957
|
-
};
|
|
1958
1768
|
const PreviewBox = ({
|
|
1959
1769
|
asset,
|
|
1960
1770
|
canUpdate,
|
|
@@ -1968,13 +1778,13 @@ const PreviewBox = ({
|
|
|
1968
1778
|
trackedLocation
|
|
1969
1779
|
}) => {
|
|
1970
1780
|
const { trackUsage } = useTracking();
|
|
1971
|
-
const previewRef = useRef(null);
|
|
1972
|
-
const [isCropImageReady, setIsCropImageReady] = useState(false);
|
|
1973
|
-
const [hasCropIntent, setHasCropIntent] = useState(null);
|
|
1974
|
-
const [assetUrl, setAssetUrl] = useState(createAssetUrl(asset, false));
|
|
1975
|
-
const [thumbnailUrl, setThumbnailUrl] = useState(createAssetUrl(asset, true));
|
|
1781
|
+
const previewRef = React.useRef(null);
|
|
1782
|
+
const [isCropImageReady, setIsCropImageReady] = React.useState(false);
|
|
1783
|
+
const [hasCropIntent, setHasCropIntent] = React.useState(null);
|
|
1784
|
+
const [assetUrl, setAssetUrl] = React.useState(createAssetUrl(asset, false));
|
|
1785
|
+
const [thumbnailUrl, setThumbnailUrl] = React.useState(createAssetUrl(asset, true));
|
|
1976
1786
|
const { formatMessage } = useIntl();
|
|
1977
|
-
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
|
|
1787
|
+
const [showConfirmDialog, setShowConfirmDialog] = React.useState(false);
|
|
1978
1788
|
const { crop, produceFile, stopCropping, isCropping, isCropperReady, width, height } = useCropImg();
|
|
1979
1789
|
const { editAsset, error, isLoading, progress, cancel } = useEditAsset();
|
|
1980
1790
|
const {
|
|
@@ -1984,7 +1794,7 @@ const PreviewBox = ({
|
|
|
1984
1794
|
error: uploadError,
|
|
1985
1795
|
progress: progressUpload
|
|
1986
1796
|
} = useUpload();
|
|
1987
|
-
useEffect(() => {
|
|
1797
|
+
React.useEffect(() => {
|
|
1988
1798
|
if (replacementFile) {
|
|
1989
1799
|
const fileLocalUrl = URL.createObjectURL(replacementFile);
|
|
1990
1800
|
if (asset.isLocal) {
|
|
@@ -1994,13 +1804,13 @@ const PreviewBox = ({
|
|
|
1994
1804
|
setThumbnailUrl(fileLocalUrl);
|
|
1995
1805
|
}
|
|
1996
1806
|
}, [replacementFile, asset]);
|
|
1997
|
-
useEffect(() => {
|
|
1807
|
+
React.useEffect(() => {
|
|
1998
1808
|
if (hasCropIntent === false) {
|
|
1999
1809
|
stopCropping();
|
|
2000
1810
|
onCropCancel();
|
|
2001
1811
|
}
|
|
2002
1812
|
}, [hasCropIntent, stopCropping, onCropCancel, onCropFinish]);
|
|
2003
|
-
useEffect(() => {
|
|
1813
|
+
React.useEffect(() => {
|
|
2004
1814
|
if (hasCropIntent && isCropImageReady) {
|
|
2005
1815
|
crop(previewRef.current);
|
|
2006
1816
|
onCropStart();
|
|
@@ -2030,8 +1840,12 @@ const PreviewBox = ({
|
|
|
2030
1840
|
const isInCroppingMode = isCropping && !isLoading;
|
|
2031
1841
|
const handleDuplication = async () => {
|
|
2032
1842
|
const nextAsset = { ...asset, width, height };
|
|
2033
|
-
const file = await produceFile(
|
|
2034
|
-
|
|
1843
|
+
const file = await produceFile(
|
|
1844
|
+
nextAsset.name,
|
|
1845
|
+
nextAsset.mime,
|
|
1846
|
+
nextAsset.updatedAt
|
|
1847
|
+
);
|
|
1848
|
+
await upload({ name: file.name, rawFile: file }, asset.folder?.id ? asset.folder.id : null);
|
|
2035
1849
|
trackUsage("didCropFile", { duplicatedFile: true, location: trackedLocation });
|
|
2036
1850
|
setHasCropIntent(false);
|
|
2037
1851
|
onCropFinish();
|
|
@@ -2076,7 +1890,7 @@ const PreviewBox = ({
|
|
|
2076
1890
|
}
|
|
2077
1891
|
),
|
|
2078
1892
|
canCopyLink && /* @__PURE__ */ jsx(CopyLinkButton, { url: assetUrl }),
|
|
2079
|
-
canUpdate && asset.mime
|
|
1893
|
+
canUpdate && asset.mime?.includes(AssetType.Image) && /* @__PURE__ */ jsx(
|
|
2080
1894
|
IconButton,
|
|
2081
1895
|
{
|
|
2082
1896
|
label: formatMessage({ id: getTrad("control-card.crop"), defaultMessage: "Crop" }),
|
|
@@ -2134,35 +1948,24 @@ const PreviewBox = ({
|
|
|
2134
1948
|
)
|
|
2135
1949
|
] });
|
|
2136
1950
|
};
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
canCopyLink: PropTypes.bool.isRequired,
|
|
2144
|
-
canDownload: PropTypes.bool.isRequired,
|
|
2145
|
-
replacementFile: PropTypes.instanceOf(File),
|
|
2146
|
-
asset: AssetDefinition.isRequired,
|
|
2147
|
-
onDelete: PropTypes.func.isRequired,
|
|
2148
|
-
onCropFinish: PropTypes.func.isRequired,
|
|
2149
|
-
onCropStart: PropTypes.func.isRequired,
|
|
2150
|
-
onCropCancel: PropTypes.func.isRequired,
|
|
2151
|
-
trackedLocation: PropTypes.string
|
|
2152
|
-
};
|
|
2153
|
-
const ReplaceMediaButton = ({ onSelectMedia, acceptedMime, trackedLocation, ...props }) => {
|
|
1951
|
+
const ReplaceMediaButton = ({
|
|
1952
|
+
onSelectMedia,
|
|
1953
|
+
acceptedMime,
|
|
1954
|
+
trackedLocation,
|
|
1955
|
+
...props
|
|
1956
|
+
}) => {
|
|
2154
1957
|
const { formatMessage } = useIntl();
|
|
2155
|
-
const inputRef = useRef(null);
|
|
1958
|
+
const inputRef = React.useRef(null);
|
|
2156
1959
|
const { trackUsage } = useTracking();
|
|
2157
1960
|
const handleClick = (e) => {
|
|
2158
1961
|
e.preventDefault();
|
|
2159
1962
|
if (trackedLocation) {
|
|
2160
1963
|
trackUsage("didReplaceMedia", { location: trackedLocation });
|
|
2161
1964
|
}
|
|
2162
|
-
inputRef.current
|
|
1965
|
+
inputRef.current?.click();
|
|
2163
1966
|
};
|
|
2164
1967
|
const handleChange = () => {
|
|
2165
|
-
const file = inputRef.current
|
|
1968
|
+
const file = inputRef.current?.files?.[0];
|
|
2166
1969
|
onSelectMedia(file);
|
|
2167
1970
|
};
|
|
2168
1971
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -2176,6 +1979,7 @@ const ReplaceMediaButton = ({ onSelectMedia, acceptedMime, trackedLocation, ...p
|
|
|
2176
1979
|
accept: acceptedMime,
|
|
2177
1980
|
type: "file",
|
|
2178
1981
|
name: "file",
|
|
1982
|
+
"data-testid": "file-input",
|
|
2179
1983
|
tabIndex: -1,
|
|
2180
1984
|
ref: inputRef,
|
|
2181
1985
|
onChange: handleChange,
|
|
@@ -2184,14 +1988,6 @@ const ReplaceMediaButton = ({ onSelectMedia, acceptedMime, trackedLocation, ...p
|
|
|
2184
1988
|
) })
|
|
2185
1989
|
] });
|
|
2186
1990
|
};
|
|
2187
|
-
ReplaceMediaButton.defaultProps = {
|
|
2188
|
-
trackedLocation: void 0
|
|
2189
|
-
};
|
|
2190
|
-
ReplaceMediaButton.propTypes = {
|
|
2191
|
-
acceptedMime: PropTypes.string.isRequired,
|
|
2192
|
-
onSelectMedia: PropTypes.func.isRequired,
|
|
2193
|
-
trackedLocation: PropTypes.string
|
|
2194
|
-
};
|
|
2195
1991
|
const LoadingBody$1 = styled(Flex)`
|
|
2196
1992
|
/* 80px are coming from the Tabs component that is not included in the ModalBody */
|
|
2197
1993
|
min-height: ${() => `calc(60vh + 8rem)`};
|
|
@@ -2205,28 +2001,28 @@ const fileInfoSchema = yup.object({
|
|
|
2205
2001
|
const EditAssetContent = ({
|
|
2206
2002
|
onClose,
|
|
2207
2003
|
asset,
|
|
2208
|
-
canUpdate,
|
|
2209
|
-
canCopyLink,
|
|
2210
|
-
canDownload,
|
|
2004
|
+
canUpdate = false,
|
|
2005
|
+
canCopyLink = false,
|
|
2006
|
+
canDownload = false,
|
|
2211
2007
|
trackedLocation
|
|
2212
2008
|
}) => {
|
|
2213
2009
|
const { formatMessage, formatDate } = useIntl();
|
|
2214
2010
|
const { trackUsage } = useTracking();
|
|
2215
|
-
const submitButtonRef = useRef(null);
|
|
2216
|
-
const [isCropping, setIsCropping] = useState(false);
|
|
2217
|
-
const [replacementFile, setReplacementFile] = useState();
|
|
2011
|
+
const submitButtonRef = React.useRef(null);
|
|
2012
|
+
const [isCropping, setIsCropping] = React.useState(false);
|
|
2013
|
+
const [replacementFile, setReplacementFile] = React.useState();
|
|
2218
2014
|
const { editAsset, isLoading } = useEditAsset();
|
|
2219
2015
|
const { data: folderStructure, isLoading: folderStructureIsLoading } = useFolderStructure({
|
|
2220
2016
|
enabled: true
|
|
2221
2017
|
});
|
|
2222
2018
|
const handleSubmit = async (values) => {
|
|
2223
|
-
const nextAsset = { ...asset, ...values, folder: values.parent
|
|
2224
|
-
if (asset
|
|
2019
|
+
const nextAsset = { ...asset, ...values, folder: values.parent?.value };
|
|
2020
|
+
if (asset?.isLocal) {
|
|
2225
2021
|
onClose(nextAsset);
|
|
2226
2022
|
} else {
|
|
2227
2023
|
const editedAsset = await editAsset(nextAsset, replacementFile);
|
|
2228
|
-
const assetType = asset?.mime
|
|
2229
|
-
const didChangeLocation = asset?.folder?.id ? asset.folder.id !== values.parent
|
|
2024
|
+
const assetType = asset?.mime?.split("/")[0];
|
|
2025
|
+
const didChangeLocation = asset?.folder?.id ? asset.folder.id !== values.parent?.value : asset?.folder === null && !!values.parent?.value;
|
|
2230
2026
|
trackUsage("didEditMediaLibraryElements", {
|
|
2231
2027
|
location: trackedLocation,
|
|
2232
2028
|
type: assetType,
|
|
@@ -2259,9 +2055,9 @@ const EditAssetContent = ({
|
|
|
2259
2055
|
};
|
|
2260
2056
|
const activeFolderId = asset?.folder?.id;
|
|
2261
2057
|
const initialFormData = !folderStructureIsLoading && {
|
|
2262
|
-
name: asset
|
|
2263
|
-
alternativeText: asset
|
|
2264
|
-
caption: asset
|
|
2058
|
+
name: asset?.name,
|
|
2059
|
+
alternativeText: asset?.alternativeText ?? void 0,
|
|
2060
|
+
caption: asset?.caption ?? void 0,
|
|
2265
2061
|
parent: {
|
|
2266
2062
|
value: activeFolderId ?? void 0,
|
|
2267
2063
|
label: findRecursiveFolderByValue(folderStructure, activeFolderId)?.label ?? folderStructure[0].label
|
|
@@ -2320,35 +2116,35 @@ const EditAssetContent = ({
|
|
|
2320
2116
|
id: getTrad("modal.file-details.size"),
|
|
2321
2117
|
defaultMessage: "Size"
|
|
2322
2118
|
}),
|
|
2323
|
-
value: formatBytes(asset.size)
|
|
2119
|
+
value: formatBytes(asset?.size ? asset.size : 0)
|
|
2324
2120
|
},
|
|
2325
2121
|
{
|
|
2326
2122
|
label: formatMessage({
|
|
2327
2123
|
id: getTrad("modal.file-details.dimensions"),
|
|
2328
2124
|
defaultMessage: "Dimensions"
|
|
2329
2125
|
}),
|
|
2330
|
-
value: asset
|
|
2126
|
+
value: asset?.height && asset.width ? `${asset.width}✕${asset.height}` : null
|
|
2331
2127
|
},
|
|
2332
2128
|
{
|
|
2333
2129
|
label: formatMessage({
|
|
2334
2130
|
id: getTrad("modal.file-details.date"),
|
|
2335
2131
|
defaultMessage: "Date"
|
|
2336
2132
|
}),
|
|
2337
|
-
value: formatDate(new Date(asset.createdAt))
|
|
2133
|
+
value: formatDate(new Date(asset?.createdAt ? asset.createdAt : ""))
|
|
2338
2134
|
},
|
|
2339
2135
|
{
|
|
2340
2136
|
label: formatMessage({
|
|
2341
2137
|
id: getTrad("modal.file-details.extension"),
|
|
2342
2138
|
defaultMessage: "Extension"
|
|
2343
2139
|
}),
|
|
2344
|
-
value: getFileExtension(asset
|
|
2140
|
+
value: getFileExtension(asset?.ext)
|
|
2345
2141
|
},
|
|
2346
2142
|
{
|
|
2347
2143
|
label: formatMessage({
|
|
2348
2144
|
id: getTrad("modal.file-details.id"),
|
|
2349
2145
|
defaultMessage: "Asset ID"
|
|
2350
2146
|
}),
|
|
2351
|
-
value: asset.id
|
|
2147
|
+
value: asset?.id ? asset.id : null
|
|
2352
2148
|
}
|
|
2353
2149
|
]
|
|
2354
2150
|
}
|
|
@@ -2445,13 +2241,13 @@ const EditAssetContent = ({
|
|
|
2445
2241
|
] }) })
|
|
2446
2242
|
] }) }),
|
|
2447
2243
|
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
|
2448
|
-
/* @__PURE__ */ jsx(Button, { onClick: () => handleClose(values), variant: "tertiary", children: formatMessage({ id: "global.cancel", defaultMessage: "Cancel" }) }),
|
|
2244
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => handleClose({ ...values }), variant: "tertiary", children: formatMessage({ id: "global.cancel", defaultMessage: "Cancel" }) }),
|
|
2449
2245
|
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
2450
2246
|
/* @__PURE__ */ jsx(
|
|
2451
2247
|
ReplaceMediaButton,
|
|
2452
2248
|
{
|
|
2453
2249
|
onSelectMedia: setReplacementFile,
|
|
2454
|
-
acceptedMime: asset
|
|
2250
|
+
acceptedMime: asset?.mime ?? "",
|
|
2455
2251
|
disabled: formDisabled,
|
|
2456
2252
|
trackedLocation
|
|
2457
2253
|
}
|
|
@@ -2459,7 +2255,7 @@ const EditAssetContent = ({
|
|
|
2459
2255
|
/* @__PURE__ */ jsx(
|
|
2460
2256
|
Button,
|
|
2461
2257
|
{
|
|
2462
|
-
onClick: () => submitButtonRef.current
|
|
2258
|
+
onClick: () => submitButtonRef.current?.click(),
|
|
2463
2259
|
loading: isLoading,
|
|
2464
2260
|
disabled: formDisabled,
|
|
2465
2261
|
children: formatMessage({ id: "global.finish", defaultMessage: "Finish" })
|
|
@@ -2471,39 +2267,24 @@ const EditAssetContent = ({
|
|
|
2471
2267
|
}
|
|
2472
2268
|
);
|
|
2473
2269
|
};
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
canUpdate
|
|
2478
|
-
canCopyLink
|
|
2479
|
-
canDownload
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
};
|
|
2492
|
-
EditAssetDialog.defaultProps = {
|
|
2493
|
-
asset: {},
|
|
2494
|
-
trackedLocation: void 0,
|
|
2495
|
-
canUpdate: false,
|
|
2496
|
-
canCopyLink: false,
|
|
2497
|
-
canDownload: false
|
|
2498
|
-
};
|
|
2499
|
-
EditAssetDialog.propTypes = {
|
|
2500
|
-
asset: AssetDefinition,
|
|
2501
|
-
canUpdate: PropTypes.bool,
|
|
2502
|
-
canCopyLink: PropTypes.bool,
|
|
2503
|
-
canDownload: PropTypes.bool,
|
|
2504
|
-
open: PropTypes.bool.isRequired,
|
|
2505
|
-
onClose: PropTypes.func.isRequired,
|
|
2506
|
-
trackedLocation: PropTypes.string
|
|
2270
|
+
const EditAssetDialog = ({
|
|
2271
|
+
open,
|
|
2272
|
+
onClose,
|
|
2273
|
+
canUpdate = false,
|
|
2274
|
+
canCopyLink = false,
|
|
2275
|
+
canDownload = false,
|
|
2276
|
+
...restProps
|
|
2277
|
+
}) => {
|
|
2278
|
+
return /* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(Modal.Content, { children: /* @__PURE__ */ jsx(
|
|
2279
|
+
EditAssetContent,
|
|
2280
|
+
{
|
|
2281
|
+
onClose,
|
|
2282
|
+
canUpdate,
|
|
2283
|
+
canCopyLink,
|
|
2284
|
+
canDownload,
|
|
2285
|
+
...restProps
|
|
2286
|
+
}
|
|
2287
|
+
) }) });
|
|
2507
2288
|
};
|
|
2508
2289
|
const useBulkRemove = () => {
|
|
2509
2290
|
const { toggleNotification } = useNotification();
|
|
@@ -2512,12 +2293,12 @@ const useBulkRemove = () => {
|
|
|
2512
2293
|
const { post } = useFetchClient();
|
|
2513
2294
|
const bulkRemoveQuery = (filesAndFolders) => {
|
|
2514
2295
|
const payload = filesAndFolders.reduce((acc, selected) => {
|
|
2515
|
-
const { id
|
|
2296
|
+
const { id, type } = selected;
|
|
2516
2297
|
const key = type === "asset" ? "fileIds" : "folderIds";
|
|
2517
2298
|
if (!acc[key]) {
|
|
2518
2299
|
acc[key] = [];
|
|
2519
2300
|
}
|
|
2520
|
-
acc[key].push(
|
|
2301
|
+
acc[key].push(id);
|
|
2521
2302
|
return acc;
|
|
2522
2303
|
}, {});
|
|
2523
2304
|
return post("/upload/actions/bulk-delete", payload);
|
|
@@ -2549,10 +2330,10 @@ const useBulkRemove = () => {
|
|
|
2549
2330
|
const remove = (...args) => mutation.mutateAsync(...args);
|
|
2550
2331
|
return { ...mutation, remove };
|
|
2551
2332
|
};
|
|
2552
|
-
const editFolderRequest = (put, post, { attrs, id
|
|
2553
|
-
const isEditing = !!
|
|
2333
|
+
const editFolderRequest = (put, post, { attrs, id }) => {
|
|
2334
|
+
const isEditing = !!id;
|
|
2554
2335
|
const method = isEditing ? put : post;
|
|
2555
|
-
return method(`/upload/folders/${
|
|
2336
|
+
return method(`/upload/folders/${id ?? ""}`, attrs).then((res) => res.data);
|
|
2556
2337
|
};
|
|
2557
2338
|
const useEditFolder = () => {
|
|
2558
2339
|
const queryClient = useQueryClient();
|
|
@@ -2563,10 +2344,10 @@ const useEditFolder = () => {
|
|
|
2563
2344
|
queryClient.refetchQueries([pluginId, "folder", "structure"], { active: true });
|
|
2564
2345
|
}
|
|
2565
2346
|
});
|
|
2566
|
-
const editFolder = (attrs,
|
|
2347
|
+
const editFolder = (attrs, id) => mutation.mutateAsync({ attrs, id });
|
|
2567
2348
|
return { ...mutation, editFolder, status: mutation.status };
|
|
2568
2349
|
};
|
|
2569
|
-
const EditFolderModalHeader = ({ isEditing }) => {
|
|
2350
|
+
const EditFolderModalHeader = ({ isEditing = false }) => {
|
|
2570
2351
|
const { formatMessage } = useIntl();
|
|
2571
2352
|
return /* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: formatMessage(
|
|
2572
2353
|
isEditing ? {
|
|
@@ -2578,20 +2359,9 @@ const EditFolderModalHeader = ({ isEditing }) => {
|
|
|
2578
2359
|
}
|
|
2579
2360
|
) }) });
|
|
2580
2361
|
};
|
|
2581
|
-
EditFolderModalHeader.defaultProps = {
|
|
2582
|
-
isEditing: false
|
|
2583
|
-
};
|
|
2584
|
-
EditFolderModalHeader.propTypes = {
|
|
2585
|
-
isEditing: PropTypes.bool
|
|
2586
|
-
};
|
|
2587
2362
|
const RemoveFolderDialog = ({ onClose, onConfirm, open }) => {
|
|
2588
2363
|
return /* @__PURE__ */ jsx(Dialog.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(ConfirmDialog, { onConfirm }) });
|
|
2589
2364
|
};
|
|
2590
|
-
RemoveFolderDialog.propTypes = {
|
|
2591
|
-
onClose: PropTypes.func.isRequired,
|
|
2592
|
-
open: PropTypes.bool.isRequired,
|
|
2593
|
-
onConfirm: PropTypes.func.isRequired
|
|
2594
|
-
};
|
|
2595
2365
|
const folderSchema = yup.object({
|
|
2596
2366
|
name: yup.string().required(),
|
|
2597
2367
|
parent: yup.object({
|
|
@@ -2599,12 +2369,17 @@ const folderSchema = yup.object({
|
|
|
2599
2369
|
value: yup.number().nullable(true)
|
|
2600
2370
|
}).nullable(true)
|
|
2601
2371
|
});
|
|
2602
|
-
const EditFolderContent = ({
|
|
2372
|
+
const EditFolderContent = ({
|
|
2373
|
+
onClose,
|
|
2374
|
+
folder,
|
|
2375
|
+
location,
|
|
2376
|
+
parentFolderId
|
|
2377
|
+
}) => {
|
|
2603
2378
|
const { data: folderStructure, isLoading: folderStructureIsLoading } = useFolderStructure({
|
|
2604
2379
|
enabled: true
|
|
2605
2380
|
});
|
|
2606
2381
|
const { canCreate, isLoading: isLoadingPermissions, canUpdate } = useMediaLibraryPermissions();
|
|
2607
|
-
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
|
|
2382
|
+
const [showConfirmDialog, setShowConfirmDialog] = React.useState(false);
|
|
2608
2383
|
const { formatMessage, formatDate } = useIntl();
|
|
2609
2384
|
const { trackUsage } = useTracking();
|
|
2610
2385
|
const { editFolder, isLoading: isEditFolderLoading } = useEditFolder();
|
|
@@ -2613,21 +2388,24 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2613
2388
|
const isLoading = isLoadingPermissions || folderStructureIsLoading;
|
|
2614
2389
|
const isEditing = !!folder;
|
|
2615
2390
|
const formDisabled = folder && !canUpdate || !folder && !canCreate;
|
|
2616
|
-
const initialFormData = !folderStructureIsLoading
|
|
2391
|
+
const initialFormData = !folderStructureIsLoading ? {
|
|
2617
2392
|
name: folder?.name ?? "",
|
|
2618
2393
|
parent: {
|
|
2619
2394
|
/* ideally we would use folderStructure[0].value, but since it is null
|
|
2620
|
-
|
|
2621
|
-
value: parentFolderId ? parseInt(parentFolderId, 10) : void 0,
|
|
2622
|
-
label: parentFolderId ? findRecursiveFolderByValue(folderStructure, parseInt(parentFolderId, 10))?.label : folderStructure[0].label
|
|
2395
|
+
react complains about rendering null as field value */
|
|
2396
|
+
value: parentFolderId ? parseInt(parentFolderId.toString(), 10) : void 0,
|
|
2397
|
+
label: parentFolderId ? folderStructure && findRecursiveFolderByValue(folderStructure, parseInt(parentFolderId.toString(), 10))?.label : folderStructure?.[0].label
|
|
2623
2398
|
}
|
|
2399
|
+
} : {
|
|
2400
|
+
name: "",
|
|
2401
|
+
parent: null
|
|
2624
2402
|
};
|
|
2625
2403
|
const handleSubmit = async (values, { setErrors }) => {
|
|
2626
2404
|
try {
|
|
2627
2405
|
await editFolder(
|
|
2628
2406
|
{
|
|
2629
2407
|
...values,
|
|
2630
|
-
parent: values.parent
|
|
2408
|
+
parent: values.parent?.value ?? null
|
|
2631
2409
|
},
|
|
2632
2410
|
folder?.id
|
|
2633
2411
|
);
|
|
@@ -2642,7 +2420,7 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2642
2420
|
})
|
|
2643
2421
|
});
|
|
2644
2422
|
if (isEditing) {
|
|
2645
|
-
const didChangeLocation = parentFolderId ? parseInt(parentFolderId, 10) !== values.parent
|
|
2423
|
+
const didChangeLocation = parentFolderId ? parseInt(parentFolderId.toString(), 10) !== values.parent?.value : parentFolderId === null && !!values.parent?.value;
|
|
2646
2424
|
trackUsage("didEditMediaLibraryElements", {
|
|
2647
2425
|
location,
|
|
2648
2426
|
type: "folder",
|
|
@@ -2654,17 +2432,22 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2654
2432
|
onClose({ created: true });
|
|
2655
2433
|
} catch (err) {
|
|
2656
2434
|
const errors = getAPIInnerErrors(err, { getTrad });
|
|
2657
|
-
const formikErrors = Object.entries(errors).reduce(
|
|
2658
|
-
acc[key]
|
|
2659
|
-
|
|
2660
|
-
|
|
2435
|
+
const formikErrors = Object.entries(errors).reduce(
|
|
2436
|
+
(acc, [key, error]) => {
|
|
2437
|
+
acc[key] = error.defaultMessage;
|
|
2438
|
+
return acc;
|
|
2439
|
+
},
|
|
2440
|
+
{}
|
|
2441
|
+
);
|
|
2661
2442
|
if (!isEmpty(formikErrors)) {
|
|
2662
2443
|
setErrors(formikErrors);
|
|
2663
2444
|
}
|
|
2664
2445
|
}
|
|
2665
2446
|
};
|
|
2666
2447
|
const handleDelete = async () => {
|
|
2667
|
-
|
|
2448
|
+
if (folder) {
|
|
2449
|
+
await remove([folder]);
|
|
2450
|
+
}
|
|
2668
2451
|
setShowConfirmDialog(false);
|
|
2669
2452
|
onClose();
|
|
2670
2453
|
};
|
|
@@ -2718,21 +2501,28 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2718
2501
|
]
|
|
2719
2502
|
}
|
|
2720
2503
|
) }),
|
|
2721
|
-
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2504
|
+
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(
|
|
2505
|
+
Field.Root,
|
|
2506
|
+
{
|
|
2507
|
+
name: "name",
|
|
2508
|
+
error: typeof errors.name === "string" ? errors.name : void 0,
|
|
2509
|
+
children: [
|
|
2510
|
+
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
|
2511
|
+
id: getTrad("form.input.label.folder-name"),
|
|
2512
|
+
defaultMessage: "Name"
|
|
2513
|
+
}) }),
|
|
2514
|
+
/* @__PURE__ */ jsx(
|
|
2515
|
+
TextInput,
|
|
2516
|
+
{
|
|
2517
|
+
value: values.name,
|
|
2518
|
+
onChange: handleChange,
|
|
2519
|
+
disabled: formDisabled
|
|
2520
|
+
}
|
|
2521
|
+
),
|
|
2522
|
+
/* @__PURE__ */ jsx(Field.Error, {})
|
|
2523
|
+
]
|
|
2524
|
+
}
|
|
2525
|
+
) }),
|
|
2736
2526
|
/* @__PURE__ */ jsx(Grid.Item, { xs: 12, col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxs(Field.Root, { id: "folder-parent", children: [
|
|
2737
2527
|
/* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
|
|
2738
2528
|
id: getTrad("form.input.label.folder-location"),
|
|
@@ -2751,7 +2541,7 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2751
2541
|
menuPortalTarget: document.querySelector("body"),
|
|
2752
2542
|
inputId: "folder-parent",
|
|
2753
2543
|
disabled: formDisabled,
|
|
2754
|
-
error: errors
|
|
2544
|
+
error: typeof errors.parent === "string" ? errors.parent : void 0,
|
|
2755
2545
|
ariaErrorMessage: "folder-parent-error"
|
|
2756
2546
|
}
|
|
2757
2547
|
),
|
|
@@ -2762,7 +2552,7 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2762
2552
|
tag: "p",
|
|
2763
2553
|
id: "folder-parent-error",
|
|
2764
2554
|
textColor: "danger600",
|
|
2765
|
-
children: errors.parent
|
|
2555
|
+
children: typeof errors.parent === "string" ? errors.parent : void 0
|
|
2766
2556
|
}
|
|
2767
2557
|
)
|
|
2768
2558
|
] }) })
|
|
@@ -2811,42 +2601,19 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2811
2601
|
)
|
|
2812
2602
|
] });
|
|
2813
2603
|
};
|
|
2814
|
-
EditFolderContent.defaultProps = {
|
|
2815
|
-
folder: void 0,
|
|
2816
|
-
location: void 0,
|
|
2817
|
-
parentFolderId: null
|
|
2818
|
-
};
|
|
2819
|
-
EditFolderContent.propTypes = {
|
|
2820
|
-
folder: FolderDefinition,
|
|
2821
|
-
location: PropTypes.string,
|
|
2822
|
-
onClose: PropTypes.func.isRequired,
|
|
2823
|
-
parentFolderId: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
2824
|
-
};
|
|
2825
2604
|
const EditFolderDialog = ({ open, onClose, ...restProps }) => {
|
|
2826
|
-
return /* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(Modal.Content, { children: /* @__PURE__ */ jsx(EditFolderContent, { ...restProps, onClose }) }) });
|
|
2827
|
-
};
|
|
2828
|
-
EditFolderDialog.defaultProps = {
|
|
2829
|
-
folder: void 0,
|
|
2830
|
-
location: void 0,
|
|
2831
|
-
parentFolderId: null
|
|
2605
|
+
return /* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(Modal.Content, { children: /* @__PURE__ */ jsx(EditFolderContent, { ...restProps, onClose, open }) }) });
|
|
2832
2606
|
};
|
|
2833
|
-
|
|
2834
|
-
folder: FolderDefinition,
|
|
2835
|
-
location: PropTypes.string,
|
|
2836
|
-
open: PropTypes.bool.isRequired,
|
|
2837
|
-
onClose: PropTypes.func.isRequired,
|
|
2838
|
-
parentFolderId: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
2839
|
-
};
|
|
2840
|
-
const useFolder = (id2, { enabled = true } = {}) => {
|
|
2607
|
+
const useFolder = (id, { enabled = true } = {}) => {
|
|
2841
2608
|
const { toggleNotification } = useNotification();
|
|
2842
2609
|
const { get } = useFetchClient();
|
|
2843
2610
|
const { formatMessage } = useIntl();
|
|
2844
2611
|
const { data, error, isLoading } = useQuery(
|
|
2845
|
-
[pluginId, "folder",
|
|
2612
|
+
[pluginId, "folder", id],
|
|
2846
2613
|
async () => {
|
|
2847
2614
|
const {
|
|
2848
2615
|
data: { data: data2 }
|
|
2849
|
-
} = await get(`/upload/folders/${
|
|
2616
|
+
} = await get(`/upload/folders/${id}`, {
|
|
2850
2617
|
params: {
|
|
2851
2618
|
populate: {
|
|
2852
2619
|
parent: {
|
|
@@ -2899,14 +2666,14 @@ const CardContainer = styled(Card$1)`
|
|
|
2899
2666
|
const AssetCardBase = ({
|
|
2900
2667
|
children,
|
|
2901
2668
|
extension,
|
|
2902
|
-
isSelectable: isSelectable2,
|
|
2669
|
+
isSelectable: isSelectable2 = true,
|
|
2903
2670
|
name: name2,
|
|
2904
2671
|
onSelect,
|
|
2905
2672
|
onRemove,
|
|
2906
2673
|
onEdit,
|
|
2907
|
-
selected,
|
|
2908
|
-
subtitle,
|
|
2909
|
-
variant
|
|
2674
|
+
selected = false,
|
|
2675
|
+
subtitle = "",
|
|
2676
|
+
variant = "Image"
|
|
2910
2677
|
}) => {
|
|
2911
2678
|
const { formatMessage } = useIntl();
|
|
2912
2679
|
const handleClick = (e) => {
|
|
@@ -2919,8 +2686,7 @@ const AssetCardBase = ({
|
|
|
2919
2686
|
};
|
|
2920
2687
|
return /* @__PURE__ */ jsxs(CardContainer, { role: "button", height: "100%", tabIndex: -1, onClick: handleClick, children: [
|
|
2921
2688
|
/* @__PURE__ */ jsxs(CardHeader, { children: [
|
|
2922
|
-
isSelectable2 &&
|
|
2923
|
-
/* @__PURE__ */ jsx("div", { onClick: handlePropagationClick, children: /* @__PURE__ */ jsx(CardCheckbox, { checked: selected, onCheckedChange: onSelect }) }),
|
|
2689
|
+
isSelectable2 && /* @__PURE__ */ jsx("div", { onClick: handlePropagationClick, children: /* @__PURE__ */ jsx(CardCheckbox, { checked: selected, onCheckedChange: onSelect }) }),
|
|
2924
2690
|
(onRemove || onEdit) && /* @__PURE__ */ jsxs(CardActionsContainer, { onClick: handlePropagationClick, position: "end", children: [
|
|
2925
2691
|
onRemove && /* @__PURE__ */ jsx(
|
|
2926
2692
|
IconButton,
|
|
@@ -2946,7 +2712,7 @@ const AssetCardBase = ({
|
|
|
2946
2712
|
] }),
|
|
2947
2713
|
/* @__PURE__ */ jsxs(CardBody, { children: [
|
|
2948
2714
|
/* @__PURE__ */ jsxs(CardContent, { children: [
|
|
2949
|
-
/* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(
|
|
2715
|
+
/* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(Typography, { tag: "h2", children: /* @__PURE__ */ jsx(CardTitle, { tag: "span", children: name2 }) }) }),
|
|
2950
2716
|
/* @__PURE__ */ jsxs(CardSubtitle, { children: [
|
|
2951
2717
|
/* @__PURE__ */ jsx(Extension$1, { children: extension }),
|
|
2952
2718
|
subtitle
|
|
@@ -2959,36 +2725,9 @@ const AssetCardBase = ({
|
|
|
2959
2725
|
] })
|
|
2960
2726
|
] });
|
|
2961
2727
|
};
|
|
2962
|
-
AssetCardBase.defaultProps = {
|
|
2963
|
-
children: void 0,
|
|
2964
|
-
isSelectable: true,
|
|
2965
|
-
onEdit: void 0,
|
|
2966
|
-
onSelect: void 0,
|
|
2967
|
-
onRemove: void 0,
|
|
2968
|
-
selected: false,
|
|
2969
|
-
subtitle: "",
|
|
2970
|
-
variant: "Image"
|
|
2971
|
-
};
|
|
2972
|
-
AssetCardBase.propTypes = {
|
|
2973
|
-
children: PropTypes.node,
|
|
2974
|
-
extension: PropTypes.string.isRequired,
|
|
2975
|
-
isSelectable: PropTypes.bool,
|
|
2976
|
-
name: PropTypes.string.isRequired,
|
|
2977
|
-
onEdit: PropTypes.func,
|
|
2978
|
-
onSelect: PropTypes.func,
|
|
2979
|
-
onRemove: PropTypes.func,
|
|
2980
|
-
selected: PropTypes.bool,
|
|
2981
|
-
subtitle: PropTypes.string,
|
|
2982
|
-
variant: PropTypes.oneOf(["Image", "Video", "Audio", "Doc"])
|
|
2983
|
-
};
|
|
2984
2728
|
const AudioPreview = ({ url, alt }) => {
|
|
2985
2729
|
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx("audio", { controls: true, src: url, children: alt }) });
|
|
2986
2730
|
};
|
|
2987
|
-
AudioPreview.defaultProps = {};
|
|
2988
|
-
AudioPreview.propTypes = {
|
|
2989
|
-
alt: PropTypes.string.isRequired,
|
|
2990
|
-
url: PropTypes.string.isRequired
|
|
2991
|
-
};
|
|
2992
2731
|
const AudioPreviewWrapper$1 = styled(Box)`
|
|
2993
2732
|
canvas,
|
|
2994
2733
|
audio {
|
|
@@ -2997,25 +2736,14 @@ const AudioPreviewWrapper$1 = styled(Box)`
|
|
|
2997
2736
|
max-height: ${({ size }) => size === "M" ? 16.4 : 8.8}rem;
|
|
2998
2737
|
}
|
|
2999
2738
|
`;
|
|
3000
|
-
const AudioAssetCard = ({
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
selected:
|
|
3008
|
-
size: "M"
|
|
3009
|
-
};
|
|
3010
|
-
AudioAssetCard.propTypes = {
|
|
3011
|
-
extension: PropTypes.string.isRequired,
|
|
3012
|
-
name: PropTypes.string.isRequired,
|
|
3013
|
-
onSelect: PropTypes.func,
|
|
3014
|
-
onEdit: PropTypes.func,
|
|
3015
|
-
onRemove: PropTypes.func,
|
|
3016
|
-
url: PropTypes.string.isRequired,
|
|
3017
|
-
selected: PropTypes.bool,
|
|
3018
|
-
size: PropTypes.oneOf(["S", "M"])
|
|
2739
|
+
const AudioAssetCard = ({
|
|
2740
|
+
name: name2,
|
|
2741
|
+
url,
|
|
2742
|
+
size = "M",
|
|
2743
|
+
selected = false,
|
|
2744
|
+
...restProps
|
|
2745
|
+
}) => {
|
|
2746
|
+
return /* @__PURE__ */ jsx(AssetCardBase, { name: name2, selected, ...restProps, variant: "Audio", children: /* @__PURE__ */ jsx(CardAsset$2, { size, children: /* @__PURE__ */ jsx(AudioPreviewWrapper$1, { size, children: /* @__PURE__ */ jsx(AudioPreview, { url, alt: name2 }) }) }) });
|
|
3019
2747
|
};
|
|
3020
2748
|
const IconWrapper$1 = styled.span`
|
|
3021
2749
|
svg {
|
|
@@ -3026,99 +2754,82 @@ const CardAsset = styled(Flex)`
|
|
|
3026
2754
|
border-radius: ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius} 0 0;
|
|
3027
2755
|
background: linear-gradient(180deg, #ffffff 0%, #f6f6f9 121.48%);
|
|
3028
2756
|
`;
|
|
3029
|
-
const DocAssetCard = ({
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
selected
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
};
|
|
3048
|
-
const ImageAssetCard = ({
|
|
2757
|
+
const DocAssetCard = ({
|
|
2758
|
+
name: name2,
|
|
2759
|
+
extension,
|
|
2760
|
+
size = "M",
|
|
2761
|
+
selected = false,
|
|
2762
|
+
...restProps
|
|
2763
|
+
}) => {
|
|
2764
|
+
return /* @__PURE__ */ jsx(
|
|
2765
|
+
AssetCardBase,
|
|
2766
|
+
{
|
|
2767
|
+
name: name2,
|
|
2768
|
+
extension,
|
|
2769
|
+
selected,
|
|
2770
|
+
...restProps,
|
|
2771
|
+
variant: "Doc",
|
|
2772
|
+
children: /* @__PURE__ */ jsx(CardAsset, { width: "100%", height: size === "S" ? `8.8rem` : `16.4rem`, justifyContent: "center", children: /* @__PURE__ */ jsx(IconWrapper$1, { children: extension === "pdf" ? /* @__PURE__ */ jsx(FilePdf, { "aria-label": name2 }) : /* @__PURE__ */ jsx(File$1, { "aria-label": name2 }) }) })
|
|
2773
|
+
}
|
|
2774
|
+
);
|
|
2775
|
+
};
|
|
2776
|
+
const ImageAssetCard = ({
|
|
2777
|
+
height,
|
|
2778
|
+
width,
|
|
2779
|
+
thumbnail,
|
|
2780
|
+
size = "M",
|
|
2781
|
+
alt,
|
|
2782
|
+
isUrlSigned,
|
|
2783
|
+
selected = false,
|
|
2784
|
+
...props
|
|
2785
|
+
}) => {
|
|
3049
2786
|
const thumbnailUrl = isUrlSigned ? thumbnail : appendSearchParamsToUrl({
|
|
3050
2787
|
url: thumbnail,
|
|
3051
2788
|
params: { updatedAt: props.updatedAt }
|
|
3052
2789
|
});
|
|
3053
|
-
|
|
3054
|
-
};
|
|
3055
|
-
ImageAssetCard.defaultProps = {
|
|
3056
|
-
height: void 0,
|
|
3057
|
-
width: void 0,
|
|
3058
|
-
selected: false,
|
|
3059
|
-
onEdit: void 0,
|
|
3060
|
-
onSelect: void 0,
|
|
3061
|
-
onRemove: void 0,
|
|
3062
|
-
size: "M",
|
|
3063
|
-
updatedAt: void 0
|
|
3064
|
-
};
|
|
3065
|
-
ImageAssetCard.propTypes = {
|
|
3066
|
-
alt: PropTypes.string.isRequired,
|
|
3067
|
-
extension: PropTypes.string.isRequired,
|
|
3068
|
-
height: PropTypes.number,
|
|
3069
|
-
name: PropTypes.string.isRequired,
|
|
3070
|
-
onEdit: PropTypes.func,
|
|
3071
|
-
onSelect: PropTypes.func,
|
|
3072
|
-
onRemove: PropTypes.func,
|
|
3073
|
-
width: PropTypes.number,
|
|
3074
|
-
thumbnail: PropTypes.string.isRequired,
|
|
3075
|
-
selected: PropTypes.bool,
|
|
3076
|
-
size: PropTypes.oneOf(["S", "M"]),
|
|
3077
|
-
updatedAt: PropTypes.string,
|
|
3078
|
-
isUrlSigned: PropTypes.bool.isRequired
|
|
2790
|
+
const subtitle = height && width ? ` - ${width}✕${height}` : void 0;
|
|
2791
|
+
return /* @__PURE__ */ jsx(AssetCardBase, { ...props, selected, subtitle, variant: "Image", children: /* @__PURE__ */ jsx(CardAsset$2, { src: thumbnailUrl, size, alt }) });
|
|
3079
2792
|
};
|
|
3080
2793
|
const HAVE_FUTURE_DATA = 3;
|
|
3081
|
-
const VideoPreview = ({
|
|
2794
|
+
const VideoPreview = ({
|
|
2795
|
+
url,
|
|
2796
|
+
mime,
|
|
2797
|
+
onLoadDuration = () => {
|
|
2798
|
+
},
|
|
2799
|
+
alt,
|
|
2800
|
+
...props
|
|
2801
|
+
}) => {
|
|
3082
2802
|
const handleTimeUpdate = (e) => {
|
|
3083
|
-
if (e.
|
|
3084
|
-
const video = e.
|
|
2803
|
+
if (e.currentTarget.currentTime > 0) {
|
|
2804
|
+
const video = e.currentTarget;
|
|
3085
2805
|
const canvas = document.createElement("canvas");
|
|
3086
2806
|
canvas.height = video.videoHeight;
|
|
3087
2807
|
canvas.width = video.videoWidth;
|
|
3088
|
-
canvas.getContext("2d")
|
|
2808
|
+
canvas.getContext("2d")?.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
3089
2809
|
video.replaceWith(canvas);
|
|
3090
|
-
onLoadDuration(video.duration);
|
|
2810
|
+
onLoadDuration && onLoadDuration(video.duration);
|
|
3091
2811
|
}
|
|
3092
2812
|
};
|
|
3093
2813
|
const handleThumbnailVisibility = (e) => {
|
|
3094
|
-
const video = e.
|
|
2814
|
+
const video = e.currentTarget;
|
|
3095
2815
|
if (video.readyState < HAVE_FUTURE_DATA)
|
|
3096
2816
|
return;
|
|
3097
2817
|
video.play();
|
|
3098
2818
|
};
|
|
3099
|
-
return /* @__PURE__ */
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
},
|
|
3114
|
-
size: "M"
|
|
3115
|
-
};
|
|
3116
|
-
VideoPreview.propTypes = {
|
|
3117
|
-
alt: PropTypes.string.isRequired,
|
|
3118
|
-
url: PropTypes.string.isRequired,
|
|
3119
|
-
mime: PropTypes.string.isRequired,
|
|
3120
|
-
onLoadDuration: PropTypes.func,
|
|
3121
|
-
size: PropTypes.oneOf(["S", "M"])
|
|
2819
|
+
return /* @__PURE__ */ jsxs(Box, { tag: "figure", ...props, children: [
|
|
2820
|
+
/* @__PURE__ */ jsx(
|
|
2821
|
+
"video",
|
|
2822
|
+
{
|
|
2823
|
+
muted: true,
|
|
2824
|
+
onLoadedData: handleThumbnailVisibility,
|
|
2825
|
+
src: url,
|
|
2826
|
+
crossOrigin: "anonymous",
|
|
2827
|
+
onTimeUpdate: handleTimeUpdate,
|
|
2828
|
+
children: /* @__PURE__ */ jsx("source", { type: mime })
|
|
2829
|
+
}
|
|
2830
|
+
),
|
|
2831
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { tag: "figcaption", children: alt })
|
|
2832
|
+
] }, url);
|
|
3122
2833
|
};
|
|
3123
2834
|
const VideoPreviewWrapper$2 = styled(Box)`
|
|
3124
2835
|
canvas,
|
|
@@ -3129,39 +2840,35 @@ const VideoPreviewWrapper$2 = styled(Box)`
|
|
|
3129
2840
|
max-height: ${({ size }) => size === "M" ? 16.4 : 8.8}rem;
|
|
3130
2841
|
}
|
|
3131
2842
|
`;
|
|
3132
|
-
const VideoAssetCard = ({
|
|
3133
|
-
|
|
2843
|
+
const VideoAssetCard = ({
|
|
2844
|
+
name: name2,
|
|
2845
|
+
url,
|
|
2846
|
+
mime,
|
|
2847
|
+
size = "M",
|
|
2848
|
+
selected = false,
|
|
2849
|
+
...props
|
|
2850
|
+
}) => {
|
|
2851
|
+
const [duration, setDuration] = React.useState();
|
|
3134
2852
|
const formattedDuration = duration && formatDuration(duration);
|
|
3135
|
-
return /* @__PURE__ */ jsxs(AssetCardBase, { name: name2, ...props, variant: "Video", children: [
|
|
2853
|
+
return /* @__PURE__ */ jsxs(AssetCardBase, { selected, name: name2, ...props, variant: "Video", children: [
|
|
3136
2854
|
/* @__PURE__ */ jsx(CardAsset$2, { size, children: /* @__PURE__ */ jsx(VideoPreviewWrapper$2, { size, children: /* @__PURE__ */ jsx(VideoPreview, { url, mime, onLoadDuration: setDuration, alt: name2 }) }) }),
|
|
3137
2855
|
/* @__PURE__ */ jsx(CardTimer, { children: formattedDuration || "..." })
|
|
3138
2856
|
] });
|
|
3139
2857
|
};
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
mime: PropTypes.string.isRequired,
|
|
3150
|
-
name: PropTypes.string.isRequired,
|
|
3151
|
-
onSelect: PropTypes.func,
|
|
3152
|
-
onEdit: PropTypes.func,
|
|
3153
|
-
onRemove: PropTypes.func,
|
|
3154
|
-
url: PropTypes.string.isRequired,
|
|
3155
|
-
selected: PropTypes.bool,
|
|
3156
|
-
size: PropTypes.oneOf(["S", "M"])
|
|
3157
|
-
};
|
|
3158
|
-
const AssetCard = ({ asset, isSelected, onSelect, onEdit, onRemove, size, local }) => {
|
|
2858
|
+
const AssetCard = ({
|
|
2859
|
+
asset,
|
|
2860
|
+
isSelected = false,
|
|
2861
|
+
onSelect,
|
|
2862
|
+
onEdit,
|
|
2863
|
+
onRemove,
|
|
2864
|
+
size = "M",
|
|
2865
|
+
local = false
|
|
2866
|
+
}) => {
|
|
3159
2867
|
const handleSelect = onSelect ? () => onSelect(asset) : void 0;
|
|
3160
2868
|
const commonAssetCardProps = {
|
|
3161
2869
|
id: asset.id,
|
|
3162
2870
|
isSelectable: asset.isSelectable,
|
|
3163
2871
|
extension: getFileExtension(asset.ext),
|
|
3164
|
-
key: asset.id,
|
|
3165
2872
|
name: asset.name,
|
|
3166
2873
|
url: local ? asset.url : createAssetUrl(asset, true),
|
|
3167
2874
|
mime: asset.mime,
|
|
@@ -3171,64 +2878,46 @@ const AssetCard = ({ asset, isSelected, onSelect, onEdit, onRemove, size, local
|
|
|
3171
2878
|
selected: isSelected,
|
|
3172
2879
|
size
|
|
3173
2880
|
};
|
|
3174
|
-
if (asset.mime
|
|
2881
|
+
if (asset.mime?.includes(AssetType.Video)) {
|
|
3175
2882
|
return /* @__PURE__ */ jsx(VideoAssetCard, { ...commonAssetCardProps });
|
|
3176
2883
|
}
|
|
3177
|
-
if (asset.mime
|
|
2884
|
+
if (asset.mime?.includes(AssetType.Image)) {
|
|
3178
2885
|
return /* @__PURE__ */ jsx(
|
|
3179
2886
|
ImageAssetCard,
|
|
3180
2887
|
{
|
|
3181
|
-
...commonAssetCardProps,
|
|
3182
2888
|
alt: asset.alternativeText || asset.name,
|
|
3183
2889
|
height: asset.height,
|
|
3184
2890
|
thumbnail: prefixFileUrlWithBackendUrl(asset?.formats?.thumbnail?.url || asset.url),
|
|
3185
2891
|
width: asset.width,
|
|
3186
2892
|
updatedAt: asset.updatedAt,
|
|
3187
|
-
isUrlSigned: asset?.isUrlSigned || false
|
|
2893
|
+
isUrlSigned: asset?.isUrlSigned || false,
|
|
2894
|
+
...commonAssetCardProps
|
|
3188
2895
|
}
|
|
3189
2896
|
);
|
|
3190
2897
|
}
|
|
3191
|
-
if (asset.mime
|
|
2898
|
+
if (asset.mime?.includes(AssetType.Audio)) {
|
|
3192
2899
|
return /* @__PURE__ */ jsx(AudioAssetCard, { ...commonAssetCardProps });
|
|
3193
2900
|
}
|
|
3194
2901
|
return /* @__PURE__ */ jsx(DocAssetCard, { ...commonAssetCardProps });
|
|
3195
2902
|
};
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
// Determine if the asset is loaded locally or from a remote resource
|
|
3199
|
-
local: false,
|
|
3200
|
-
onSelect: void 0,
|
|
3201
|
-
onEdit: void 0,
|
|
3202
|
-
onRemove: void 0,
|
|
3203
|
-
size: "M"
|
|
3204
|
-
};
|
|
3205
|
-
AssetCard.propTypes = {
|
|
3206
|
-
asset: AssetDefinition.isRequired,
|
|
3207
|
-
local: PropTypes.bool,
|
|
3208
|
-
onSelect: PropTypes.func,
|
|
3209
|
-
onEdit: PropTypes.func,
|
|
3210
|
-
onRemove: PropTypes.func,
|
|
3211
|
-
isSelected: PropTypes.bool,
|
|
3212
|
-
size: PropTypes.oneOf(["S", "M"])
|
|
3213
|
-
};
|
|
3214
|
-
const Draggable = ({ children, id: id2, index: index2, moveItem }) => {
|
|
3215
|
-
const ref = useRef(null);
|
|
2903
|
+
const Draggable = ({ children, id, index, moveItem }) => {
|
|
2904
|
+
const ref = React.useRef(null);
|
|
3216
2905
|
const [, drop] = useDrop({
|
|
3217
2906
|
accept: "draggable",
|
|
3218
2907
|
hover(hoveredOverItem) {
|
|
3219
2908
|
if (!ref.current) {
|
|
3220
2909
|
return;
|
|
3221
2910
|
}
|
|
3222
|
-
if (hoveredOverItem.id !==
|
|
3223
|
-
moveItem(hoveredOverItem.index,
|
|
3224
|
-
hoveredOverItem.index =
|
|
2911
|
+
if (hoveredOverItem.id !== id) {
|
|
2912
|
+
moveItem(hoveredOverItem.index, index);
|
|
2913
|
+
hoveredOverItem.index = index;
|
|
3225
2914
|
}
|
|
3226
2915
|
}
|
|
3227
2916
|
});
|
|
3228
2917
|
const [{ isDragging }, drag] = useDrag({
|
|
3229
2918
|
type: "draggable",
|
|
3230
2919
|
item() {
|
|
3231
|
-
return { index
|
|
2920
|
+
return { index, id };
|
|
3232
2921
|
},
|
|
3233
2922
|
collect: (monitor) => ({
|
|
3234
2923
|
isDragging: monitor.isDragging()
|
|
@@ -3238,28 +2927,22 @@ const Draggable = ({ children, id: id2, index: index2, moveItem }) => {
|
|
|
3238
2927
|
drag(drop(ref));
|
|
3239
2928
|
return /* @__PURE__ */ jsx("div", { ref, style: { opacity, cursor: "move" }, children });
|
|
3240
2929
|
};
|
|
3241
|
-
Draggable.propTypes = {
|
|
3242
|
-
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
3243
|
-
index: PropTypes.number.isRequired,
|
|
3244
|
-
children: PropTypes.node.isRequired,
|
|
3245
|
-
moveItem: PropTypes.func.isRequired
|
|
3246
|
-
};
|
|
3247
2930
|
const AssetGridList = ({
|
|
3248
|
-
allowedTypes,
|
|
2931
|
+
allowedTypes = ["files", "images", "videos", "audios"],
|
|
3249
2932
|
assets,
|
|
3250
2933
|
onEditAsset,
|
|
3251
2934
|
onSelectAsset,
|
|
3252
2935
|
selectedAssets,
|
|
3253
|
-
size,
|
|
2936
|
+
size = "M",
|
|
3254
2937
|
onReorderAsset,
|
|
3255
|
-
title
|
|
2938
|
+
title = null
|
|
3256
2939
|
}) => {
|
|
3257
2940
|
return /* @__PURE__ */ jsxs(KeyboardNavigable, { tagName: "article", children: [
|
|
3258
2941
|
title && /* @__PURE__ */ jsx(Box, { paddingTop: 2, paddingBottom: 2, children: /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "delta", fontWeight: "semiBold", children: title }) }),
|
|
3259
|
-
/* @__PURE__ */ jsx(Grid.Root, { gap: 4, children: assets.map((asset,
|
|
2942
|
+
/* @__PURE__ */ jsx(Grid.Root, { gap: 4, children: assets.map((asset, index) => {
|
|
3260
2943
|
const isSelected = !!selectedAssets.find((currentAsset) => currentAsset.id === asset.id);
|
|
3261
2944
|
if (onReorderAsset) {
|
|
3262
|
-
return /* @__PURE__ */ jsx(Grid.Item, { col: 3, height: "100%", children: /* @__PURE__ */ jsx(Draggable, { index
|
|
2945
|
+
return /* @__PURE__ */ jsx(Grid.Item, { col: 3, height: "100%", children: /* @__PURE__ */ jsx(Draggable, { index, moveItem: onReorderAsset, id: asset.id, children: /* @__PURE__ */ jsx(
|
|
3263
2946
|
AssetCard,
|
|
3264
2947
|
{
|
|
3265
2948
|
allowedTypes,
|
|
@@ -3286,32 +2969,19 @@ const AssetGridList = ({
|
|
|
3286
2969
|
}) })
|
|
3287
2970
|
] });
|
|
3288
2971
|
};
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
};
|
|
3296
|
-
AssetGridList.propTypes = {
|
|
3297
|
-
allowedTypes: PropTypes.arrayOf(PropTypes.string),
|
|
3298
|
-
assets: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
|
|
3299
|
-
onEditAsset: PropTypes.func,
|
|
3300
|
-
onSelectAsset: PropTypes.func.isRequired,
|
|
3301
|
-
selectedAssets: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
|
|
3302
|
-
size: PropTypes.oneOf(["S", "M"]),
|
|
3303
|
-
onReorderAsset: PropTypes.func,
|
|
3304
|
-
title: PropTypes.string
|
|
3305
|
-
};
|
|
3306
|
-
const CrumbSimpleMenuAsync = ({ parentsToOmit, currentFolderId, onChangeFolder }) => {
|
|
3307
|
-
const [shouldFetch, setShouldFetch] = useState(false);
|
|
2972
|
+
const CrumbSimpleMenuAsync = ({
|
|
2973
|
+
parentsToOmit = [],
|
|
2974
|
+
currentFolderId,
|
|
2975
|
+
onChangeFolder
|
|
2976
|
+
}) => {
|
|
2977
|
+
const [shouldFetch, setShouldFetch] = React.useState(false);
|
|
3308
2978
|
const { data, isLoading } = useFolderStructure({ enabled: shouldFetch });
|
|
3309
2979
|
const { pathname } = useLocation();
|
|
3310
2980
|
const [{ query }] = useQueryParams();
|
|
3311
2981
|
const { formatMessage } = useIntl();
|
|
3312
2982
|
const allAscendants = data && getFolderParents(data, currentFolderId);
|
|
3313
2983
|
const filteredAscendants = allAscendants && allAscendants.filter(
|
|
3314
|
-
(ascendant) => !parentsToOmit.includes(ascendant.id) && ascendant.id !== null
|
|
2984
|
+
(ascendant) => typeof ascendant.id === "number" && !parentsToOmit.includes(ascendant.id) && ascendant.id !== null
|
|
3315
2985
|
);
|
|
3316
2986
|
return /* @__PURE__ */ jsxs(
|
|
3317
2987
|
CrumbSimpleMenu,
|
|
@@ -3335,40 +3005,35 @@ const CrumbSimpleMenuAsync = ({ parentsToOmit, currentFolderId, onChangeFolder }
|
|
|
3335
3005
|
{
|
|
3336
3006
|
tag: "button",
|
|
3337
3007
|
type: "button",
|
|
3338
|
-
onClick: () => onChangeFolder(ascendant.id, ascendant.path),
|
|
3008
|
+
onClick: () => onChangeFolder(Number(ascendant.id), ascendant.path),
|
|
3339
3009
|
children: ascendant.label
|
|
3340
3010
|
},
|
|
3341
3011
|
ascendant.id
|
|
3342
3012
|
);
|
|
3343
3013
|
}
|
|
3344
3014
|
const url = getFolderURL(pathname, query, {
|
|
3345
|
-
folder: ascendant?.id,
|
|
3015
|
+
folder: typeof ascendant?.id === "string" ? ascendant.id : void 0,
|
|
3346
3016
|
folderPath: ascendant?.path
|
|
3347
3017
|
});
|
|
3348
|
-
return /* @__PURE__ */ jsx(MenuItem, { isLink: true,
|
|
3018
|
+
return /* @__PURE__ */ jsx(MenuItem, { isLink: true, href: url, children: ascendant.label }, ascendant.id);
|
|
3349
3019
|
})
|
|
3350
3020
|
]
|
|
3351
3021
|
}
|
|
3352
3022
|
);
|
|
3353
3023
|
};
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
onChangeFolder
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
currentFolderId: PropTypes.number,
|
|
3361
|
-
onChangeFolder: PropTypes.func,
|
|
3362
|
-
parentsToOmit: PropTypes.arrayOf(PropTypes.number)
|
|
3363
|
-
};
|
|
3364
|
-
const Breadcrumbs = ({ breadcrumbs, onChangeFolder, currentFolderId, ...props }) => {
|
|
3024
|
+
const Breadcrumbs = ({
|
|
3025
|
+
breadcrumbs,
|
|
3026
|
+
onChangeFolder,
|
|
3027
|
+
currentFolderId,
|
|
3028
|
+
...props
|
|
3029
|
+
}) => {
|
|
3365
3030
|
const { formatMessage } = useIntl();
|
|
3366
|
-
return /* @__PURE__ */ jsx(Breadcrumbs$1, { ...props, children: breadcrumbs.map((crumb,
|
|
3031
|
+
return /* @__PURE__ */ jsx(Breadcrumbs$1, { ...props, children: breadcrumbs.map((crumb, index) => {
|
|
3367
3032
|
if (Array.isArray(crumb)) {
|
|
3368
3033
|
return /* @__PURE__ */ jsx(
|
|
3369
3034
|
CrumbSimpleMenuAsync,
|
|
3370
3035
|
{
|
|
3371
|
-
parentsToOmit: [...breadcrumbs].splice(
|
|
3036
|
+
parentsToOmit: [...breadcrumbs].splice(index + 1, breadcrumbs.length - 1).map((parent) => parent.id),
|
|
3372
3037
|
currentFolderId,
|
|
3373
3038
|
onChangeFolder
|
|
3374
3039
|
},
|
|
@@ -3377,14 +3042,23 @@ const Breadcrumbs = ({ breadcrumbs, onChangeFolder, currentFolderId, ...props })
|
|
|
3377
3042
|
}
|
|
3378
3043
|
const isCurrentFolderMediaLibrary = crumb.id === null && currentFolderId === void 0;
|
|
3379
3044
|
if (currentFolderId !== crumb.id && !isCurrentFolderMediaLibrary) {
|
|
3045
|
+
if (onChangeFolder) {
|
|
3046
|
+
return /* @__PURE__ */ jsx(
|
|
3047
|
+
CrumbLink,
|
|
3048
|
+
{
|
|
3049
|
+
type: "button",
|
|
3050
|
+
onClick: () => onChangeFolder(crumb.id, crumb.path),
|
|
3051
|
+
children: typeof crumb.label !== "string" && crumb.label?.id ? formatMessage(crumb.label) : crumb.label
|
|
3052
|
+
},
|
|
3053
|
+
`breadcrumb-${crumb?.id ?? "root"}`
|
|
3054
|
+
);
|
|
3055
|
+
}
|
|
3380
3056
|
return /* @__PURE__ */ jsx(
|
|
3381
3057
|
CrumbLink,
|
|
3382
3058
|
{
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
onClick: onChangeFolder && (() => onChangeFolder(crumb.id, crumb.path)),
|
|
3387
|
-
children: crumb.label?.id ? formatMessage(crumb.label) : crumb.label
|
|
3059
|
+
to: crumb.href,
|
|
3060
|
+
tag: Link$1,
|
|
3061
|
+
children: typeof crumb.label !== "string" && crumb.label?.id ? formatMessage(crumb.label) : crumb.label
|
|
3388
3062
|
},
|
|
3389
3063
|
`breadcrumb-${crumb?.id ?? "root"}`
|
|
3390
3064
|
);
|
|
@@ -3392,22 +3066,13 @@ const Breadcrumbs = ({ breadcrumbs, onChangeFolder, currentFolderId, ...props })
|
|
|
3392
3066
|
return /* @__PURE__ */ jsx(
|
|
3393
3067
|
Crumb,
|
|
3394
3068
|
{
|
|
3395
|
-
isCurrent:
|
|
3396
|
-
children: crumb.label?.id ? formatMessage(crumb.label) : crumb.label
|
|
3069
|
+
isCurrent: index + 1 === breadcrumbs.length,
|
|
3070
|
+
children: typeof crumb.label !== "string" && crumb.label?.id ? formatMessage(crumb.label) : crumb.label
|
|
3397
3071
|
},
|
|
3398
3072
|
`breadcrumb-${crumb?.id ?? "root"}`
|
|
3399
3073
|
);
|
|
3400
3074
|
}) });
|
|
3401
3075
|
};
|
|
3402
|
-
Breadcrumbs.defaultProps = {
|
|
3403
|
-
currentFolderId: void 0,
|
|
3404
|
-
onChangeFolder: void 0
|
|
3405
|
-
};
|
|
3406
|
-
Breadcrumbs.propTypes = {
|
|
3407
|
-
breadcrumbs: BreadcrumbsDefinition.isRequired,
|
|
3408
|
-
currentFolderId: PropTypes.number,
|
|
3409
|
-
onChangeFolder: PropTypes.func
|
|
3410
|
-
};
|
|
3411
3076
|
const EmptyAssetCard = styled(Box)`
|
|
3412
3077
|
background: linear-gradient(
|
|
3413
3078
|
180deg,
|
|
@@ -3430,11 +3095,13 @@ const EmptyAssetGrid = ({ count, size }) => {
|
|
|
3430
3095
|
`empty-asset-card-${idx}`
|
|
3431
3096
|
)) });
|
|
3432
3097
|
};
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3098
|
+
const EmptyAssets = ({
|
|
3099
|
+
icon: Icon = EmptyDocuments,
|
|
3100
|
+
content,
|
|
3101
|
+
action,
|
|
3102
|
+
size = "M",
|
|
3103
|
+
count = 12
|
|
3104
|
+
}) => {
|
|
3438
3105
|
return /* @__PURE__ */ jsxs(Box, { position: "relative", children: [
|
|
3439
3106
|
/* @__PURE__ */ jsx(EmptyAssetGrid, { size, count }),
|
|
3440
3107
|
/* @__PURE__ */ jsx(Box, { position: "absolute", top: 11, width: "100%", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 4, textAlign: "center", children: [
|
|
@@ -3446,29 +3113,10 @@ const EmptyAssets = ({ icon: Icon = EmptyDocuments, content, action, size, count
|
|
|
3446
3113
|
] }) })
|
|
3447
3114
|
] });
|
|
3448
3115
|
};
|
|
3449
|
-
EmptyAssets.defaultProps = {
|
|
3450
|
-
action: void 0,
|
|
3451
|
-
icon: void 0,
|
|
3452
|
-
size: "M",
|
|
3453
|
-
count: 12
|
|
3454
|
-
};
|
|
3455
|
-
EmptyAssets.propTypes = {
|
|
3456
|
-
action: PropTypes.node,
|
|
3457
|
-
icon: PropTypes.elementType,
|
|
3458
|
-
content: PropTypes.string.isRequired,
|
|
3459
|
-
size: PropTypes.string,
|
|
3460
|
-
count: PropTypes.number
|
|
3461
|
-
};
|
|
3462
3116
|
const FolderCardContext = createContext({});
|
|
3463
3117
|
function useFolderCard() {
|
|
3464
3118
|
return useContext(FolderCardContext);
|
|
3465
3119
|
}
|
|
3466
|
-
let id = 0;
|
|
3467
|
-
const genId = () => ++id;
|
|
3468
|
-
const useId = (initialId) => {
|
|
3469
|
-
const idRef = useRef(`${initialId}-${genId()}`);
|
|
3470
|
-
return idRef.current;
|
|
3471
|
-
};
|
|
3472
3120
|
const FauxClickWrapper = styled.button`
|
|
3473
3121
|
height: 100%;
|
|
3474
3122
|
left: 0;
|
|
@@ -3498,16 +3146,24 @@ const Card = styled(Box)`
|
|
|
3498
3146
|
}
|
|
3499
3147
|
}
|
|
3500
3148
|
`;
|
|
3501
|
-
const FolderCard = forwardRef(
|
|
3502
|
-
({
|
|
3503
|
-
|
|
3504
|
-
|
|
3149
|
+
const FolderCard = React.forwardRef(
|
|
3150
|
+
({
|
|
3151
|
+
children,
|
|
3152
|
+
startAction = null,
|
|
3153
|
+
cardActions = null,
|
|
3154
|
+
ariaLabel,
|
|
3155
|
+
onClick,
|
|
3156
|
+
to,
|
|
3157
|
+
...props
|
|
3158
|
+
}, ref) => {
|
|
3159
|
+
const generatedId = React.useId();
|
|
3160
|
+
const fodlerCtxValue = React.useMemo(() => ({ id: generatedId }), [generatedId]);
|
|
3505
3161
|
return /* @__PURE__ */ jsx(FolderCardContext.Provider, { value: fodlerCtxValue, children: /* @__PURE__ */ jsxs(Card, { position: "relative", tabIndex: 0, $isCardActions: !!cardActions, ref, ...props, children: [
|
|
3506
3162
|
/* @__PURE__ */ jsx(
|
|
3507
3163
|
FauxClickWrapper,
|
|
3508
3164
|
{
|
|
3509
3165
|
to: to || void 0,
|
|
3510
|
-
|
|
3166
|
+
as: to ? NavLink : "button",
|
|
3511
3167
|
type: to ? void 0 : "button",
|
|
3512
3168
|
onClick,
|
|
3513
3169
|
tabIndex: -1,
|
|
@@ -3543,39 +3199,24 @@ const FolderCard = forwardRef(
|
|
|
3543
3199
|
}
|
|
3544
3200
|
),
|
|
3545
3201
|
children,
|
|
3546
|
-
/* @__PURE__ */ jsx(CardActionDisplay, { children: /* @__PURE__ */ jsx(CardAction, { right: 4, children: cardActions }) })
|
|
3202
|
+
/* @__PURE__ */ jsx(CardActionDisplay, { children: /* @__PURE__ */ jsx(CardAction, { right: 4, position: "end", children: cardActions }) })
|
|
3547
3203
|
]
|
|
3548
3204
|
}
|
|
3549
3205
|
)
|
|
3550
3206
|
] }) });
|
|
3551
3207
|
}
|
|
3552
3208
|
);
|
|
3553
|
-
FolderCard.defaultProps = {
|
|
3554
|
-
id: void 0,
|
|
3555
|
-
cardActions: null,
|
|
3556
|
-
startAction: null,
|
|
3557
|
-
to: void 0,
|
|
3558
|
-
onClick: void 0
|
|
3559
|
-
};
|
|
3560
|
-
FolderCard.propTypes = {
|
|
3561
|
-
ariaLabel: PropTypes.string.isRequired,
|
|
3562
|
-
children: PropTypes.node.isRequired,
|
|
3563
|
-
id: PropTypes.string,
|
|
3564
|
-
onClick: PropTypes.func,
|
|
3565
|
-
startAction: PropTypes.element,
|
|
3566
|
-
cardActions: PropTypes.element,
|
|
3567
|
-
to: PropTypes.string
|
|
3568
|
-
};
|
|
3569
3209
|
const StyledBox = styled(Flex)`
|
|
3570
3210
|
user-select: none;
|
|
3571
3211
|
`;
|
|
3572
3212
|
const FolderCardBody = (props) => {
|
|
3573
|
-
const { id
|
|
3213
|
+
const { id } = useFolderCard();
|
|
3574
3214
|
return /* @__PURE__ */ jsx(
|
|
3575
3215
|
StyledBox,
|
|
3576
3216
|
{
|
|
3577
3217
|
...props,
|
|
3578
|
-
id: `${
|
|
3218
|
+
id: `${id}-title`,
|
|
3219
|
+
"data-testid": `${id}-title`,
|
|
3579
3220
|
alignItems: "flex-start",
|
|
3580
3221
|
direction: "column",
|
|
3581
3222
|
maxWidth: "100%",
|
|
@@ -3608,25 +3249,12 @@ const FolderCardBodyAction = ({ to, ...props }) => {
|
|
|
3608
3249
|
}
|
|
3609
3250
|
return /* @__PURE__ */ jsx(BoxOutline, { padding: 1, tag: "button", type: "button", maxWidth: "100%", ...props });
|
|
3610
3251
|
};
|
|
3611
|
-
|
|
3612
|
-
to: void 0
|
|
3613
|
-
};
|
|
3614
|
-
FolderCardBodyAction.propTypes = {
|
|
3615
|
-
to: PropTypes.string
|
|
3616
|
-
};
|
|
3617
|
-
const FolderGridList = ({ title, children }) => {
|
|
3252
|
+
const FolderGridList = ({ title = null, children }) => {
|
|
3618
3253
|
return /* @__PURE__ */ jsxs(KeyboardNavigable, { tagName: "article", children: [
|
|
3619
3254
|
title && /* @__PURE__ */ jsx(Box, { paddingBottom: 2, children: /* @__PURE__ */ jsx(Typography, { tag: "h2", variant: "delta", fontWeight: "semiBold", children: title }) }),
|
|
3620
3255
|
/* @__PURE__ */ jsx(Grid.Root, { gap: 4, children })
|
|
3621
3256
|
] });
|
|
3622
3257
|
};
|
|
3623
|
-
FolderGridList.defaultProps = {
|
|
3624
|
-
title: null
|
|
3625
|
-
};
|
|
3626
|
-
FolderGridList.propTypes = {
|
|
3627
|
-
children: PropTypes.node.isRequired,
|
|
3628
|
-
title: PropTypes.string
|
|
3629
|
-
};
|
|
3630
3258
|
const SortPicker = ({ onChangeSort, value }) => {
|
|
3631
3259
|
const { formatMessage } = useIntl();
|
|
3632
3260
|
return /* @__PURE__ */ jsx(
|
|
@@ -3634,7 +3262,7 @@ const SortPicker = ({ onChangeSort, value }) => {
|
|
|
3634
3262
|
{
|
|
3635
3263
|
size: "S",
|
|
3636
3264
|
value,
|
|
3637
|
-
onChange: (value2) => onChangeSort(value2),
|
|
3265
|
+
onChange: (value2) => onChangeSort(value2.toString()),
|
|
3638
3266
|
"aria-label": formatMessage({
|
|
3639
3267
|
id: getTrad("sort.label"),
|
|
3640
3268
|
defaultMessage: "Sort by"
|
|
@@ -3647,13 +3275,6 @@ const SortPicker = ({ onChangeSort, value }) => {
|
|
|
3647
3275
|
}
|
|
3648
3276
|
);
|
|
3649
3277
|
};
|
|
3650
|
-
SortPicker.defaultProps = {
|
|
3651
|
-
value: void 0
|
|
3652
|
-
};
|
|
3653
|
-
SortPicker.propTypes = {
|
|
3654
|
-
onChangeSort: PropTypes.func.isRequired,
|
|
3655
|
-
value: PropTypes.string
|
|
3656
|
-
};
|
|
3657
3278
|
const VideoPreviewWrapper$1 = styled(Box)`
|
|
3658
3279
|
figure {
|
|
3659
3280
|
width: ${({ theme }) => theme.spaces[7]};
|
|
@@ -3669,6 +3290,7 @@ const VideoPreviewWrapper$1 = styled(Box)`
|
|
|
3669
3290
|
}
|
|
3670
3291
|
`;
|
|
3671
3292
|
const PreviewCell = ({ type, content }) => {
|
|
3293
|
+
const { formatMessage } = useIntl();
|
|
3672
3294
|
if (type === "folder") {
|
|
3673
3295
|
return /* @__PURE__ */ jsx(
|
|
3674
3296
|
Flex,
|
|
@@ -3678,20 +3300,39 @@ const PreviewCell = ({ type, content }) => {
|
|
|
3678
3300
|
width: "3.2rem",
|
|
3679
3301
|
height: "3.2rem",
|
|
3680
3302
|
borderRadius: "50%",
|
|
3681
|
-
children: /* @__PURE__ */ jsx(
|
|
3303
|
+
children: /* @__PURE__ */ jsx(
|
|
3304
|
+
Folder,
|
|
3305
|
+
{
|
|
3306
|
+
"aria-label": formatMessage({
|
|
3307
|
+
id: getTrad("header.actions.add-assets.folder"),
|
|
3308
|
+
defaultMessage: "folder"
|
|
3309
|
+
}),
|
|
3310
|
+
fill: "secondary500",
|
|
3311
|
+
width: "1.6rem",
|
|
3312
|
+
height: "1.6rem"
|
|
3313
|
+
}
|
|
3314
|
+
)
|
|
3682
3315
|
}
|
|
3683
3316
|
);
|
|
3684
3317
|
}
|
|
3685
3318
|
const { alternativeText, ext, formats, mime, name: name2, url } = content;
|
|
3686
|
-
if (mime
|
|
3319
|
+
if (mime?.includes(AssetType.Image)) {
|
|
3687
3320
|
const mediaURL = prefixFileUrlWithBackendUrl(formats?.thumbnail?.url) ?? prefixFileUrlWithBackendUrl(url);
|
|
3688
|
-
return /* @__PURE__ */ jsx(
|
|
3321
|
+
return /* @__PURE__ */ jsx(
|
|
3322
|
+
Avatar.Item,
|
|
3323
|
+
{
|
|
3324
|
+
src: mediaURL,
|
|
3325
|
+
alt: alternativeText || void 0,
|
|
3326
|
+
preview: true,
|
|
3327
|
+
fallback: alternativeText
|
|
3328
|
+
}
|
|
3329
|
+
);
|
|
3689
3330
|
}
|
|
3690
|
-
if (mime
|
|
3331
|
+
if (mime?.includes(AssetType.Video)) {
|
|
3691
3332
|
return /* @__PURE__ */ jsx(VideoPreviewWrapper$1, { children: /* @__PURE__ */ jsx(
|
|
3692
3333
|
VideoPreview,
|
|
3693
3334
|
{
|
|
3694
|
-
url: createAssetUrl(content, true),
|
|
3335
|
+
url: createAssetUrl(content, true) || "",
|
|
3695
3336
|
mime,
|
|
3696
3337
|
alt: alternativeText ?? name2
|
|
3697
3338
|
}
|
|
@@ -3699,28 +3340,16 @@ const PreviewCell = ({ type, content }) => {
|
|
|
3699
3340
|
}
|
|
3700
3341
|
return /* @__PURE__ */ jsx(Box, { background: "secondary100", color: "secondary600", width: "3.2rem", height: "3.2rem", children: getFileExtension(ext) });
|
|
3701
3342
|
};
|
|
3702
|
-
PreviewCell.propTypes = {
|
|
3703
|
-
content: PropTypes.shape({
|
|
3704
|
-
alternativeText: PropTypes.string,
|
|
3705
|
-
ext: PropTypes.string,
|
|
3706
|
-
formats: PropTypes.shape({
|
|
3707
|
-
thumbnail: PropTypes.shape({
|
|
3708
|
-
url: PropTypes.string
|
|
3709
|
-
})
|
|
3710
|
-
}),
|
|
3711
|
-
mime: PropTypes.string,
|
|
3712
|
-
name: PropTypes.string,
|
|
3713
|
-
url: PropTypes.string
|
|
3714
|
-
}).isRequired,
|
|
3715
|
-
type: PropTypes.string.isRequired
|
|
3716
|
-
};
|
|
3717
3343
|
const CellContent = ({ cellType, contentType, content, name: name2 }) => {
|
|
3718
3344
|
const { formatDate, formatMessage } = useIntl();
|
|
3345
|
+
const contentValue = content[name2];
|
|
3719
3346
|
switch (cellType) {
|
|
3720
3347
|
case "image":
|
|
3721
3348
|
return /* @__PURE__ */ jsx(PreviewCell, { type: contentType, content });
|
|
3722
3349
|
case "date":
|
|
3723
|
-
|
|
3350
|
+
if (typeof contentValue === "string") {
|
|
3351
|
+
return /* @__PURE__ */ jsx(Typography, { children: formatDate(parseISO(contentValue), { dateStyle: "full" }) });
|
|
3352
|
+
}
|
|
3724
3353
|
case "size":
|
|
3725
3354
|
if (contentType === "folder")
|
|
3726
3355
|
return /* @__PURE__ */ jsx(
|
|
@@ -3733,7 +3362,9 @@ const CellContent = ({ cellType, contentType, content, name: name2 }) => {
|
|
|
3733
3362
|
children: "-"
|
|
3734
3363
|
}
|
|
3735
3364
|
);
|
|
3736
|
-
|
|
3365
|
+
if (typeof contentValue === "string" || typeof contentValue === "number") {
|
|
3366
|
+
return /* @__PURE__ */ jsx(Typography, { children: formatBytes(contentValue) });
|
|
3367
|
+
}
|
|
3737
3368
|
case "ext":
|
|
3738
3369
|
if (contentType === "folder")
|
|
3739
3370
|
return /* @__PURE__ */ jsx(
|
|
@@ -3746,9 +3377,13 @@ const CellContent = ({ cellType, contentType, content, name: name2 }) => {
|
|
|
3746
3377
|
children: "-"
|
|
3747
3378
|
}
|
|
3748
3379
|
);
|
|
3749
|
-
|
|
3380
|
+
if (typeof contentValue === "string") {
|
|
3381
|
+
return /* @__PURE__ */ jsx(Typography, { children: getFileExtension(contentValue)?.toUpperCase() });
|
|
3382
|
+
}
|
|
3750
3383
|
case "text":
|
|
3751
|
-
|
|
3384
|
+
if (typeof contentValue === "string") {
|
|
3385
|
+
return /* @__PURE__ */ jsx(Typography, { children: contentValue });
|
|
3386
|
+
}
|
|
3752
3387
|
default:
|
|
3753
3388
|
return /* @__PURE__ */ jsx(
|
|
3754
3389
|
Typography,
|
|
@@ -3762,135 +3397,126 @@ const CellContent = ({ cellType, contentType, content, name: name2 }) => {
|
|
|
3762
3397
|
);
|
|
3763
3398
|
}
|
|
3764
3399
|
};
|
|
3765
|
-
CellContent.propTypes = {
|
|
3766
|
-
cellType: PropTypes.string.isRequired,
|
|
3767
|
-
contentType: PropTypes.string.isRequired,
|
|
3768
|
-
content: PropTypes.shape({
|
|
3769
|
-
alternativeText: PropTypes.string,
|
|
3770
|
-
ext: PropTypes.string,
|
|
3771
|
-
formats: PropTypes.shape({
|
|
3772
|
-
thumbnail: PropTypes.shape({
|
|
3773
|
-
url: PropTypes.string
|
|
3774
|
-
})
|
|
3775
|
-
}),
|
|
3776
|
-
mime: PropTypes.string,
|
|
3777
|
-
url: PropTypes.string
|
|
3778
|
-
}).isRequired,
|
|
3779
|
-
name: PropTypes.string.isRequired
|
|
3780
|
-
};
|
|
3781
3400
|
const TableRows = ({
|
|
3782
|
-
onChangeFolder,
|
|
3401
|
+
onChangeFolder = null,
|
|
3783
3402
|
onEditAsset,
|
|
3784
3403
|
onEditFolder,
|
|
3785
3404
|
onSelectOne,
|
|
3786
|
-
rows,
|
|
3787
|
-
selected
|
|
3405
|
+
rows = [],
|
|
3406
|
+
selected = []
|
|
3788
3407
|
}) => {
|
|
3789
3408
|
const { formatMessage } = useIntl();
|
|
3790
|
-
const handleRowClickFn = (element,
|
|
3409
|
+
const handleRowClickFn = (element, id, path, elementType) => {
|
|
3791
3410
|
if (elementType === "asset") {
|
|
3792
3411
|
onEditAsset(element);
|
|
3793
3412
|
} else {
|
|
3794
|
-
onChangeFolder
|
|
3413
|
+
if (onChangeFolder) {
|
|
3414
|
+
onChangeFolder(id, path);
|
|
3415
|
+
}
|
|
3795
3416
|
}
|
|
3796
3417
|
};
|
|
3797
3418
|
return /* @__PURE__ */ jsx(Tbody, { children: rows.map((element) => {
|
|
3798
|
-
const { path, id
|
|
3419
|
+
const { path, id, isSelectable: isSelectable2, name: name2, folderURL, type: contentType } = element;
|
|
3799
3420
|
const isSelected = !!selected.find(
|
|
3800
|
-
(currentRow) => currentRow.id ===
|
|
3421
|
+
(currentRow) => currentRow.id === id && currentRow.type === contentType
|
|
3801
3422
|
);
|
|
3802
|
-
return /* @__PURE__ */ jsxs(
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3423
|
+
return /* @__PURE__ */ jsxs(
|
|
3424
|
+
Tr,
|
|
3425
|
+
{
|
|
3426
|
+
onClick: () => handleRowClickFn(element, id, path || void 0, contentType),
|
|
3427
|
+
children: [
|
|
3428
|
+
/* @__PURE__ */ jsx(Td, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(
|
|
3429
|
+
Checkbox,
|
|
3807
3430
|
{
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3431
|
+
"aria-label": formatMessage(
|
|
3432
|
+
{
|
|
3433
|
+
id: contentType === "asset" ? "list-assets-select" : "list.folder.select",
|
|
3434
|
+
defaultMessage: contentType === "asset" ? "Select {name} asset" : "Select {name} folder"
|
|
3435
|
+
},
|
|
3436
|
+
{ name: name2 }
|
|
3437
|
+
),
|
|
3438
|
+
disabled: !isSelectable2,
|
|
3439
|
+
onCheckedChange: () => onSelectOne(element),
|
|
3440
|
+
checked: isSelected
|
|
3441
|
+
}
|
|
3442
|
+
) }),
|
|
3443
|
+
tableHeaders.map(({ name: name22, type: cellType }) => {
|
|
3444
|
+
return /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(
|
|
3445
|
+
CellContent,
|
|
3446
|
+
{
|
|
3447
|
+
content: element,
|
|
3448
|
+
cellType,
|
|
3449
|
+
contentType,
|
|
3450
|
+
name: name22
|
|
3451
|
+
}
|
|
3452
|
+
) }, name22);
|
|
3453
|
+
}),
|
|
3454
|
+
/* @__PURE__ */ jsx(Td, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "flex-end", children: [
|
|
3455
|
+
contentType === "folder" && (folderURL ? /* @__PURE__ */ jsx(
|
|
3456
|
+
IconButton,
|
|
3457
|
+
{
|
|
3458
|
+
tag: Link$1,
|
|
3459
|
+
label: formatMessage({
|
|
3460
|
+
id: getTrad("list.folders.link-label"),
|
|
3461
|
+
defaultMessage: "Access folder"
|
|
3462
|
+
}),
|
|
3463
|
+
to: folderURL,
|
|
3464
|
+
variant: "ghost",
|
|
3465
|
+
children: /* @__PURE__ */ jsx(Eye, {})
|
|
3466
|
+
}
|
|
3467
|
+
) : /* @__PURE__ */ jsx(
|
|
3468
|
+
IconButton,
|
|
3469
|
+
{
|
|
3470
|
+
tag: "button",
|
|
3471
|
+
label: formatMessage({
|
|
3472
|
+
id: getTrad("list.folders.link-label"),
|
|
3473
|
+
defaultMessage: "Access folder"
|
|
3474
|
+
}),
|
|
3475
|
+
onClick: () => onChangeFolder && onChangeFolder(id),
|
|
3476
|
+
variant: "ghost",
|
|
3477
|
+
children: /* @__PURE__ */ jsx(Eye, {})
|
|
3478
|
+
}
|
|
3479
|
+
)),
|
|
3480
|
+
/* @__PURE__ */ jsx(
|
|
3481
|
+
IconButton,
|
|
3482
|
+
{
|
|
3483
|
+
label: formatMessage({
|
|
3484
|
+
id: getTrad("control-card.edit"),
|
|
3485
|
+
defaultMessage: "Edit"
|
|
3486
|
+
}),
|
|
3487
|
+
onClick: () => contentType === "asset" ? onEditAsset(element) : onEditFolder(element),
|
|
3488
|
+
variant: "ghost",
|
|
3489
|
+
children: /* @__PURE__ */ jsx(Pencil, {})
|
|
3490
|
+
}
|
|
3491
|
+
)
|
|
3492
|
+
] }) })
|
|
3493
|
+
]
|
|
3494
|
+
},
|
|
3495
|
+
id
|
|
3496
|
+
);
|
|
3858
3497
|
}) });
|
|
3859
3498
|
};
|
|
3860
|
-
TableRows.defaultProps = {
|
|
3861
|
-
onChangeFolder: null,
|
|
3862
|
-
rows: [],
|
|
3863
|
-
selected: []
|
|
3864
|
-
};
|
|
3865
|
-
TableRows.propTypes = {
|
|
3866
|
-
onChangeFolder: PropTypes.func,
|
|
3867
|
-
onEditAsset: PropTypes.func.isRequired,
|
|
3868
|
-
onEditFolder: PropTypes.func.isRequired,
|
|
3869
|
-
onSelectOne: PropTypes.func.isRequired,
|
|
3870
|
-
rows: PropTypes.arrayOf(AssetDefinition, FolderDefinition),
|
|
3871
|
-
selected: PropTypes.arrayOf(AssetDefinition, FolderDefinition)
|
|
3872
|
-
};
|
|
3873
3499
|
const TableList = ({
|
|
3874
|
-
assetCount,
|
|
3875
|
-
folderCount,
|
|
3876
|
-
indeterminate,
|
|
3877
|
-
onChangeSort,
|
|
3878
|
-
onChangeFolder,
|
|
3879
|
-
onEditAsset,
|
|
3880
|
-
onEditFolder,
|
|
3500
|
+
assetCount = 0,
|
|
3501
|
+
folderCount = 0,
|
|
3502
|
+
indeterminate = false,
|
|
3503
|
+
onChangeSort = null,
|
|
3504
|
+
onChangeFolder = null,
|
|
3505
|
+
onEditAsset = null,
|
|
3506
|
+
onEditFolder = null,
|
|
3881
3507
|
onSelectAll,
|
|
3882
3508
|
onSelectOne,
|
|
3883
|
-
rows,
|
|
3884
|
-
selected,
|
|
3885
|
-
shouldDisableBulkSelect,
|
|
3886
|
-
sortQuery
|
|
3509
|
+
rows = [],
|
|
3510
|
+
selected = [],
|
|
3511
|
+
shouldDisableBulkSelect = false,
|
|
3512
|
+
sortQuery = ""
|
|
3887
3513
|
}) => {
|
|
3888
3514
|
const { formatMessage } = useIntl();
|
|
3889
3515
|
const [sortBy, sortOrder] = sortQuery.split(":");
|
|
3890
3516
|
const handleClickSort = (isSorted, name2) => {
|
|
3891
3517
|
const nextSortOrder = isSorted && sortOrder === "ASC" ? "DESC" : "ASC";
|
|
3892
3518
|
const nextSort = `${name2}:${nextSortOrder}`;
|
|
3893
|
-
onChangeSort(nextSort);
|
|
3519
|
+
onChangeSort && onChangeSort(nextSort);
|
|
3894
3520
|
};
|
|
3895
3521
|
return /* @__PURE__ */ jsxs(Table, { colCount: tableHeaders.length + 2, rowCount: assetCount + folderCount + 1, children: [
|
|
3896
3522
|
/* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
|
|
@@ -3931,7 +3557,6 @@ const TableList = ({
|
|
|
3931
3557
|
{
|
|
3932
3558
|
onClick: () => handleClickSort(isSorted, name2),
|
|
3933
3559
|
tag: isSorted ? "span" : "button",
|
|
3934
|
-
label: !isSorted ? sortLabel : "",
|
|
3935
3560
|
textColor: "neutral600",
|
|
3936
3561
|
variant: "sigma",
|
|
3937
3562
|
children: tableHeaderLabel
|
|
@@ -3959,41 +3584,13 @@ const TableList = ({
|
|
|
3959
3584
|
)
|
|
3960
3585
|
] });
|
|
3961
3586
|
};
|
|
3962
|
-
TableList.defaultProps = {
|
|
3963
|
-
assetCount: 0,
|
|
3964
|
-
folderCount: 0,
|
|
3965
|
-
indeterminate: false,
|
|
3966
|
-
onChangeSort: null,
|
|
3967
|
-
onChangeFolder: null,
|
|
3968
|
-
onEditAsset: null,
|
|
3969
|
-
onEditFolder: null,
|
|
3970
|
-
rows: [],
|
|
3971
|
-
selected: [],
|
|
3972
|
-
shouldDisableBulkSelect: false,
|
|
3973
|
-
sortQuery: ""
|
|
3974
|
-
};
|
|
3975
|
-
TableList.propTypes = {
|
|
3976
|
-
assetCount: PropTypes.number,
|
|
3977
|
-
folderCount: PropTypes.number,
|
|
3978
|
-
indeterminate: PropTypes.bool,
|
|
3979
|
-
onChangeSort: PropTypes.func,
|
|
3980
|
-
onChangeFolder: PropTypes.func,
|
|
3981
|
-
onEditAsset: PropTypes.func,
|
|
3982
|
-
onEditFolder: PropTypes.func,
|
|
3983
|
-
onSelectAll: PropTypes.func.isRequired,
|
|
3984
|
-
onSelectOne: PropTypes.func.isRequired,
|
|
3985
|
-
rows: PropTypes.arrayOf(AssetDefinition, FolderDefinition),
|
|
3986
|
-
selected: PropTypes.arrayOf(AssetDefinition, FolderDefinition),
|
|
3987
|
-
shouldDisableBulkSelect: PropTypes.bool,
|
|
3988
|
-
sortQuery: PropTypes.string
|
|
3989
|
-
};
|
|
3990
3587
|
const FilterTag = ({ attribute, filter, onClick, operator, value }) => {
|
|
3991
3588
|
const { formatMessage, formatDate, formatTime } = useIntl();
|
|
3992
3589
|
const handleClick = () => {
|
|
3993
3590
|
onClick(filter);
|
|
3994
3591
|
};
|
|
3995
3592
|
const { fieldSchema } = attribute;
|
|
3996
|
-
const type = fieldSchema
|
|
3593
|
+
const type = fieldSchema?.type;
|
|
3997
3594
|
let formattedValue = value;
|
|
3998
3595
|
if (type === "date") {
|
|
3999
3596
|
formattedValue = formatDate(value, { dateStyle: "full" });
|
|
@@ -4004,43 +3601,42 @@ const FilterTag = ({ attribute, filter, onClick, operator, value }) => {
|
|
|
4004
3601
|
if (type === "time") {
|
|
4005
3602
|
const [hour, minute] = value.split(":");
|
|
4006
3603
|
const date = /* @__PURE__ */ new Date();
|
|
4007
|
-
date.setHours(hour);
|
|
4008
|
-
date.setMinutes(minute);
|
|
3604
|
+
date.setHours(Number(hour));
|
|
3605
|
+
date.setMinutes(Number(minute));
|
|
4009
3606
|
formattedValue = formatTime(date, {
|
|
4010
|
-
|
|
4011
|
-
|
|
3607
|
+
hour: "numeric",
|
|
3608
|
+
minute: "numeric"
|
|
4012
3609
|
});
|
|
4013
3610
|
}
|
|
4014
|
-
const content = `${attribute.metadatas
|
|
3611
|
+
const content = `${attribute.metadatas?.label} ${formatMessage({
|
|
4015
3612
|
id: `components.FilterOptions.FILTER_TYPES.${operator}`,
|
|
4016
3613
|
defaultMessage: operator
|
|
4017
3614
|
})} ${formattedValue}`;
|
|
4018
3615
|
return /* @__PURE__ */ jsx(Tag, { onClick: handleClick, icon: /* @__PURE__ */ jsx(Cross, {}), padding: 1, children: content });
|
|
4019
3616
|
};
|
|
4020
|
-
FilterTag.propTypes = {
|
|
4021
|
-
attribute: PropTypes.shape({
|
|
4022
|
-
name: PropTypes.string.isRequired,
|
|
4023
|
-
fieldSchema: PropTypes.object.isRequired,
|
|
4024
|
-
metadatas: PropTypes.shape({ label: PropTypes.string.isRequired }).isRequired
|
|
4025
|
-
}).isRequired,
|
|
4026
|
-
filter: PropTypes.object.isRequired,
|
|
4027
|
-
onClick: PropTypes.func.isRequired,
|
|
4028
|
-
operator: PropTypes.string.isRequired,
|
|
4029
|
-
value: PropTypes.string.isRequired
|
|
4030
|
-
};
|
|
4031
3617
|
const FilterList = ({ appliedFilters, filtersSchema, onRemoveFilter }) => {
|
|
4032
3618
|
const handleClick = (filter) => {
|
|
4033
3619
|
const nextFilters = appliedFilters.filter((prevFilter) => {
|
|
4034
3620
|
const name2 = Object.keys(filter)[0];
|
|
4035
|
-
const
|
|
4036
|
-
|
|
4037
|
-
|
|
3621
|
+
const filterName = filter[name2];
|
|
3622
|
+
if (filterName !== void 0) {
|
|
3623
|
+
const filterType = Object.keys(filterName)[0];
|
|
3624
|
+
const filterValue = filterName[filterType];
|
|
3625
|
+
if (typeof filterValue === "string") {
|
|
3626
|
+
const decodedValue = decodeURIComponent(filterValue);
|
|
3627
|
+
return prevFilter[name2]?.[filterType] !== decodedValue;
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
return true;
|
|
4038
3631
|
});
|
|
4039
3632
|
onRemoveFilter(nextFilters);
|
|
4040
3633
|
};
|
|
4041
3634
|
return appliedFilters.map((filter, i) => {
|
|
4042
3635
|
const attributeName = Object.keys(filter)[0];
|
|
4043
3636
|
const attribute = filtersSchema.find(({ name: name2 }) => name2 === attributeName);
|
|
3637
|
+
if (!attribute) {
|
|
3638
|
+
return null;
|
|
3639
|
+
}
|
|
4044
3640
|
const filterObj = filter[attributeName];
|
|
4045
3641
|
const operator = Object.keys(filterObj)[0];
|
|
4046
3642
|
let value = filterObj[operator];
|
|
@@ -4052,7 +3648,7 @@ const FilterList = ({ appliedFilters, filtersSchema, onRemoveFilter }) => {
|
|
|
4052
3648
|
value = Array.isArray(value) || typeof value === "object" ? Object.values(value).join(", ") : decodeURIComponent(value);
|
|
4053
3649
|
}
|
|
4054
3650
|
let displayedOperator = operator;
|
|
4055
|
-
if (attribute
|
|
3651
|
+
if (attribute?.name === "mime") {
|
|
4056
3652
|
displayedOperator = operator === "$contains" ? "$eq" : "$ne";
|
|
4057
3653
|
if (operator === "$not") {
|
|
4058
3654
|
value = "file";
|
|
@@ -4076,65 +3672,45 @@ const FilterList = ({ appliedFilters, filtersSchema, onRemoveFilter }) => {
|
|
|
4076
3672
|
);
|
|
4077
3673
|
});
|
|
4078
3674
|
};
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
name: PropTypes.string.isRequired,
|
|
4087
|
-
metadatas: PropTypes.shape({ label: PropTypes.string }),
|
|
4088
|
-
fieldSchema: PropTypes.shape({
|
|
4089
|
-
type: PropTypes.string,
|
|
4090
|
-
mainField: PropTypes.shape({
|
|
4091
|
-
name: PropTypes.string,
|
|
4092
|
-
type: PropTypes.string
|
|
4093
|
-
})
|
|
4094
|
-
})
|
|
4095
|
-
})
|
|
4096
|
-
),
|
|
4097
|
-
onRemoveFilter: PropTypes.func.isRequired
|
|
4098
|
-
};
|
|
4099
|
-
const FilterValueInput = ({ label, onChange, options, type, value }) => {
|
|
3675
|
+
const FilterValueInput = ({
|
|
3676
|
+
label = "",
|
|
3677
|
+
onChange,
|
|
3678
|
+
options = [],
|
|
3679
|
+
type,
|
|
3680
|
+
value = ""
|
|
3681
|
+
}) => {
|
|
4100
3682
|
const { formatMessage } = useIntl();
|
|
4101
3683
|
if (type === "date") {
|
|
4102
3684
|
return /* @__PURE__ */ jsx(
|
|
4103
3685
|
DateTimePicker,
|
|
4104
3686
|
{
|
|
4105
3687
|
clearLabel: formatMessage({ id: "clearLabel", defaultMessage: "Clear" }),
|
|
4106
|
-
|
|
3688
|
+
"aria-label": label,
|
|
4107
3689
|
name: "datetimepicker",
|
|
4108
3690
|
onChange: (date) => {
|
|
4109
3691
|
const formattedDate = date ? new Date(date).toISOString() : "";
|
|
4110
3692
|
onChange(formattedDate);
|
|
4111
3693
|
},
|
|
4112
3694
|
onClear: () => onChange(""),
|
|
4113
|
-
value: value ? new Date(value) : void 0
|
|
4114
|
-
selectedDateLabel: (formattedDate) => `Date picker, current is ${formattedDate}`,
|
|
4115
|
-
selectButtonTitle: formatMessage({ id: "selectButtonTitle", defaultMessage: "Select" })
|
|
3695
|
+
value: value ? new Date(value) : void 0
|
|
4116
3696
|
}
|
|
4117
3697
|
);
|
|
4118
3698
|
}
|
|
4119
|
-
return /* @__PURE__ */ jsx(
|
|
4120
|
-
|
|
4121
|
-
|
|
3699
|
+
return /* @__PURE__ */ jsx(
|
|
3700
|
+
SingleSelect,
|
|
3701
|
+
{
|
|
3702
|
+
"aria-label": label,
|
|
3703
|
+
onChange: (value2) => onChange(value2.toString()),
|
|
3704
|
+
value,
|
|
3705
|
+
children: options?.map((option) => {
|
|
3706
|
+
return /* @__PURE__ */ jsx(SingleSelectOption, { value: option.value, children: option.label }, option.value);
|
|
3707
|
+
})
|
|
3708
|
+
}
|
|
3709
|
+
);
|
|
4122
3710
|
};
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
value: ""
|
|
4127
|
-
};
|
|
4128
|
-
FilterValueInput.propTypes = {
|
|
4129
|
-
label: PropTypes.string,
|
|
4130
|
-
onChange: PropTypes.func.isRequired,
|
|
4131
|
-
options: PropTypes.arrayOf(
|
|
4132
|
-
PropTypes.shape({ label: PropTypes.string.isRequired, value: PropTypes.string.isRequired })
|
|
4133
|
-
),
|
|
4134
|
-
type: PropTypes.string.isRequired,
|
|
4135
|
-
value: PropTypes.any
|
|
4136
|
-
};
|
|
4137
|
-
const getFilterList = ({ fieldSchema: { type: fieldType, mainField } }) => {
|
|
3711
|
+
const getFilterList = ({
|
|
3712
|
+
fieldSchema: { type: fieldType, mainField }
|
|
3713
|
+
}) => {
|
|
4138
3714
|
const type = mainField?.schema.type ? mainField.schema.type : fieldType;
|
|
4139
3715
|
switch (type) {
|
|
4140
3716
|
case "enumeration": {
|
|
@@ -4229,30 +3805,38 @@ const getFilterList = ({ fieldSchema: { type: fieldType, mainField } }) => {
|
|
|
4229
3805
|
];
|
|
4230
3806
|
}
|
|
4231
3807
|
};
|
|
4232
|
-
const FilterPopover = ({
|
|
3808
|
+
const FilterPopover = ({
|
|
3809
|
+
displayedFilters: displayedFilters2,
|
|
3810
|
+
filters,
|
|
3811
|
+
onSubmit,
|
|
3812
|
+
onToggle
|
|
3813
|
+
}) => {
|
|
4233
3814
|
const { formatMessage } = useIntl();
|
|
4234
|
-
const [modifiedData, setModifiedData] = useState({
|
|
3815
|
+
const [modifiedData, setModifiedData] = React.useState({
|
|
4235
3816
|
name: "createdAt",
|
|
4236
3817
|
filter: "$eq",
|
|
4237
3818
|
value: ""
|
|
4238
3819
|
});
|
|
4239
3820
|
const handleChangeFilterField = (value) => {
|
|
4240
3821
|
const nextField = displayedFilters2.find((f) => f.name === value);
|
|
3822
|
+
if (!nextField) {
|
|
3823
|
+
return;
|
|
3824
|
+
}
|
|
4241
3825
|
const {
|
|
4242
3826
|
fieldSchema: { type, options }
|
|
4243
3827
|
} = nextField;
|
|
4244
3828
|
let filterValue = "";
|
|
4245
3829
|
if (type === "enumeration") {
|
|
4246
|
-
filterValue = options[0].value;
|
|
3830
|
+
filterValue = options?.[0].value || "";
|
|
4247
3831
|
}
|
|
4248
3832
|
const filter = getFilterList(nextField)[0].value;
|
|
4249
|
-
setModifiedData({ name: value, filter, value: filterValue });
|
|
3833
|
+
setModifiedData({ name: value.toString(), filter, value: filterValue });
|
|
4250
3834
|
};
|
|
4251
3835
|
const handleChangeOperator = (operator) => {
|
|
4252
3836
|
if (modifiedData.name === "mime") {
|
|
4253
|
-
setModifiedData((prev) => ({ ...prev, filter: operator, value: "image" }));
|
|
3837
|
+
setModifiedData((prev) => ({ ...prev, filter: operator.toString(), value: "image" }));
|
|
4254
3838
|
} else {
|
|
4255
|
-
setModifiedData((prev) => ({ ...prev, filter: operator, value: "" }));
|
|
3839
|
+
setModifiedData((prev) => ({ ...prev, filter: operator.toString(), value: "" }));
|
|
4256
3840
|
}
|
|
4257
3841
|
};
|
|
4258
3842
|
const handleSubmit = (e) => {
|
|
@@ -4272,7 +3856,9 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4272
3856
|
let filterToAdd2;
|
|
4273
3857
|
if (modifiedData.filter === "$contains") {
|
|
4274
3858
|
hasCurrentFilter = alreadyAppliedFilters.find((filter) => {
|
|
4275
|
-
|
|
3859
|
+
if (typeof filter.mime?.$not !== "string" && !Array.isArray(filter.mime?.$not)) {
|
|
3860
|
+
return filter.mime?.$not?.$contains !== void 0;
|
|
3861
|
+
}
|
|
4276
3862
|
}) !== void 0;
|
|
4277
3863
|
filterToAdd2 = {
|
|
4278
3864
|
mime: {
|
|
@@ -4301,7 +3887,8 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4301
3887
|
return;
|
|
4302
3888
|
}
|
|
4303
3889
|
const hasFilter2 = alreadyAppliedFilters.find((filter) => {
|
|
4304
|
-
|
|
3890
|
+
const modifiedDataFilter = modifiedData.filter;
|
|
3891
|
+
return filter.mime && filter.mime[modifiedDataFilter] === modifiedData.value;
|
|
4305
3892
|
}) !== void 0;
|
|
4306
3893
|
if (hasFilter2) {
|
|
4307
3894
|
onToggle();
|
|
@@ -4312,7 +3899,7 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4312
3899
|
if (filterType !== "mime") {
|
|
4313
3900
|
return true;
|
|
4314
3901
|
}
|
|
4315
|
-
if (filter.mime?.$not?.$contains !== void 0) {
|
|
3902
|
+
if (typeof filter.mime?.$not !== "string" && !Array.isArray(filter.mime?.$not) && filter.mime?.$not?.$contains !== void 0) {
|
|
4316
3903
|
return false;
|
|
4317
3904
|
}
|
|
4318
3905
|
if (Array.isArray(filter?.mime?.$contains)) {
|
|
@@ -4325,7 +3912,7 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4325
3912
|
return filter.mime?.[oppositeFilter] === modifiedData.value;
|
|
4326
3913
|
});
|
|
4327
3914
|
const hasOppositeFilter = oppositeFilterIndex !== -1;
|
|
4328
|
-
|
|
3915
|
+
const filterToAdd = { [modifiedData.name]: { [modifiedData.filter]: modifiedData.value } };
|
|
4329
3916
|
if (!hasOppositeFilter) {
|
|
4330
3917
|
const nextFilters = [...filtersWithoutFile, filterToAdd];
|
|
4331
3918
|
onSubmit(nextFilters);
|
|
@@ -4341,10 +3928,11 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4341
3928
|
return;
|
|
4342
3929
|
}
|
|
4343
3930
|
const hasFilter = filters.find((filter) => {
|
|
4344
|
-
|
|
3931
|
+
const modifiedDataName = modifiedData.name;
|
|
3932
|
+
return filter[modifiedDataName] && filter[modifiedDataName]?.[modifiedDataName] === encodedValue;
|
|
4345
3933
|
}) !== void 0;
|
|
4346
3934
|
if (!hasFilter) {
|
|
4347
|
-
|
|
3935
|
+
const filterToAdd = { [modifiedData.name]: { [modifiedData.filter]: encodedValue } };
|
|
4348
3936
|
const nextFilters = [...filters, filterToAdd];
|
|
4349
3937
|
onSubmit(nextFilters);
|
|
4350
3938
|
}
|
|
@@ -4365,7 +3953,7 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4365
3953
|
onChange: handleChangeFilterField,
|
|
4366
3954
|
value: modifiedData.name,
|
|
4367
3955
|
children: displayedFilters2.map((filter) => {
|
|
4368
|
-
return /* @__PURE__ */ jsx(SingleSelectOption, { value: filter.name, children: filter.metadatas
|
|
3956
|
+
return /* @__PURE__ */ jsx(SingleSelectOption, { value: filter.name, children: filter.metadatas?.label }, filter.name);
|
|
4369
3957
|
})
|
|
4370
3958
|
}
|
|
4371
3959
|
) }),
|
|
@@ -4388,8 +3976,8 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4388
3976
|
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
4389
3977
|
FilterValueInput,
|
|
4390
3978
|
{
|
|
4391
|
-
...appliedFilter
|
|
4392
|
-
...appliedFilter
|
|
3979
|
+
...appliedFilter?.metadatas,
|
|
3980
|
+
...appliedFilter?.fieldSchema,
|
|
4393
3981
|
value: modifiedData.value,
|
|
4394
3982
|
onChange: (value) => setModifiedData((prev) => ({ ...prev, value }))
|
|
4395
3983
|
}
|
|
@@ -4397,18 +3985,6 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4397
3985
|
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Button, { size: "L", variant: "secondary", startIcon: /* @__PURE__ */ jsx(Plus, {}), type: "submit", fullWidth: true, children: formatMessage({ id: "app.utils.add-filter", defaultMessage: "Add filter" }) }) })
|
|
4398
3986
|
] }) }) });
|
|
4399
3987
|
};
|
|
4400
|
-
FilterPopover.propTypes = {
|
|
4401
|
-
displayedFilters: PropTypes.arrayOf(
|
|
4402
|
-
PropTypes.shape({
|
|
4403
|
-
name: PropTypes.string.isRequired,
|
|
4404
|
-
metadatas: PropTypes.shape({ label: PropTypes.string }),
|
|
4405
|
-
fieldSchema: PropTypes.shape({ type: PropTypes.string })
|
|
4406
|
-
})
|
|
4407
|
-
).isRequired,
|
|
4408
|
-
filters: PropTypes.array.isRequired,
|
|
4409
|
-
onSubmit: PropTypes.func.isRequired,
|
|
4410
|
-
onToggle: PropTypes.func.isRequired
|
|
4411
|
-
};
|
|
4412
3988
|
const Filters = ({ appliedFilters, onChangeFilters }) => {
|
|
4413
3989
|
const [open, setOpen] = React.useState(false);
|
|
4414
3990
|
const { formatMessage } = useIntl();
|
|
@@ -4417,7 +3993,7 @@ const Filters = ({ appliedFilters, onChangeFilters }) => {
|
|
|
4417
3993
|
/* @__PURE__ */ jsx(
|
|
4418
3994
|
FilterPopover,
|
|
4419
3995
|
{
|
|
4420
|
-
onToggle: setOpen,
|
|
3996
|
+
onToggle: () => setOpen((prev) => !prev),
|
|
4421
3997
|
displayedFilters,
|
|
4422
3998
|
filters: appliedFilters,
|
|
4423
3999
|
onSubmit: onChangeFilters
|
|
@@ -4433,14 +4009,10 @@ const Filters = ({ appliedFilters, onChangeFilters }) => {
|
|
|
4433
4009
|
)
|
|
4434
4010
|
] });
|
|
4435
4011
|
};
|
|
4436
|
-
Filters.propTypes = {
|
|
4437
|
-
appliedFilters: PropTypes.array.isRequired,
|
|
4438
|
-
onChangeFilters: PropTypes.func.isRequired
|
|
4439
|
-
};
|
|
4440
4012
|
const PageSize = ({ onChangePageSize, pageSize }) => {
|
|
4441
4013
|
const { formatMessage } = useIntl();
|
|
4442
4014
|
const handleChange = (value) => {
|
|
4443
|
-
onChangePageSize(value);
|
|
4015
|
+
onChangePageSize(Number(value));
|
|
4444
4016
|
};
|
|
4445
4017
|
return /* @__PURE__ */ jsxs(Flex, { children: [
|
|
4446
4018
|
/* @__PURE__ */ jsxs(
|
|
@@ -4467,16 +4039,21 @@ const PageSize = ({ onChangePageSize, pageSize }) => {
|
|
|
4467
4039
|
}) }) })
|
|
4468
4040
|
] });
|
|
4469
4041
|
};
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4042
|
+
const PaginationContext = React.createContext({ activePage: 1, pageCount: 1 });
|
|
4043
|
+
const usePagination = () => React.useContext(PaginationContext);
|
|
4044
|
+
const Pagination = ({
|
|
4045
|
+
children,
|
|
4046
|
+
activePage,
|
|
4047
|
+
pageCount,
|
|
4048
|
+
label = "pagination"
|
|
4049
|
+
}) => {
|
|
4050
|
+
const paginationValue = React.useMemo(() => ({ activePage, pageCount }), [activePage, pageCount]);
|
|
4051
|
+
return /* @__PURE__ */ jsx(PaginationContext.Provider, { value: paginationValue, children: /* @__PURE__ */ jsx(Box, { tag: "nav", "aria-label": label, children: /* @__PURE__ */ jsx(Flex, { tag: "ul", gap: 1, children }) }) });
|
|
4473
4052
|
};
|
|
4474
|
-
const PaginationContext = createContext({ activePage: 1, pageCount: 1 });
|
|
4475
|
-
const usePagination = () => useContext(PaginationContext);
|
|
4476
4053
|
const PaginationText = styled(Typography)`
|
|
4477
4054
|
line-height: revert;
|
|
4478
4055
|
`;
|
|
4479
|
-
const
|
|
4056
|
+
const linkWrapperStyles = css`
|
|
4480
4057
|
padding: ${({ theme }) => theme.spaces[3]};
|
|
4481
4058
|
border-radius: ${({ theme }) => theme.borderRadius};
|
|
4482
4059
|
box-shadow: ${({ $active, theme }) => $active ? theme.shadows.filterShadow : void 0};
|
|
@@ -4513,8 +4090,14 @@ const LinkWrapper = styled.button`
|
|
|
4513
4090
|
}
|
|
4514
4091
|
}
|
|
4515
4092
|
`;
|
|
4516
|
-
|
|
4517
|
-
|
|
4093
|
+
const LinkWrapperButton = styled.button`
|
|
4094
|
+
${linkWrapperStyles}
|
|
4095
|
+
`;
|
|
4096
|
+
const LinkWrapperDiv = styled.div`
|
|
4097
|
+
${linkWrapperStyles}
|
|
4098
|
+
`;
|
|
4099
|
+
LinkWrapperButton.defaultProps = { type: "button" };
|
|
4100
|
+
const PageLinkWrapper = styled(LinkWrapperButton)`
|
|
4518
4101
|
color: ${({ theme, $active }) => $active ? theme.colors.primary700 : theme.colors.neutral800};
|
|
4519
4102
|
background: ${({ theme, $active }) => $active ? theme.colors.neutral0 : void 0};
|
|
4520
4103
|
|
|
@@ -4522,7 +4105,7 @@ const PageLinkWrapper = styled(LinkWrapper)`
|
|
|
4522
4105
|
box-shadow: ${({ theme }) => theme.shadows.filterShadow};
|
|
4523
4106
|
}
|
|
4524
4107
|
`;
|
|
4525
|
-
const ActionLinkWrapper = styled(
|
|
4108
|
+
const ActionLinkWrapper = styled(LinkWrapperButton)`
|
|
4526
4109
|
font-size: 1.1rem;
|
|
4527
4110
|
svg path {
|
|
4528
4111
|
fill: ${(p) => p["aria-disabled"] ? p.theme.colors.neutral300 : p.theme.colors.neutral600};
|
|
@@ -4539,7 +4122,7 @@ const ActionLinkWrapper = styled(LinkWrapper)`
|
|
|
4539
4122
|
pointer-events: none;
|
|
4540
4123
|
` : void 0}
|
|
4541
4124
|
`;
|
|
4542
|
-
const DotsWrapper = styled(
|
|
4125
|
+
const DotsWrapper = styled(LinkWrapperDiv)`
|
|
4543
4126
|
color: ${({ theme }) => theme.colors.neutral800};
|
|
4544
4127
|
`;
|
|
4545
4128
|
const PreviousLink = ({ children, ...props }) => {
|
|
@@ -4566,36 +4149,15 @@ const PageLink = ({ number, children, ...props }) => {
|
|
|
4566
4149
|
/* @__PURE__ */ jsx(PaginationText, { "aria-hidden": true, variant: "pi", fontWeight: isActive ? "bold" : "", children: number })
|
|
4567
4150
|
] }) });
|
|
4568
4151
|
};
|
|
4569
|
-
const Dots = ({ children, ...props }) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(DotsWrapper, { ...props,
|
|
4152
|
+
const Dots = ({ children, ...props }) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(DotsWrapper, { ...props, as: "div", children: [
|
|
4570
4153
|
/* @__PURE__ */ jsx(VisuallyHidden, { children }),
|
|
4571
4154
|
/* @__PURE__ */ jsx(PaginationText, { "aria-hidden": true, small: true, children: "…" })
|
|
4572
4155
|
] }) });
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
}
|
|
4577
|
-
|
|
4578
|
-
children: PropTypes.node.isRequired
|
|
4579
|
-
};
|
|
4580
|
-
NextLink.propTypes = sharedPropTypes;
|
|
4581
|
-
PreviousLink.propTypes = sharedPropTypes;
|
|
4582
|
-
Dots.propTypes = {
|
|
4583
|
-
children: PropTypes.node.isRequired
|
|
4584
|
-
};
|
|
4585
|
-
const Pagination = ({ children, label, activePage, pageCount }) => {
|
|
4586
|
-
const paginationValue = useMemo(() => ({ activePage, pageCount }), [activePage, pageCount]);
|
|
4587
|
-
return /* @__PURE__ */ jsx(PaginationContext.Provider, { value: paginationValue, children: /* @__PURE__ */ jsx(Box, { tag: "nav", "aria-label": label, children: /* @__PURE__ */ jsx(Flex, { tag: "ul", gap: 1, children }) }) });
|
|
4588
|
-
};
|
|
4589
|
-
Pagination.defaultProps = {
|
|
4590
|
-
label: "pagination"
|
|
4591
|
-
};
|
|
4592
|
-
Pagination.propTypes = {
|
|
4593
|
-
activePage: PropTypes.number.isRequired,
|
|
4594
|
-
children: PropTypes.node.isRequired,
|
|
4595
|
-
label: PropTypes.string,
|
|
4596
|
-
pageCount: PropTypes.number.isRequired
|
|
4597
|
-
};
|
|
4598
|
-
const PaginationFooter = ({ activePage, onChangePage, pagination: { pageCount } }) => {
|
|
4156
|
+
const PaginationFooter = ({
|
|
4157
|
+
activePage,
|
|
4158
|
+
onChangePage,
|
|
4159
|
+
pagination: { pageCount }
|
|
4160
|
+
}) => {
|
|
4599
4161
|
const { formatMessage } = useIntl();
|
|
4600
4162
|
const previousActivePage = activePage - 1;
|
|
4601
4163
|
const nextActivePage = activePage + 1;
|
|
@@ -4635,7 +4197,7 @@ const PaginationFooter = ({ activePage, onChangePage, pagination: { pageCount }
|
|
|
4635
4197
|
] });
|
|
4636
4198
|
}
|
|
4637
4199
|
let firstLinksToCreate = [];
|
|
4638
|
-
|
|
4200
|
+
const lastLinks = [];
|
|
4639
4201
|
let lastLinksToCreate = [];
|
|
4640
4202
|
const middleLinks = [];
|
|
4641
4203
|
if (pageCount > 1) {
|
|
@@ -4732,21 +4294,16 @@ const PaginationFooter = ({ activePage, onChangePage, pagination: { pageCount }
|
|
|
4732
4294
|
}) })
|
|
4733
4295
|
] });
|
|
4734
4296
|
};
|
|
4735
|
-
|
|
4736
|
-
activePage: PropTypes.number.isRequired,
|
|
4737
|
-
onChangePage: PropTypes.func.isRequired,
|
|
4738
|
-
pagination: PropTypes.shape({ pageCount: PropTypes.number.isRequired }).isRequired
|
|
4739
|
-
};
|
|
4740
|
-
const SearchAsset = ({ onChangeSearch, queryValue }) => {
|
|
4297
|
+
const SearchAsset = ({ onChangeSearch, queryValue = null }) => {
|
|
4741
4298
|
const { formatMessage } = useIntl();
|
|
4742
4299
|
const { trackUsage } = useTracking();
|
|
4743
|
-
const [isOpen, setIsOpen] = useState(!!queryValue);
|
|
4744
|
-
const [value, setValue] = useState(queryValue || "");
|
|
4745
|
-
const wrapperRef = useRef(null);
|
|
4746
|
-
useLayoutEffect(() => {
|
|
4300
|
+
const [isOpen, setIsOpen] = React.useState(!!queryValue);
|
|
4301
|
+
const [value, setValue] = React.useState(queryValue || "");
|
|
4302
|
+
const wrapperRef = React.useRef(null);
|
|
4303
|
+
React.useLayoutEffect(() => {
|
|
4747
4304
|
if (isOpen) {
|
|
4748
4305
|
setTimeout(() => {
|
|
4749
|
-
wrapperRef.current
|
|
4306
|
+
wrapperRef.current?.querySelector("input")?.focus();
|
|
4750
4307
|
}, 0);
|
|
4751
4308
|
}
|
|
4752
4309
|
}, [isOpen]);
|
|
@@ -4774,6 +4331,7 @@ const SearchAsset = ({ onChangeSearch, queryValue }) => {
|
|
|
4774
4331
|
id: getTrad("search.clear.label"),
|
|
4775
4332
|
defaultMessage: "Clear the search"
|
|
4776
4333
|
}),
|
|
4334
|
+
"aria-label": "search",
|
|
4777
4335
|
size: "S",
|
|
4778
4336
|
value,
|
|
4779
4337
|
placeholder: formatMessage({
|
|
@@ -4786,13 +4344,6 @@ const SearchAsset = ({ onChangeSearch, queryValue }) => {
|
|
|
4786
4344
|
}
|
|
4787
4345
|
return /* @__PURE__ */ jsx(IconButton, { label: "Search", onClick: handleToggle, children: /* @__PURE__ */ jsx(Search, {}) });
|
|
4788
4346
|
};
|
|
4789
|
-
SearchAsset.defaultProps = {
|
|
4790
|
-
queryValue: null
|
|
4791
|
-
};
|
|
4792
|
-
SearchAsset.propTypes = {
|
|
4793
|
-
onChangeSearch: PropTypes.func.isRequired,
|
|
4794
|
-
queryValue: PropTypes.string
|
|
4795
|
-
};
|
|
4796
4347
|
const isSelectable = (allowedTypes, mime = "") => {
|
|
4797
4348
|
if (!mime)
|
|
4798
4349
|
return false;
|
|
@@ -4810,12 +4361,12 @@ const ActionContainer = styled(Box)`
|
|
|
4810
4361
|
}
|
|
4811
4362
|
`;
|
|
4812
4363
|
const BrowseStep = ({
|
|
4813
|
-
allowedTypes,
|
|
4364
|
+
allowedTypes = [],
|
|
4814
4365
|
assets: rawAssets,
|
|
4815
4366
|
canCreate,
|
|
4816
4367
|
canRead,
|
|
4817
|
-
folders,
|
|
4818
|
-
multiple,
|
|
4368
|
+
folders = [],
|
|
4369
|
+
multiple = false,
|
|
4819
4370
|
onAddAsset,
|
|
4820
4371
|
onChangeFilters,
|
|
4821
4372
|
onChangePage,
|
|
@@ -4846,7 +4397,7 @@ const BrowseStep = ({
|
|
|
4846
4397
|
isSelectable: isSelectable(singularTypes, asset?.mime),
|
|
4847
4398
|
type: "asset"
|
|
4848
4399
|
}));
|
|
4849
|
-
const breadcrumbs = !isCurrentFolderLoading
|
|
4400
|
+
const breadcrumbs = !isCurrentFolderLoading ? getBreadcrumbDataCM(currentFolder) : void 0;
|
|
4850
4401
|
const allAllowedAsset = getAllowedFiles(allowedTypes, assets);
|
|
4851
4402
|
const areAllAssetSelected = allAllowedAsset.length > 0 && selectedAssets.length > 0 && allAllowedAsset.every(
|
|
4852
4403
|
(asset) => selectedAssets.findIndex((currAsset) => currAsset.id === asset.id) !== -1
|
|
@@ -4855,7 +4406,7 @@ const BrowseStep = ({
|
|
|
4855
4406
|
(asset) => selectedAssets.findIndex((currAsset) => currAsset.id === asset.id) !== -1
|
|
4856
4407
|
);
|
|
4857
4408
|
const isSearching = !!queryObject?._q;
|
|
4858
|
-
const isFiltering = queryObject?.filters?.$and?.length > 0;
|
|
4409
|
+
const isFiltering = !!queryObject?.filters?.$and?.length && queryObject.filters.$and.length > 0;
|
|
4859
4410
|
const isSearchingOrFiltering = isSearching || isFiltering;
|
|
4860
4411
|
const assetCount = assets.length;
|
|
4861
4412
|
const folderCount = folders.length;
|
|
@@ -4915,11 +4466,10 @@ const BrowseStep = ({
|
|
|
4915
4466
|
/* @__PURE__ */ jsx(SearchAsset, { onChangeSearch, queryValue: queryObject._q || "" })
|
|
4916
4467
|
] })
|
|
4917
4468
|
] }) }),
|
|
4918
|
-
canRead && breadcrumbs?.length > 0 && currentFolder && /* @__PURE__ */ jsx(Box, { paddingTop: 3, children: /* @__PURE__ */ jsx(
|
|
4469
|
+
canRead && breadcrumbs?.length && breadcrumbs.length > 0 && currentFolder && /* @__PURE__ */ jsx(Box, { paddingTop: 3, children: /* @__PURE__ */ jsx(
|
|
4919
4470
|
Breadcrumbs,
|
|
4920
4471
|
{
|
|
4921
4472
|
onChangeFolder,
|
|
4922
|
-
tag: "nav",
|
|
4923
4473
|
label: formatMessage({
|
|
4924
4474
|
id: getTrad("header.breadcrumbs.nav.label"),
|
|
4925
4475
|
defaultMessage: "Folders navigation"
|
|
@@ -5038,8 +4588,8 @@ const BrowseStep = ({
|
|
|
5038
4588
|
defaultMessage: "{folderCount, plural, =0 {# folder} one {# folder} other {# folders}}, {filesCount, plural, =0 {# asset} one {# asset} other {# assets}}"
|
|
5039
4589
|
},
|
|
5040
4590
|
{
|
|
5041
|
-
folderCount: folder.children
|
|
5042
|
-
filesCount: folder.files
|
|
4591
|
+
folderCount: folder.children?.count,
|
|
4592
|
+
filesCount: folder.files?.count
|
|
5043
4593
|
}
|
|
5044
4594
|
)
|
|
5045
4595
|
}
|
|
@@ -5076,7 +4626,13 @@ const BrowseStep = ({
|
|
|
5076
4626
|
) })
|
|
5077
4627
|
] }),
|
|
5078
4628
|
pagination.pageCount > 0 && /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", paddingTop: 4, children: [
|
|
5079
|
-
/* @__PURE__ */ jsx(
|
|
4629
|
+
/* @__PURE__ */ jsx(
|
|
4630
|
+
PageSize,
|
|
4631
|
+
{
|
|
4632
|
+
pageSize: queryObject.pageSize,
|
|
4633
|
+
onChangePageSize
|
|
4634
|
+
}
|
|
4635
|
+
),
|
|
5080
4636
|
/* @__PURE__ */ jsx(
|
|
5081
4637
|
PaginationFooter,
|
|
5082
4638
|
{
|
|
@@ -5088,41 +4644,6 @@ const BrowseStep = ({
|
|
|
5088
4644
|
] })
|
|
5089
4645
|
] });
|
|
5090
4646
|
};
|
|
5091
|
-
BrowseStep.defaultProps = {
|
|
5092
|
-
allowedTypes: [],
|
|
5093
|
-
folders: [],
|
|
5094
|
-
multiple: false,
|
|
5095
|
-
onSelectAllAsset: void 0
|
|
5096
|
-
};
|
|
5097
|
-
BrowseStep.propTypes = {
|
|
5098
|
-
allowedTypes: PropTypes.arrayOf(PropTypes.string),
|
|
5099
|
-
assets: PropTypes.arrayOf(AssetDefinition).isRequired,
|
|
5100
|
-
canCreate: PropTypes.bool.isRequired,
|
|
5101
|
-
canRead: PropTypes.bool.isRequired,
|
|
5102
|
-
folders: PropTypes.arrayOf(FolderDefinition),
|
|
5103
|
-
multiple: PropTypes.bool,
|
|
5104
|
-
onAddAsset: PropTypes.func.isRequired,
|
|
5105
|
-
onChangeFilters: PropTypes.func.isRequired,
|
|
5106
|
-
onChangeFolder: PropTypes.func.isRequired,
|
|
5107
|
-
onChangePage: PropTypes.func.isRequired,
|
|
5108
|
-
onChangePageSize: PropTypes.func.isRequired,
|
|
5109
|
-
onChangeSort: PropTypes.func.isRequired,
|
|
5110
|
-
onChangeSearch: PropTypes.func.isRequired,
|
|
5111
|
-
onEditAsset: PropTypes.func.isRequired,
|
|
5112
|
-
onEditFolder: PropTypes.func.isRequired,
|
|
5113
|
-
onSelectAsset: PropTypes.func.isRequired,
|
|
5114
|
-
onSelectAllAsset: PropTypes.func,
|
|
5115
|
-
queryObject: PropTypes.shape({
|
|
5116
|
-
filters: PropTypes.object,
|
|
5117
|
-
page: PropTypes.number.isRequired,
|
|
5118
|
-
pageSize: PropTypes.number.isRequired,
|
|
5119
|
-
_q: PropTypes.string,
|
|
5120
|
-
sort: PropTypes.string,
|
|
5121
|
-
folder: PropTypes.number
|
|
5122
|
-
}).isRequired,
|
|
5123
|
-
pagination: PropTypes.shape({ pageCount: PropTypes.number.isRequired }).isRequired,
|
|
5124
|
-
selectedAssets: PropTypes.arrayOf(PropTypes.shape({})).isRequired
|
|
5125
|
-
};
|
|
5126
4647
|
const DialogFooter = ({ onClose, onValidate }) => {
|
|
5127
4648
|
const { formatMessage } = useIntl();
|
|
5128
4649
|
return /* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
|
@@ -5130,17 +4651,14 @@ const DialogFooter = ({ onClose, onValidate }) => {
|
|
|
5130
4651
|
onValidate && /* @__PURE__ */ jsx(Button, { onClick: onValidate, children: formatMessage({ id: "global.finish", defaultMessage: "Finish" }) })
|
|
5131
4652
|
] });
|
|
5132
4653
|
};
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
onValidate: PropTypes.func
|
|
5139
|
-
};
|
|
5140
|
-
const SelectedStep = ({ selectedAssets, onSelectAsset, onReorderAsset }) => {
|
|
4654
|
+
const SelectedStep = ({
|
|
4655
|
+
selectedAssets,
|
|
4656
|
+
onSelectAsset,
|
|
4657
|
+
onReorderAsset
|
|
4658
|
+
}) => {
|
|
5141
4659
|
const { formatMessage } = useIntl();
|
|
5142
4660
|
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
|
|
5143
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 0, children: [
|
|
4661
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 0, direction: "column", alignItems: "start", children: [
|
|
5144
4662
|
/* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral800", children: formatMessage(
|
|
5145
4663
|
{
|
|
5146
4664
|
id: getTrad("list.assets.to-upload"),
|
|
@@ -5165,32 +4683,24 @@ const SelectedStep = ({ selectedAssets, onSelectAsset, onReorderAsset }) => {
|
|
|
5165
4683
|
)
|
|
5166
4684
|
] });
|
|
5167
4685
|
};
|
|
5168
|
-
SelectedStep.defaultProps = {
|
|
5169
|
-
onReorderAsset: void 0
|
|
5170
|
-
};
|
|
5171
|
-
SelectedStep.propTypes = {
|
|
5172
|
-
onSelectAsset: PropTypes.func.isRequired,
|
|
5173
|
-
selectedAssets: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
|
|
5174
|
-
onReorderAsset: PropTypes.func
|
|
5175
|
-
};
|
|
5176
4686
|
const LoadingBody = styled(Flex)`
|
|
5177
4687
|
/* 80px are coming from the Tabs component that is not included in the ModalBody */
|
|
5178
4688
|
min-height: ${() => `calc(60vh + 8rem)`};
|
|
5179
4689
|
`;
|
|
5180
4690
|
const AssetContent = ({
|
|
5181
|
-
allowedTypes,
|
|
5182
|
-
folderId,
|
|
4691
|
+
allowedTypes = [],
|
|
4692
|
+
folderId = null,
|
|
5183
4693
|
onClose,
|
|
5184
4694
|
onAddAsset,
|
|
5185
4695
|
onAddFolder,
|
|
5186
4696
|
onChangeFolder,
|
|
5187
4697
|
onValidate,
|
|
5188
|
-
multiple,
|
|
5189
|
-
initiallySelectedAssets,
|
|
4698
|
+
multiple = false,
|
|
4699
|
+
initiallySelectedAssets = [],
|
|
5190
4700
|
trackedLocation
|
|
5191
4701
|
}) => {
|
|
5192
|
-
const [assetToEdit, setAssetToEdit] = useState(void 0);
|
|
5193
|
-
const [folderToEdit, setFolderToEdit] = useState(void 0);
|
|
4702
|
+
const [assetToEdit, setAssetToEdit] = React.useState(void 0);
|
|
4703
|
+
const [folderToEdit, setFolderToEdit] = React.useState(void 0);
|
|
5194
4704
|
const { formatMessage } = useIntl();
|
|
5195
4705
|
const {
|
|
5196
4706
|
canRead,
|
|
@@ -5312,7 +4822,9 @@ const AssetContent = ({
|
|
|
5312
4822
|
};
|
|
5313
4823
|
const handleFolderChange = (folderId2, folderPath) => {
|
|
5314
4824
|
onChangeFolder(folderId2);
|
|
5315
|
-
onChangeFolderParam
|
|
4825
|
+
if (onChangeFolderParam) {
|
|
4826
|
+
onChangeFolderParam(folderId2, folderPath);
|
|
4827
|
+
}
|
|
5316
4828
|
};
|
|
5317
4829
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5318
4830
|
/* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: formatMessage({
|
|
@@ -5371,11 +4883,11 @@ const AssetContent = ({
|
|
|
5371
4883
|
pagination,
|
|
5372
4884
|
queryObject,
|
|
5373
4885
|
onAddAsset,
|
|
5374
|
-
onChangeFilters,
|
|
4886
|
+
onChangeFilters: (filters) => onChangeFilters(filters),
|
|
5375
4887
|
onChangeFolder: handleFolderChange,
|
|
5376
4888
|
onChangePage,
|
|
5377
4889
|
onChangePageSize,
|
|
5378
|
-
onChangeSort,
|
|
4890
|
+
onChangeSort: (sort) => onChangeSort(sort),
|
|
5379
4891
|
onChangeSearch
|
|
5380
4892
|
}
|
|
5381
4893
|
) }),
|
|
@@ -5392,49 +4904,9 @@ const AssetContent = ({
|
|
|
5392
4904
|
/* @__PURE__ */ jsx(DialogFooter, { onClose, onValidate: () => onValidate(selectedAssets) })
|
|
5393
4905
|
] });
|
|
5394
4906
|
};
|
|
5395
|
-
|
|
5396
|
-
allowedTypes: [],
|
|
5397
|
-
folderId: null,
|
|
5398
|
-
initiallySelectedAssets: [],
|
|
5399
|
-
multiple: false,
|
|
5400
|
-
trackedLocation: void 0
|
|
5401
|
-
};
|
|
5402
|
-
AssetContent.propTypes = {
|
|
5403
|
-
allowedTypes: PropTypes.arrayOf(PropTypes.string),
|
|
5404
|
-
folderId: PropTypes.number,
|
|
5405
|
-
initiallySelectedAssets: PropTypes.arrayOf(AssetDefinition),
|
|
5406
|
-
multiple: PropTypes.bool,
|
|
5407
|
-
onAddAsset: PropTypes.func.isRequired,
|
|
5408
|
-
onAddFolder: PropTypes.func.isRequired,
|
|
5409
|
-
onChangeFolder: PropTypes.func.isRequired,
|
|
5410
|
-
onClose: PropTypes.func.isRequired,
|
|
5411
|
-
onValidate: PropTypes.func.isRequired,
|
|
5412
|
-
trackedLocation: PropTypes.string
|
|
5413
|
-
};
|
|
5414
|
-
const AssetDialog = ({ open, onClose, ...restProps }) => {
|
|
4907
|
+
const AssetDialog = ({ open = false, onClose, ...restProps }) => {
|
|
5415
4908
|
return /* @__PURE__ */ jsx(Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsx(Modal.Content, { children: /* @__PURE__ */ jsx(AssetContent, { onClose, ...restProps }) }) });
|
|
5416
4909
|
};
|
|
5417
|
-
AssetDialog.defaultProps = {
|
|
5418
|
-
allowedTypes: [],
|
|
5419
|
-
folderId: null,
|
|
5420
|
-
initiallySelectedAssets: [],
|
|
5421
|
-
multiple: false,
|
|
5422
|
-
open: false,
|
|
5423
|
-
trackedLocation: void 0
|
|
5424
|
-
};
|
|
5425
|
-
AssetDialog.propTypes = {
|
|
5426
|
-
allowedTypes: PropTypes.arrayOf(PropTypes.string),
|
|
5427
|
-
folderId: PropTypes.number,
|
|
5428
|
-
initiallySelectedAssets: PropTypes.arrayOf(AssetDefinition),
|
|
5429
|
-
multiple: PropTypes.bool,
|
|
5430
|
-
onAddAsset: PropTypes.func.isRequired,
|
|
5431
|
-
onAddFolder: PropTypes.func.isRequired,
|
|
5432
|
-
onChangeFolder: PropTypes.func.isRequired,
|
|
5433
|
-
open: PropTypes.bool,
|
|
5434
|
-
onClose: PropTypes.func.isRequired,
|
|
5435
|
-
onValidate: PropTypes.func.isRequired,
|
|
5436
|
-
trackedLocation: PropTypes.string
|
|
5437
|
-
};
|
|
5438
4910
|
const TabsRoot = styled(Tabs.Root)`
|
|
5439
4911
|
display: flex;
|
|
5440
4912
|
flex-direction: column;
|
|
@@ -5457,10 +4929,14 @@ const OpaqueBox = styled(Box)`
|
|
|
5457
4929
|
opacity: 0;
|
|
5458
4930
|
cursor: pointer;
|
|
5459
4931
|
`;
|
|
5460
|
-
const FromComputerForm = ({
|
|
4932
|
+
const FromComputerForm = ({
|
|
4933
|
+
onClose,
|
|
4934
|
+
onAddAssets,
|
|
4935
|
+
trackedLocation
|
|
4936
|
+
}) => {
|
|
5461
4937
|
const { formatMessage } = useIntl();
|
|
5462
|
-
const [dragOver, setDragOver] = useState(false);
|
|
5463
|
-
const inputRef = useRef(null);
|
|
4938
|
+
const [dragOver, setDragOver] = React.useState(false);
|
|
4939
|
+
const inputRef = React.useRef(null);
|
|
5464
4940
|
const { trackUsage } = useTracking();
|
|
5465
4941
|
const handleDragOver = (event) => {
|
|
5466
4942
|
event.preventDefault();
|
|
@@ -5472,15 +4948,19 @@ const FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => {
|
|
|
5472
4948
|
const handleDragLeave = () => setDragOver(false);
|
|
5473
4949
|
const handleClick = (e) => {
|
|
5474
4950
|
e.preventDefault();
|
|
5475
|
-
inputRef.current
|
|
4951
|
+
inputRef.current?.click();
|
|
5476
4952
|
};
|
|
5477
4953
|
const handleChange = () => {
|
|
5478
|
-
const files2 = inputRef.current
|
|
4954
|
+
const files2 = inputRef.current?.files;
|
|
5479
4955
|
const assets = [];
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
4956
|
+
if (files2) {
|
|
4957
|
+
for (let i = 0; i < files2.length; i++) {
|
|
4958
|
+
const file = files2.item(i);
|
|
4959
|
+
if (file) {
|
|
4960
|
+
const asset = rawFileToAsset(file, AssetSource.Computer);
|
|
4961
|
+
assets.push(asset);
|
|
4962
|
+
}
|
|
4963
|
+
}
|
|
5484
4964
|
}
|
|
5485
4965
|
if (trackedLocation) {
|
|
5486
4966
|
trackUsage("didSelectFile", { source: "computer", location: trackedLocation });
|
|
@@ -5494,8 +4974,10 @@ const FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => {
|
|
|
5494
4974
|
const assets = [];
|
|
5495
4975
|
for (let i = 0; i < files2.length; i++) {
|
|
5496
4976
|
const file = files2.item(i);
|
|
5497
|
-
|
|
5498
|
-
|
|
4977
|
+
if (file) {
|
|
4978
|
+
const asset = rawFileToAsset(file, AssetSource.Computer);
|
|
4979
|
+
assets.push(asset);
|
|
4980
|
+
}
|
|
5499
4981
|
}
|
|
5500
4982
|
onAddAssets(assets);
|
|
5501
4983
|
}
|
|
@@ -5535,6 +5017,10 @@ const FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => {
|
|
|
5535
5017
|
type: "file",
|
|
5536
5018
|
multiple: true,
|
|
5537
5019
|
name: "files",
|
|
5020
|
+
"aria-label": formatMessage({
|
|
5021
|
+
id: getTrad("input.label"),
|
|
5022
|
+
defaultMessage: "Drag & Drop here or"
|
|
5023
|
+
}),
|
|
5538
5024
|
tabIndex: -1,
|
|
5539
5025
|
ref: inputRef,
|
|
5540
5026
|
zIndex: 1,
|
|
@@ -5554,17 +5040,9 @@ const FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => {
|
|
|
5554
5040
|
}) }) })
|
|
5555
5041
|
] });
|
|
5556
5042
|
};
|
|
5557
|
-
FromComputerForm.defaultProps = {
|
|
5558
|
-
trackedLocation: void 0
|
|
5559
|
-
};
|
|
5560
|
-
FromComputerForm.propTypes = {
|
|
5561
|
-
onClose: PropTypes.func.isRequired,
|
|
5562
|
-
onAddAssets: PropTypes.func.isRequired,
|
|
5563
|
-
trackedLocation: PropTypes.string
|
|
5564
|
-
};
|
|
5565
5043
|
const FromUrlForm = ({ onClose, onAddAsset, trackedLocation }) => {
|
|
5566
|
-
const [loading, setLoading] = useState(false);
|
|
5567
|
-
const [error, setError] = useState(void 0);
|
|
5044
|
+
const [loading, setLoading] = React.useState(false);
|
|
5045
|
+
const [error, setError] = React.useState(void 0);
|
|
5568
5046
|
const { formatMessage } = useIntl();
|
|
5569
5047
|
const { trackUsage } = useTracking();
|
|
5570
5048
|
const handleSubmit = async ({ urls }) => {
|
|
@@ -5619,14 +5097,6 @@ const FromUrlForm = ({ onClose, onAddAsset, trackedLocation }) => {
|
|
|
5619
5097
|
}
|
|
5620
5098
|
);
|
|
5621
5099
|
};
|
|
5622
|
-
FromUrlForm.defaultProps = {
|
|
5623
|
-
trackedLocation: void 0
|
|
5624
|
-
};
|
|
5625
|
-
FromUrlForm.propTypes = {
|
|
5626
|
-
onClose: PropTypes.func.isRequired,
|
|
5627
|
-
onAddAsset: PropTypes.func.isRequired,
|
|
5628
|
-
trackedLocation: PropTypes.string
|
|
5629
|
-
};
|
|
5630
5100
|
const AddAssetStep = ({ onClose, onAddAsset, trackedLocation }) => {
|
|
5631
5101
|
const { formatMessage } = useIntl();
|
|
5632
5102
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -5676,14 +5146,6 @@ const AddAssetStep = ({ onClose, onAddAsset, trackedLocation }) => {
|
|
|
5676
5146
|
] })
|
|
5677
5147
|
] });
|
|
5678
5148
|
};
|
|
5679
|
-
AddAssetStep.defaultProps = {
|
|
5680
|
-
trackedLocation: void 0
|
|
5681
|
-
};
|
|
5682
|
-
AddAssetStep.propTypes = {
|
|
5683
|
-
onClose: PropTypes.func.isRequired,
|
|
5684
|
-
onAddAsset: PropTypes.func.isRequired,
|
|
5685
|
-
trackedLocation: PropTypes.string
|
|
5686
|
-
};
|
|
5687
5149
|
const UploadProgressWrapper = styled.div`
|
|
5688
5150
|
height: 8.8rem;
|
|
5689
5151
|
width: 100%;
|
|
@@ -5696,7 +5158,7 @@ const UploadingAssetCard = ({
|
|
|
5696
5158
|
onCancel,
|
|
5697
5159
|
onStatusChange,
|
|
5698
5160
|
addUploadedFiles,
|
|
5699
|
-
folderId
|
|
5161
|
+
folderId = null
|
|
5700
5162
|
}) => {
|
|
5701
5163
|
const { upload, cancel, error, progress, status } = useUpload();
|
|
5702
5164
|
const { formatMessage } = useIntl();
|
|
@@ -5720,16 +5182,16 @@ const UploadingAssetCard = ({
|
|
|
5720
5182
|
defaultMessage: "Audio"
|
|
5721
5183
|
});
|
|
5722
5184
|
}
|
|
5723
|
-
useEffect(() => {
|
|
5185
|
+
React.useEffect(() => {
|
|
5724
5186
|
const uploadFile = async () => {
|
|
5725
|
-
const files2 = await upload(asset, folderId);
|
|
5187
|
+
const files2 = await upload(asset, folderId ? Number(folderId) : null);
|
|
5726
5188
|
if (addUploadedFiles) {
|
|
5727
5189
|
addUploadedFiles(files2);
|
|
5728
5190
|
}
|
|
5729
5191
|
};
|
|
5730
5192
|
uploadFile();
|
|
5731
5193
|
}, []);
|
|
5732
|
-
useEffect(() => {
|
|
5194
|
+
React.useEffect(() => {
|
|
5733
5195
|
onStatusChange(status);
|
|
5734
5196
|
}, [status, onStatusChange]);
|
|
5735
5197
|
const handleCancel = () => {
|
|
@@ -5738,19 +5200,26 @@ const UploadingAssetCard = ({
|
|
|
5738
5200
|
};
|
|
5739
5201
|
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
|
5740
5202
|
/* @__PURE__ */ jsxs(Card$1, { borderColor: error ? "danger600" : "neutral150", children: [
|
|
5741
|
-
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(UploadProgressWrapper, { children: /* @__PURE__ */ jsx(
|
|
5203
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(UploadProgressWrapper, { children: /* @__PURE__ */ jsx(
|
|
5204
|
+
UploadProgress,
|
|
5205
|
+
{
|
|
5206
|
+
error: error || void 0,
|
|
5207
|
+
onCancel: handleCancel,
|
|
5208
|
+
progress
|
|
5209
|
+
}
|
|
5210
|
+
) }) }),
|
|
5742
5211
|
/* @__PURE__ */ jsxs(CardBody, { children: [
|
|
5743
5212
|
/* @__PURE__ */ jsxs(CardContent, { children: [
|
|
5744
|
-
/* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(
|
|
5213
|
+
/* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(Typography, { tag: "h2", children: /* @__PURE__ */ jsx(CardTitle, { tag: "span", children: asset.name }) }) }),
|
|
5745
5214
|
/* @__PURE__ */ jsx(CardSubtitle, { children: /* @__PURE__ */ jsx(Extension, { children: asset.ext }) })
|
|
5746
5215
|
] }),
|
|
5747
5216
|
/* @__PURE__ */ jsx(Flex, { paddingTop: 1, grow: 1, children: /* @__PURE__ */ jsx(CardBadge, { children: badgeContent }) })
|
|
5748
5217
|
] })
|
|
5749
5218
|
] }),
|
|
5750
5219
|
error ? /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "danger600", children: formatMessage(
|
|
5751
|
-
error?.
|
|
5752
|
-
id: getTrad(`apiError.${error.
|
|
5753
|
-
defaultMessage: error.
|
|
5220
|
+
error?.message ? {
|
|
5221
|
+
id: getTrad(`apiError.${error.message}`),
|
|
5222
|
+
defaultMessage: error.message
|
|
5754
5223
|
/* See issue: https://github.com/strapi/strapi/issues/13867
|
|
5755
5224
|
A proxy might return an error, before the request reaches Strapi
|
|
5756
5225
|
and therefore we need to handle errors gracefully.
|
|
@@ -5762,22 +5231,6 @@ const UploadingAssetCard = ({
|
|
|
5762
5231
|
) }) : void 0
|
|
5763
5232
|
] });
|
|
5764
5233
|
};
|
|
5765
|
-
UploadingAssetCard.defaultProps = {
|
|
5766
|
-
addUploadedFiles: void 0,
|
|
5767
|
-
folderId: null
|
|
5768
|
-
};
|
|
5769
|
-
UploadingAssetCard.propTypes = {
|
|
5770
|
-
addUploadedFiles: PropTypes.func,
|
|
5771
|
-
asset: PropTypes.shape({
|
|
5772
|
-
name: PropTypes.string,
|
|
5773
|
-
ext: PropTypes.string,
|
|
5774
|
-
rawFile: PropTypes.instanceOf(File),
|
|
5775
|
-
type: PropTypes.oneOf(Object.values(AssetType))
|
|
5776
|
-
}).isRequired,
|
|
5777
|
-
folderId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
5778
|
-
onCancel: PropTypes.func.isRequired,
|
|
5779
|
-
onStatusChange: PropTypes.func.isRequired
|
|
5780
|
-
};
|
|
5781
5234
|
const Status = {
|
|
5782
5235
|
Idle: "IDLE",
|
|
5783
5236
|
Uploading: "UPLOADING",
|
|
@@ -5795,21 +5248,28 @@ const PendingAssetStep = ({
|
|
|
5795
5248
|
onUploadSucceed,
|
|
5796
5249
|
trackedLocation
|
|
5797
5250
|
}) => {
|
|
5798
|
-
const assetCountRef = useRef(0);
|
|
5251
|
+
const assetCountRef = React.useRef(0);
|
|
5799
5252
|
const { formatMessage } = useIntl();
|
|
5800
5253
|
const { trackUsage } = useTracking();
|
|
5801
|
-
const [uploadStatus, setUploadStatus] = useState(Status.Idle);
|
|
5254
|
+
const [uploadStatus, setUploadStatus] = React.useState(Status.Idle);
|
|
5802
5255
|
const handleSubmit = async (e) => {
|
|
5803
5256
|
e.preventDefault();
|
|
5804
5257
|
e.stopPropagation();
|
|
5805
|
-
const assetsCountByType = assets.reduce(
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
acc[type]
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5258
|
+
const assetsCountByType = assets.reduce(
|
|
5259
|
+
(acc, asset) => {
|
|
5260
|
+
const { type } = asset;
|
|
5261
|
+
if (type !== void 0 && !acc[type]) {
|
|
5262
|
+
acc[type] = 0;
|
|
5263
|
+
}
|
|
5264
|
+
if (type !== void 0) {
|
|
5265
|
+
const accType = acc[type];
|
|
5266
|
+
const currentCount = typeof accType === "string" ? accType : accType.toString();
|
|
5267
|
+
acc[type] = `${parseInt(currentCount, 10) + 1}`;
|
|
5268
|
+
}
|
|
5269
|
+
return acc;
|
|
5270
|
+
},
|
|
5271
|
+
{}
|
|
5272
|
+
);
|
|
5813
5273
|
trackUsage("willAddMediaLibraryAssets", {
|
|
5814
5274
|
location: trackedLocation,
|
|
5815
5275
|
...assetsCountByType
|
|
@@ -5895,40 +5355,24 @@ const PendingAssetStep = ({
|
|
|
5895
5355
|
] })
|
|
5896
5356
|
] });
|
|
5897
5357
|
};
|
|
5898
|
-
PendingAssetStep.defaultProps = {
|
|
5899
|
-
addUploadedFiles: void 0,
|
|
5900
|
-
folderId: null,
|
|
5901
|
-
trackedLocation: void 0
|
|
5902
|
-
};
|
|
5903
|
-
PendingAssetStep.propTypes = {
|
|
5904
|
-
addUploadedFiles: PropTypes.func,
|
|
5905
|
-
assets: PropTypes.arrayOf(AssetDefinition).isRequired,
|
|
5906
|
-
folderId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
5907
|
-
onClose: PropTypes.func.isRequired,
|
|
5908
|
-
onEditAsset: PropTypes.func.isRequired,
|
|
5909
|
-
onRemoveAsset: PropTypes.func.isRequired,
|
|
5910
|
-
onClickAddAsset: PropTypes.func.isRequired,
|
|
5911
|
-
onUploadSucceed: PropTypes.func.isRequired,
|
|
5912
|
-
onCancelUpload: PropTypes.func.isRequired,
|
|
5913
|
-
trackedLocation: PropTypes.string
|
|
5914
|
-
};
|
|
5915
5358
|
const Steps = {
|
|
5916
5359
|
AddAsset: "AddAsset",
|
|
5917
5360
|
PendingAsset: "PendingAsset"
|
|
5918
5361
|
};
|
|
5919
5362
|
const UploadAssetDialog = ({
|
|
5920
5363
|
initialAssetsToAdd,
|
|
5921
|
-
folderId,
|
|
5922
|
-
onClose
|
|
5364
|
+
folderId = null,
|
|
5365
|
+
onClose = () => {
|
|
5366
|
+
},
|
|
5923
5367
|
addUploadedFiles,
|
|
5924
5368
|
trackedLocation,
|
|
5925
5369
|
open,
|
|
5926
5370
|
validateAssetsTypes = (_, cb) => cb()
|
|
5927
5371
|
}) => {
|
|
5928
5372
|
const { formatMessage } = useIntl();
|
|
5929
|
-
const [step, setStep] = useState(initialAssetsToAdd ? Steps.PendingAsset : Steps.AddAsset);
|
|
5930
|
-
const [assets, setAssets] = useState(initialAssetsToAdd || []);
|
|
5931
|
-
const [assetToEdit, setAssetToEdit] = useState(void 0);
|
|
5373
|
+
const [step, setStep] = React.useState(initialAssetsToAdd ? Steps.PendingAsset : Steps.AddAsset);
|
|
5374
|
+
const [assets, setAssets] = React.useState(initialAssetsToAdd || []);
|
|
5375
|
+
const [assetToEdit, setAssetToEdit] = React.useState(void 0);
|
|
5932
5376
|
const handleAddToPendingAssets = (nextAssets) => {
|
|
5933
5377
|
validateAssetsTypes(nextAssets, () => {
|
|
5934
5378
|
setAssets((prevAssets) => prevAssets.concat(nextAssets));
|
|
@@ -5953,7 +5397,7 @@ const UploadAssetDialog = ({
|
|
|
5953
5397
|
}
|
|
5954
5398
|
};
|
|
5955
5399
|
const handleAssetEditValidation = (nextAsset) => {
|
|
5956
|
-
if (nextAsset) {
|
|
5400
|
+
if (nextAsset && typeof nextAsset !== "boolean") {
|
|
5957
5401
|
const nextAssets = assets.map((asset) => asset === assetToEdit ? nextAsset : asset);
|
|
5958
5402
|
setAssets(nextAssets);
|
|
5959
5403
|
}
|
|
@@ -5983,7 +5427,7 @@ const UploadAssetDialog = ({
|
|
|
5983
5427
|
AddAssetStep,
|
|
5984
5428
|
{
|
|
5985
5429
|
onClose,
|
|
5986
|
-
onAddAsset: handleAddToPendingAssets,
|
|
5430
|
+
onAddAsset: (assets2) => handleAddToPendingAssets(assets2),
|
|
5987
5431
|
trackedLocation
|
|
5988
5432
|
}
|
|
5989
5433
|
) }),
|
|
@@ -6016,32 +5460,18 @@ const UploadAssetDialog = ({
|
|
|
6016
5460
|
) })
|
|
6017
5461
|
] });
|
|
6018
5462
|
};
|
|
6019
|
-
UploadAssetDialog.defaultProps = {
|
|
6020
|
-
addUploadedFiles: void 0,
|
|
6021
|
-
folderId: null,
|
|
6022
|
-
initialAssetsToAdd: void 0,
|
|
6023
|
-
onClose() {
|
|
6024
|
-
},
|
|
6025
|
-
trackedLocation: void 0,
|
|
6026
|
-
validateAssetsTypes: void 0
|
|
6027
|
-
};
|
|
6028
|
-
UploadAssetDialog.propTypes = {
|
|
6029
|
-
addUploadedFiles: PropTypes.func,
|
|
6030
|
-
folderId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
6031
|
-
initialAssetsToAdd: PropTypes.arrayOf(AssetDefinition),
|
|
6032
|
-
open: PropTypes.bool.isRequired,
|
|
6033
|
-
onClose: PropTypes.func,
|
|
6034
|
-
trackedLocation: PropTypes.string,
|
|
6035
|
-
validateAssetsTypes: PropTypes.func
|
|
6036
|
-
};
|
|
6037
5463
|
const STEPS$1 = {
|
|
6038
5464
|
AssetSelect: "SelectAsset",
|
|
6039
5465
|
AssetUpload: "UploadAsset",
|
|
6040
5466
|
FolderCreate: "FolderCreate"
|
|
6041
5467
|
};
|
|
6042
|
-
const MediaLibraryDialog = ({
|
|
6043
|
-
|
|
6044
|
-
|
|
5468
|
+
const MediaLibraryDialog = ({
|
|
5469
|
+
onClose,
|
|
5470
|
+
onSelectAssets,
|
|
5471
|
+
allowedTypes = ["files", "images", "videos", "audios"]
|
|
5472
|
+
}) => {
|
|
5473
|
+
const [step, setStep] = React.useState(STEPS$1.AssetSelect);
|
|
5474
|
+
const [folderId, setFolderId] = React.useState(null);
|
|
6045
5475
|
switch (step) {
|
|
6046
5476
|
case STEPS$1.AssetSelect:
|
|
6047
5477
|
return /* @__PURE__ */ jsx(
|
|
@@ -6071,14 +5501,6 @@ const MediaLibraryDialog = ({ onClose, onSelectAssets, allowedTypes }) => {
|
|
|
6071
5501
|
return /* @__PURE__ */ jsx(UploadAssetDialog, { open: true, onClose: () => setStep(STEPS$1.AssetSelect), folderId });
|
|
6072
5502
|
}
|
|
6073
5503
|
};
|
|
6074
|
-
MediaLibraryDialog.defaultProps = {
|
|
6075
|
-
allowedTypes: ["files", "images", "videos", "audios"]
|
|
6076
|
-
};
|
|
6077
|
-
MediaLibraryDialog.propTypes = {
|
|
6078
|
-
allowedTypes: PropTypes.arrayOf(PropTypes.string),
|
|
6079
|
-
onClose: PropTypes.func.isRequired,
|
|
6080
|
-
onSelectAssets: PropTypes.func.isRequired
|
|
6081
|
-
};
|
|
6082
5504
|
const DocAsset = styled(Flex)`
|
|
6083
5505
|
background: linear-gradient(180deg, #ffffff 0%, #f6f6f9 121.48%);
|
|
6084
5506
|
`;
|
|
@@ -6096,7 +5518,7 @@ const AudioPreviewWrapper = styled(Box)`
|
|
|
6096
5518
|
}
|
|
6097
5519
|
`;
|
|
6098
5520
|
const CarouselAsset = ({ asset }) => {
|
|
6099
|
-
if (asset.mime
|
|
5521
|
+
if (asset.mime?.includes(AssetType.Video)) {
|
|
6100
5522
|
return /* @__PURE__ */ jsx(VideoPreviewWrapper, { height: "100%", children: /* @__PURE__ */ jsx(
|
|
6101
5523
|
VideoPreview,
|
|
6102
5524
|
{
|
|
@@ -6106,10 +5528,16 @@ const CarouselAsset = ({ asset }) => {
|
|
|
6106
5528
|
}
|
|
6107
5529
|
) });
|
|
6108
5530
|
}
|
|
6109
|
-
if (asset.mime
|
|
6110
|
-
return /* @__PURE__ */ jsx(AudioPreviewWrapper, { children: /* @__PURE__ */ jsx(
|
|
5531
|
+
if (asset.mime?.includes(AssetType.Audio)) {
|
|
5532
|
+
return /* @__PURE__ */ jsx(AudioPreviewWrapper, { children: /* @__PURE__ */ jsx(
|
|
5533
|
+
AudioPreview,
|
|
5534
|
+
{
|
|
5535
|
+
url: createAssetUrl(asset, true),
|
|
5536
|
+
alt: asset.alternativeText || asset.name
|
|
5537
|
+
}
|
|
5538
|
+
) });
|
|
6111
5539
|
}
|
|
6112
|
-
if (asset.mime
|
|
5540
|
+
if (asset.mime?.includes(AssetType.Image)) {
|
|
6113
5541
|
return /* @__PURE__ */ jsx(
|
|
6114
5542
|
Box,
|
|
6115
5543
|
{
|
|
@@ -6121,12 +5549,14 @@ const CarouselAsset = ({ asset }) => {
|
|
|
6121
5549
|
}
|
|
6122
5550
|
);
|
|
6123
5551
|
}
|
|
6124
|
-
return /* @__PURE__ */ jsx(DocAsset, { width: "100%", height: "100%", justifyContent: "center", hasRadius: true, children: asset.ext
|
|
6125
|
-
};
|
|
6126
|
-
CarouselAsset.propTypes = {
|
|
6127
|
-
asset: AssetDefinition.isRequired
|
|
5552
|
+
return /* @__PURE__ */ jsx(DocAsset, { width: "100%", height: "100%", justifyContent: "center", hasRadius: true, children: asset.ext?.includes("pdf") ? /* @__PURE__ */ jsx(FilePdf, { "aria-label": asset.alternativeText || asset.name, width: "24px", height: "32px" }) : /* @__PURE__ */ jsx(File$1, { "aria-label": asset.alternativeText || asset.name, width: "24px", height: "32px" }) });
|
|
6128
5553
|
};
|
|
6129
|
-
const CarouselAssetActions = ({
|
|
5554
|
+
const CarouselAssetActions = ({
|
|
5555
|
+
asset,
|
|
5556
|
+
onDeleteAsset,
|
|
5557
|
+
onAddAsset,
|
|
5558
|
+
onEditAsset
|
|
5559
|
+
}) => {
|
|
6130
5560
|
const { formatMessage } = useIntl();
|
|
6131
5561
|
return /* @__PURE__ */ jsxs(CarouselActions, { children: [
|
|
6132
5562
|
onAddAsset && /* @__PURE__ */ jsx(
|
|
@@ -6165,23 +5595,16 @@ const CarouselAssetActions = ({ asset, onDeleteAsset, onAddAsset, onEditAsset })
|
|
|
6165
5595
|
)
|
|
6166
5596
|
] });
|
|
6167
5597
|
};
|
|
6168
|
-
CarouselAssetActions.defaultProps = {
|
|
6169
|
-
onAddAsset: void 0,
|
|
6170
|
-
onDeleteAsset: void 0,
|
|
6171
|
-
onEditAsset: void 0
|
|
6172
|
-
};
|
|
6173
|
-
CarouselAssetActions.propTypes = {
|
|
6174
|
-
asset: AssetDefinition.isRequired,
|
|
6175
|
-
onAddAsset: PropTypes.func,
|
|
6176
|
-
onEditAsset: PropTypes.func,
|
|
6177
|
-
onDeleteAsset: PropTypes.func
|
|
6178
|
-
};
|
|
6179
5598
|
const TextAlignTypography = styled(Typography)`
|
|
6180
5599
|
align-items: center;
|
|
6181
5600
|
`;
|
|
6182
|
-
const EmptyStateAsset = ({
|
|
5601
|
+
const EmptyStateAsset = ({
|
|
5602
|
+
disabled = false,
|
|
5603
|
+
onClick,
|
|
5604
|
+
onDropAsset
|
|
5605
|
+
}) => {
|
|
6183
5606
|
const { formatMessage } = useIntl();
|
|
6184
|
-
const [dragOver, setDragOver] = useState(false);
|
|
5607
|
+
const [dragOver, setDragOver] = React.useState(false);
|
|
6185
5608
|
const handleDragEnter = (e) => {
|
|
6186
5609
|
e.preventDefault();
|
|
6187
5610
|
setDragOver(true);
|
|
@@ -6201,8 +5624,10 @@ const EmptyStateAsset = ({ disabled, onClick, onDropAsset }) => {
|
|
|
6201
5624
|
const assets = [];
|
|
6202
5625
|
for (let i = 0; i < files2.length; i++) {
|
|
6203
5626
|
const file = files2.item(i);
|
|
6204
|
-
|
|
6205
|
-
|
|
5627
|
+
if (file) {
|
|
5628
|
+
const asset = rawFileToAsset(file, AssetSource.Computer);
|
|
5629
|
+
assets.push(asset);
|
|
5630
|
+
}
|
|
6206
5631
|
}
|
|
6207
5632
|
onDropAsset(assets);
|
|
6208
5633
|
}
|
|
@@ -6257,19 +5682,10 @@ const EmptyStateAsset = ({ disabled, onClick, onDropAsset }) => {
|
|
|
6257
5682
|
}
|
|
6258
5683
|
);
|
|
6259
5684
|
};
|
|
6260
|
-
|
|
6261
|
-
disabled: false,
|
|
6262
|
-
onDropAsset: void 0
|
|
6263
|
-
};
|
|
6264
|
-
EmptyStateAsset.propTypes = {
|
|
6265
|
-
disabled: PropTypes.bool,
|
|
6266
|
-
onClick: PropTypes.func.isRequired,
|
|
6267
|
-
onDropAsset: PropTypes.func
|
|
6268
|
-
};
|
|
6269
|
-
const CarouselAssets = forwardRef(
|
|
5685
|
+
const CarouselAssets = React.forwardRef(
|
|
6270
5686
|
({
|
|
6271
5687
|
assets,
|
|
6272
|
-
disabled,
|
|
5688
|
+
disabled = false,
|
|
6273
5689
|
error,
|
|
6274
5690
|
hint,
|
|
6275
5691
|
label,
|
|
@@ -6281,12 +5697,12 @@ const CarouselAssets = forwardRef(
|
|
|
6281
5697
|
onEditAsset,
|
|
6282
5698
|
onNext,
|
|
6283
5699
|
onPrevious,
|
|
6284
|
-
required,
|
|
5700
|
+
required = false,
|
|
6285
5701
|
selectedAssetIndex,
|
|
6286
5702
|
trackedLocation
|
|
6287
5703
|
}, forwardedRef) => {
|
|
6288
5704
|
const { formatMessage } = useIntl();
|
|
6289
|
-
const [isEditingAsset, setIsEditingAsset] = useState(false);
|
|
5705
|
+
const [isEditingAsset, setIsEditingAsset] = React.useState(false);
|
|
6290
5706
|
const currentAsset = assets[selectedAssetIndex];
|
|
6291
5707
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6292
5708
|
/* @__PURE__ */ jsx(
|
|
@@ -6329,9 +5745,16 @@ const CarouselAssets = forwardRef(
|
|
|
6329
5745
|
},
|
|
6330
5746
|
{ n: 1, m: 1 }
|
|
6331
5747
|
),
|
|
6332
|
-
children: /* @__PURE__ */ jsx(
|
|
5748
|
+
children: /* @__PURE__ */ jsx(
|
|
5749
|
+
EmptyStateAsset,
|
|
5750
|
+
{
|
|
5751
|
+
disabled,
|
|
5752
|
+
onClick: onAddAsset,
|
|
5753
|
+
onDropAsset
|
|
5754
|
+
}
|
|
5755
|
+
)
|
|
6333
5756
|
}
|
|
6334
|
-
) : assets.map((asset,
|
|
5757
|
+
) : assets.map((asset, index) => /* @__PURE__ */ jsx(
|
|
6335
5758
|
CarouselSlide,
|
|
6336
5759
|
{
|
|
6337
5760
|
label: formatMessage(
|
|
@@ -6339,7 +5762,7 @@ const CarouselAssets = forwardRef(
|
|
|
6339
5762
|
id: getTrad("mediaLibraryInput.slideCount"),
|
|
6340
5763
|
defaultMessage: "{n} of {m} slides"
|
|
6341
5764
|
},
|
|
6342
|
-
{ n:
|
|
5765
|
+
{ n: index + 1, m: assets.length }
|
|
6343
5766
|
),
|
|
6344
5767
|
children: /* @__PURE__ */ jsx(CarouselAsset, { asset })
|
|
6345
5768
|
},
|
|
@@ -6356,8 +5779,8 @@ const CarouselAssets = forwardRef(
|
|
|
6356
5779
|
if (editedAsset === null) {
|
|
6357
5780
|
onDeleteAssetFromMediaLibrary();
|
|
6358
5781
|
}
|
|
6359
|
-
if (editedAsset) {
|
|
6360
|
-
onEditAsset(editedAsset);
|
|
5782
|
+
if (editedAsset && typeof editedAsset !== "boolean") {
|
|
5783
|
+
onEditAsset?.(editedAsset);
|
|
6361
5784
|
}
|
|
6362
5785
|
},
|
|
6363
5786
|
asset: currentAsset,
|
|
@@ -6370,50 +5793,31 @@ const CarouselAssets = forwardRef(
|
|
|
6370
5793
|
] });
|
|
6371
5794
|
}
|
|
6372
5795
|
);
|
|
6373
|
-
CarouselAssets.defaultProps = {
|
|
6374
|
-
disabled: false,
|
|
6375
|
-
error: void 0,
|
|
6376
|
-
hint: void 0,
|
|
6377
|
-
labelAction: void 0,
|
|
6378
|
-
onDropAsset: void 0,
|
|
6379
|
-
required: false,
|
|
6380
|
-
trackedLocation: void 0
|
|
6381
|
-
};
|
|
6382
|
-
CarouselAssets.propTypes = {
|
|
6383
|
-
assets: PropTypes.arrayOf(AssetDefinition).isRequired,
|
|
6384
|
-
disabled: PropTypes.bool,
|
|
6385
|
-
error: PropTypes.string,
|
|
6386
|
-
hint: PropTypes.string,
|
|
6387
|
-
label: PropTypes.string.isRequired,
|
|
6388
|
-
labelAction: PropTypes.node,
|
|
6389
|
-
onAddAsset: PropTypes.func.isRequired,
|
|
6390
|
-
onDeleteAsset: PropTypes.func.isRequired,
|
|
6391
|
-
onDeleteAssetFromMediaLibrary: PropTypes.func.isRequired,
|
|
6392
|
-
onDropAsset: PropTypes.func,
|
|
6393
|
-
onEditAsset: PropTypes.func.isRequired,
|
|
6394
|
-
onNext: PropTypes.func.isRequired,
|
|
6395
|
-
onPrevious: PropTypes.func.isRequired,
|
|
6396
|
-
required: PropTypes.bool,
|
|
6397
|
-
selectedAssetIndex: PropTypes.number.isRequired,
|
|
6398
|
-
trackedLocation: PropTypes.string
|
|
6399
|
-
};
|
|
6400
5796
|
const STEPS = {
|
|
6401
5797
|
AssetSelect: "SelectAsset",
|
|
6402
5798
|
AssetUpload: "UploadAsset",
|
|
6403
5799
|
FolderCreate: "FolderCreate"
|
|
6404
5800
|
};
|
|
6405
|
-
const MediaLibraryInput = forwardRef(
|
|
6406
|
-
({
|
|
5801
|
+
const MediaLibraryInput = React.forwardRef(
|
|
5802
|
+
({
|
|
5803
|
+
attribute: { allowedTypes = ["videos", "files", "images", "audios"], multiple = false },
|
|
5804
|
+
label,
|
|
5805
|
+
hint,
|
|
5806
|
+
disabled = false,
|
|
5807
|
+
labelAction = void 0,
|
|
5808
|
+
name: name2,
|
|
5809
|
+
required = false
|
|
5810
|
+
}, forwardedRef) => {
|
|
6407
5811
|
const { formatMessage } = useIntl();
|
|
6408
5812
|
const { onChange, value, error } = useField(name2);
|
|
6409
5813
|
const fieldAllowedTypes = allowedTypes || ["files", "images", "videos", "audios"];
|
|
6410
|
-
const [uploadedFiles, setUploadedFiles] = useState([]);
|
|
6411
|
-
const [step, setStep] = useState(void 0);
|
|
6412
|
-
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
6413
|
-
const [droppedAssets, setDroppedAssets] = useState();
|
|
6414
|
-
const [folderId, setFolderId] = useState(null);
|
|
5814
|
+
const [uploadedFiles, setUploadedFiles] = React.useState([]);
|
|
5815
|
+
const [step, setStep] = React.useState(void 0);
|
|
5816
|
+
const [selectedIndex, setSelectedIndex] = React.useState(0);
|
|
5817
|
+
const [droppedAssets, setDroppedAssets] = React.useState();
|
|
5818
|
+
const [folderId, setFolderId] = React.useState(null);
|
|
6415
5819
|
const { toggleNotification } = useNotification();
|
|
6416
|
-
useEffect(() => {
|
|
5820
|
+
React.useEffect(() => {
|
|
6417
5821
|
if (step === void 0) {
|
|
6418
5822
|
setUploadedFiles([]);
|
|
6419
5823
|
}
|
|
@@ -6425,9 +5829,8 @@ const MediaLibraryInput = forwardRef(
|
|
|
6425
5829
|
selectedAssets = [value];
|
|
6426
5830
|
}
|
|
6427
5831
|
const handleValidation = (nextSelectedAssets) => {
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
});
|
|
5832
|
+
const value2 = multiple ? nextSelectedAssets : nextSelectedAssets[0];
|
|
5833
|
+
onChange(name2, value2);
|
|
6431
5834
|
setStep(void 0);
|
|
6432
5835
|
};
|
|
6433
5836
|
const handleDeleteAssetFromMediaLibrary = () => {
|
|
@@ -6440,9 +5843,8 @@ const MediaLibraryInput = forwardRef(
|
|
|
6440
5843
|
} else {
|
|
6441
5844
|
nextValue = null;
|
|
6442
5845
|
}
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
});
|
|
5846
|
+
const value2 = nextValue;
|
|
5847
|
+
onChange(name2, value2);
|
|
6446
5848
|
setSelectedIndex(0);
|
|
6447
5849
|
};
|
|
6448
5850
|
const handleDeleteAsset = (asset) => {
|
|
@@ -6453,18 +5855,14 @@ const MediaLibraryInput = forwardRef(
|
|
|
6453
5855
|
} else {
|
|
6454
5856
|
nextValue = null;
|
|
6455
5857
|
}
|
|
6456
|
-
onChange(
|
|
6457
|
-
target: { name: name2, value: nextValue }
|
|
6458
|
-
});
|
|
5858
|
+
onChange(name2, nextValue);
|
|
6459
5859
|
setSelectedIndex(0);
|
|
6460
5860
|
};
|
|
6461
5861
|
const handleAssetEdit = (asset) => {
|
|
6462
5862
|
const nextSelectedAssets = selectedAssets.map(
|
|
6463
5863
|
(prevAsset) => prevAsset.id === asset.id ? asset : prevAsset
|
|
6464
5864
|
);
|
|
6465
|
-
onChange(
|
|
6466
|
-
target: { name: name2, value: multiple ? nextSelectedAssets : nextSelectedAssets[0] }
|
|
6467
|
-
});
|
|
5865
|
+
onChange(name2, multiple ? nextSelectedAssets : nextSelectedAssets[0]);
|
|
6468
5866
|
};
|
|
6469
5867
|
const validateAssetsTypes = (assets, callback) => {
|
|
6470
5868
|
const allowedAssets = getAllowedFiles(fieldAllowedTypes, assets);
|
|
@@ -6506,7 +5904,10 @@ const MediaLibraryInput = forwardRef(
|
|
|
6506
5904
|
};
|
|
6507
5905
|
let initiallySelectedAssets = selectedAssets;
|
|
6508
5906
|
if (uploadedFiles.length > 0) {
|
|
6509
|
-
const allowedUploadedFiles = getAllowedFiles(
|
|
5907
|
+
const allowedUploadedFiles = getAllowedFiles(
|
|
5908
|
+
fieldAllowedTypes,
|
|
5909
|
+
uploadedFiles
|
|
5910
|
+
);
|
|
6510
5911
|
initiallySelectedAssets = multiple ? [...allowedUploadedFiles, ...selectedAssets] : [allowedUploadedFiles[0]];
|
|
6511
5912
|
}
|
|
6512
5913
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -6574,28 +5975,8 @@ const MediaLibraryInput = forwardRef(
|
|
|
6574
5975
|
] });
|
|
6575
5976
|
}
|
|
6576
5977
|
);
|
|
6577
|
-
MediaLibraryInput.defaultProps = {
|
|
6578
|
-
attribute: { allowedTypes: ["videos", "files", "images", "audios"], multiple: false },
|
|
6579
|
-
disabled: false,
|
|
6580
|
-
hint: void 0,
|
|
6581
|
-
label: void 0,
|
|
6582
|
-
labelAction: void 0,
|
|
6583
|
-
required: false
|
|
6584
|
-
};
|
|
6585
|
-
MediaLibraryInput.propTypes = {
|
|
6586
|
-
attribute: PropTypes.shape({
|
|
6587
|
-
allowedTypes: PropTypes.arrayOf(PropTypes.string),
|
|
6588
|
-
multiple: PropTypes.bool
|
|
6589
|
-
}),
|
|
6590
|
-
disabled: PropTypes.bool,
|
|
6591
|
-
hint: PropTypes.string,
|
|
6592
|
-
label: PropTypes.string,
|
|
6593
|
-
labelAction: PropTypes.node,
|
|
6594
|
-
name: PropTypes.string.isRequired,
|
|
6595
|
-
required: PropTypes.bool
|
|
6596
|
-
};
|
|
6597
5978
|
const name = pluginPkg.strapi.name;
|
|
6598
|
-
const
|
|
5979
|
+
const admin = {
|
|
6599
5980
|
register(app) {
|
|
6600
5981
|
app.addMenuLink({
|
|
6601
5982
|
to: `plugins/${pluginId}`,
|
|
@@ -6605,21 +5986,32 @@ const index = {
|
|
|
6605
5986
|
defaultMessage: "Media Library"
|
|
6606
5987
|
},
|
|
6607
5988
|
permissions: PERMISSIONS.main,
|
|
6608
|
-
Component: () => import("./
|
|
5989
|
+
Component: () => import("./App-D1ayH-QS.mjs").then((mod) => ({ default: mod.Upload })),
|
|
6609
5990
|
position: 4
|
|
6610
5991
|
});
|
|
6611
5992
|
app.addSettingsLink("global", {
|
|
6612
5993
|
id: "media-library-settings",
|
|
5994
|
+
to: "media-library",
|
|
6613
5995
|
intlLabel: {
|
|
6614
5996
|
id: getTrad("plugin.name"),
|
|
6615
5997
|
defaultMessage: "Media Library"
|
|
6616
5998
|
},
|
|
6617
|
-
|
|
6618
|
-
|
|
5999
|
+
async Component() {
|
|
6000
|
+
const { ProtectedSettingsPage } = await import("./SettingsPage-BYC3ism8.mjs");
|
|
6001
|
+
return { default: ProtectedSettingsPage };
|
|
6002
|
+
},
|
|
6619
6003
|
permissions: PERMISSIONS.settings
|
|
6620
6004
|
});
|
|
6621
|
-
app.addFields({
|
|
6622
|
-
|
|
6005
|
+
app.addFields({
|
|
6006
|
+
type: "media",
|
|
6007
|
+
Component: MediaLibraryInput
|
|
6008
|
+
});
|
|
6009
|
+
app.addComponents([
|
|
6010
|
+
{
|
|
6011
|
+
name: "media-library",
|
|
6012
|
+
Component: MediaLibraryDialog
|
|
6013
|
+
}
|
|
6014
|
+
]);
|
|
6623
6015
|
app.registerPlugin({
|
|
6624
6016
|
id: pluginId,
|
|
6625
6017
|
name
|
|
@@ -6645,16 +6037,13 @@ const index = {
|
|
|
6645
6037
|
}
|
|
6646
6038
|
};
|
|
6647
6039
|
export {
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6040
|
+
AssetGridList as A,
|
|
6041
|
+
Breadcrumbs as B,
|
|
6042
|
+
pageSizes as C,
|
|
6043
|
+
sortOptions as D,
|
|
6652
6044
|
EmptyAssets as E,
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
pageSizes as H,
|
|
6656
|
-
sortOptions as I,
|
|
6657
|
-
index as J,
|
|
6045
|
+
FilterPopover as F,
|
|
6046
|
+
admin as G,
|
|
6658
6047
|
PERMISSIONS as P,
|
|
6659
6048
|
SelectTree as S,
|
|
6660
6049
|
TableList as T,
|
|
@@ -6662,28 +6051,28 @@ export {
|
|
|
6662
6051
|
getFolderURL as a,
|
|
6663
6052
|
useBulkRemove as b,
|
|
6664
6053
|
useFolderStructure as c,
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6054
|
+
displayedFilters as d,
|
|
6055
|
+
FilterList as e,
|
|
6056
|
+
useMediaLibraryPermissions as f,
|
|
6668
6057
|
getTrad as g,
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6058
|
+
usePersistentState as h,
|
|
6059
|
+
useAssets as i,
|
|
6060
|
+
useFolders as j,
|
|
6061
|
+
containsAssetFilter as k,
|
|
6673
6062
|
localStorageKeys as l,
|
|
6674
|
-
|
|
6063
|
+
useFolder as m,
|
|
6675
6064
|
normalizeAPIError as n,
|
|
6676
|
-
|
|
6065
|
+
useSelectionState as o,
|
|
6677
6066
|
pluginId as p,
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6067
|
+
SortPicker as q,
|
|
6068
|
+
FolderGridList as r,
|
|
6069
|
+
FolderCard as s,
|
|
6070
|
+
FolderCardBody as t,
|
|
6682
6071
|
useFolderCard as u,
|
|
6683
6072
|
viewOptions as v,
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6073
|
+
FolderCardBodyAction as w,
|
|
6074
|
+
EditFolderDialog as x,
|
|
6075
|
+
EditAssetDialog as y,
|
|
6076
|
+
useConfig as z
|
|
6688
6077
|
};
|
|
6689
|
-
//# sourceMappingURL=index-
|
|
6078
|
+
//# sourceMappingURL=index-Clesg6BA.mjs.map
|