@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
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
const icons = require("@strapi/icons");
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const React = require("react");
|
|
5
|
-
const PropTypes = require("prop-types");
|
|
6
5
|
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
|
7
6
|
const designSystem = require("@strapi/design-system");
|
|
8
7
|
const reactIntl = require("react-intl");
|
|
9
8
|
const styledComponents = require("styled-components");
|
|
9
|
+
const reactQuery = require("react-query");
|
|
10
|
+
const qs = require("qs");
|
|
10
11
|
const byteSize = require("byte-size");
|
|
11
12
|
const dateFns = require("date-fns");
|
|
12
|
-
const qs = require("qs");
|
|
13
13
|
const yup = require("yup");
|
|
14
|
-
const reactQuery = require("react-query");
|
|
15
14
|
const formik = require("formik");
|
|
16
15
|
const isEqual = require("lodash/isEqual");
|
|
17
16
|
const ReactSelect = require("react-select");
|
|
@@ -42,7 +41,6 @@ function _interopNamespace(e) {
|
|
|
42
41
|
return Object.freeze(n);
|
|
43
42
|
}
|
|
44
43
|
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
|
45
|
-
const PropTypes__default = /* @__PURE__ */ _interopDefault(PropTypes);
|
|
46
44
|
const byteSize__default = /* @__PURE__ */ _interopDefault(byteSize);
|
|
47
45
|
const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
|
48
46
|
const isEqual__default = /* @__PURE__ */ _interopDefault(isEqual);
|
|
@@ -60,7 +58,7 @@ const __variableDynamicImportRuntimeHelper = (glob, path) => {
|
|
|
60
58
|
});
|
|
61
59
|
};
|
|
62
60
|
const name$1 = "@strapi/upload";
|
|
63
|
-
const version = "5.
|
|
61
|
+
const version = "5.4.0";
|
|
64
62
|
const description = "Makes it easy to upload images and files to your Strapi Application.";
|
|
65
63
|
const license = "SEE LICENSE IN LICENSE";
|
|
66
64
|
const author = {
|
|
@@ -78,7 +76,7 @@ const maintainers = [
|
|
|
78
76
|
const exports$1 = {
|
|
79
77
|
"./strapi-admin": {
|
|
80
78
|
types: "./dist/admin/src/index.d.ts",
|
|
81
|
-
source: "./admin/src/index.
|
|
79
|
+
source: "./admin/src/index.ts",
|
|
82
80
|
"import": "./dist/admin/index.mjs",
|
|
83
81
|
require: "./dist/admin/index.js",
|
|
84
82
|
"default": "./dist/admin/index.js"
|
|
@@ -116,10 +114,10 @@ const scripts = {
|
|
|
116
114
|
watch: "pack-up watch"
|
|
117
115
|
};
|
|
118
116
|
const dependencies = {
|
|
119
|
-
"@strapi/design-system": "2.0.0-rc.
|
|
120
|
-
"@strapi/icons": "2.0.0-rc.
|
|
121
|
-
"@strapi/provider-upload-local": "
|
|
122
|
-
"@strapi/utils": "
|
|
117
|
+
"@strapi/design-system": "2.0.0-rc.12",
|
|
118
|
+
"@strapi/icons": "2.0.0-rc.12",
|
|
119
|
+
"@strapi/provider-upload-local": "5.4.0",
|
|
120
|
+
"@strapi/utils": "5.4.0",
|
|
123
121
|
"byte-size": "8.1.1",
|
|
124
122
|
cropperjs: "1.6.1",
|
|
125
123
|
"date-fns": "2.30.0",
|
|
@@ -141,9 +139,9 @@ const dependencies = {
|
|
|
141
139
|
yup: "0.32.9"
|
|
142
140
|
};
|
|
143
141
|
const devDependencies = {
|
|
144
|
-
"@strapi/admin": "
|
|
142
|
+
"@strapi/admin": "5.4.0",
|
|
145
143
|
"@strapi/pack-up": "5.0.0",
|
|
146
|
-
"@strapi/types": "
|
|
144
|
+
"@strapi/types": "5.4.0",
|
|
147
145
|
"@testing-library/dom": "10.1.0",
|
|
148
146
|
"@testing-library/react": "15.0.7",
|
|
149
147
|
"@testing-library/user-event": "14.5.2",
|
|
@@ -162,7 +160,7 @@ const devDependencies = {
|
|
|
162
160
|
"styled-components": "6.1.8"
|
|
163
161
|
};
|
|
164
162
|
const peerDependencies = {
|
|
165
|
-
"@strapi/admin": "^5.0.0
|
|
163
|
+
"@strapi/admin": "^5.0.0",
|
|
166
164
|
react: "^17.0.0 || ^18.0.0",
|
|
167
165
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
168
166
|
"react-router-dom": "^6.0.0",
|
|
@@ -179,6 +177,7 @@ const strapi = {
|
|
|
179
177
|
required: true,
|
|
180
178
|
kind: "plugin"
|
|
181
179
|
};
|
|
180
|
+
const gitHead = "7d785703f52464577d077c4618cbe68b44f8a9cd";
|
|
182
181
|
const pluginPkg = {
|
|
183
182
|
name: name$1,
|
|
184
183
|
version,
|
|
@@ -193,7 +192,150 @@ const pluginPkg = {
|
|
|
193
192
|
devDependencies,
|
|
194
193
|
peerDependencies,
|
|
195
194
|
engines,
|
|
196
|
-
strapi
|
|
195
|
+
strapi,
|
|
196
|
+
gitHead
|
|
197
|
+
};
|
|
198
|
+
const pluginId = pluginPkg.name.replace(/^@strapi\//i, "");
|
|
199
|
+
const useAssets = ({ skipWhen = false, query = {} } = {}) => {
|
|
200
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
201
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
|
202
|
+
const { notifyStatus } = designSystem.useNotifyAT();
|
|
203
|
+
const { get } = strapiAdmin.useFetchClient();
|
|
204
|
+
const { folderPath, _q, ...paramsExceptFolderAndQ } = query;
|
|
205
|
+
let params;
|
|
206
|
+
if (_q) {
|
|
207
|
+
params = {
|
|
208
|
+
...paramsExceptFolderAndQ,
|
|
209
|
+
_q: encodeURIComponent(_q)
|
|
210
|
+
};
|
|
211
|
+
} else {
|
|
212
|
+
params = {
|
|
213
|
+
...paramsExceptFolderAndQ,
|
|
214
|
+
filters: {
|
|
215
|
+
$and: [
|
|
216
|
+
...paramsExceptFolderAndQ?.filters?.$and ?? [],
|
|
217
|
+
{
|
|
218
|
+
folderPath: { $eq: folderPath ?? "/" }
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
const { data, error, isLoading } = reactQuery.useQuery(
|
|
225
|
+
[pluginId, "assets", params],
|
|
226
|
+
async () => {
|
|
227
|
+
const { data: data2 } = await get("/upload/files", { params });
|
|
228
|
+
return data2;
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
enabled: !skipWhen,
|
|
232
|
+
staleTime: 0,
|
|
233
|
+
cacheTime: 0,
|
|
234
|
+
select(data2) {
|
|
235
|
+
if (data2?.results && Array.isArray(data2.results)) {
|
|
236
|
+
return {
|
|
237
|
+
...data2,
|
|
238
|
+
results: data2.results.filter((asset) => asset.name).map((asset) => ({
|
|
239
|
+
...asset,
|
|
240
|
+
/**
|
|
241
|
+
* Mime and ext cannot be null in the front-end because
|
|
242
|
+
* we expect them to be strings and use the `includes` method.
|
|
243
|
+
*/
|
|
244
|
+
mime: asset.mime ?? "",
|
|
245
|
+
ext: asset.ext ?? ""
|
|
246
|
+
}))
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return data2;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
React__namespace.useEffect(() => {
|
|
254
|
+
if (data) {
|
|
255
|
+
notifyStatus(
|
|
256
|
+
formatMessage({
|
|
257
|
+
id: "list.asset.at.finished",
|
|
258
|
+
defaultMessage: "The assets have finished loading."
|
|
259
|
+
})
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
}, [data, formatMessage, notifyStatus]);
|
|
263
|
+
React__namespace.useEffect(() => {
|
|
264
|
+
if (error) {
|
|
265
|
+
toggleNotification({
|
|
266
|
+
type: "danger",
|
|
267
|
+
message: formatMessage({ id: "notification.error" })
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}, [error, formatMessage, toggleNotification]);
|
|
271
|
+
return { data, error, isLoading };
|
|
272
|
+
};
|
|
273
|
+
const useFolders = ({ enabled = true, query = {} } = {}) => {
|
|
274
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
275
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
|
276
|
+
const { notifyStatus } = designSystem.useNotifyAT();
|
|
277
|
+
const { folder, _q, ...paramsExceptFolderAndQ } = query;
|
|
278
|
+
const { get } = strapiAdmin.useFetchClient();
|
|
279
|
+
let params;
|
|
280
|
+
if (_q) {
|
|
281
|
+
params = {
|
|
282
|
+
...paramsExceptFolderAndQ,
|
|
283
|
+
pagination: {
|
|
284
|
+
pageSize: -1
|
|
285
|
+
},
|
|
286
|
+
_q
|
|
287
|
+
};
|
|
288
|
+
} else {
|
|
289
|
+
params = {
|
|
290
|
+
...paramsExceptFolderAndQ,
|
|
291
|
+
pagination: {
|
|
292
|
+
pageSize: -1
|
|
293
|
+
},
|
|
294
|
+
filters: {
|
|
295
|
+
$and: [
|
|
296
|
+
...paramsExceptFolderAndQ?.filters?.$and ?? [],
|
|
297
|
+
{
|
|
298
|
+
parent: {
|
|
299
|
+
id: folder ?? {
|
|
300
|
+
$null: true
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
]
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
const { data, error, isLoading } = reactQuery.useQuery(
|
|
309
|
+
[pluginId, "folders", qs.stringify(params)],
|
|
310
|
+
async () => {
|
|
311
|
+
const {
|
|
312
|
+
data: { data: data2 }
|
|
313
|
+
} = await get("/upload/folders", { params });
|
|
314
|
+
return data2;
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
enabled,
|
|
318
|
+
staleTime: 0,
|
|
319
|
+
cacheTime: 0,
|
|
320
|
+
onError() {
|
|
321
|
+
toggleNotification({
|
|
322
|
+
type: "danger",
|
|
323
|
+
message: formatMessage({ id: "notification.error" })
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
React__namespace.useEffect(() => {
|
|
329
|
+
if (data) {
|
|
330
|
+
notifyStatus(
|
|
331
|
+
formatMessage({
|
|
332
|
+
id: "list.asset.at.finished",
|
|
333
|
+
defaultMessage: "The folders have finished loading."
|
|
334
|
+
})
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
}, [data, formatMessage, notifyStatus]);
|
|
338
|
+
return { data, error, isLoading };
|
|
197
339
|
};
|
|
198
340
|
const appendSearchParamsToUrl = ({ url, params }) => {
|
|
199
341
|
if (url === void 0 || typeof params !== "object") {
|
|
@@ -364,10 +506,9 @@ function getAPIInnerErrors(error, { getTrad: getTrad2 }) {
|
|
|
364
506
|
}
|
|
365
507
|
return normalizedError?.defaultMessage;
|
|
366
508
|
}
|
|
367
|
-
const
|
|
368
|
-
const getTrad = (id2) => `${pluginId}.${id2}`;
|
|
509
|
+
const getTrad = (id) => `${pluginId}.${id}`;
|
|
369
510
|
const getBreadcrumbDataCM = (folder) => {
|
|
370
|
-
|
|
511
|
+
const data = [
|
|
371
512
|
{
|
|
372
513
|
id: null,
|
|
373
514
|
label: { id: getTrad("plugin.name"), defaultMessage: "Media Library" }
|
|
@@ -419,7 +560,7 @@ const getFolderParents = (folders, currentFolderId) => {
|
|
|
419
560
|
}
|
|
420
561
|
let { parent } = currentFolder;
|
|
421
562
|
while (parent !== void 0) {
|
|
422
|
-
|
|
563
|
+
const parentToStore = flatFolders.find(({ value }) => value === parent);
|
|
423
564
|
parents.push({ id: parentToStore?.value, label: parentToStore?.label });
|
|
424
565
|
parent = parentToStore?.parent;
|
|
425
566
|
}
|
|
@@ -432,9 +573,9 @@ const move = (array, oldIndex, newIndex) => {
|
|
|
432
573
|
array.splice(newIndex, 0, array.splice(oldIndex, 1)[0]);
|
|
433
574
|
return array;
|
|
434
575
|
};
|
|
435
|
-
const moveElement = (array,
|
|
436
|
-
const newIndex =
|
|
437
|
-
return move(array,
|
|
576
|
+
const moveElement = (array, index, offset) => {
|
|
577
|
+
const newIndex = index + offset;
|
|
578
|
+
return move(array, index, newIndex);
|
|
438
579
|
};
|
|
439
580
|
const prefixPluginTranslations = (trad, pluginId2) => {
|
|
440
581
|
if (!pluginId2) {
|
|
@@ -445,68 +586,17 @@ const prefixPluginTranslations = (trad, pluginId2) => {
|
|
|
445
586
|
return acc;
|
|
446
587
|
}, {});
|
|
447
588
|
};
|
|
448
|
-
var AssetType$1 = /* @__PURE__ */ ((AssetType2) => {
|
|
449
|
-
AssetType2["Video"] = "video";
|
|
450
|
-
AssetType2["Image"] = "image";
|
|
451
|
-
AssetType2["Document"] = "doc";
|
|
452
|
-
AssetType2["Audio"] = "audio";
|
|
453
|
-
return AssetType2;
|
|
454
|
-
})(AssetType$1 || {});
|
|
455
|
-
var AssetSource$1 = /* @__PURE__ */ ((AssetSource2) => {
|
|
456
|
-
AssetSource2["Url"] = "url";
|
|
457
|
-
AssetSource2["Computer"] = "computer";
|
|
458
|
-
return AssetSource2;
|
|
459
|
-
})(AssetSource$1 || {});
|
|
460
|
-
const PERMISSIONS$1 = {
|
|
461
|
-
// This permission regards the main component (App) and is used to tell
|
|
462
|
-
// If the plugin link should be displayed in the menu
|
|
463
|
-
// And also if the plugin is accessible. This use case is found when a user types the url of the
|
|
464
|
-
// plugin directly in the browser
|
|
465
|
-
main: [
|
|
466
|
-
{ action: "plugin::upload.read", subject: null },
|
|
467
|
-
{
|
|
468
|
-
action: "plugin::upload.assets.create",
|
|
469
|
-
subject: null
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
action: "plugin::upload.assets.update",
|
|
473
|
-
subject: null
|
|
474
|
-
}
|
|
475
|
-
],
|
|
476
|
-
copyLink: [
|
|
477
|
-
{
|
|
478
|
-
action: "plugin::upload.assets.copy-link",
|
|
479
|
-
subject: null
|
|
480
|
-
}
|
|
481
|
-
],
|
|
482
|
-
create: [
|
|
483
|
-
{
|
|
484
|
-
action: "plugin::upload.assets.create",
|
|
485
|
-
subject: null
|
|
486
|
-
}
|
|
487
|
-
],
|
|
488
|
-
download: [
|
|
489
|
-
{
|
|
490
|
-
action: "plugin::upload.assets.download",
|
|
491
|
-
subject: null
|
|
492
|
-
}
|
|
493
|
-
],
|
|
494
|
-
read: [{ action: "plugin::upload.read", subject: null }],
|
|
495
|
-
configureView: [{ action: "plugin::upload.configure-view", subject: null }],
|
|
496
|
-
settings: [{ action: "plugin::upload.settings.read", subject: null }],
|
|
497
|
-
update: [{ action: "plugin::upload.assets.update", subject: null, fields: null }]
|
|
498
|
-
};
|
|
499
589
|
const typeFromMime = (mime) => {
|
|
500
|
-
if (mime.includes(AssetType
|
|
501
|
-
return AssetType
|
|
590
|
+
if (mime.includes(AssetType.Image)) {
|
|
591
|
+
return AssetType.Image;
|
|
502
592
|
}
|
|
503
|
-
if (mime.includes(AssetType
|
|
504
|
-
return AssetType
|
|
593
|
+
if (mime.includes(AssetType.Video)) {
|
|
594
|
+
return AssetType.Video;
|
|
505
595
|
}
|
|
506
|
-
if (mime.includes(AssetType
|
|
507
|
-
return AssetType
|
|
596
|
+
if (mime.includes(AssetType.Audio)) {
|
|
597
|
+
return AssetType.Audio;
|
|
508
598
|
}
|
|
509
|
-
return AssetType
|
|
599
|
+
return AssetType.Document;
|
|
510
600
|
};
|
|
511
601
|
const rawFileToAsset = (rawFile, assetSource) => {
|
|
512
602
|
return {
|
|
@@ -542,12 +632,12 @@ const urlsToAssets = async (urls) => {
|
|
|
542
632
|
);
|
|
543
633
|
const assetsResults = await Promise.all(assetPromises);
|
|
544
634
|
const assets = assetsResults.map((fullFilledAsset) => ({
|
|
545
|
-
source: AssetSource
|
|
635
|
+
source: AssetSource.Url,
|
|
546
636
|
name: fullFilledAsset.name,
|
|
547
637
|
type: typeFromMime(fullFilledAsset.mime),
|
|
548
638
|
url: fullFilledAsset.url,
|
|
549
639
|
ext: fullFilledAsset.url.split(".").pop(),
|
|
550
|
-
mime: fullFilledAsset.mime,
|
|
640
|
+
mime: fullFilledAsset.mime ? fullFilledAsset.mime : void 0,
|
|
551
641
|
rawFile: fullFilledAsset.rawFile
|
|
552
642
|
}));
|
|
553
643
|
return assets;
|
|
@@ -592,342 +682,131 @@ const urlSchema = yup__namespace.object().shape({
|
|
|
592
682
|
}
|
|
593
683
|
})
|
|
594
684
|
});
|
|
595
|
-
|
|
596
|
-
Video
|
|
597
|
-
Image
|
|
598
|
-
Document
|
|
599
|
-
Audio
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
createdAt: PropTypes__default.default.string.isRequired,
|
|
608
|
-
name: PropTypes__default.default.string.isRequired,
|
|
609
|
-
updatedAt: PropTypes__default.default.string.isRequired,
|
|
610
|
-
pathId: PropTypes__default.default.number.isRequired,
|
|
611
|
-
path: PropTypes__default.default.string.isRequired
|
|
612
|
-
};
|
|
613
|
-
ParentFolderShape.parent = PropTypes__default.default.shape(ParentFolderShape);
|
|
614
|
-
const FolderShape = {
|
|
615
|
-
id: PropTypes__default.default.number,
|
|
616
|
-
children: PropTypes__default.default.shape({
|
|
617
|
-
count: PropTypes__default.default.number.isRequired
|
|
618
|
-
}),
|
|
619
|
-
createdAt: PropTypes__default.default.string,
|
|
620
|
-
createdBy: PropTypes__default.default.shape(),
|
|
621
|
-
files: PropTypes__default.default.shape({
|
|
622
|
-
count: PropTypes__default.default.number.isRequired
|
|
623
|
-
}),
|
|
624
|
-
name: PropTypes__default.default.string,
|
|
625
|
-
updatedAt: PropTypes__default.default.string,
|
|
626
|
-
updatedBy: PropTypes__default.default.shape(),
|
|
627
|
-
pathId: PropTypes__default.default.number,
|
|
628
|
-
path: PropTypes__default.default.string
|
|
629
|
-
};
|
|
630
|
-
FolderShape.parent = PropTypes__default.default.shape(ParentFolderShape);
|
|
631
|
-
const FolderDefinition = PropTypes__default.default.shape(FolderShape);
|
|
632
|
-
const FolderStructure = PropTypes__default.default.shape({
|
|
633
|
-
value: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
634
|
-
label: PropTypes__default.default.string.isRequired,
|
|
635
|
-
children: PropTypes__default.default.array
|
|
636
|
-
});
|
|
637
|
-
FolderStructure.children = PropTypes__default.default.arrayOf(PropTypes__default.default.shape(FolderStructure));
|
|
638
|
-
FolderStructure.defaultProps = {
|
|
639
|
-
children: void 0
|
|
640
|
-
};
|
|
641
|
-
PropTypes__default.default.arrayOf(FolderStructure);
|
|
642
|
-
const AssetDefinition = PropTypes__default.default.shape({
|
|
643
|
-
id: PropTypes__default.default.number,
|
|
644
|
-
height: PropTypes__default.default.number,
|
|
645
|
-
width: PropTypes__default.default.number,
|
|
646
|
-
size: PropTypes__default.default.number,
|
|
647
|
-
createdAt: PropTypes__default.default.string,
|
|
648
|
-
ext: PropTypes__default.default.string,
|
|
649
|
-
mime: PropTypes__default.default.string,
|
|
650
|
-
name: PropTypes__default.default.string,
|
|
651
|
-
url: PropTypes__default.default.string,
|
|
652
|
-
updatedAt: PropTypes__default.default.string,
|
|
653
|
-
alternativeText: PropTypes__default.default.string,
|
|
654
|
-
caption: PropTypes__default.default.string,
|
|
655
|
-
folder: PropTypes__default.default.shape(FolderDefinition),
|
|
656
|
-
formats: PropTypes__default.default.shape({
|
|
657
|
-
thumbnail: PropTypes__default.default.shape({
|
|
658
|
-
url: PropTypes__default.default.string
|
|
659
|
-
})
|
|
660
|
-
})
|
|
661
|
-
});
|
|
662
|
-
const CrumbDefinition = PropTypes__default.default.shape({
|
|
663
|
-
id: PropTypes__default.default.number,
|
|
664
|
-
label: PropTypes__default.default.oneOfType([
|
|
665
|
-
PropTypes__default.default.string,
|
|
666
|
-
PropTypes__default.default.shape({
|
|
667
|
-
id: PropTypes__default.default.string.isRequired,
|
|
668
|
-
defaultMessage: PropTypes__default.default.string.isRequired
|
|
669
|
-
})
|
|
670
|
-
]).isRequired,
|
|
671
|
-
href: PropTypes__default.default.string
|
|
672
|
-
});
|
|
673
|
-
const CrumbMenuDefinition = PropTypes__default.default.arrayOf(CrumbDefinition);
|
|
674
|
-
const BreadcrumbsDefinition = PropTypes__default.default.arrayOf(
|
|
675
|
-
PropTypes__default.default.oneOfType([CrumbDefinition, CrumbMenuDefinition])
|
|
676
|
-
);
|
|
677
|
-
const viewOptions = {
|
|
678
|
-
GRID: 0,
|
|
679
|
-
LIST: 1
|
|
680
|
-
};
|
|
681
|
-
const tableHeaders = [
|
|
682
|
-
{
|
|
683
|
-
name: "preview",
|
|
684
|
-
key: "preview",
|
|
685
|
-
metadatas: {
|
|
686
|
-
label: { id: getTrad("list.table.header.preview"), defaultMessage: "preview" },
|
|
687
|
-
isSortable: false
|
|
688
|
-
},
|
|
689
|
-
type: "image"
|
|
690
|
-
},
|
|
691
|
-
{
|
|
692
|
-
name: "name",
|
|
693
|
-
key: "name",
|
|
694
|
-
metadatas: {
|
|
695
|
-
label: { id: getTrad("list.table.header.name"), defaultMessage: "name" },
|
|
696
|
-
isSortable: true
|
|
697
|
-
},
|
|
698
|
-
type: "text"
|
|
699
|
-
},
|
|
700
|
-
{
|
|
701
|
-
name: "ext",
|
|
702
|
-
key: "extension",
|
|
703
|
-
metadatas: {
|
|
704
|
-
label: { id: getTrad("list.table.header.ext"), defaultMessage: "extension" },
|
|
705
|
-
isSortable: false
|
|
706
|
-
},
|
|
707
|
-
type: "ext"
|
|
708
|
-
},
|
|
709
|
-
{
|
|
710
|
-
name: "size",
|
|
711
|
-
key: "size",
|
|
712
|
-
metadatas: {
|
|
713
|
-
label: { id: getTrad("list.table.header.size"), defaultMessage: "size" },
|
|
714
|
-
isSortable: false
|
|
715
|
-
},
|
|
716
|
-
type: "size"
|
|
717
|
-
},
|
|
718
|
-
{
|
|
719
|
-
name: "createdAt",
|
|
720
|
-
key: "createdAt",
|
|
721
|
-
metadatas: {
|
|
722
|
-
label: { id: getTrad("list.table.header.createdAt"), defaultMessage: "created" },
|
|
723
|
-
isSortable: true
|
|
724
|
-
},
|
|
725
|
-
type: "date"
|
|
726
|
-
},
|
|
727
|
-
{
|
|
728
|
-
name: "updatedAt",
|
|
729
|
-
key: "updatedAt",
|
|
730
|
-
metadatas: {
|
|
731
|
-
label: { id: getTrad("list.table.header.updatedAt"), defaultMessage: "last update" },
|
|
732
|
-
isSortable: true
|
|
733
|
-
},
|
|
734
|
-
type: "date"
|
|
735
|
-
}
|
|
736
|
-
];
|
|
737
|
-
const pageSizes = [10, 20, 50, 100];
|
|
738
|
-
const sortOptions = [
|
|
739
|
-
{ key: "sort.created_at_desc", value: "createdAt:DESC" },
|
|
740
|
-
{ key: "sort.created_at_asc", value: "createdAt:ASC" },
|
|
741
|
-
{ key: "sort.name_asc", value: "name:ASC" },
|
|
742
|
-
{ key: "sort.name_desc", value: "name:DESC" },
|
|
743
|
-
{ key: "sort.updated_at_desc", value: "updatedAt:DESC" },
|
|
744
|
-
{ key: "sort.updated_at_asc", value: "updatedAt:ASC" }
|
|
745
|
-
];
|
|
746
|
-
const localStorageKeys = {
|
|
747
|
-
modalView: `STRAPI_UPLOAD_MODAL_VIEW`,
|
|
748
|
-
view: `STRAPI_UPLOAD_LIBRARY_VIEW`
|
|
749
|
-
};
|
|
685
|
+
var AssetType = /* @__PURE__ */ ((AssetType2) => {
|
|
686
|
+
AssetType2["Video"] = "video";
|
|
687
|
+
AssetType2["Image"] = "image";
|
|
688
|
+
AssetType2["Document"] = "doc";
|
|
689
|
+
AssetType2["Audio"] = "audio";
|
|
690
|
+
return AssetType2;
|
|
691
|
+
})(AssetType || {});
|
|
692
|
+
var AssetSource = /* @__PURE__ */ ((AssetSource2) => {
|
|
693
|
+
AssetSource2["Url"] = "url";
|
|
694
|
+
AssetSource2["Computer"] = "computer";
|
|
695
|
+
return AssetSource2;
|
|
696
|
+
})(AssetSource || {});
|
|
750
697
|
const PERMISSIONS = {
|
|
751
698
|
// This permission regards the main component (App) and is used to tell
|
|
752
699
|
// If the plugin link should be displayed in the menu
|
|
753
700
|
// And also if the plugin is accessible. This use case is found when a user types the url of the
|
|
754
701
|
// plugin directly in the browser
|
|
755
|
-
main: [
|
|
756
|
-
{ action: "plugin::upload.read", subject: null },
|
|
757
|
-
{
|
|
758
|
-
action: "plugin::upload.assets.create",
|
|
759
|
-
subject: null
|
|
760
|
-
},
|
|
761
|
-
{
|
|
762
|
-
action: "plugin::upload.assets.update",
|
|
763
|
-
subject: null
|
|
764
|
-
}
|
|
765
|
-
],
|
|
766
|
-
copyLink: [
|
|
767
|
-
{
|
|
768
|
-
action: "plugin::upload.assets.copy-link",
|
|
769
|
-
subject: null
|
|
770
|
-
}
|
|
771
|
-
],
|
|
772
|
-
create: [
|
|
773
|
-
{
|
|
774
|
-
action: "plugin::upload.assets.create",
|
|
775
|
-
subject: null
|
|
776
|
-
}
|
|
777
|
-
],
|
|
778
|
-
download: [
|
|
779
|
-
{
|
|
780
|
-
action: "plugin::upload.assets.download",
|
|
781
|
-
subject: null
|
|
782
|
-
}
|
|
783
|
-
],
|
|
784
|
-
read: [{ action: "plugin::upload.read", subject: null }],
|
|
785
|
-
configureView: [{ action: "plugin::upload.configure-view", subject: null }],
|
|
786
|
-
settings: [{ action: "plugin::upload.settings.read", subject: null }],
|
|
787
|
-
update: [{ action: "plugin::upload.assets.update", subject: null, fields: null }]
|
|
788
|
-
};
|
|
789
|
-
const useAssets = ({ skipWhen = false, query = {} } = {}) => {
|
|
790
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
791
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
|
792
|
-
const { notifyStatus } = designSystem.useNotifyAT();
|
|
793
|
-
const { get } = strapiAdmin.useFetchClient();
|
|
794
|
-
const { folderPath, _q, ...paramsExceptFolderAndQ } = query;
|
|
795
|
-
let params;
|
|
796
|
-
if (_q) {
|
|
797
|
-
params = {
|
|
798
|
-
...paramsExceptFolderAndQ,
|
|
799
|
-
_q: encodeURIComponent(_q)
|
|
800
|
-
};
|
|
801
|
-
} else {
|
|
802
|
-
params = {
|
|
803
|
-
...paramsExceptFolderAndQ,
|
|
804
|
-
filters: {
|
|
805
|
-
$and: [
|
|
806
|
-
...paramsExceptFolderAndQ?.filters?.$and ?? [],
|
|
807
|
-
{
|
|
808
|
-
folderPath: { $eq: folderPath ?? "/" }
|
|
809
|
-
}
|
|
810
|
-
]
|
|
811
|
-
}
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
const { data, error, isLoading } = reactQuery.useQuery(
|
|
815
|
-
[pluginId, "assets", params],
|
|
816
|
-
async () => {
|
|
817
|
-
const { data: data2 } = await get("/upload/files", { params });
|
|
818
|
-
return data2;
|
|
819
|
-
},
|
|
820
|
-
{
|
|
821
|
-
enabled: !skipWhen,
|
|
822
|
-
staleTime: 0,
|
|
823
|
-
cacheTime: 0,
|
|
824
|
-
select(data2) {
|
|
825
|
-
if (data2?.results && Array.isArray(data2.results)) {
|
|
826
|
-
return {
|
|
827
|
-
...data2,
|
|
828
|
-
results: data2.results.filter((asset) => asset.name).map((asset) => ({
|
|
829
|
-
...asset,
|
|
830
|
-
/**
|
|
831
|
-
* Mime and ext cannot be null in the front-end because
|
|
832
|
-
* we expect them to be strings and use the `includes` method.
|
|
833
|
-
*/
|
|
834
|
-
mime: asset.mime ?? "",
|
|
835
|
-
ext: asset.ext ?? ""
|
|
836
|
-
}))
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
|
-
return data2;
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
);
|
|
843
|
-
React__namespace.useEffect(() => {
|
|
844
|
-
if (data) {
|
|
845
|
-
notifyStatus(
|
|
846
|
-
formatMessage({
|
|
847
|
-
id: "list.asset.at.finished",
|
|
848
|
-
defaultMessage: "The assets have finished loading."
|
|
849
|
-
})
|
|
850
|
-
);
|
|
851
|
-
}
|
|
852
|
-
}, [data, formatMessage, notifyStatus]);
|
|
853
|
-
React__namespace.useEffect(() => {
|
|
854
|
-
if (error) {
|
|
855
|
-
toggleNotification({
|
|
856
|
-
type: "danger",
|
|
857
|
-
message: formatMessage({ id: "notification.error" })
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
}, [error, formatMessage, toggleNotification]);
|
|
861
|
-
return { data, error, isLoading };
|
|
862
|
-
};
|
|
863
|
-
const useFolders = ({ enabled = true, query = {} } = {}) => {
|
|
864
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
865
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
|
866
|
-
const { notifyStatus } = designSystem.useNotifyAT();
|
|
867
|
-
const { folder, _q, ...paramsExceptFolderAndQ } = query;
|
|
868
|
-
const { get } = strapiAdmin.useFetchClient();
|
|
869
|
-
let params;
|
|
870
|
-
if (_q) {
|
|
871
|
-
params = {
|
|
872
|
-
...paramsExceptFolderAndQ,
|
|
873
|
-
pagination: {
|
|
874
|
-
pageSize: -1
|
|
875
|
-
},
|
|
876
|
-
_q
|
|
877
|
-
};
|
|
878
|
-
} else {
|
|
879
|
-
params = {
|
|
880
|
-
...paramsExceptFolderAndQ,
|
|
881
|
-
pagination: {
|
|
882
|
-
pageSize: -1
|
|
883
|
-
},
|
|
884
|
-
filters: {
|
|
885
|
-
$and: [
|
|
886
|
-
...paramsExceptFolderAndQ?.filters?.$and ?? [],
|
|
887
|
-
{
|
|
888
|
-
parent: {
|
|
889
|
-
id: folder ?? {
|
|
890
|
-
$null: true
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
]
|
|
895
|
-
}
|
|
896
|
-
};
|
|
897
|
-
}
|
|
898
|
-
const { data, error, isLoading } = reactQuery.useQuery(
|
|
899
|
-
[pluginId, "folders", qs.stringify(params)],
|
|
900
|
-
async () => {
|
|
901
|
-
const {
|
|
902
|
-
data: { data: data2 }
|
|
903
|
-
} = await get("/upload/folders", { params });
|
|
904
|
-
return data2;
|
|
702
|
+
main: [
|
|
703
|
+
{ action: "plugin::upload.read", subject: null },
|
|
704
|
+
{
|
|
705
|
+
action: "plugin::upload.assets.create",
|
|
706
|
+
subject: null
|
|
905
707
|
},
|
|
906
708
|
{
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
cacheTime: 0,
|
|
910
|
-
onError() {
|
|
911
|
-
toggleNotification({
|
|
912
|
-
type: "danger",
|
|
913
|
-
message: formatMessage({ id: "notification.error" })
|
|
914
|
-
});
|
|
915
|
-
}
|
|
709
|
+
action: "plugin::upload.assets.update",
|
|
710
|
+
subject: null
|
|
916
711
|
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
id: "list.asset.at.finished",
|
|
923
|
-
defaultMessage: "The folders have finished loading."
|
|
924
|
-
})
|
|
925
|
-
);
|
|
712
|
+
],
|
|
713
|
+
copyLink: [
|
|
714
|
+
{
|
|
715
|
+
action: "plugin::upload.assets.copy-link",
|
|
716
|
+
subject: null
|
|
926
717
|
}
|
|
927
|
-
|
|
928
|
-
|
|
718
|
+
],
|
|
719
|
+
create: [
|
|
720
|
+
{
|
|
721
|
+
action: "plugin::upload.assets.create",
|
|
722
|
+
subject: null
|
|
723
|
+
}
|
|
724
|
+
],
|
|
725
|
+
download: [
|
|
726
|
+
{
|
|
727
|
+
action: "plugin::upload.assets.download",
|
|
728
|
+
subject: null
|
|
729
|
+
}
|
|
730
|
+
],
|
|
731
|
+
read: [{ action: "plugin::upload.read", subject: null }],
|
|
732
|
+
configureView: [{ action: "plugin::upload.configure-view", subject: null }],
|
|
733
|
+
settings: [{ action: "plugin::upload.settings.read", subject: null }],
|
|
734
|
+
update: [{ action: "plugin::upload.assets.update", subject: null, fields: null }]
|
|
735
|
+
};
|
|
736
|
+
const tableHeaders = [
|
|
737
|
+
{
|
|
738
|
+
name: "preview",
|
|
739
|
+
key: "preview",
|
|
740
|
+
metadatas: {
|
|
741
|
+
label: { id: getTrad("list.table.header.preview"), defaultMessage: "preview" },
|
|
742
|
+
isSortable: false
|
|
743
|
+
},
|
|
744
|
+
type: "image"
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
name: "name",
|
|
748
|
+
key: "name",
|
|
749
|
+
metadatas: {
|
|
750
|
+
label: { id: getTrad("list.table.header.name"), defaultMessage: "name" },
|
|
751
|
+
isSortable: true
|
|
752
|
+
},
|
|
753
|
+
type: "text"
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
name: "ext",
|
|
757
|
+
key: "extension",
|
|
758
|
+
metadatas: {
|
|
759
|
+
label: { id: getTrad("list.table.header.ext"), defaultMessage: "extension" },
|
|
760
|
+
isSortable: false
|
|
761
|
+
},
|
|
762
|
+
type: "ext"
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
name: "size",
|
|
766
|
+
key: "size",
|
|
767
|
+
metadatas: {
|
|
768
|
+
label: { id: getTrad("list.table.header.size"), defaultMessage: "size" },
|
|
769
|
+
isSortable: false
|
|
770
|
+
},
|
|
771
|
+
type: "size"
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
name: "createdAt",
|
|
775
|
+
key: "createdAt",
|
|
776
|
+
metadatas: {
|
|
777
|
+
label: { id: getTrad("list.table.header.createdAt"), defaultMessage: "created" },
|
|
778
|
+
isSortable: true
|
|
779
|
+
},
|
|
780
|
+
type: "date"
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
name: "updatedAt",
|
|
784
|
+
key: "updatedAt",
|
|
785
|
+
metadatas: {
|
|
786
|
+
label: { id: getTrad("list.table.header.updatedAt"), defaultMessage: "last update" },
|
|
787
|
+
isSortable: true
|
|
788
|
+
},
|
|
789
|
+
type: "date"
|
|
790
|
+
}
|
|
791
|
+
];
|
|
792
|
+
const sortOptions = [
|
|
793
|
+
{ key: "sort.created_at_desc", value: "createdAt:DESC" },
|
|
794
|
+
{ key: "sort.created_at_asc", value: "createdAt:ASC" },
|
|
795
|
+
{ key: "sort.name_asc", value: "name:ASC" },
|
|
796
|
+
{ key: "sort.name_desc", value: "name:DESC" },
|
|
797
|
+
{ key: "sort.updated_at_desc", value: "updatedAt:DESC" },
|
|
798
|
+
{ key: "sort.updated_at_asc", value: "updatedAt:ASC" }
|
|
799
|
+
];
|
|
800
|
+
const pageSizes = [10, 20, 50, 100];
|
|
801
|
+
const localStorageKeys = {
|
|
802
|
+
modalView: `STRAPI_UPLOAD_MODAL_VIEW`,
|
|
803
|
+
view: `STRAPI_UPLOAD_LIBRARY_VIEW`
|
|
804
|
+
};
|
|
805
|
+
const viewOptions = {
|
|
806
|
+
GRID: 0,
|
|
807
|
+
LIST: 1
|
|
929
808
|
};
|
|
930
|
-
const { main, ...restPermissions } = PERMISSIONS
|
|
809
|
+
const { main: _main, ...restPermissions } = PERMISSIONS;
|
|
931
810
|
const useMediaLibraryPermissions = () => {
|
|
932
811
|
const { allowedActions, isLoading } = strapiAdmin.useRBAC(restPermissions);
|
|
933
812
|
return { ...allowedActions, isLoading };
|
|
@@ -1062,13 +941,13 @@ const useModalQueryParams = (initialState) => {
|
|
|
1062
941
|
const useSelectionState = (keys, initialValue) => {
|
|
1063
942
|
const [selections, setSelections] = React__namespace.useState(initialValue);
|
|
1064
943
|
const selectOne = (selection) => {
|
|
1065
|
-
const
|
|
944
|
+
const index = selections.findIndex(
|
|
1066
945
|
(currentSelection) => keys.every((key) => currentSelection[key] === selection[key])
|
|
1067
946
|
);
|
|
1068
|
-
if (
|
|
947
|
+
if (index > -1) {
|
|
1069
948
|
setSelections((prevSelected) => [
|
|
1070
|
-
...prevSelected.slice(0,
|
|
1071
|
-
...prevSelected.slice(
|
|
949
|
+
...prevSelected.slice(0, index),
|
|
950
|
+
...prevSelected.slice(index + 1)
|
|
1072
951
|
]);
|
|
1073
952
|
} else {
|
|
1074
953
|
setSelections((prevSelected) => [...prevSelected, selection]);
|
|
@@ -1082,10 +961,10 @@ const useSelectionState = (keys, initialValue) => {
|
|
|
1082
961
|
}
|
|
1083
962
|
};
|
|
1084
963
|
const selectOnly = (nextSelection) => {
|
|
1085
|
-
const
|
|
964
|
+
const index = selections.findIndex(
|
|
1086
965
|
(currentSelection) => keys.every((key) => currentSelection[key] === nextSelection[key])
|
|
1087
966
|
);
|
|
1088
|
-
if (
|
|
967
|
+
if (index > -1) {
|
|
1089
968
|
setSelections([]);
|
|
1090
969
|
} else {
|
|
1091
970
|
setSelections([nextSelection]);
|
|
@@ -1225,14 +1104,6 @@ const ContextInfo = ({ blocks }) => {
|
|
|
1225
1104
|
}
|
|
1226
1105
|
);
|
|
1227
1106
|
};
|
|
1228
|
-
ContextInfo.propTypes = {
|
|
1229
|
-
blocks: PropTypes__default.default.arrayOf(
|
|
1230
|
-
PropTypes__default.default.shape({
|
|
1231
|
-
label: PropTypes__default.default.string,
|
|
1232
|
-
value: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number])
|
|
1233
|
-
})
|
|
1234
|
-
).isRequired
|
|
1235
|
-
};
|
|
1236
1107
|
const ToggleButton = styledComponents.styled(designSystem.Flex)`
|
|
1237
1108
|
align-self: flex-end;
|
|
1238
1109
|
height: 2.2rem;
|
|
@@ -1249,9 +1120,9 @@ const Option = ({ children, data, selectProps, ...props }) => {
|
|
|
1249
1120
|
const { maxDisplayDepth, openValues, onOptionToggle } = selectProps;
|
|
1250
1121
|
const isOpen = openValues.includes(value);
|
|
1251
1122
|
const Icon = isOpen ? icons.ChevronUp : icons.ChevronDown;
|
|
1252
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ReactSelect.components.Option, { ...props, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "start", children: [
|
|
1123
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReactSelect.components.Option, { data, selectProps, ...props, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "start", children: [
|
|
1253
1124
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", ellipsis: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: { paddingLeft: `${Math.min(depth, maxDisplayDepth) * 14}px` }, children }) }),
|
|
1254
|
-
options?.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1125
|
+
options && options?.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1255
1126
|
ToggleButton,
|
|
1256
1127
|
{
|
|
1257
1128
|
"aria-label": formatMessage({
|
|
@@ -1273,18 +1144,8 @@ const Option = ({ children, data, selectProps, ...props }) => {
|
|
|
1273
1144
|
)
|
|
1274
1145
|
] }) });
|
|
1275
1146
|
};
|
|
1276
|
-
Option.propTypes = {
|
|
1277
|
-
children: PropTypes__default.default.node.isRequired,
|
|
1278
|
-
data: PropTypes__default.default.object.isRequired,
|
|
1279
|
-
onToggle: PropTypes__default.default.func.isRequired,
|
|
1280
|
-
selectProps: PropTypes__default.default.shape({
|
|
1281
|
-
maxDisplayDepth: PropTypes__default.default.number,
|
|
1282
|
-
openValues: PropTypes__default.default.arrayOf(PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number])),
|
|
1283
|
-
onOptionToggle: PropTypes__default.default.func
|
|
1284
|
-
}).isRequired
|
|
1285
|
-
};
|
|
1286
1147
|
function getOpenValues(options, defaultValue = {}) {
|
|
1287
|
-
|
|
1148
|
+
const values = [];
|
|
1288
1149
|
const { value } = defaultValue;
|
|
1289
1150
|
const option = options.find((option2) => option2.value === value);
|
|
1290
1151
|
if (!option) {
|
|
@@ -1294,6 +1155,9 @@ function getOpenValues(options, defaultValue = {}) {
|
|
|
1294
1155
|
let { parent } = option;
|
|
1295
1156
|
while (parent !== void 0) {
|
|
1296
1157
|
const option2 = options.find(({ value: value2 }) => value2 === parent);
|
|
1158
|
+
if (!option2) {
|
|
1159
|
+
break;
|
|
1160
|
+
}
|
|
1297
1161
|
values.push(option2.value);
|
|
1298
1162
|
parent = option2.parent;
|
|
1299
1163
|
}
|
|
@@ -1301,15 +1165,28 @@ function getOpenValues(options, defaultValue = {}) {
|
|
|
1301
1165
|
}
|
|
1302
1166
|
function getValuesToClose(options, value) {
|
|
1303
1167
|
const optionForValue = options.find((option) => option.value === value);
|
|
1168
|
+
if (!optionForValue) {
|
|
1169
|
+
return [];
|
|
1170
|
+
}
|
|
1304
1171
|
return options.filter((option) => option.depth >= optionForValue.depth).map((option) => option.value);
|
|
1305
1172
|
}
|
|
1306
1173
|
const hasParent = (option) => !option.parent;
|
|
1307
|
-
const SelectTree = ({
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1174
|
+
const SelectTree = ({
|
|
1175
|
+
options: defaultOptions,
|
|
1176
|
+
maxDisplayDepth = 5,
|
|
1177
|
+
defaultValue,
|
|
1178
|
+
...props
|
|
1179
|
+
}) => {
|
|
1180
|
+
const flatDefaultOptions = React__namespace.useMemo(() => flattenTree(defaultOptions), [defaultOptions]);
|
|
1181
|
+
const optionsFiltered = React__namespace.useMemo(
|
|
1182
|
+
() => flatDefaultOptions.filter(hasParent),
|
|
1183
|
+
[flatDefaultOptions]
|
|
1184
|
+
);
|
|
1185
|
+
const [options, setOptions] = React__namespace.useState(optionsFiltered);
|
|
1186
|
+
const [openValues, setOpenValues] = React__namespace.useState(
|
|
1187
|
+
getOpenValues(flatDefaultOptions, defaultValue)
|
|
1188
|
+
);
|
|
1189
|
+
React__namespace.useEffect(() => {
|
|
1313
1190
|
if (openValues.length === 0) {
|
|
1314
1191
|
setOptions(flatDefaultOptions.filter((option) => option.parent === void 0));
|
|
1315
1192
|
} else {
|
|
@@ -1351,7 +1228,13 @@ const SelectTree = ({ options: defaultOptions, maxDisplayDepth, defaultValue, ..
|
|
|
1351
1228
|
}
|
|
1352
1229
|
);
|
|
1353
1230
|
};
|
|
1354
|
-
const Select = ({
|
|
1231
|
+
const Select = ({
|
|
1232
|
+
components: components2 = {},
|
|
1233
|
+
styles = {},
|
|
1234
|
+
error,
|
|
1235
|
+
ariaErrorMessage,
|
|
1236
|
+
...props
|
|
1237
|
+
}) => {
|
|
1355
1238
|
const theme = styledComponents.useTheme();
|
|
1356
1239
|
const customStyles = getSelectStyles(theme, error);
|
|
1357
1240
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1359,11 +1242,11 @@ const Select = ({ components: components2, styles, error, ariaErrorMessage, ...p
|
|
|
1359
1242
|
{
|
|
1360
1243
|
menuPosition: "fixed",
|
|
1361
1244
|
components: {
|
|
1245
|
+
...components2,
|
|
1362
1246
|
ClearIndicator,
|
|
1363
1247
|
DropdownIndicator,
|
|
1364
1248
|
IndicatorSeparator: () => null,
|
|
1365
|
-
LoadingIndicator: () => null
|
|
1366
|
-
...components2
|
|
1249
|
+
LoadingIndicator: () => null
|
|
1367
1250
|
},
|
|
1368
1251
|
"aria-errormessage": error && ariaErrorMessage,
|
|
1369
1252
|
"aria-invalid": !!error,
|
|
@@ -1372,18 +1255,6 @@ const Select = ({ components: components2, styles, error, ariaErrorMessage, ...p
|
|
|
1372
1255
|
}
|
|
1373
1256
|
);
|
|
1374
1257
|
};
|
|
1375
|
-
Select.defaultProps = {
|
|
1376
|
-
ariaErrorMessage: "",
|
|
1377
|
-
components: {},
|
|
1378
|
-
error: void 0,
|
|
1379
|
-
styles: {}
|
|
1380
|
-
};
|
|
1381
|
-
Select.propTypes = {
|
|
1382
|
-
components: PropTypes__default.default.object,
|
|
1383
|
-
styles: PropTypes__default.default.object,
|
|
1384
|
-
error: PropTypes__default.default.string,
|
|
1385
|
-
ariaErrorMessage: PropTypes__default.default.string
|
|
1386
|
-
};
|
|
1387
1258
|
const IconBox = styledComponents.styled(designSystem.Box)`
|
|
1388
1259
|
background: transparent;
|
|
1389
1260
|
border: none;
|
|
@@ -1413,13 +1284,7 @@ const CarretBox = styledComponents.styled(IconBox)`
|
|
|
1413
1284
|
}
|
|
1414
1285
|
`;
|
|
1415
1286
|
const DropdownIndicator = ({ innerProps }) => {
|
|
1416
|
-
return (
|
|
1417
|
-
// @ts-expect-error – issue with the ref attached to `innerProps`
|
|
1418
|
-
/* @__PURE__ */ jsxRuntime.jsx(CarretBox, { paddingRight: 3, ...innerProps, children: /* @__PURE__ */ jsxRuntime.jsx(icons.CaretDown, {}) })
|
|
1419
|
-
);
|
|
1420
|
-
};
|
|
1421
|
-
DropdownIndicator.propTypes = {
|
|
1422
|
-
innerProps: PropTypes__default.default.object.isRequired
|
|
1287
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CarretBox, { paddingRight: 3, ...innerProps, children: /* @__PURE__ */ jsxRuntime.jsx(icons.CaretDown, {}) });
|
|
1423
1288
|
};
|
|
1424
1289
|
const getSelectStyles = (theme, error) => {
|
|
1425
1290
|
return {
|
|
@@ -1431,8 +1296,8 @@ const getSelectStyles = (theme, error) => {
|
|
|
1431
1296
|
}),
|
|
1432
1297
|
control(base, state) {
|
|
1433
1298
|
let borderColor = theme.colors.neutral200;
|
|
1434
|
-
let boxShadowColor;
|
|
1435
|
-
let backgroundColor;
|
|
1299
|
+
let boxShadowColor = void 0;
|
|
1300
|
+
let backgroundColor = void 0;
|
|
1436
1301
|
if (state.isFocused) {
|
|
1437
1302
|
borderColor = theme.colors.primary600;
|
|
1438
1303
|
boxShadowColor = theme.colors.primary600;
|
|
@@ -1487,8 +1352,9 @@ const getSelectStyles = (theme, error) => {
|
|
|
1487
1352
|
paddingRight: theme.spaces[1],
|
|
1488
1353
|
paddingBottom: theme.spaces[1]
|
|
1489
1354
|
}),
|
|
1355
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1490
1356
|
option(base, state) {
|
|
1491
|
-
let backgroundColor = base
|
|
1357
|
+
let backgroundColor = base?.backgroundColor;
|
|
1492
1358
|
if (state.isFocused || state.isSelected) {
|
|
1493
1359
|
backgroundColor = theme.colors.primary100;
|
|
1494
1360
|
}
|
|
@@ -1529,26 +1395,6 @@ const getSelectStyles = (theme, error) => {
|
|
|
1529
1395
|
})
|
|
1530
1396
|
};
|
|
1531
1397
|
};
|
|
1532
|
-
const OptionShape = PropTypes__default.default.shape({
|
|
1533
|
-
value: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
1534
|
-
label: PropTypes__default.default.string.isRequired,
|
|
1535
|
-
children: PropTypes__default.default.array
|
|
1536
|
-
});
|
|
1537
|
-
OptionShape.children = PropTypes__default.default.arrayOf(PropTypes__default.default.shape(OptionShape));
|
|
1538
|
-
OptionShape.defaultProps = {
|
|
1539
|
-
children: void 0
|
|
1540
|
-
};
|
|
1541
|
-
SelectTree.defaultProps = {
|
|
1542
|
-
defaultValue: void 0,
|
|
1543
|
-
maxDisplayDepth: 5
|
|
1544
|
-
};
|
|
1545
|
-
SelectTree.propTypes = {
|
|
1546
|
-
defaultValue: PropTypes__default.default.shape({
|
|
1547
|
-
value: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string])
|
|
1548
|
-
}),
|
|
1549
|
-
maxDisplayDepth: PropTypes__default.default.number,
|
|
1550
|
-
options: PropTypes__default.default.arrayOf(OptionShape).isRequired
|
|
1551
|
-
};
|
|
1552
1398
|
const DialogHeader = () => {
|
|
1553
1399
|
const { formatMessage } = reactIntl.useIntl();
|
|
1554
1400
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: formatMessage({ id: "global.details", defaultMessage: "Details" }) }) });
|
|
@@ -1662,6 +1508,7 @@ const useUpload = () => {
|
|
|
1662
1508
|
const cancel = () => abortController.abort();
|
|
1663
1509
|
return {
|
|
1664
1510
|
upload,
|
|
1511
|
+
isLoading: mutation.isLoading,
|
|
1665
1512
|
cancel,
|
|
1666
1513
|
error: mutation.error,
|
|
1667
1514
|
progress,
|
|
@@ -1696,9 +1543,6 @@ const CopyLinkButton = ({ url }) => {
|
|
|
1696
1543
|
}
|
|
1697
1544
|
);
|
|
1698
1545
|
};
|
|
1699
|
-
CopyLinkButton.propTypes = {
|
|
1700
|
-
url: PropTypes__default.default.string.isRequired
|
|
1701
|
-
};
|
|
1702
1546
|
const BoxWrapper = styledComponents.styled(designSystem.Flex)`
|
|
1703
1547
|
border-radius: ${({ theme }) => `${theme.borderRadius} ${theme.borderRadius} 0 0`};
|
|
1704
1548
|
width: 100%;
|
|
@@ -1730,10 +1574,11 @@ const CancelButton = styledComponents.styled.button`
|
|
|
1730
1574
|
}
|
|
1731
1575
|
}
|
|
1732
1576
|
`;
|
|
1733
|
-
const UploadProgress = ({ onCancel, progress, error }) => {
|
|
1577
|
+
const UploadProgress = ({ onCancel, progress = 0, error }) => {
|
|
1734
1578
|
const { formatMessage } = reactIntl.useIntl();
|
|
1735
1579
|
return /* @__PURE__ */ jsxRuntime.jsx(BoxWrapper, { alignItems: "center", background: error ? "danger100" : "neutral150", error, children: error ? /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, { "aria-label": error?.message }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 2, width: "100%", children: [
|
|
1736
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ProgressBar, { value: progress
|
|
1580
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.ProgressBar, { value: progress }),
|
|
1581
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: `${progress}/100%` }),
|
|
1737
1582
|
/* @__PURE__ */ jsxRuntime.jsx(CancelButton, { type: "button", onClick: onCancel, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
|
1738
1583
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", tag: "span", textColor: "inherit", children: formatMessage({
|
|
1739
1584
|
id: "app.components.Button.cancel",
|
|
@@ -1743,15 +1588,6 @@ const UploadProgress = ({ onCancel, progress, error }) => {
|
|
|
1743
1588
|
] }) })
|
|
1744
1589
|
] }) });
|
|
1745
1590
|
};
|
|
1746
|
-
UploadProgress.defaultProps = {
|
|
1747
|
-
error: void 0,
|
|
1748
|
-
progress: 0
|
|
1749
|
-
};
|
|
1750
|
-
UploadProgress.propTypes = {
|
|
1751
|
-
error: PropTypes__default.default.instanceOf(Error),
|
|
1752
|
-
onCancel: PropTypes__default.default.func.isRequired,
|
|
1753
|
-
progress: PropTypes__default.default.number
|
|
1754
|
-
};
|
|
1755
1591
|
const useRemoveAsset = (onSuccess) => {
|
|
1756
1592
|
const { toggleNotification } = strapiAdmin.useNotification();
|
|
1757
1593
|
const { formatMessage } = reactIntl.useIntl();
|
|
@@ -1787,25 +1623,11 @@ const RemoveAssetDialog = ({ open, onClose, asset }) => {
|
|
|
1787
1623
|
onClose(null);
|
|
1788
1624
|
});
|
|
1789
1625
|
const handleConfirm = async (event) => {
|
|
1790
|
-
event
|
|
1626
|
+
event?.preventDefault();
|
|
1791
1627
|
await removeAsset(asset.id);
|
|
1792
1628
|
};
|
|
1793
1629
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.ConfirmDialog, { onConfirm: handleConfirm }) });
|
|
1794
1630
|
};
|
|
1795
|
-
RemoveAssetDialog.propTypes = {
|
|
1796
|
-
onClose: PropTypes__default.default.func.isRequired,
|
|
1797
|
-
open: PropTypes__default.default.bool.isRequired,
|
|
1798
|
-
asset: PropTypes__default.default.shape({
|
|
1799
|
-
id: PropTypes__default.default.number,
|
|
1800
|
-
height: PropTypes__default.default.number,
|
|
1801
|
-
width: PropTypes__default.default.number,
|
|
1802
|
-
size: PropTypes__default.default.number,
|
|
1803
|
-
createdAt: PropTypes__default.default.string,
|
|
1804
|
-
ext: PropTypes__default.default.string,
|
|
1805
|
-
name: PropTypes__default.default.string,
|
|
1806
|
-
url: PropTypes__default.default.string
|
|
1807
|
-
}).isRequired
|
|
1808
|
-
};
|
|
1809
1631
|
const usePersistentState = (key, defaultValue) => {
|
|
1810
1632
|
const [value, setValue] = React.useState(() => {
|
|
1811
1633
|
const stickyValue = window.localStorage.getItem(key);
|
|
@@ -1827,7 +1649,7 @@ const CardAsset$1 = styledComponents.styled(designSystem.Flex)`
|
|
|
1827
1649
|
border-radius: ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius} 0 0;
|
|
1828
1650
|
background: linear-gradient(180deg, #ffffff 0%, #f6f6f9 121.48%);
|
|
1829
1651
|
`;
|
|
1830
|
-
const AssetPreview =
|
|
1652
|
+
const AssetPreview = React__namespace.forwardRef(({ mime, url, name: name2, ...props }, ref) => {
|
|
1831
1653
|
const [lang] = usePersistentState("strapi-admin-language", "en");
|
|
1832
1654
|
if (mime.includes(AssetType.Image)) {
|
|
1833
1655
|
return /* @__PURE__ */ jsxRuntime.jsx("img", { ref, src: url, alt: name2, ...props });
|
|
@@ -1844,11 +1666,6 @@ const AssetPreview = React.forwardRef(({ mime, url, name: name2, ...props }, ref
|
|
|
1844
1666
|
return /* @__PURE__ */ jsxRuntime.jsx(CardAsset$1, { justifyContent: "center", ...props, children: /* @__PURE__ */ jsxRuntime.jsx(icons.File, { "aria-label": name2 }) });
|
|
1845
1667
|
});
|
|
1846
1668
|
AssetPreview.displayName = "AssetPreview";
|
|
1847
|
-
AssetPreview.propTypes = {
|
|
1848
|
-
mime: PropTypes__default.default.string.isRequired,
|
|
1849
|
-
name: PropTypes__default.default.string.isRequired,
|
|
1850
|
-
url: PropTypes__default.default.string.isRequired
|
|
1851
|
-
};
|
|
1852
1669
|
const RelativeBox = styledComponents.styled(designSystem.Box)`
|
|
1853
1670
|
position: relative;
|
|
1854
1671
|
`;
|
|
@@ -1975,14 +1792,6 @@ const Trigger = styledComponents.styled(designSystem.Menu.Trigger)`
|
|
|
1975
1792
|
}
|
|
1976
1793
|
}
|
|
1977
1794
|
`;
|
|
1978
|
-
CroppingActions.defaultProps = {
|
|
1979
|
-
onDuplicate: void 0
|
|
1980
|
-
};
|
|
1981
|
-
CroppingActions.propTypes = {
|
|
1982
|
-
onCancel: PropTypes__default.default.func.isRequired,
|
|
1983
|
-
onDuplicate: PropTypes__default.default.func,
|
|
1984
|
-
onValidate: PropTypes__default.default.func.isRequired
|
|
1985
|
-
};
|
|
1986
1795
|
const PreviewBox = ({
|
|
1987
1796
|
asset,
|
|
1988
1797
|
canUpdate,
|
|
@@ -1996,13 +1805,13 @@ const PreviewBox = ({
|
|
|
1996
1805
|
trackedLocation
|
|
1997
1806
|
}) => {
|
|
1998
1807
|
const { trackUsage } = strapiAdmin.useTracking();
|
|
1999
|
-
const previewRef =
|
|
2000
|
-
const [isCropImageReady, setIsCropImageReady] =
|
|
2001
|
-
const [hasCropIntent, setHasCropIntent] =
|
|
2002
|
-
const [assetUrl, setAssetUrl] =
|
|
2003
|
-
const [thumbnailUrl, setThumbnailUrl] =
|
|
1808
|
+
const previewRef = React__namespace.useRef(null);
|
|
1809
|
+
const [isCropImageReady, setIsCropImageReady] = React__namespace.useState(false);
|
|
1810
|
+
const [hasCropIntent, setHasCropIntent] = React__namespace.useState(null);
|
|
1811
|
+
const [assetUrl, setAssetUrl] = React__namespace.useState(createAssetUrl(asset, false));
|
|
1812
|
+
const [thumbnailUrl, setThumbnailUrl] = React__namespace.useState(createAssetUrl(asset, true));
|
|
2004
1813
|
const { formatMessage } = reactIntl.useIntl();
|
|
2005
|
-
const [showConfirmDialog, setShowConfirmDialog] =
|
|
1814
|
+
const [showConfirmDialog, setShowConfirmDialog] = React__namespace.useState(false);
|
|
2006
1815
|
const { crop, produceFile, stopCropping, isCropping, isCropperReady, width, height } = useCropImg();
|
|
2007
1816
|
const { editAsset, error, isLoading, progress, cancel } = useEditAsset();
|
|
2008
1817
|
const {
|
|
@@ -2012,7 +1821,7 @@ const PreviewBox = ({
|
|
|
2012
1821
|
error: uploadError,
|
|
2013
1822
|
progress: progressUpload
|
|
2014
1823
|
} = useUpload();
|
|
2015
|
-
|
|
1824
|
+
React__namespace.useEffect(() => {
|
|
2016
1825
|
if (replacementFile) {
|
|
2017
1826
|
const fileLocalUrl = URL.createObjectURL(replacementFile);
|
|
2018
1827
|
if (asset.isLocal) {
|
|
@@ -2022,13 +1831,13 @@ const PreviewBox = ({
|
|
|
2022
1831
|
setThumbnailUrl(fileLocalUrl);
|
|
2023
1832
|
}
|
|
2024
1833
|
}, [replacementFile, asset]);
|
|
2025
|
-
|
|
1834
|
+
React__namespace.useEffect(() => {
|
|
2026
1835
|
if (hasCropIntent === false) {
|
|
2027
1836
|
stopCropping();
|
|
2028
1837
|
onCropCancel();
|
|
2029
1838
|
}
|
|
2030
1839
|
}, [hasCropIntent, stopCropping, onCropCancel, onCropFinish]);
|
|
2031
|
-
|
|
1840
|
+
React__namespace.useEffect(() => {
|
|
2032
1841
|
if (hasCropIntent && isCropImageReady) {
|
|
2033
1842
|
crop(previewRef.current);
|
|
2034
1843
|
onCropStart();
|
|
@@ -2058,8 +1867,12 @@ const PreviewBox = ({
|
|
|
2058
1867
|
const isInCroppingMode = isCropping && !isLoading;
|
|
2059
1868
|
const handleDuplication = async () => {
|
|
2060
1869
|
const nextAsset = { ...asset, width, height };
|
|
2061
|
-
const file = await produceFile(
|
|
2062
|
-
|
|
1870
|
+
const file = await produceFile(
|
|
1871
|
+
nextAsset.name,
|
|
1872
|
+
nextAsset.mime,
|
|
1873
|
+
nextAsset.updatedAt
|
|
1874
|
+
);
|
|
1875
|
+
await upload({ name: file.name, rawFile: file }, asset.folder?.id ? asset.folder.id : null);
|
|
2063
1876
|
trackUsage("didCropFile", { duplicatedFile: true, location: trackedLocation });
|
|
2064
1877
|
setHasCropIntent(false);
|
|
2065
1878
|
onCropFinish();
|
|
@@ -2104,7 +1917,7 @@ const PreviewBox = ({
|
|
|
2104
1917
|
}
|
|
2105
1918
|
),
|
|
2106
1919
|
canCopyLink && /* @__PURE__ */ jsxRuntime.jsx(CopyLinkButton, { url: assetUrl }),
|
|
2107
|
-
canUpdate && asset.mime
|
|
1920
|
+
canUpdate && asset.mime?.includes(AssetType.Image) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2108
1921
|
designSystem.IconButton,
|
|
2109
1922
|
{
|
|
2110
1923
|
label: formatMessage({ id: getTrad("control-card.crop"), defaultMessage: "Crop" }),
|
|
@@ -2162,35 +1975,24 @@ const PreviewBox = ({
|
|
|
2162
1975
|
)
|
|
2163
1976
|
] });
|
|
2164
1977
|
};
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
canCopyLink: PropTypes__default.default.bool.isRequired,
|
|
2172
|
-
canDownload: PropTypes__default.default.bool.isRequired,
|
|
2173
|
-
replacementFile: PropTypes__default.default.instanceOf(File),
|
|
2174
|
-
asset: AssetDefinition.isRequired,
|
|
2175
|
-
onDelete: PropTypes__default.default.func.isRequired,
|
|
2176
|
-
onCropFinish: PropTypes__default.default.func.isRequired,
|
|
2177
|
-
onCropStart: PropTypes__default.default.func.isRequired,
|
|
2178
|
-
onCropCancel: PropTypes__default.default.func.isRequired,
|
|
2179
|
-
trackedLocation: PropTypes__default.default.string
|
|
2180
|
-
};
|
|
2181
|
-
const ReplaceMediaButton = ({ onSelectMedia, acceptedMime, trackedLocation, ...props }) => {
|
|
1978
|
+
const ReplaceMediaButton = ({
|
|
1979
|
+
onSelectMedia,
|
|
1980
|
+
acceptedMime,
|
|
1981
|
+
trackedLocation,
|
|
1982
|
+
...props
|
|
1983
|
+
}) => {
|
|
2182
1984
|
const { formatMessage } = reactIntl.useIntl();
|
|
2183
|
-
const inputRef =
|
|
1985
|
+
const inputRef = React__namespace.useRef(null);
|
|
2184
1986
|
const { trackUsage } = strapiAdmin.useTracking();
|
|
2185
1987
|
const handleClick = (e) => {
|
|
2186
1988
|
e.preventDefault();
|
|
2187
1989
|
if (trackedLocation) {
|
|
2188
1990
|
trackUsage("didReplaceMedia", { location: trackedLocation });
|
|
2189
1991
|
}
|
|
2190
|
-
inputRef.current
|
|
1992
|
+
inputRef.current?.click();
|
|
2191
1993
|
};
|
|
2192
1994
|
const handleChange = () => {
|
|
2193
|
-
const file = inputRef.current
|
|
1995
|
+
const file = inputRef.current?.files?.[0];
|
|
2194
1996
|
onSelectMedia(file);
|
|
2195
1997
|
};
|
|
2196
1998
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -2204,6 +2006,7 @@ const ReplaceMediaButton = ({ onSelectMedia, acceptedMime, trackedLocation, ...p
|
|
|
2204
2006
|
accept: acceptedMime,
|
|
2205
2007
|
type: "file",
|
|
2206
2008
|
name: "file",
|
|
2009
|
+
"data-testid": "file-input",
|
|
2207
2010
|
tabIndex: -1,
|
|
2208
2011
|
ref: inputRef,
|
|
2209
2012
|
onChange: handleChange,
|
|
@@ -2212,14 +2015,6 @@ const ReplaceMediaButton = ({ onSelectMedia, acceptedMime, trackedLocation, ...p
|
|
|
2212
2015
|
) })
|
|
2213
2016
|
] });
|
|
2214
2017
|
};
|
|
2215
|
-
ReplaceMediaButton.defaultProps = {
|
|
2216
|
-
trackedLocation: void 0
|
|
2217
|
-
};
|
|
2218
|
-
ReplaceMediaButton.propTypes = {
|
|
2219
|
-
acceptedMime: PropTypes__default.default.string.isRequired,
|
|
2220
|
-
onSelectMedia: PropTypes__default.default.func.isRequired,
|
|
2221
|
-
trackedLocation: PropTypes__default.default.string
|
|
2222
|
-
};
|
|
2223
2018
|
const LoadingBody$1 = styledComponents.styled(designSystem.Flex)`
|
|
2224
2019
|
/* 80px are coming from the Tabs component that is not included in the ModalBody */
|
|
2225
2020
|
min-height: ${() => `calc(60vh + 8rem)`};
|
|
@@ -2233,28 +2028,28 @@ const fileInfoSchema = yup__namespace.object({
|
|
|
2233
2028
|
const EditAssetContent = ({
|
|
2234
2029
|
onClose,
|
|
2235
2030
|
asset,
|
|
2236
|
-
canUpdate,
|
|
2237
|
-
canCopyLink,
|
|
2238
|
-
canDownload,
|
|
2031
|
+
canUpdate = false,
|
|
2032
|
+
canCopyLink = false,
|
|
2033
|
+
canDownload = false,
|
|
2239
2034
|
trackedLocation
|
|
2240
2035
|
}) => {
|
|
2241
2036
|
const { formatMessage, formatDate } = reactIntl.useIntl();
|
|
2242
2037
|
const { trackUsage } = strapiAdmin.useTracking();
|
|
2243
|
-
const submitButtonRef =
|
|
2244
|
-
const [isCropping, setIsCropping] =
|
|
2245
|
-
const [replacementFile, setReplacementFile] =
|
|
2038
|
+
const submitButtonRef = React__namespace.useRef(null);
|
|
2039
|
+
const [isCropping, setIsCropping] = React__namespace.useState(false);
|
|
2040
|
+
const [replacementFile, setReplacementFile] = React__namespace.useState();
|
|
2246
2041
|
const { editAsset, isLoading } = useEditAsset();
|
|
2247
2042
|
const { data: folderStructure, isLoading: folderStructureIsLoading } = useFolderStructure({
|
|
2248
2043
|
enabled: true
|
|
2249
2044
|
});
|
|
2250
2045
|
const handleSubmit = async (values) => {
|
|
2251
|
-
const nextAsset = { ...asset, ...values, folder: values.parent
|
|
2252
|
-
if (asset
|
|
2046
|
+
const nextAsset = { ...asset, ...values, folder: values.parent?.value };
|
|
2047
|
+
if (asset?.isLocal) {
|
|
2253
2048
|
onClose(nextAsset);
|
|
2254
2049
|
} else {
|
|
2255
2050
|
const editedAsset = await editAsset(nextAsset, replacementFile);
|
|
2256
|
-
const assetType = asset?.mime
|
|
2257
|
-
const didChangeLocation = asset?.folder?.id ? asset.folder.id !== values.parent
|
|
2051
|
+
const assetType = asset?.mime?.split("/")[0];
|
|
2052
|
+
const didChangeLocation = asset?.folder?.id ? asset.folder.id !== values.parent?.value : asset?.folder === null && !!values.parent?.value;
|
|
2258
2053
|
trackUsage("didEditMediaLibraryElements", {
|
|
2259
2054
|
location: trackedLocation,
|
|
2260
2055
|
type: assetType,
|
|
@@ -2287,9 +2082,9 @@ const EditAssetContent = ({
|
|
|
2287
2082
|
};
|
|
2288
2083
|
const activeFolderId = asset?.folder?.id;
|
|
2289
2084
|
const initialFormData = !folderStructureIsLoading && {
|
|
2290
|
-
name: asset
|
|
2291
|
-
alternativeText: asset
|
|
2292
|
-
caption: asset
|
|
2085
|
+
name: asset?.name,
|
|
2086
|
+
alternativeText: asset?.alternativeText ?? void 0,
|
|
2087
|
+
caption: asset?.caption ?? void 0,
|
|
2293
2088
|
parent: {
|
|
2294
2089
|
value: activeFolderId ?? void 0,
|
|
2295
2090
|
label: findRecursiveFolderByValue(folderStructure, activeFolderId)?.label ?? folderStructure[0].label
|
|
@@ -2348,35 +2143,35 @@ const EditAssetContent = ({
|
|
|
2348
2143
|
id: getTrad("modal.file-details.size"),
|
|
2349
2144
|
defaultMessage: "Size"
|
|
2350
2145
|
}),
|
|
2351
|
-
value: formatBytes(asset.size)
|
|
2146
|
+
value: formatBytes(asset?.size ? asset.size : 0)
|
|
2352
2147
|
},
|
|
2353
2148
|
{
|
|
2354
2149
|
label: formatMessage({
|
|
2355
2150
|
id: getTrad("modal.file-details.dimensions"),
|
|
2356
2151
|
defaultMessage: "Dimensions"
|
|
2357
2152
|
}),
|
|
2358
|
-
value: asset
|
|
2153
|
+
value: asset?.height && asset.width ? `${asset.width}✕${asset.height}` : null
|
|
2359
2154
|
},
|
|
2360
2155
|
{
|
|
2361
2156
|
label: formatMessage({
|
|
2362
2157
|
id: getTrad("modal.file-details.date"),
|
|
2363
2158
|
defaultMessage: "Date"
|
|
2364
2159
|
}),
|
|
2365
|
-
value: formatDate(new Date(asset.createdAt))
|
|
2160
|
+
value: formatDate(new Date(asset?.createdAt ? asset.createdAt : ""))
|
|
2366
2161
|
},
|
|
2367
2162
|
{
|
|
2368
2163
|
label: formatMessage({
|
|
2369
2164
|
id: getTrad("modal.file-details.extension"),
|
|
2370
2165
|
defaultMessage: "Extension"
|
|
2371
2166
|
}),
|
|
2372
|
-
value: getFileExtension(asset
|
|
2167
|
+
value: getFileExtension(asset?.ext)
|
|
2373
2168
|
},
|
|
2374
2169
|
{
|
|
2375
2170
|
label: formatMessage({
|
|
2376
2171
|
id: getTrad("modal.file-details.id"),
|
|
2377
2172
|
defaultMessage: "Asset ID"
|
|
2378
2173
|
}),
|
|
2379
|
-
value: asset.id
|
|
2174
|
+
value: asset?.id ? asset.id : null
|
|
2380
2175
|
}
|
|
2381
2176
|
]
|
|
2382
2177
|
}
|
|
@@ -2473,13 +2268,13 @@ const EditAssetContent = ({
|
|
|
2473
2268
|
] }) })
|
|
2474
2269
|
] }) }),
|
|
2475
2270
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
|
2476
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: () => handleClose(values), variant: "tertiary", children: formatMessage({ id: "global.cancel", defaultMessage: "Cancel" }) }),
|
|
2271
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: () => handleClose({ ...values }), variant: "tertiary", children: formatMessage({ id: "global.cancel", defaultMessage: "Cancel" }) }),
|
|
2477
2272
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
|
|
2478
2273
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2479
2274
|
ReplaceMediaButton,
|
|
2480
2275
|
{
|
|
2481
2276
|
onSelectMedia: setReplacementFile,
|
|
2482
|
-
acceptedMime: asset
|
|
2277
|
+
acceptedMime: asset?.mime ?? "",
|
|
2483
2278
|
disabled: formDisabled,
|
|
2484
2279
|
trackedLocation
|
|
2485
2280
|
}
|
|
@@ -2487,7 +2282,7 @@ const EditAssetContent = ({
|
|
|
2487
2282
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2488
2283
|
designSystem.Button,
|
|
2489
2284
|
{
|
|
2490
|
-
onClick: () => submitButtonRef.current
|
|
2285
|
+
onClick: () => submitButtonRef.current?.click(),
|
|
2491
2286
|
loading: isLoading,
|
|
2492
2287
|
disabled: formDisabled,
|
|
2493
2288
|
children: formatMessage({ id: "global.finish", defaultMessage: "Finish" })
|
|
@@ -2499,39 +2294,24 @@ const EditAssetContent = ({
|
|
|
2499
2294
|
}
|
|
2500
2295
|
);
|
|
2501
2296
|
};
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
canUpdate
|
|
2506
|
-
canCopyLink
|
|
2507
|
-
canDownload
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
};
|
|
2520
|
-
EditAssetDialog.defaultProps = {
|
|
2521
|
-
asset: {},
|
|
2522
|
-
trackedLocation: void 0,
|
|
2523
|
-
canUpdate: false,
|
|
2524
|
-
canCopyLink: false,
|
|
2525
|
-
canDownload: false
|
|
2526
|
-
};
|
|
2527
|
-
EditAssetDialog.propTypes = {
|
|
2528
|
-
asset: AssetDefinition,
|
|
2529
|
-
canUpdate: PropTypes__default.default.bool,
|
|
2530
|
-
canCopyLink: PropTypes__default.default.bool,
|
|
2531
|
-
canDownload: PropTypes__default.default.bool,
|
|
2532
|
-
open: PropTypes__default.default.bool.isRequired,
|
|
2533
|
-
onClose: PropTypes__default.default.func.isRequired,
|
|
2534
|
-
trackedLocation: PropTypes__default.default.string
|
|
2297
|
+
const EditAssetDialog = ({
|
|
2298
|
+
open,
|
|
2299
|
+
onClose,
|
|
2300
|
+
canUpdate = false,
|
|
2301
|
+
canCopyLink = false,
|
|
2302
|
+
canDownload = false,
|
|
2303
|
+
...restProps
|
|
2304
|
+
}) => {
|
|
2305
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2306
|
+
EditAssetContent,
|
|
2307
|
+
{
|
|
2308
|
+
onClose,
|
|
2309
|
+
canUpdate,
|
|
2310
|
+
canCopyLink,
|
|
2311
|
+
canDownload,
|
|
2312
|
+
...restProps
|
|
2313
|
+
}
|
|
2314
|
+
) }) });
|
|
2535
2315
|
};
|
|
2536
2316
|
const useBulkRemove = () => {
|
|
2537
2317
|
const { toggleNotification } = strapiAdmin.useNotification();
|
|
@@ -2540,12 +2320,12 @@ const useBulkRemove = () => {
|
|
|
2540
2320
|
const { post } = strapiAdmin.useFetchClient();
|
|
2541
2321
|
const bulkRemoveQuery = (filesAndFolders) => {
|
|
2542
2322
|
const payload = filesAndFolders.reduce((acc, selected) => {
|
|
2543
|
-
const { id
|
|
2323
|
+
const { id, type } = selected;
|
|
2544
2324
|
const key = type === "asset" ? "fileIds" : "folderIds";
|
|
2545
2325
|
if (!acc[key]) {
|
|
2546
2326
|
acc[key] = [];
|
|
2547
2327
|
}
|
|
2548
|
-
acc[key].push(
|
|
2328
|
+
acc[key].push(id);
|
|
2549
2329
|
return acc;
|
|
2550
2330
|
}, {});
|
|
2551
2331
|
return post("/upload/actions/bulk-delete", payload);
|
|
@@ -2577,10 +2357,10 @@ const useBulkRemove = () => {
|
|
|
2577
2357
|
const remove = (...args) => mutation.mutateAsync(...args);
|
|
2578
2358
|
return { ...mutation, remove };
|
|
2579
2359
|
};
|
|
2580
|
-
const editFolderRequest = (put, post, { attrs, id
|
|
2581
|
-
const isEditing = !!
|
|
2360
|
+
const editFolderRequest = (put, post, { attrs, id }) => {
|
|
2361
|
+
const isEditing = !!id;
|
|
2582
2362
|
const method = isEditing ? put : post;
|
|
2583
|
-
return method(`/upload/folders/${
|
|
2363
|
+
return method(`/upload/folders/${id ?? ""}`, attrs).then((res) => res.data);
|
|
2584
2364
|
};
|
|
2585
2365
|
const useEditFolder = () => {
|
|
2586
2366
|
const queryClient = reactQuery.useQueryClient();
|
|
@@ -2591,10 +2371,10 @@ const useEditFolder = () => {
|
|
|
2591
2371
|
queryClient.refetchQueries([pluginId, "folder", "structure"], { active: true });
|
|
2592
2372
|
}
|
|
2593
2373
|
});
|
|
2594
|
-
const editFolder = (attrs,
|
|
2374
|
+
const editFolder = (attrs, id) => mutation.mutateAsync({ attrs, id });
|
|
2595
2375
|
return { ...mutation, editFolder, status: mutation.status };
|
|
2596
2376
|
};
|
|
2597
|
-
const EditFolderModalHeader = ({ isEditing }) => {
|
|
2377
|
+
const EditFolderModalHeader = ({ isEditing = false }) => {
|
|
2598
2378
|
const { formatMessage } = reactIntl.useIntl();
|
|
2599
2379
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: formatMessage(
|
|
2600
2380
|
isEditing ? {
|
|
@@ -2606,20 +2386,9 @@ const EditFolderModalHeader = ({ isEditing }) => {
|
|
|
2606
2386
|
}
|
|
2607
2387
|
) }) });
|
|
2608
2388
|
};
|
|
2609
|
-
EditFolderModalHeader.defaultProps = {
|
|
2610
|
-
isEditing: false
|
|
2611
|
-
};
|
|
2612
|
-
EditFolderModalHeader.propTypes = {
|
|
2613
|
-
isEditing: PropTypes__default.default.bool
|
|
2614
|
-
};
|
|
2615
2389
|
const RemoveFolderDialog = ({ onClose, onConfirm, open }) => {
|
|
2616
2390
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.ConfirmDialog, { onConfirm }) });
|
|
2617
2391
|
};
|
|
2618
|
-
RemoveFolderDialog.propTypes = {
|
|
2619
|
-
onClose: PropTypes__default.default.func.isRequired,
|
|
2620
|
-
open: PropTypes__default.default.bool.isRequired,
|
|
2621
|
-
onConfirm: PropTypes__default.default.func.isRequired
|
|
2622
|
-
};
|
|
2623
2392
|
const folderSchema = yup__namespace.object({
|
|
2624
2393
|
name: yup__namespace.string().required(),
|
|
2625
2394
|
parent: yup__namespace.object({
|
|
@@ -2627,12 +2396,17 @@ const folderSchema = yup__namespace.object({
|
|
|
2627
2396
|
value: yup__namespace.number().nullable(true)
|
|
2628
2397
|
}).nullable(true)
|
|
2629
2398
|
});
|
|
2630
|
-
const EditFolderContent = ({
|
|
2399
|
+
const EditFolderContent = ({
|
|
2400
|
+
onClose,
|
|
2401
|
+
folder,
|
|
2402
|
+
location,
|
|
2403
|
+
parentFolderId
|
|
2404
|
+
}) => {
|
|
2631
2405
|
const { data: folderStructure, isLoading: folderStructureIsLoading } = useFolderStructure({
|
|
2632
2406
|
enabled: true
|
|
2633
2407
|
});
|
|
2634
2408
|
const { canCreate, isLoading: isLoadingPermissions, canUpdate } = useMediaLibraryPermissions();
|
|
2635
|
-
const [showConfirmDialog, setShowConfirmDialog] =
|
|
2409
|
+
const [showConfirmDialog, setShowConfirmDialog] = React__namespace.useState(false);
|
|
2636
2410
|
const { formatMessage, formatDate } = reactIntl.useIntl();
|
|
2637
2411
|
const { trackUsage } = strapiAdmin.useTracking();
|
|
2638
2412
|
const { editFolder, isLoading: isEditFolderLoading } = useEditFolder();
|
|
@@ -2641,21 +2415,24 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2641
2415
|
const isLoading = isLoadingPermissions || folderStructureIsLoading;
|
|
2642
2416
|
const isEditing = !!folder;
|
|
2643
2417
|
const formDisabled = folder && !canUpdate || !folder && !canCreate;
|
|
2644
|
-
const initialFormData = !folderStructureIsLoading
|
|
2418
|
+
const initialFormData = !folderStructureIsLoading ? {
|
|
2645
2419
|
name: folder?.name ?? "",
|
|
2646
2420
|
parent: {
|
|
2647
2421
|
/* ideally we would use folderStructure[0].value, but since it is null
|
|
2648
|
-
|
|
2649
|
-
value: parentFolderId ? parseInt(parentFolderId, 10) : void 0,
|
|
2650
|
-
label: parentFolderId ? findRecursiveFolderByValue(folderStructure, parseInt(parentFolderId, 10))?.label : folderStructure[0].label
|
|
2422
|
+
react complains about rendering null as field value */
|
|
2423
|
+
value: parentFolderId ? parseInt(parentFolderId.toString(), 10) : void 0,
|
|
2424
|
+
label: parentFolderId ? folderStructure && findRecursiveFolderByValue(folderStructure, parseInt(parentFolderId.toString(), 10))?.label : folderStructure?.[0].label
|
|
2651
2425
|
}
|
|
2426
|
+
} : {
|
|
2427
|
+
name: "",
|
|
2428
|
+
parent: null
|
|
2652
2429
|
};
|
|
2653
2430
|
const handleSubmit = async (values, { setErrors }) => {
|
|
2654
2431
|
try {
|
|
2655
2432
|
await editFolder(
|
|
2656
2433
|
{
|
|
2657
2434
|
...values,
|
|
2658
|
-
parent: values.parent
|
|
2435
|
+
parent: values.parent?.value ?? null
|
|
2659
2436
|
},
|
|
2660
2437
|
folder?.id
|
|
2661
2438
|
);
|
|
@@ -2670,7 +2447,7 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2670
2447
|
})
|
|
2671
2448
|
});
|
|
2672
2449
|
if (isEditing) {
|
|
2673
|
-
const didChangeLocation = parentFolderId ? parseInt(parentFolderId, 10) !== values.parent
|
|
2450
|
+
const didChangeLocation = parentFolderId ? parseInt(parentFolderId.toString(), 10) !== values.parent?.value : parentFolderId === null && !!values.parent?.value;
|
|
2674
2451
|
trackUsage("didEditMediaLibraryElements", {
|
|
2675
2452
|
location,
|
|
2676
2453
|
type: "folder",
|
|
@@ -2682,17 +2459,22 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2682
2459
|
onClose({ created: true });
|
|
2683
2460
|
} catch (err) {
|
|
2684
2461
|
const errors = getAPIInnerErrors(err, { getTrad });
|
|
2685
|
-
const formikErrors = Object.entries(errors).reduce(
|
|
2686
|
-
acc[key]
|
|
2687
|
-
|
|
2688
|
-
|
|
2462
|
+
const formikErrors = Object.entries(errors).reduce(
|
|
2463
|
+
(acc, [key, error]) => {
|
|
2464
|
+
acc[key] = error.defaultMessage;
|
|
2465
|
+
return acc;
|
|
2466
|
+
},
|
|
2467
|
+
{}
|
|
2468
|
+
);
|
|
2689
2469
|
if (!isEmpty__default.default(formikErrors)) {
|
|
2690
2470
|
setErrors(formikErrors);
|
|
2691
2471
|
}
|
|
2692
2472
|
}
|
|
2693
2473
|
};
|
|
2694
2474
|
const handleDelete = async () => {
|
|
2695
|
-
|
|
2475
|
+
if (folder) {
|
|
2476
|
+
await remove([folder]);
|
|
2477
|
+
}
|
|
2696
2478
|
setShowConfirmDialog(false);
|
|
2697
2479
|
onClose();
|
|
2698
2480
|
};
|
|
@@ -2746,21 +2528,28 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2746
2528
|
]
|
|
2747
2529
|
}
|
|
2748
2530
|
) }),
|
|
2749
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2531
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2532
|
+
designSystem.Field.Root,
|
|
2533
|
+
{
|
|
2534
|
+
name: "name",
|
|
2535
|
+
error: typeof errors.name === "string" ? errors.name : void 0,
|
|
2536
|
+
children: [
|
|
2537
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
|
2538
|
+
id: getTrad("form.input.label.folder-name"),
|
|
2539
|
+
defaultMessage: "Name"
|
|
2540
|
+
}) }),
|
|
2541
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2542
|
+
designSystem.TextInput,
|
|
2543
|
+
{
|
|
2544
|
+
value: values.name,
|
|
2545
|
+
onChange: handleChange,
|
|
2546
|
+
disabled: formDisabled
|
|
2547
|
+
}
|
|
2548
|
+
),
|
|
2549
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
2550
|
+
]
|
|
2551
|
+
}
|
|
2552
|
+
) }),
|
|
2764
2553
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { xs: 12, col: 6, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { id: "folder-parent", children: [
|
|
2765
2554
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
|
|
2766
2555
|
id: getTrad("form.input.label.folder-location"),
|
|
@@ -2779,7 +2568,7 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2779
2568
|
menuPortalTarget: document.querySelector("body"),
|
|
2780
2569
|
inputId: "folder-parent",
|
|
2781
2570
|
disabled: formDisabled,
|
|
2782
|
-
error: errors
|
|
2571
|
+
error: typeof errors.parent === "string" ? errors.parent : void 0,
|
|
2783
2572
|
ariaErrorMessage: "folder-parent-error"
|
|
2784
2573
|
}
|
|
2785
2574
|
),
|
|
@@ -2790,7 +2579,7 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2790
2579
|
tag: "p",
|
|
2791
2580
|
id: "folder-parent-error",
|
|
2792
2581
|
textColor: "danger600",
|
|
2793
|
-
children: errors.parent
|
|
2582
|
+
children: typeof errors.parent === "string" ? errors.parent : void 0
|
|
2794
2583
|
}
|
|
2795
2584
|
)
|
|
2796
2585
|
] }) })
|
|
@@ -2839,42 +2628,19 @@ const EditFolderContent = ({ onClose, folder, location, parentFolderId }) => {
|
|
|
2839
2628
|
)
|
|
2840
2629
|
] });
|
|
2841
2630
|
};
|
|
2842
|
-
EditFolderContent.defaultProps = {
|
|
2843
|
-
folder: void 0,
|
|
2844
|
-
location: void 0,
|
|
2845
|
-
parentFolderId: null
|
|
2846
|
-
};
|
|
2847
|
-
EditFolderContent.propTypes = {
|
|
2848
|
-
folder: FolderDefinition,
|
|
2849
|
-
location: PropTypes__default.default.string,
|
|
2850
|
-
onClose: PropTypes__default.default.func.isRequired,
|
|
2851
|
-
parentFolderId: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number])
|
|
2852
|
-
};
|
|
2853
2631
|
const EditFolderDialog = ({ open, onClose, ...restProps }) => {
|
|
2854
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(EditFolderContent, { ...restProps, onClose }) }) });
|
|
2855
|
-
};
|
|
2856
|
-
EditFolderDialog.defaultProps = {
|
|
2857
|
-
folder: void 0,
|
|
2858
|
-
location: void 0,
|
|
2859
|
-
parentFolderId: null
|
|
2632
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(EditFolderContent, { ...restProps, onClose, open }) }) });
|
|
2860
2633
|
};
|
|
2861
|
-
|
|
2862
|
-
folder: FolderDefinition,
|
|
2863
|
-
location: PropTypes__default.default.string,
|
|
2864
|
-
open: PropTypes__default.default.bool.isRequired,
|
|
2865
|
-
onClose: PropTypes__default.default.func.isRequired,
|
|
2866
|
-
parentFolderId: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number])
|
|
2867
|
-
};
|
|
2868
|
-
const useFolder = (id2, { enabled = true } = {}) => {
|
|
2634
|
+
const useFolder = (id, { enabled = true } = {}) => {
|
|
2869
2635
|
const { toggleNotification } = strapiAdmin.useNotification();
|
|
2870
2636
|
const { get } = strapiAdmin.useFetchClient();
|
|
2871
2637
|
const { formatMessage } = reactIntl.useIntl();
|
|
2872
2638
|
const { data, error, isLoading } = reactQuery.useQuery(
|
|
2873
|
-
[pluginId, "folder",
|
|
2639
|
+
[pluginId, "folder", id],
|
|
2874
2640
|
async () => {
|
|
2875
2641
|
const {
|
|
2876
2642
|
data: { data: data2 }
|
|
2877
|
-
} = await get(`/upload/folders/${
|
|
2643
|
+
} = await get(`/upload/folders/${id}`, {
|
|
2878
2644
|
params: {
|
|
2879
2645
|
populate: {
|
|
2880
2646
|
parent: {
|
|
@@ -2927,14 +2693,14 @@ const CardContainer = styledComponents.styled(designSystem.Card)`
|
|
|
2927
2693
|
const AssetCardBase = ({
|
|
2928
2694
|
children,
|
|
2929
2695
|
extension,
|
|
2930
|
-
isSelectable: isSelectable2,
|
|
2696
|
+
isSelectable: isSelectable2 = true,
|
|
2931
2697
|
name: name2,
|
|
2932
2698
|
onSelect,
|
|
2933
2699
|
onRemove,
|
|
2934
2700
|
onEdit,
|
|
2935
|
-
selected,
|
|
2936
|
-
subtitle,
|
|
2937
|
-
variant
|
|
2701
|
+
selected = false,
|
|
2702
|
+
subtitle = "",
|
|
2703
|
+
variant = "Image"
|
|
2938
2704
|
}) => {
|
|
2939
2705
|
const { formatMessage } = reactIntl.useIntl();
|
|
2940
2706
|
const handleClick = (e) => {
|
|
@@ -2947,8 +2713,7 @@ const AssetCardBase = ({
|
|
|
2947
2713
|
};
|
|
2948
2714
|
return /* @__PURE__ */ jsxRuntime.jsxs(CardContainer, { role: "button", height: "100%", tabIndex: -1, onClick: handleClick, children: [
|
|
2949
2715
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardHeader, { children: [
|
|
2950
|
-
isSelectable2 &&
|
|
2951
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { onClick: handlePropagationClick, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardCheckbox, { checked: selected, onCheckedChange: onSelect }) }),
|
|
2716
|
+
isSelectable2 && /* @__PURE__ */ jsxRuntime.jsx("div", { onClick: handlePropagationClick, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardCheckbox, { checked: selected, onCheckedChange: onSelect }) }),
|
|
2952
2717
|
(onRemove || onEdit) && /* @__PURE__ */ jsxRuntime.jsxs(CardActionsContainer, { onClick: handlePropagationClick, position: "end", children: [
|
|
2953
2718
|
onRemove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2954
2719
|
designSystem.IconButton,
|
|
@@ -2974,7 +2739,7 @@ const AssetCardBase = ({
|
|
|
2974
2739
|
] }),
|
|
2975
2740
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardBody, { children: [
|
|
2976
2741
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardContent, { children: [
|
|
2977
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
|
2742
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardTitle, { tag: "span", children: name2 }) }) }),
|
|
2978
2743
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardSubtitle, { children: [
|
|
2979
2744
|
/* @__PURE__ */ jsxRuntime.jsx(Extension$1, { children: extension }),
|
|
2980
2745
|
subtitle
|
|
@@ -2987,36 +2752,9 @@ const AssetCardBase = ({
|
|
|
2987
2752
|
] })
|
|
2988
2753
|
] });
|
|
2989
2754
|
};
|
|
2990
|
-
AssetCardBase.defaultProps = {
|
|
2991
|
-
children: void 0,
|
|
2992
|
-
isSelectable: true,
|
|
2993
|
-
onEdit: void 0,
|
|
2994
|
-
onSelect: void 0,
|
|
2995
|
-
onRemove: void 0,
|
|
2996
|
-
selected: false,
|
|
2997
|
-
subtitle: "",
|
|
2998
|
-
variant: "Image"
|
|
2999
|
-
};
|
|
3000
|
-
AssetCardBase.propTypes = {
|
|
3001
|
-
children: PropTypes__default.default.node,
|
|
3002
|
-
extension: PropTypes__default.default.string.isRequired,
|
|
3003
|
-
isSelectable: PropTypes__default.default.bool,
|
|
3004
|
-
name: PropTypes__default.default.string.isRequired,
|
|
3005
|
-
onEdit: PropTypes__default.default.func,
|
|
3006
|
-
onSelect: PropTypes__default.default.func,
|
|
3007
|
-
onRemove: PropTypes__default.default.func,
|
|
3008
|
-
selected: PropTypes__default.default.bool,
|
|
3009
|
-
subtitle: PropTypes__default.default.string,
|
|
3010
|
-
variant: PropTypes__default.default.oneOf(["Image", "Video", "Audio", "Doc"])
|
|
3011
|
-
};
|
|
3012
2755
|
const AudioPreview = ({ url, alt }) => {
|
|
3013
2756
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx("audio", { controls: true, src: url, children: alt }) });
|
|
3014
2757
|
};
|
|
3015
|
-
AudioPreview.defaultProps = {};
|
|
3016
|
-
AudioPreview.propTypes = {
|
|
3017
|
-
alt: PropTypes__default.default.string.isRequired,
|
|
3018
|
-
url: PropTypes__default.default.string.isRequired
|
|
3019
|
-
};
|
|
3020
2758
|
const AudioPreviewWrapper$1 = styledComponents.styled(designSystem.Box)`
|
|
3021
2759
|
canvas,
|
|
3022
2760
|
audio {
|
|
@@ -3025,25 +2763,14 @@ const AudioPreviewWrapper$1 = styledComponents.styled(designSystem.Box)`
|
|
|
3025
2763
|
max-height: ${({ size }) => size === "M" ? 16.4 : 8.8}rem;
|
|
3026
2764
|
}
|
|
3027
2765
|
`;
|
|
3028
|
-
const AudioAssetCard = ({
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
selected:
|
|
3036
|
-
size: "M"
|
|
3037
|
-
};
|
|
3038
|
-
AudioAssetCard.propTypes = {
|
|
3039
|
-
extension: PropTypes__default.default.string.isRequired,
|
|
3040
|
-
name: PropTypes__default.default.string.isRequired,
|
|
3041
|
-
onSelect: PropTypes__default.default.func,
|
|
3042
|
-
onEdit: PropTypes__default.default.func,
|
|
3043
|
-
onRemove: PropTypes__default.default.func,
|
|
3044
|
-
url: PropTypes__default.default.string.isRequired,
|
|
3045
|
-
selected: PropTypes__default.default.bool,
|
|
3046
|
-
size: PropTypes__default.default.oneOf(["S", "M"])
|
|
2766
|
+
const AudioAssetCard = ({
|
|
2767
|
+
name: name2,
|
|
2768
|
+
url,
|
|
2769
|
+
size = "M",
|
|
2770
|
+
selected = false,
|
|
2771
|
+
...restProps
|
|
2772
|
+
}) => {
|
|
2773
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AssetCardBase, { name: name2, selected, ...restProps, variant: "Audio", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardAsset, { size, children: /* @__PURE__ */ jsxRuntime.jsx(AudioPreviewWrapper$1, { size, children: /* @__PURE__ */ jsxRuntime.jsx(AudioPreview, { url, alt: name2 }) }) }) });
|
|
3047
2774
|
};
|
|
3048
2775
|
const IconWrapper$1 = styledComponents.styled.span`
|
|
3049
2776
|
svg {
|
|
@@ -3054,99 +2781,82 @@ const CardAsset = styledComponents.styled(designSystem.Flex)`
|
|
|
3054
2781
|
border-radius: ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius} 0 0;
|
|
3055
2782
|
background: linear-gradient(180deg, #ffffff 0%, #f6f6f9 121.48%);
|
|
3056
2783
|
`;
|
|
3057
|
-
const DocAssetCard = ({
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
selected
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
2784
|
+
const DocAssetCard = ({
|
|
2785
|
+
name: name2,
|
|
2786
|
+
extension,
|
|
2787
|
+
size = "M",
|
|
2788
|
+
selected = false,
|
|
2789
|
+
...restProps
|
|
2790
|
+
}) => {
|
|
2791
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2792
|
+
AssetCardBase,
|
|
2793
|
+
{
|
|
2794
|
+
name: name2,
|
|
2795
|
+
extension,
|
|
2796
|
+
selected,
|
|
2797
|
+
...restProps,
|
|
2798
|
+
variant: "Doc",
|
|
2799
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(CardAsset, { width: "100%", height: size === "S" ? `8.8rem` : `16.4rem`, justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(IconWrapper$1, { children: extension === "pdf" ? /* @__PURE__ */ jsxRuntime.jsx(icons.FilePdf, { "aria-label": name2 }) : /* @__PURE__ */ jsxRuntime.jsx(icons.File, { "aria-label": name2 }) }) })
|
|
2800
|
+
}
|
|
2801
|
+
);
|
|
3075
2802
|
};
|
|
3076
|
-
const ImageAssetCard = ({
|
|
2803
|
+
const ImageAssetCard = ({
|
|
2804
|
+
height,
|
|
2805
|
+
width,
|
|
2806
|
+
thumbnail,
|
|
2807
|
+
size = "M",
|
|
2808
|
+
alt,
|
|
2809
|
+
isUrlSigned,
|
|
2810
|
+
selected = false,
|
|
2811
|
+
...props
|
|
2812
|
+
}) => {
|
|
3077
2813
|
const thumbnailUrl = isUrlSigned ? thumbnail : appendSearchParamsToUrl({
|
|
3078
2814
|
url: thumbnail,
|
|
3079
2815
|
params: { updatedAt: props.updatedAt }
|
|
3080
2816
|
});
|
|
3081
|
-
|
|
3082
|
-
};
|
|
3083
|
-
ImageAssetCard.defaultProps = {
|
|
3084
|
-
height: void 0,
|
|
3085
|
-
width: void 0,
|
|
3086
|
-
selected: false,
|
|
3087
|
-
onEdit: void 0,
|
|
3088
|
-
onSelect: void 0,
|
|
3089
|
-
onRemove: void 0,
|
|
3090
|
-
size: "M",
|
|
3091
|
-
updatedAt: void 0
|
|
3092
|
-
};
|
|
3093
|
-
ImageAssetCard.propTypes = {
|
|
3094
|
-
alt: PropTypes__default.default.string.isRequired,
|
|
3095
|
-
extension: PropTypes__default.default.string.isRequired,
|
|
3096
|
-
height: PropTypes__default.default.number,
|
|
3097
|
-
name: PropTypes__default.default.string.isRequired,
|
|
3098
|
-
onEdit: PropTypes__default.default.func,
|
|
3099
|
-
onSelect: PropTypes__default.default.func,
|
|
3100
|
-
onRemove: PropTypes__default.default.func,
|
|
3101
|
-
width: PropTypes__default.default.number,
|
|
3102
|
-
thumbnail: PropTypes__default.default.string.isRequired,
|
|
3103
|
-
selected: PropTypes__default.default.bool,
|
|
3104
|
-
size: PropTypes__default.default.oneOf(["S", "M"]),
|
|
3105
|
-
updatedAt: PropTypes__default.default.string,
|
|
3106
|
-
isUrlSigned: PropTypes__default.default.bool.isRequired
|
|
2817
|
+
const subtitle = height && width ? ` - ${width}✕${height}` : void 0;
|
|
2818
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AssetCardBase, { ...props, selected, subtitle, variant: "Image", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardAsset, { src: thumbnailUrl, size, alt }) });
|
|
3107
2819
|
};
|
|
3108
2820
|
const HAVE_FUTURE_DATA = 3;
|
|
3109
|
-
const VideoPreview = ({
|
|
2821
|
+
const VideoPreview = ({
|
|
2822
|
+
url,
|
|
2823
|
+
mime,
|
|
2824
|
+
onLoadDuration = () => {
|
|
2825
|
+
},
|
|
2826
|
+
alt,
|
|
2827
|
+
...props
|
|
2828
|
+
}) => {
|
|
3110
2829
|
const handleTimeUpdate = (e) => {
|
|
3111
|
-
if (e.
|
|
3112
|
-
const video = e.
|
|
2830
|
+
if (e.currentTarget.currentTime > 0) {
|
|
2831
|
+
const video = e.currentTarget;
|
|
3113
2832
|
const canvas = document.createElement("canvas");
|
|
3114
2833
|
canvas.height = video.videoHeight;
|
|
3115
2834
|
canvas.width = video.videoWidth;
|
|
3116
|
-
canvas.getContext("2d")
|
|
2835
|
+
canvas.getContext("2d")?.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
3117
2836
|
video.replaceWith(canvas);
|
|
3118
|
-
onLoadDuration(video.duration);
|
|
2837
|
+
onLoadDuration && onLoadDuration(video.duration);
|
|
3119
2838
|
}
|
|
3120
2839
|
};
|
|
3121
2840
|
const handleThumbnailVisibility = (e) => {
|
|
3122
|
-
const video = e.
|
|
2841
|
+
const video = e.currentTarget;
|
|
3123
2842
|
if (video.readyState < HAVE_FUTURE_DATA)
|
|
3124
2843
|
return;
|
|
3125
2844
|
video.play();
|
|
3126
2845
|
};
|
|
3127
|
-
return /* @__PURE__ */
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
},
|
|
3142
|
-
size: "M"
|
|
3143
|
-
};
|
|
3144
|
-
VideoPreview.propTypes = {
|
|
3145
|
-
alt: PropTypes__default.default.string.isRequired,
|
|
3146
|
-
url: PropTypes__default.default.string.isRequired,
|
|
3147
|
-
mime: PropTypes__default.default.string.isRequired,
|
|
3148
|
-
onLoadDuration: PropTypes__default.default.func,
|
|
3149
|
-
size: PropTypes__default.default.oneOf(["S", "M"])
|
|
2846
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { tag: "figure", ...props, children: [
|
|
2847
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2848
|
+
"video",
|
|
2849
|
+
{
|
|
2850
|
+
muted: true,
|
|
2851
|
+
onLoadedData: handleThumbnailVisibility,
|
|
2852
|
+
src: url,
|
|
2853
|
+
crossOrigin: "anonymous",
|
|
2854
|
+
onTimeUpdate: handleTimeUpdate,
|
|
2855
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("source", { type: mime })
|
|
2856
|
+
}
|
|
2857
|
+
),
|
|
2858
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "figcaption", children: alt })
|
|
2859
|
+
] }, url);
|
|
3150
2860
|
};
|
|
3151
2861
|
const VideoPreviewWrapper$2 = styledComponents.styled(designSystem.Box)`
|
|
3152
2862
|
canvas,
|
|
@@ -3157,39 +2867,35 @@ const VideoPreviewWrapper$2 = styledComponents.styled(designSystem.Box)`
|
|
|
3157
2867
|
max-height: ${({ size }) => size === "M" ? 16.4 : 8.8}rem;
|
|
3158
2868
|
}
|
|
3159
2869
|
`;
|
|
3160
|
-
const VideoAssetCard = ({
|
|
3161
|
-
|
|
2870
|
+
const VideoAssetCard = ({
|
|
2871
|
+
name: name2,
|
|
2872
|
+
url,
|
|
2873
|
+
mime,
|
|
2874
|
+
size = "M",
|
|
2875
|
+
selected = false,
|
|
2876
|
+
...props
|
|
2877
|
+
}) => {
|
|
2878
|
+
const [duration, setDuration] = React__namespace.useState();
|
|
3162
2879
|
const formattedDuration = duration && formatDuration(duration);
|
|
3163
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(AssetCardBase, { name: name2, ...props, variant: "Video", children: [
|
|
2880
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(AssetCardBase, { selected, name: name2, ...props, variant: "Video", children: [
|
|
3164
2881
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.CardAsset, { size, children: /* @__PURE__ */ jsxRuntime.jsx(VideoPreviewWrapper$2, { size, children: /* @__PURE__ */ jsxRuntime.jsx(VideoPreview, { url, mime, onLoadDuration: setDuration, alt: name2 }) }) }),
|
|
3165
2882
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.CardTimer, { children: formattedDuration || "..." })
|
|
3166
2883
|
] });
|
|
3167
2884
|
};
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
mime: PropTypes__default.default.string.isRequired,
|
|
3178
|
-
name: PropTypes__default.default.string.isRequired,
|
|
3179
|
-
onSelect: PropTypes__default.default.func,
|
|
3180
|
-
onEdit: PropTypes__default.default.func,
|
|
3181
|
-
onRemove: PropTypes__default.default.func,
|
|
3182
|
-
url: PropTypes__default.default.string.isRequired,
|
|
3183
|
-
selected: PropTypes__default.default.bool,
|
|
3184
|
-
size: PropTypes__default.default.oneOf(["S", "M"])
|
|
3185
|
-
};
|
|
3186
|
-
const AssetCard = ({ asset, isSelected, onSelect, onEdit, onRemove, size, local }) => {
|
|
2885
|
+
const AssetCard = ({
|
|
2886
|
+
asset,
|
|
2887
|
+
isSelected = false,
|
|
2888
|
+
onSelect,
|
|
2889
|
+
onEdit,
|
|
2890
|
+
onRemove,
|
|
2891
|
+
size = "M",
|
|
2892
|
+
local = false
|
|
2893
|
+
}) => {
|
|
3187
2894
|
const handleSelect = onSelect ? () => onSelect(asset) : void 0;
|
|
3188
2895
|
const commonAssetCardProps = {
|
|
3189
2896
|
id: asset.id,
|
|
3190
2897
|
isSelectable: asset.isSelectable,
|
|
3191
2898
|
extension: getFileExtension(asset.ext),
|
|
3192
|
-
key: asset.id,
|
|
3193
2899
|
name: asset.name,
|
|
3194
2900
|
url: local ? asset.url : createAssetUrl(asset, true),
|
|
3195
2901
|
mime: asset.mime,
|
|
@@ -3199,64 +2905,46 @@ const AssetCard = ({ asset, isSelected, onSelect, onEdit, onRemove, size, local
|
|
|
3199
2905
|
selected: isSelected,
|
|
3200
2906
|
size
|
|
3201
2907
|
};
|
|
3202
|
-
if (asset.mime
|
|
2908
|
+
if (asset.mime?.includes(AssetType.Video)) {
|
|
3203
2909
|
return /* @__PURE__ */ jsxRuntime.jsx(VideoAssetCard, { ...commonAssetCardProps });
|
|
3204
2910
|
}
|
|
3205
|
-
if (asset.mime
|
|
2911
|
+
if (asset.mime?.includes(AssetType.Image)) {
|
|
3206
2912
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3207
2913
|
ImageAssetCard,
|
|
3208
2914
|
{
|
|
3209
|
-
...commonAssetCardProps,
|
|
3210
2915
|
alt: asset.alternativeText || asset.name,
|
|
3211
2916
|
height: asset.height,
|
|
3212
2917
|
thumbnail: prefixFileUrlWithBackendUrl(asset?.formats?.thumbnail?.url || asset.url),
|
|
3213
2918
|
width: asset.width,
|
|
3214
2919
|
updatedAt: asset.updatedAt,
|
|
3215
|
-
isUrlSigned: asset?.isUrlSigned || false
|
|
2920
|
+
isUrlSigned: asset?.isUrlSigned || false,
|
|
2921
|
+
...commonAssetCardProps
|
|
3216
2922
|
}
|
|
3217
2923
|
);
|
|
3218
2924
|
}
|
|
3219
|
-
if (asset.mime
|
|
2925
|
+
if (asset.mime?.includes(AssetType.Audio)) {
|
|
3220
2926
|
return /* @__PURE__ */ jsxRuntime.jsx(AudioAssetCard, { ...commonAssetCardProps });
|
|
3221
2927
|
}
|
|
3222
2928
|
return /* @__PURE__ */ jsxRuntime.jsx(DocAssetCard, { ...commonAssetCardProps });
|
|
3223
2929
|
};
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
// Determine if the asset is loaded locally or from a remote resource
|
|
3227
|
-
local: false,
|
|
3228
|
-
onSelect: void 0,
|
|
3229
|
-
onEdit: void 0,
|
|
3230
|
-
onRemove: void 0,
|
|
3231
|
-
size: "M"
|
|
3232
|
-
};
|
|
3233
|
-
AssetCard.propTypes = {
|
|
3234
|
-
asset: AssetDefinition.isRequired,
|
|
3235
|
-
local: PropTypes__default.default.bool,
|
|
3236
|
-
onSelect: PropTypes__default.default.func,
|
|
3237
|
-
onEdit: PropTypes__default.default.func,
|
|
3238
|
-
onRemove: PropTypes__default.default.func,
|
|
3239
|
-
isSelected: PropTypes__default.default.bool,
|
|
3240
|
-
size: PropTypes__default.default.oneOf(["S", "M"])
|
|
3241
|
-
};
|
|
3242
|
-
const Draggable = ({ children, id: id2, index: index2, moveItem }) => {
|
|
3243
|
-
const ref = React.useRef(null);
|
|
2930
|
+
const Draggable = ({ children, id, index, moveItem }) => {
|
|
2931
|
+
const ref = React__namespace.useRef(null);
|
|
3244
2932
|
const [, drop] = reactDnd.useDrop({
|
|
3245
2933
|
accept: "draggable",
|
|
3246
2934
|
hover(hoveredOverItem) {
|
|
3247
2935
|
if (!ref.current) {
|
|
3248
2936
|
return;
|
|
3249
2937
|
}
|
|
3250
|
-
if (hoveredOverItem.id !==
|
|
3251
|
-
moveItem(hoveredOverItem.index,
|
|
3252
|
-
hoveredOverItem.index =
|
|
2938
|
+
if (hoveredOverItem.id !== id) {
|
|
2939
|
+
moveItem(hoveredOverItem.index, index);
|
|
2940
|
+
hoveredOverItem.index = index;
|
|
3253
2941
|
}
|
|
3254
2942
|
}
|
|
3255
2943
|
});
|
|
3256
2944
|
const [{ isDragging }, drag] = reactDnd.useDrag({
|
|
3257
2945
|
type: "draggable",
|
|
3258
2946
|
item() {
|
|
3259
|
-
return { index
|
|
2947
|
+
return { index, id };
|
|
3260
2948
|
},
|
|
3261
2949
|
collect: (monitor) => ({
|
|
3262
2950
|
isDragging: monitor.isDragging()
|
|
@@ -3266,28 +2954,22 @@ const Draggable = ({ children, id: id2, index: index2, moveItem }) => {
|
|
|
3266
2954
|
drag(drop(ref));
|
|
3267
2955
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, style: { opacity, cursor: "move" }, children });
|
|
3268
2956
|
};
|
|
3269
|
-
Draggable.propTypes = {
|
|
3270
|
-
id: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number]).isRequired,
|
|
3271
|
-
index: PropTypes__default.default.number.isRequired,
|
|
3272
|
-
children: PropTypes__default.default.node.isRequired,
|
|
3273
|
-
moveItem: PropTypes__default.default.func.isRequired
|
|
3274
|
-
};
|
|
3275
2957
|
const AssetGridList = ({
|
|
3276
|
-
allowedTypes,
|
|
2958
|
+
allowedTypes = ["files", "images", "videos", "audios"],
|
|
3277
2959
|
assets,
|
|
3278
2960
|
onEditAsset,
|
|
3279
2961
|
onSelectAsset,
|
|
3280
2962
|
selectedAssets,
|
|
3281
|
-
size,
|
|
2963
|
+
size = "M",
|
|
3282
2964
|
onReorderAsset,
|
|
3283
|
-
title
|
|
2965
|
+
title = null
|
|
3284
2966
|
}) => {
|
|
3285
2967
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.KeyboardNavigable, { tagName: "article", children: [
|
|
3286
2968
|
title && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, paddingBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "delta", fontWeight: "semiBold", children: title }) }),
|
|
3287
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: assets.map((asset,
|
|
2969
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: assets.map((asset, index) => {
|
|
3288
2970
|
const isSelected = !!selectedAssets.find((currentAsset) => currentAsset.id === asset.id);
|
|
3289
2971
|
if (onReorderAsset) {
|
|
3290
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 3, height: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(Draggable, { index
|
|
2972
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 3, height: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(Draggable, { index, moveItem: onReorderAsset, id: asset.id, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3291
2973
|
AssetCard,
|
|
3292
2974
|
{
|
|
3293
2975
|
allowedTypes,
|
|
@@ -3314,32 +2996,19 @@ const AssetGridList = ({
|
|
|
3314
2996
|
}) })
|
|
3315
2997
|
] });
|
|
3316
2998
|
};
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
};
|
|
3324
|
-
AssetGridList.propTypes = {
|
|
3325
|
-
allowedTypes: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
|
|
3326
|
-
assets: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({})).isRequired,
|
|
3327
|
-
onEditAsset: PropTypes__default.default.func,
|
|
3328
|
-
onSelectAsset: PropTypes__default.default.func.isRequired,
|
|
3329
|
-
selectedAssets: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({})).isRequired,
|
|
3330
|
-
size: PropTypes__default.default.oneOf(["S", "M"]),
|
|
3331
|
-
onReorderAsset: PropTypes__default.default.func,
|
|
3332
|
-
title: PropTypes__default.default.string
|
|
3333
|
-
};
|
|
3334
|
-
const CrumbSimpleMenuAsync = ({ parentsToOmit, currentFolderId, onChangeFolder }) => {
|
|
3335
|
-
const [shouldFetch, setShouldFetch] = React.useState(false);
|
|
2999
|
+
const CrumbSimpleMenuAsync = ({
|
|
3000
|
+
parentsToOmit = [],
|
|
3001
|
+
currentFolderId,
|
|
3002
|
+
onChangeFolder
|
|
3003
|
+
}) => {
|
|
3004
|
+
const [shouldFetch, setShouldFetch] = React__namespace.useState(false);
|
|
3336
3005
|
const { data, isLoading } = useFolderStructure({ enabled: shouldFetch });
|
|
3337
3006
|
const { pathname } = reactRouterDom.useLocation();
|
|
3338
3007
|
const [{ query }] = strapiAdmin.useQueryParams();
|
|
3339
3008
|
const { formatMessage } = reactIntl.useIntl();
|
|
3340
3009
|
const allAscendants = data && getFolderParents(data, currentFolderId);
|
|
3341
3010
|
const filteredAscendants = allAscendants && allAscendants.filter(
|
|
3342
|
-
(ascendant) => !parentsToOmit.includes(ascendant.id) && ascendant.id !== null
|
|
3011
|
+
(ascendant) => typeof ascendant.id === "number" && !parentsToOmit.includes(ascendant.id) && ascendant.id !== null
|
|
3343
3012
|
);
|
|
3344
3013
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3345
3014
|
designSystem.CrumbSimpleMenu,
|
|
@@ -3363,40 +3032,35 @@ const CrumbSimpleMenuAsync = ({ parentsToOmit, currentFolderId, onChangeFolder }
|
|
|
3363
3032
|
{
|
|
3364
3033
|
tag: "button",
|
|
3365
3034
|
type: "button",
|
|
3366
|
-
onClick: () => onChangeFolder(ascendant.id, ascendant.path),
|
|
3035
|
+
onClick: () => onChangeFolder(Number(ascendant.id), ascendant.path),
|
|
3367
3036
|
children: ascendant.label
|
|
3368
3037
|
},
|
|
3369
3038
|
ascendant.id
|
|
3370
3039
|
);
|
|
3371
3040
|
}
|
|
3372
3041
|
const url = getFolderURL(pathname, query, {
|
|
3373
|
-
folder: ascendant?.id,
|
|
3042
|
+
folder: typeof ascendant?.id === "string" ? ascendant.id : void 0,
|
|
3374
3043
|
folderPath: ascendant?.path
|
|
3375
3044
|
});
|
|
3376
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { isLink: true,
|
|
3045
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { isLink: true, href: url, children: ascendant.label }, ascendant.id);
|
|
3377
3046
|
})
|
|
3378
3047
|
]
|
|
3379
3048
|
}
|
|
3380
|
-
);
|
|
3381
|
-
};
|
|
3382
|
-
CrumbSimpleMenuAsync.defaultProps = {
|
|
3383
|
-
currentFolderId: void 0,
|
|
3384
|
-
onChangeFolder: void 0,
|
|
3385
|
-
parentsToOmit: []
|
|
3386
|
-
};
|
|
3387
|
-
CrumbSimpleMenuAsync.propTypes = {
|
|
3388
|
-
currentFolderId: PropTypes__default.default.number,
|
|
3389
|
-
onChangeFolder: PropTypes__default.default.func,
|
|
3390
|
-
parentsToOmit: PropTypes__default.default.arrayOf(PropTypes__default.default.number)
|
|
3049
|
+
);
|
|
3391
3050
|
};
|
|
3392
|
-
const Breadcrumbs = ({
|
|
3051
|
+
const Breadcrumbs = ({
|
|
3052
|
+
breadcrumbs,
|
|
3053
|
+
onChangeFolder,
|
|
3054
|
+
currentFolderId,
|
|
3055
|
+
...props
|
|
3056
|
+
}) => {
|
|
3393
3057
|
const { formatMessage } = reactIntl.useIntl();
|
|
3394
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Breadcrumbs, { ...props, children: breadcrumbs.map((crumb,
|
|
3058
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Breadcrumbs, { ...props, children: breadcrumbs.map((crumb, index) => {
|
|
3395
3059
|
if (Array.isArray(crumb)) {
|
|
3396
3060
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3397
3061
|
CrumbSimpleMenuAsync,
|
|
3398
3062
|
{
|
|
3399
|
-
parentsToOmit: [...breadcrumbs].splice(
|
|
3063
|
+
parentsToOmit: [...breadcrumbs].splice(index + 1, breadcrumbs.length - 1).map((parent) => parent.id),
|
|
3400
3064
|
currentFolderId,
|
|
3401
3065
|
onChangeFolder
|
|
3402
3066
|
},
|
|
@@ -3405,14 +3069,23 @@ const Breadcrumbs = ({ breadcrumbs, onChangeFolder, currentFolderId, ...props })
|
|
|
3405
3069
|
}
|
|
3406
3070
|
const isCurrentFolderMediaLibrary = crumb.id === null && currentFolderId === void 0;
|
|
3407
3071
|
if (currentFolderId !== crumb.id && !isCurrentFolderMediaLibrary) {
|
|
3072
|
+
if (onChangeFolder) {
|
|
3073
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3074
|
+
designSystem.CrumbLink,
|
|
3075
|
+
{
|
|
3076
|
+
type: "button",
|
|
3077
|
+
onClick: () => onChangeFolder(crumb.id, crumb.path),
|
|
3078
|
+
children: typeof crumb.label !== "string" && crumb.label?.id ? formatMessage(crumb.label) : crumb.label
|
|
3079
|
+
},
|
|
3080
|
+
`breadcrumb-${crumb?.id ?? "root"}`
|
|
3081
|
+
);
|
|
3082
|
+
}
|
|
3408
3083
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3409
3084
|
designSystem.CrumbLink,
|
|
3410
3085
|
{
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
onClick: onChangeFolder && (() => onChangeFolder(crumb.id, crumb.path)),
|
|
3415
|
-
children: crumb.label?.id ? formatMessage(crumb.label) : crumb.label
|
|
3086
|
+
to: crumb.href,
|
|
3087
|
+
tag: reactRouterDom.Link,
|
|
3088
|
+
children: typeof crumb.label !== "string" && crumb.label?.id ? formatMessage(crumb.label) : crumb.label
|
|
3416
3089
|
},
|
|
3417
3090
|
`breadcrumb-${crumb?.id ?? "root"}`
|
|
3418
3091
|
);
|
|
@@ -3420,22 +3093,13 @@ const Breadcrumbs = ({ breadcrumbs, onChangeFolder, currentFolderId, ...props })
|
|
|
3420
3093
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3421
3094
|
designSystem.Crumb,
|
|
3422
3095
|
{
|
|
3423
|
-
isCurrent:
|
|
3424
|
-
children: crumb.label?.id ? formatMessage(crumb.label) : crumb.label
|
|
3096
|
+
isCurrent: index + 1 === breadcrumbs.length,
|
|
3097
|
+
children: typeof crumb.label !== "string" && crumb.label?.id ? formatMessage(crumb.label) : crumb.label
|
|
3425
3098
|
},
|
|
3426
3099
|
`breadcrumb-${crumb?.id ?? "root"}`
|
|
3427
3100
|
);
|
|
3428
3101
|
}) });
|
|
3429
3102
|
};
|
|
3430
|
-
Breadcrumbs.defaultProps = {
|
|
3431
|
-
currentFolderId: void 0,
|
|
3432
|
-
onChangeFolder: void 0
|
|
3433
|
-
};
|
|
3434
|
-
Breadcrumbs.propTypes = {
|
|
3435
|
-
breadcrumbs: BreadcrumbsDefinition.isRequired,
|
|
3436
|
-
currentFolderId: PropTypes__default.default.number,
|
|
3437
|
-
onChangeFolder: PropTypes__default.default.func
|
|
3438
|
-
};
|
|
3439
3103
|
const EmptyAssetCard = styledComponents.styled(designSystem.Box)`
|
|
3440
3104
|
background: linear-gradient(
|
|
3441
3105
|
180deg,
|
|
@@ -3458,11 +3122,13 @@ const EmptyAssetGrid = ({ count, size }) => {
|
|
|
3458
3122
|
`empty-asset-card-${idx}`
|
|
3459
3123
|
)) });
|
|
3460
3124
|
};
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3125
|
+
const EmptyAssets = ({
|
|
3126
|
+
icon: Icon = symbols.EmptyDocuments,
|
|
3127
|
+
content,
|
|
3128
|
+
action,
|
|
3129
|
+
size = "M",
|
|
3130
|
+
count = 12
|
|
3131
|
+
}) => {
|
|
3466
3132
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { position: "relative", children: [
|
|
3467
3133
|
/* @__PURE__ */ jsxRuntime.jsx(EmptyAssetGrid, { size, count }),
|
|
3468
3134
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { position: "absolute", top: 11, width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 4, textAlign: "center", children: [
|
|
@@ -3474,29 +3140,10 @@ const EmptyAssets = ({ icon: Icon = symbols.EmptyDocuments, content, action, siz
|
|
|
3474
3140
|
] }) })
|
|
3475
3141
|
] });
|
|
3476
3142
|
};
|
|
3477
|
-
EmptyAssets.defaultProps = {
|
|
3478
|
-
action: void 0,
|
|
3479
|
-
icon: void 0,
|
|
3480
|
-
size: "M",
|
|
3481
|
-
count: 12
|
|
3482
|
-
};
|
|
3483
|
-
EmptyAssets.propTypes = {
|
|
3484
|
-
action: PropTypes__default.default.node,
|
|
3485
|
-
icon: PropTypes__default.default.elementType,
|
|
3486
|
-
content: PropTypes__default.default.string.isRequired,
|
|
3487
|
-
size: PropTypes__default.default.string,
|
|
3488
|
-
count: PropTypes__default.default.number
|
|
3489
|
-
};
|
|
3490
3143
|
const FolderCardContext = React.createContext({});
|
|
3491
3144
|
function useFolderCard() {
|
|
3492
3145
|
return React.useContext(FolderCardContext);
|
|
3493
3146
|
}
|
|
3494
|
-
let id = 0;
|
|
3495
|
-
const genId = () => ++id;
|
|
3496
|
-
const useId = (initialId) => {
|
|
3497
|
-
const idRef = React.useRef(`${initialId}-${genId()}`);
|
|
3498
|
-
return idRef.current;
|
|
3499
|
-
};
|
|
3500
3147
|
const FauxClickWrapper = styledComponents.styled.button`
|
|
3501
3148
|
height: 100%;
|
|
3502
3149
|
left: 0;
|
|
@@ -3526,16 +3173,24 @@ const Card = styledComponents.styled(designSystem.Box)`
|
|
|
3526
3173
|
}
|
|
3527
3174
|
}
|
|
3528
3175
|
`;
|
|
3529
|
-
const FolderCard =
|
|
3530
|
-
({
|
|
3531
|
-
|
|
3532
|
-
|
|
3176
|
+
const FolderCard = React__namespace.forwardRef(
|
|
3177
|
+
({
|
|
3178
|
+
children,
|
|
3179
|
+
startAction = null,
|
|
3180
|
+
cardActions = null,
|
|
3181
|
+
ariaLabel,
|
|
3182
|
+
onClick,
|
|
3183
|
+
to,
|
|
3184
|
+
...props
|
|
3185
|
+
}, ref) => {
|
|
3186
|
+
const generatedId = React__namespace.useId();
|
|
3187
|
+
const fodlerCtxValue = React__namespace.useMemo(() => ({ id: generatedId }), [generatedId]);
|
|
3533
3188
|
return /* @__PURE__ */ jsxRuntime.jsx(FolderCardContext.Provider, { value: fodlerCtxValue, children: /* @__PURE__ */ jsxRuntime.jsxs(Card, { position: "relative", tabIndex: 0, $isCardActions: !!cardActions, ref, ...props, children: [
|
|
3534
3189
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3535
3190
|
FauxClickWrapper,
|
|
3536
3191
|
{
|
|
3537
3192
|
to: to || void 0,
|
|
3538
|
-
|
|
3193
|
+
as: to ? reactRouterDom.NavLink : "button",
|
|
3539
3194
|
type: to ? void 0 : "button",
|
|
3540
3195
|
onClick,
|
|
3541
3196
|
tabIndex: -1,
|
|
@@ -3571,39 +3226,24 @@ const FolderCard = React.forwardRef(
|
|
|
3571
3226
|
}
|
|
3572
3227
|
),
|
|
3573
3228
|
children,
|
|
3574
|
-
/* @__PURE__ */ jsxRuntime.jsx(CardActionDisplay, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardAction, { right: 4, children: cardActions }) })
|
|
3229
|
+
/* @__PURE__ */ jsxRuntime.jsx(CardActionDisplay, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardAction, { right: 4, position: "end", children: cardActions }) })
|
|
3575
3230
|
]
|
|
3576
3231
|
}
|
|
3577
3232
|
)
|
|
3578
3233
|
] }) });
|
|
3579
3234
|
}
|
|
3580
3235
|
);
|
|
3581
|
-
FolderCard.defaultProps = {
|
|
3582
|
-
id: void 0,
|
|
3583
|
-
cardActions: null,
|
|
3584
|
-
startAction: null,
|
|
3585
|
-
to: void 0,
|
|
3586
|
-
onClick: void 0
|
|
3587
|
-
};
|
|
3588
|
-
FolderCard.propTypes = {
|
|
3589
|
-
ariaLabel: PropTypes__default.default.string.isRequired,
|
|
3590
|
-
children: PropTypes__default.default.node.isRequired,
|
|
3591
|
-
id: PropTypes__default.default.string,
|
|
3592
|
-
onClick: PropTypes__default.default.func,
|
|
3593
|
-
startAction: PropTypes__default.default.element,
|
|
3594
|
-
cardActions: PropTypes__default.default.element,
|
|
3595
|
-
to: PropTypes__default.default.string
|
|
3596
|
-
};
|
|
3597
3236
|
const StyledBox = styledComponents.styled(designSystem.Flex)`
|
|
3598
3237
|
user-select: none;
|
|
3599
3238
|
`;
|
|
3600
3239
|
const FolderCardBody = (props) => {
|
|
3601
|
-
const { id
|
|
3240
|
+
const { id } = useFolderCard();
|
|
3602
3241
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3603
3242
|
StyledBox,
|
|
3604
3243
|
{
|
|
3605
3244
|
...props,
|
|
3606
|
-
id: `${
|
|
3245
|
+
id: `${id}-title`,
|
|
3246
|
+
"data-testid": `${id}-title`,
|
|
3607
3247
|
alignItems: "flex-start",
|
|
3608
3248
|
direction: "column",
|
|
3609
3249
|
maxWidth: "100%",
|
|
@@ -3636,25 +3276,12 @@ const FolderCardBodyAction = ({ to, ...props }) => {
|
|
|
3636
3276
|
}
|
|
3637
3277
|
return /* @__PURE__ */ jsxRuntime.jsx(BoxOutline, { padding: 1, tag: "button", type: "button", maxWidth: "100%", ...props });
|
|
3638
3278
|
};
|
|
3639
|
-
|
|
3640
|
-
to: void 0
|
|
3641
|
-
};
|
|
3642
|
-
FolderCardBodyAction.propTypes = {
|
|
3643
|
-
to: PropTypes__default.default.string
|
|
3644
|
-
};
|
|
3645
|
-
const FolderGridList = ({ title, children }) => {
|
|
3279
|
+
const FolderGridList = ({ title = null, children }) => {
|
|
3646
3280
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.KeyboardNavigable, { tagName: "article", children: [
|
|
3647
3281
|
title && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "delta", fontWeight: "semiBold", children: title }) }),
|
|
3648
3282
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children })
|
|
3649
3283
|
] });
|
|
3650
3284
|
};
|
|
3651
|
-
FolderGridList.defaultProps = {
|
|
3652
|
-
title: null
|
|
3653
|
-
};
|
|
3654
|
-
FolderGridList.propTypes = {
|
|
3655
|
-
children: PropTypes__default.default.node.isRequired,
|
|
3656
|
-
title: PropTypes__default.default.string
|
|
3657
|
-
};
|
|
3658
3285
|
const SortPicker = ({ onChangeSort, value }) => {
|
|
3659
3286
|
const { formatMessage } = reactIntl.useIntl();
|
|
3660
3287
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3662,7 +3289,7 @@ const SortPicker = ({ onChangeSort, value }) => {
|
|
|
3662
3289
|
{
|
|
3663
3290
|
size: "S",
|
|
3664
3291
|
value,
|
|
3665
|
-
onChange: (value2) => onChangeSort(value2),
|
|
3292
|
+
onChange: (value2) => onChangeSort(value2.toString()),
|
|
3666
3293
|
"aria-label": formatMessage({
|
|
3667
3294
|
id: getTrad("sort.label"),
|
|
3668
3295
|
defaultMessage: "Sort by"
|
|
@@ -3675,13 +3302,6 @@ const SortPicker = ({ onChangeSort, value }) => {
|
|
|
3675
3302
|
}
|
|
3676
3303
|
);
|
|
3677
3304
|
};
|
|
3678
|
-
SortPicker.defaultProps = {
|
|
3679
|
-
value: void 0
|
|
3680
|
-
};
|
|
3681
|
-
SortPicker.propTypes = {
|
|
3682
|
-
onChangeSort: PropTypes__default.default.func.isRequired,
|
|
3683
|
-
value: PropTypes__default.default.string
|
|
3684
|
-
};
|
|
3685
3305
|
const VideoPreviewWrapper$1 = styledComponents.styled(designSystem.Box)`
|
|
3686
3306
|
figure {
|
|
3687
3307
|
width: ${({ theme }) => theme.spaces[7]};
|
|
@@ -3697,6 +3317,7 @@ const VideoPreviewWrapper$1 = styledComponents.styled(designSystem.Box)`
|
|
|
3697
3317
|
}
|
|
3698
3318
|
`;
|
|
3699
3319
|
const PreviewCell = ({ type, content }) => {
|
|
3320
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
3700
3321
|
if (type === "folder") {
|
|
3701
3322
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3702
3323
|
designSystem.Flex,
|
|
@@ -3706,20 +3327,39 @@ const PreviewCell = ({ type, content }) => {
|
|
|
3706
3327
|
width: "3.2rem",
|
|
3707
3328
|
height: "3.2rem",
|
|
3708
3329
|
borderRadius: "50%",
|
|
3709
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3330
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3331
|
+
icons.Folder,
|
|
3332
|
+
{
|
|
3333
|
+
"aria-label": formatMessage({
|
|
3334
|
+
id: getTrad("header.actions.add-assets.folder"),
|
|
3335
|
+
defaultMessage: "folder"
|
|
3336
|
+
}),
|
|
3337
|
+
fill: "secondary500",
|
|
3338
|
+
width: "1.6rem",
|
|
3339
|
+
height: "1.6rem"
|
|
3340
|
+
}
|
|
3341
|
+
)
|
|
3710
3342
|
}
|
|
3711
3343
|
);
|
|
3712
3344
|
}
|
|
3713
3345
|
const { alternativeText, ext, formats, mime, name: name2, url } = content;
|
|
3714
|
-
if (mime
|
|
3346
|
+
if (mime?.includes(AssetType.Image)) {
|
|
3715
3347
|
const mediaURL = prefixFileUrlWithBackendUrl(formats?.thumbnail?.url) ?? prefixFileUrlWithBackendUrl(url);
|
|
3716
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3348
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3349
|
+
designSystem.Avatar.Item,
|
|
3350
|
+
{
|
|
3351
|
+
src: mediaURL,
|
|
3352
|
+
alt: alternativeText || void 0,
|
|
3353
|
+
preview: true,
|
|
3354
|
+
fallback: alternativeText
|
|
3355
|
+
}
|
|
3356
|
+
);
|
|
3717
3357
|
}
|
|
3718
|
-
if (mime
|
|
3358
|
+
if (mime?.includes(AssetType.Video)) {
|
|
3719
3359
|
return /* @__PURE__ */ jsxRuntime.jsx(VideoPreviewWrapper$1, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3720
3360
|
VideoPreview,
|
|
3721
3361
|
{
|
|
3722
|
-
url: createAssetUrl(content, true),
|
|
3362
|
+
url: createAssetUrl(content, true) || "",
|
|
3723
3363
|
mime,
|
|
3724
3364
|
alt: alternativeText ?? name2
|
|
3725
3365
|
}
|
|
@@ -3727,28 +3367,16 @@ const PreviewCell = ({ type, content }) => {
|
|
|
3727
3367
|
}
|
|
3728
3368
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { background: "secondary100", color: "secondary600", width: "3.2rem", height: "3.2rem", children: getFileExtension(ext) });
|
|
3729
3369
|
};
|
|
3730
|
-
PreviewCell.propTypes = {
|
|
3731
|
-
content: PropTypes__default.default.shape({
|
|
3732
|
-
alternativeText: PropTypes__default.default.string,
|
|
3733
|
-
ext: PropTypes__default.default.string,
|
|
3734
|
-
formats: PropTypes__default.default.shape({
|
|
3735
|
-
thumbnail: PropTypes__default.default.shape({
|
|
3736
|
-
url: PropTypes__default.default.string
|
|
3737
|
-
})
|
|
3738
|
-
}),
|
|
3739
|
-
mime: PropTypes__default.default.string,
|
|
3740
|
-
name: PropTypes__default.default.string,
|
|
3741
|
-
url: PropTypes__default.default.string
|
|
3742
|
-
}).isRequired,
|
|
3743
|
-
type: PropTypes__default.default.string.isRequired
|
|
3744
|
-
};
|
|
3745
3370
|
const CellContent = ({ cellType, contentType, content, name: name2 }) => {
|
|
3746
3371
|
const { formatDate, formatMessage } = reactIntl.useIntl();
|
|
3372
|
+
const contentValue = content[name2];
|
|
3747
3373
|
switch (cellType) {
|
|
3748
3374
|
case "image":
|
|
3749
3375
|
return /* @__PURE__ */ jsxRuntime.jsx(PreviewCell, { type: contentType, content });
|
|
3750
3376
|
case "date":
|
|
3751
|
-
|
|
3377
|
+
if (typeof contentValue === "string") {
|
|
3378
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatDate(parseISO__default.default(contentValue), { dateStyle: "full" }) });
|
|
3379
|
+
}
|
|
3752
3380
|
case "size":
|
|
3753
3381
|
if (contentType === "folder")
|
|
3754
3382
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3761,7 +3389,9 @@ const CellContent = ({ cellType, contentType, content, name: name2 }) => {
|
|
|
3761
3389
|
children: "-"
|
|
3762
3390
|
}
|
|
3763
3391
|
);
|
|
3764
|
-
|
|
3392
|
+
if (typeof contentValue === "string" || typeof contentValue === "number") {
|
|
3393
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatBytes(contentValue) });
|
|
3394
|
+
}
|
|
3765
3395
|
case "ext":
|
|
3766
3396
|
if (contentType === "folder")
|
|
3767
3397
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3774,9 +3404,13 @@ const CellContent = ({ cellType, contentType, content, name: name2 }) => {
|
|
|
3774
3404
|
children: "-"
|
|
3775
3405
|
}
|
|
3776
3406
|
);
|
|
3777
|
-
|
|
3407
|
+
if (typeof contentValue === "string") {
|
|
3408
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFileExtension(contentValue)?.toUpperCase() });
|
|
3409
|
+
}
|
|
3778
3410
|
case "text":
|
|
3779
|
-
|
|
3411
|
+
if (typeof contentValue === "string") {
|
|
3412
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: contentValue });
|
|
3413
|
+
}
|
|
3780
3414
|
default:
|
|
3781
3415
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3782
3416
|
designSystem.Typography,
|
|
@@ -3790,135 +3424,126 @@ const CellContent = ({ cellType, contentType, content, name: name2 }) => {
|
|
|
3790
3424
|
);
|
|
3791
3425
|
}
|
|
3792
3426
|
};
|
|
3793
|
-
CellContent.propTypes = {
|
|
3794
|
-
cellType: PropTypes__default.default.string.isRequired,
|
|
3795
|
-
contentType: PropTypes__default.default.string.isRequired,
|
|
3796
|
-
content: PropTypes__default.default.shape({
|
|
3797
|
-
alternativeText: PropTypes__default.default.string,
|
|
3798
|
-
ext: PropTypes__default.default.string,
|
|
3799
|
-
formats: PropTypes__default.default.shape({
|
|
3800
|
-
thumbnail: PropTypes__default.default.shape({
|
|
3801
|
-
url: PropTypes__default.default.string
|
|
3802
|
-
})
|
|
3803
|
-
}),
|
|
3804
|
-
mime: PropTypes__default.default.string,
|
|
3805
|
-
url: PropTypes__default.default.string
|
|
3806
|
-
}).isRequired,
|
|
3807
|
-
name: PropTypes__default.default.string.isRequired
|
|
3808
|
-
};
|
|
3809
3427
|
const TableRows = ({
|
|
3810
|
-
onChangeFolder,
|
|
3428
|
+
onChangeFolder = null,
|
|
3811
3429
|
onEditAsset,
|
|
3812
3430
|
onEditFolder,
|
|
3813
3431
|
onSelectOne,
|
|
3814
|
-
rows,
|
|
3815
|
-
selected
|
|
3432
|
+
rows = [],
|
|
3433
|
+
selected = []
|
|
3816
3434
|
}) => {
|
|
3817
3435
|
const { formatMessage } = reactIntl.useIntl();
|
|
3818
|
-
const handleRowClickFn = (element,
|
|
3436
|
+
const handleRowClickFn = (element, id, path, elementType) => {
|
|
3819
3437
|
if (elementType === "asset") {
|
|
3820
3438
|
onEditAsset(element);
|
|
3821
3439
|
} else {
|
|
3822
|
-
onChangeFolder
|
|
3440
|
+
if (onChangeFolder) {
|
|
3441
|
+
onChangeFolder(id, path);
|
|
3442
|
+
}
|
|
3823
3443
|
}
|
|
3824
3444
|
};
|
|
3825
3445
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: rows.map((element) => {
|
|
3826
|
-
const { path, id
|
|
3446
|
+
const { path, id, isSelectable: isSelectable2, name: name2, folderURL, type: contentType } = element;
|
|
3827
3447
|
const isSelected = !!selected.find(
|
|
3828
|
-
(currentRow) => currentRow.id ===
|
|
3448
|
+
(currentRow) => currentRow.id === id && currentRow.type === contentType
|
|
3829
3449
|
);
|
|
3830
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3450
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3451
|
+
designSystem.Tr,
|
|
3452
|
+
{
|
|
3453
|
+
onClick: () => handleRowClickFn(element, id, path || void 0, contentType),
|
|
3454
|
+
children: [
|
|
3455
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3456
|
+
designSystem.Checkbox,
|
|
3835
3457
|
{
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
designSystem.
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3458
|
+
"aria-label": formatMessage(
|
|
3459
|
+
{
|
|
3460
|
+
id: contentType === "asset" ? "list-assets-select" : "list.folder.select",
|
|
3461
|
+
defaultMessage: contentType === "asset" ? "Select {name} asset" : "Select {name} folder"
|
|
3462
|
+
},
|
|
3463
|
+
{ name: name2 }
|
|
3464
|
+
),
|
|
3465
|
+
disabled: !isSelectable2,
|
|
3466
|
+
onCheckedChange: () => onSelectOne(element),
|
|
3467
|
+
checked: isSelected
|
|
3468
|
+
}
|
|
3469
|
+
) }),
|
|
3470
|
+
tableHeaders.map(({ name: name22, type: cellType }) => {
|
|
3471
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3472
|
+
CellContent,
|
|
3473
|
+
{
|
|
3474
|
+
content: element,
|
|
3475
|
+
cellType,
|
|
3476
|
+
contentType,
|
|
3477
|
+
name: name22
|
|
3478
|
+
}
|
|
3479
|
+
) }, name22);
|
|
3480
|
+
}),
|
|
3481
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "flex-end", children: [
|
|
3482
|
+
contentType === "folder" && (folderURL ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3483
|
+
designSystem.IconButton,
|
|
3484
|
+
{
|
|
3485
|
+
tag: reactRouterDom.Link,
|
|
3486
|
+
label: formatMessage({
|
|
3487
|
+
id: getTrad("list.folders.link-label"),
|
|
3488
|
+
defaultMessage: "Access folder"
|
|
3489
|
+
}),
|
|
3490
|
+
to: folderURL,
|
|
3491
|
+
variant: "ghost",
|
|
3492
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
|
|
3493
|
+
}
|
|
3494
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3495
|
+
designSystem.IconButton,
|
|
3496
|
+
{
|
|
3497
|
+
tag: "button",
|
|
3498
|
+
label: formatMessage({
|
|
3499
|
+
id: getTrad("list.folders.link-label"),
|
|
3500
|
+
defaultMessage: "Access folder"
|
|
3501
|
+
}),
|
|
3502
|
+
onClick: () => onChangeFolder && onChangeFolder(id),
|
|
3503
|
+
variant: "ghost",
|
|
3504
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, {})
|
|
3505
|
+
}
|
|
3506
|
+
)),
|
|
3507
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3508
|
+
designSystem.IconButton,
|
|
3509
|
+
{
|
|
3510
|
+
label: formatMessage({
|
|
3511
|
+
id: getTrad("control-card.edit"),
|
|
3512
|
+
defaultMessage: "Edit"
|
|
3513
|
+
}),
|
|
3514
|
+
onClick: () => contentType === "asset" ? onEditAsset(element) : onEditFolder(element),
|
|
3515
|
+
variant: "ghost",
|
|
3516
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {})
|
|
3517
|
+
}
|
|
3518
|
+
)
|
|
3519
|
+
] }) })
|
|
3520
|
+
]
|
|
3521
|
+
},
|
|
3522
|
+
id
|
|
3523
|
+
);
|
|
3886
3524
|
}) });
|
|
3887
3525
|
};
|
|
3888
|
-
TableRows.defaultProps = {
|
|
3889
|
-
onChangeFolder: null,
|
|
3890
|
-
rows: [],
|
|
3891
|
-
selected: []
|
|
3892
|
-
};
|
|
3893
|
-
TableRows.propTypes = {
|
|
3894
|
-
onChangeFolder: PropTypes__default.default.func,
|
|
3895
|
-
onEditAsset: PropTypes__default.default.func.isRequired,
|
|
3896
|
-
onEditFolder: PropTypes__default.default.func.isRequired,
|
|
3897
|
-
onSelectOne: PropTypes__default.default.func.isRequired,
|
|
3898
|
-
rows: PropTypes__default.default.arrayOf(AssetDefinition, FolderDefinition),
|
|
3899
|
-
selected: PropTypes__default.default.arrayOf(AssetDefinition, FolderDefinition)
|
|
3900
|
-
};
|
|
3901
3526
|
const TableList = ({
|
|
3902
|
-
assetCount,
|
|
3903
|
-
folderCount,
|
|
3904
|
-
indeterminate,
|
|
3905
|
-
onChangeSort,
|
|
3906
|
-
onChangeFolder,
|
|
3907
|
-
onEditAsset,
|
|
3908
|
-
onEditFolder,
|
|
3527
|
+
assetCount = 0,
|
|
3528
|
+
folderCount = 0,
|
|
3529
|
+
indeterminate = false,
|
|
3530
|
+
onChangeSort = null,
|
|
3531
|
+
onChangeFolder = null,
|
|
3532
|
+
onEditAsset = null,
|
|
3533
|
+
onEditFolder = null,
|
|
3909
3534
|
onSelectAll,
|
|
3910
3535
|
onSelectOne,
|
|
3911
|
-
rows,
|
|
3912
|
-
selected,
|
|
3913
|
-
shouldDisableBulkSelect,
|
|
3914
|
-
sortQuery
|
|
3536
|
+
rows = [],
|
|
3537
|
+
selected = [],
|
|
3538
|
+
shouldDisableBulkSelect = false,
|
|
3539
|
+
sortQuery = ""
|
|
3915
3540
|
}) => {
|
|
3916
3541
|
const { formatMessage } = reactIntl.useIntl();
|
|
3917
3542
|
const [sortBy, sortOrder] = sortQuery.split(":");
|
|
3918
3543
|
const handleClickSort = (isSorted, name2) => {
|
|
3919
3544
|
const nextSortOrder = isSorted && sortOrder === "ASC" ? "DESC" : "ASC";
|
|
3920
3545
|
const nextSort = `${name2}:${nextSortOrder}`;
|
|
3921
|
-
onChangeSort(nextSort);
|
|
3546
|
+
onChangeSort && onChangeSort(nextSort);
|
|
3922
3547
|
};
|
|
3923
3548
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: tableHeaders.length + 2, rowCount: assetCount + folderCount + 1, children: [
|
|
3924
3549
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
|
|
@@ -3959,7 +3584,6 @@ const TableList = ({
|
|
|
3959
3584
|
{
|
|
3960
3585
|
onClick: () => handleClickSort(isSorted, name2),
|
|
3961
3586
|
tag: isSorted ? "span" : "button",
|
|
3962
|
-
label: !isSorted ? sortLabel : "",
|
|
3963
3587
|
textColor: "neutral600",
|
|
3964
3588
|
variant: "sigma",
|
|
3965
3589
|
children: tableHeaderLabel
|
|
@@ -3987,41 +3611,13 @@ const TableList = ({
|
|
|
3987
3611
|
)
|
|
3988
3612
|
] });
|
|
3989
3613
|
};
|
|
3990
|
-
TableList.defaultProps = {
|
|
3991
|
-
assetCount: 0,
|
|
3992
|
-
folderCount: 0,
|
|
3993
|
-
indeterminate: false,
|
|
3994
|
-
onChangeSort: null,
|
|
3995
|
-
onChangeFolder: null,
|
|
3996
|
-
onEditAsset: null,
|
|
3997
|
-
onEditFolder: null,
|
|
3998
|
-
rows: [],
|
|
3999
|
-
selected: [],
|
|
4000
|
-
shouldDisableBulkSelect: false,
|
|
4001
|
-
sortQuery: ""
|
|
4002
|
-
};
|
|
4003
|
-
TableList.propTypes = {
|
|
4004
|
-
assetCount: PropTypes__default.default.number,
|
|
4005
|
-
folderCount: PropTypes__default.default.number,
|
|
4006
|
-
indeterminate: PropTypes__default.default.bool,
|
|
4007
|
-
onChangeSort: PropTypes__default.default.func,
|
|
4008
|
-
onChangeFolder: PropTypes__default.default.func,
|
|
4009
|
-
onEditAsset: PropTypes__default.default.func,
|
|
4010
|
-
onEditFolder: PropTypes__default.default.func,
|
|
4011
|
-
onSelectAll: PropTypes__default.default.func.isRequired,
|
|
4012
|
-
onSelectOne: PropTypes__default.default.func.isRequired,
|
|
4013
|
-
rows: PropTypes__default.default.arrayOf(AssetDefinition, FolderDefinition),
|
|
4014
|
-
selected: PropTypes__default.default.arrayOf(AssetDefinition, FolderDefinition),
|
|
4015
|
-
shouldDisableBulkSelect: PropTypes__default.default.bool,
|
|
4016
|
-
sortQuery: PropTypes__default.default.string
|
|
4017
|
-
};
|
|
4018
3614
|
const FilterTag = ({ attribute, filter, onClick, operator, value }) => {
|
|
4019
3615
|
const { formatMessage, formatDate, formatTime } = reactIntl.useIntl();
|
|
4020
3616
|
const handleClick = () => {
|
|
4021
3617
|
onClick(filter);
|
|
4022
3618
|
};
|
|
4023
3619
|
const { fieldSchema } = attribute;
|
|
4024
|
-
const type = fieldSchema
|
|
3620
|
+
const type = fieldSchema?.type;
|
|
4025
3621
|
let formattedValue = value;
|
|
4026
3622
|
if (type === "date") {
|
|
4027
3623
|
formattedValue = formatDate(value, { dateStyle: "full" });
|
|
@@ -4032,43 +3628,42 @@ const FilterTag = ({ attribute, filter, onClick, operator, value }) => {
|
|
|
4032
3628
|
if (type === "time") {
|
|
4033
3629
|
const [hour, minute] = value.split(":");
|
|
4034
3630
|
const date = /* @__PURE__ */ new Date();
|
|
4035
|
-
date.setHours(hour);
|
|
4036
|
-
date.setMinutes(minute);
|
|
3631
|
+
date.setHours(Number(hour));
|
|
3632
|
+
date.setMinutes(Number(minute));
|
|
4037
3633
|
formattedValue = formatTime(date, {
|
|
4038
|
-
|
|
4039
|
-
|
|
3634
|
+
hour: "numeric",
|
|
3635
|
+
minute: "numeric"
|
|
4040
3636
|
});
|
|
4041
3637
|
}
|
|
4042
|
-
const content = `${attribute.metadatas
|
|
3638
|
+
const content = `${attribute.metadatas?.label} ${formatMessage({
|
|
4043
3639
|
id: `components.FilterOptions.FILTER_TYPES.${operator}`,
|
|
4044
3640
|
defaultMessage: operator
|
|
4045
3641
|
})} ${formattedValue}`;
|
|
4046
3642
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tag, { onClick: handleClick, icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {}), padding: 1, children: content });
|
|
4047
3643
|
};
|
|
4048
|
-
FilterTag.propTypes = {
|
|
4049
|
-
attribute: PropTypes__default.default.shape({
|
|
4050
|
-
name: PropTypes__default.default.string.isRequired,
|
|
4051
|
-
fieldSchema: PropTypes__default.default.object.isRequired,
|
|
4052
|
-
metadatas: PropTypes__default.default.shape({ label: PropTypes__default.default.string.isRequired }).isRequired
|
|
4053
|
-
}).isRequired,
|
|
4054
|
-
filter: PropTypes__default.default.object.isRequired,
|
|
4055
|
-
onClick: PropTypes__default.default.func.isRequired,
|
|
4056
|
-
operator: PropTypes__default.default.string.isRequired,
|
|
4057
|
-
value: PropTypes__default.default.string.isRequired
|
|
4058
|
-
};
|
|
4059
3644
|
const FilterList = ({ appliedFilters, filtersSchema, onRemoveFilter }) => {
|
|
4060
3645
|
const handleClick = (filter) => {
|
|
4061
3646
|
const nextFilters = appliedFilters.filter((prevFilter) => {
|
|
4062
3647
|
const name2 = Object.keys(filter)[0];
|
|
4063
|
-
const
|
|
4064
|
-
|
|
4065
|
-
|
|
3648
|
+
const filterName = filter[name2];
|
|
3649
|
+
if (filterName !== void 0) {
|
|
3650
|
+
const filterType = Object.keys(filterName)[0];
|
|
3651
|
+
const filterValue = filterName[filterType];
|
|
3652
|
+
if (typeof filterValue === "string") {
|
|
3653
|
+
const decodedValue = decodeURIComponent(filterValue);
|
|
3654
|
+
return prevFilter[name2]?.[filterType] !== decodedValue;
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3657
|
+
return true;
|
|
4066
3658
|
});
|
|
4067
3659
|
onRemoveFilter(nextFilters);
|
|
4068
3660
|
};
|
|
4069
3661
|
return appliedFilters.map((filter, i) => {
|
|
4070
3662
|
const attributeName = Object.keys(filter)[0];
|
|
4071
3663
|
const attribute = filtersSchema.find(({ name: name2 }) => name2 === attributeName);
|
|
3664
|
+
if (!attribute) {
|
|
3665
|
+
return null;
|
|
3666
|
+
}
|
|
4072
3667
|
const filterObj = filter[attributeName];
|
|
4073
3668
|
const operator = Object.keys(filterObj)[0];
|
|
4074
3669
|
let value = filterObj[operator];
|
|
@@ -4080,7 +3675,7 @@ const FilterList = ({ appliedFilters, filtersSchema, onRemoveFilter }) => {
|
|
|
4080
3675
|
value = Array.isArray(value) || typeof value === "object" ? Object.values(value).join(", ") : decodeURIComponent(value);
|
|
4081
3676
|
}
|
|
4082
3677
|
let displayedOperator = operator;
|
|
4083
|
-
if (attribute
|
|
3678
|
+
if (attribute?.name === "mime") {
|
|
4084
3679
|
displayedOperator = operator === "$contains" ? "$eq" : "$ne";
|
|
4085
3680
|
if (operator === "$not") {
|
|
4086
3681
|
value = "file";
|
|
@@ -4104,65 +3699,45 @@ const FilterList = ({ appliedFilters, filtersSchema, onRemoveFilter }) => {
|
|
|
4104
3699
|
);
|
|
4105
3700
|
});
|
|
4106
3701
|
};
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
name: PropTypes__default.default.string.isRequired,
|
|
4115
|
-
metadatas: PropTypes__default.default.shape({ label: PropTypes__default.default.string }),
|
|
4116
|
-
fieldSchema: PropTypes__default.default.shape({
|
|
4117
|
-
type: PropTypes__default.default.string,
|
|
4118
|
-
mainField: PropTypes__default.default.shape({
|
|
4119
|
-
name: PropTypes__default.default.string,
|
|
4120
|
-
type: PropTypes__default.default.string
|
|
4121
|
-
})
|
|
4122
|
-
})
|
|
4123
|
-
})
|
|
4124
|
-
),
|
|
4125
|
-
onRemoveFilter: PropTypes__default.default.func.isRequired
|
|
4126
|
-
};
|
|
4127
|
-
const FilterValueInput = ({ label, onChange, options, type, value }) => {
|
|
3702
|
+
const FilterValueInput = ({
|
|
3703
|
+
label = "",
|
|
3704
|
+
onChange,
|
|
3705
|
+
options = [],
|
|
3706
|
+
type,
|
|
3707
|
+
value = ""
|
|
3708
|
+
}) => {
|
|
4128
3709
|
const { formatMessage } = reactIntl.useIntl();
|
|
4129
3710
|
if (type === "date") {
|
|
4130
3711
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4131
3712
|
designSystem.DateTimePicker,
|
|
4132
3713
|
{
|
|
4133
3714
|
clearLabel: formatMessage({ id: "clearLabel", defaultMessage: "Clear" }),
|
|
4134
|
-
|
|
3715
|
+
"aria-label": label,
|
|
4135
3716
|
name: "datetimepicker",
|
|
4136
3717
|
onChange: (date) => {
|
|
4137
3718
|
const formattedDate = date ? new Date(date).toISOString() : "";
|
|
4138
3719
|
onChange(formattedDate);
|
|
4139
3720
|
},
|
|
4140
3721
|
onClear: () => onChange(""),
|
|
4141
|
-
value: value ? new Date(value) : void 0
|
|
4142
|
-
selectedDateLabel: (formattedDate) => `Date picker, current is ${formattedDate}`,
|
|
4143
|
-
selectButtonTitle: formatMessage({ id: "selectButtonTitle", defaultMessage: "Select" })
|
|
3722
|
+
value: value ? new Date(value) : void 0
|
|
4144
3723
|
}
|
|
4145
3724
|
);
|
|
4146
3725
|
}
|
|
4147
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
}
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
onChange: PropTypes__default.default.func.isRequired,
|
|
4159
|
-
options: PropTypes__default.default.arrayOf(
|
|
4160
|
-
PropTypes__default.default.shape({ label: PropTypes__default.default.string.isRequired, value: PropTypes__default.default.string.isRequired })
|
|
4161
|
-
),
|
|
4162
|
-
type: PropTypes__default.default.string.isRequired,
|
|
4163
|
-
value: PropTypes__default.default.any
|
|
3726
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3727
|
+
designSystem.SingleSelect,
|
|
3728
|
+
{
|
|
3729
|
+
"aria-label": label,
|
|
3730
|
+
onChange: (value2) => onChange(value2.toString()),
|
|
3731
|
+
value,
|
|
3732
|
+
children: options?.map((option) => {
|
|
3733
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: option.value, children: option.label }, option.value);
|
|
3734
|
+
})
|
|
3735
|
+
}
|
|
3736
|
+
);
|
|
4164
3737
|
};
|
|
4165
|
-
const getFilterList = ({
|
|
3738
|
+
const getFilterList = ({
|
|
3739
|
+
fieldSchema: { type: fieldType, mainField }
|
|
3740
|
+
}) => {
|
|
4166
3741
|
const type = mainField?.schema.type ? mainField.schema.type : fieldType;
|
|
4167
3742
|
switch (type) {
|
|
4168
3743
|
case "enumeration": {
|
|
@@ -4257,30 +3832,38 @@ const getFilterList = ({ fieldSchema: { type: fieldType, mainField } }) => {
|
|
|
4257
3832
|
];
|
|
4258
3833
|
}
|
|
4259
3834
|
};
|
|
4260
|
-
const FilterPopover = ({
|
|
3835
|
+
const FilterPopover = ({
|
|
3836
|
+
displayedFilters: displayedFilters2,
|
|
3837
|
+
filters,
|
|
3838
|
+
onSubmit,
|
|
3839
|
+
onToggle
|
|
3840
|
+
}) => {
|
|
4261
3841
|
const { formatMessage } = reactIntl.useIntl();
|
|
4262
|
-
const [modifiedData, setModifiedData] =
|
|
3842
|
+
const [modifiedData, setModifiedData] = React__namespace.useState({
|
|
4263
3843
|
name: "createdAt",
|
|
4264
3844
|
filter: "$eq",
|
|
4265
3845
|
value: ""
|
|
4266
3846
|
});
|
|
4267
3847
|
const handleChangeFilterField = (value) => {
|
|
4268
3848
|
const nextField = displayedFilters2.find((f) => f.name === value);
|
|
3849
|
+
if (!nextField) {
|
|
3850
|
+
return;
|
|
3851
|
+
}
|
|
4269
3852
|
const {
|
|
4270
3853
|
fieldSchema: { type, options }
|
|
4271
3854
|
} = nextField;
|
|
4272
3855
|
let filterValue = "";
|
|
4273
3856
|
if (type === "enumeration") {
|
|
4274
|
-
filterValue = options[0].value;
|
|
3857
|
+
filterValue = options?.[0].value || "";
|
|
4275
3858
|
}
|
|
4276
3859
|
const filter = getFilterList(nextField)[0].value;
|
|
4277
|
-
setModifiedData({ name: value, filter, value: filterValue });
|
|
3860
|
+
setModifiedData({ name: value.toString(), filter, value: filterValue });
|
|
4278
3861
|
};
|
|
4279
3862
|
const handleChangeOperator = (operator) => {
|
|
4280
3863
|
if (modifiedData.name === "mime") {
|
|
4281
|
-
setModifiedData((prev) => ({ ...prev, filter: operator, value: "image" }));
|
|
3864
|
+
setModifiedData((prev) => ({ ...prev, filter: operator.toString(), value: "image" }));
|
|
4282
3865
|
} else {
|
|
4283
|
-
setModifiedData((prev) => ({ ...prev, filter: operator, value: "" }));
|
|
3866
|
+
setModifiedData((prev) => ({ ...prev, filter: operator.toString(), value: "" }));
|
|
4284
3867
|
}
|
|
4285
3868
|
};
|
|
4286
3869
|
const handleSubmit = (e) => {
|
|
@@ -4300,7 +3883,9 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4300
3883
|
let filterToAdd2;
|
|
4301
3884
|
if (modifiedData.filter === "$contains") {
|
|
4302
3885
|
hasCurrentFilter = alreadyAppliedFilters.find((filter) => {
|
|
4303
|
-
|
|
3886
|
+
if (typeof filter.mime?.$not !== "string" && !Array.isArray(filter.mime?.$not)) {
|
|
3887
|
+
return filter.mime?.$not?.$contains !== void 0;
|
|
3888
|
+
}
|
|
4304
3889
|
}) !== void 0;
|
|
4305
3890
|
filterToAdd2 = {
|
|
4306
3891
|
mime: {
|
|
@@ -4329,7 +3914,8 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4329
3914
|
return;
|
|
4330
3915
|
}
|
|
4331
3916
|
const hasFilter2 = alreadyAppliedFilters.find((filter) => {
|
|
4332
|
-
|
|
3917
|
+
const modifiedDataFilter = modifiedData.filter;
|
|
3918
|
+
return filter.mime && filter.mime[modifiedDataFilter] === modifiedData.value;
|
|
4333
3919
|
}) !== void 0;
|
|
4334
3920
|
if (hasFilter2) {
|
|
4335
3921
|
onToggle();
|
|
@@ -4340,7 +3926,7 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4340
3926
|
if (filterType !== "mime") {
|
|
4341
3927
|
return true;
|
|
4342
3928
|
}
|
|
4343
|
-
if (filter.mime?.$not?.$contains !== void 0) {
|
|
3929
|
+
if (typeof filter.mime?.$not !== "string" && !Array.isArray(filter.mime?.$not) && filter.mime?.$not?.$contains !== void 0) {
|
|
4344
3930
|
return false;
|
|
4345
3931
|
}
|
|
4346
3932
|
if (Array.isArray(filter?.mime?.$contains)) {
|
|
@@ -4353,7 +3939,7 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4353
3939
|
return filter.mime?.[oppositeFilter] === modifiedData.value;
|
|
4354
3940
|
});
|
|
4355
3941
|
const hasOppositeFilter = oppositeFilterIndex !== -1;
|
|
4356
|
-
|
|
3942
|
+
const filterToAdd = { [modifiedData.name]: { [modifiedData.filter]: modifiedData.value } };
|
|
4357
3943
|
if (!hasOppositeFilter) {
|
|
4358
3944
|
const nextFilters = [...filtersWithoutFile, filterToAdd];
|
|
4359
3945
|
onSubmit(nextFilters);
|
|
@@ -4369,10 +3955,11 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4369
3955
|
return;
|
|
4370
3956
|
}
|
|
4371
3957
|
const hasFilter = filters.find((filter) => {
|
|
4372
|
-
|
|
3958
|
+
const modifiedDataName = modifiedData.name;
|
|
3959
|
+
return filter[modifiedDataName] && filter[modifiedDataName]?.[modifiedDataName] === encodedValue;
|
|
4373
3960
|
}) !== void 0;
|
|
4374
3961
|
if (!hasFilter) {
|
|
4375
|
-
|
|
3962
|
+
const filterToAdd = { [modifiedData.name]: { [modifiedData.filter]: encodedValue } };
|
|
4376
3963
|
const nextFilters = [...filters, filterToAdd];
|
|
4377
3964
|
onSubmit(nextFilters);
|
|
4378
3965
|
}
|
|
@@ -4393,7 +3980,7 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4393
3980
|
onChange: handleChangeFilterField,
|
|
4394
3981
|
value: modifiedData.name,
|
|
4395
3982
|
children: displayedFilters2.map((filter) => {
|
|
4396
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: filter.name, children: filter.metadatas
|
|
3983
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: filter.name, children: filter.metadatas?.label }, filter.name);
|
|
4397
3984
|
})
|
|
4398
3985
|
}
|
|
4399
3986
|
) }),
|
|
@@ -4416,8 +4003,8 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4416
4003
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4417
4004
|
FilterValueInput,
|
|
4418
4005
|
{
|
|
4419
|
-
...appliedFilter
|
|
4420
|
-
...appliedFilter
|
|
4006
|
+
...appliedFilter?.metadatas,
|
|
4007
|
+
...appliedFilter?.fieldSchema,
|
|
4421
4008
|
value: modifiedData.value,
|
|
4422
4009
|
onChange: (value) => setModifiedData((prev) => ({ ...prev, value }))
|
|
4423
4010
|
}
|
|
@@ -4425,18 +4012,6 @@ const FilterPopover = ({ displayedFilters: displayedFilters2, filters, onSubmit,
|
|
|
4425
4012
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { size: "L", variant: "secondary", startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Plus, {}), type: "submit", fullWidth: true, children: formatMessage({ id: "app.utils.add-filter", defaultMessage: "Add filter" }) }) })
|
|
4426
4013
|
] }) }) });
|
|
4427
4014
|
};
|
|
4428
|
-
FilterPopover.propTypes = {
|
|
4429
|
-
displayedFilters: PropTypes__default.default.arrayOf(
|
|
4430
|
-
PropTypes__default.default.shape({
|
|
4431
|
-
name: PropTypes__default.default.string.isRequired,
|
|
4432
|
-
metadatas: PropTypes__default.default.shape({ label: PropTypes__default.default.string }),
|
|
4433
|
-
fieldSchema: PropTypes__default.default.shape({ type: PropTypes__default.default.string })
|
|
4434
|
-
})
|
|
4435
|
-
).isRequired,
|
|
4436
|
-
filters: PropTypes__default.default.array.isRequired,
|
|
4437
|
-
onSubmit: PropTypes__default.default.func.isRequired,
|
|
4438
|
-
onToggle: PropTypes__default.default.func.isRequired
|
|
4439
|
-
};
|
|
4440
4015
|
const Filters = ({ appliedFilters, onChangeFilters }) => {
|
|
4441
4016
|
const [open, setOpen] = React__namespace.useState(false);
|
|
4442
4017
|
const { formatMessage } = reactIntl.useIntl();
|
|
@@ -4445,7 +4020,7 @@ const Filters = ({ appliedFilters, onChangeFilters }) => {
|
|
|
4445
4020
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4446
4021
|
FilterPopover,
|
|
4447
4022
|
{
|
|
4448
|
-
onToggle: setOpen,
|
|
4023
|
+
onToggle: () => setOpen((prev) => !prev),
|
|
4449
4024
|
displayedFilters,
|
|
4450
4025
|
filters: appliedFilters,
|
|
4451
4026
|
onSubmit: onChangeFilters
|
|
@@ -4461,14 +4036,10 @@ const Filters = ({ appliedFilters, onChangeFilters }) => {
|
|
|
4461
4036
|
)
|
|
4462
4037
|
] });
|
|
4463
4038
|
};
|
|
4464
|
-
Filters.propTypes = {
|
|
4465
|
-
appliedFilters: PropTypes__default.default.array.isRequired,
|
|
4466
|
-
onChangeFilters: PropTypes__default.default.func.isRequired
|
|
4467
|
-
};
|
|
4468
4039
|
const PageSize = ({ onChangePageSize, pageSize }) => {
|
|
4469
4040
|
const { formatMessage } = reactIntl.useIntl();
|
|
4470
4041
|
const handleChange = (value) => {
|
|
4471
|
-
onChangePageSize(value);
|
|
4042
|
+
onChangePageSize(Number(value));
|
|
4472
4043
|
};
|
|
4473
4044
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
|
|
4474
4045
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -4495,16 +4066,21 @@ const PageSize = ({ onChangePageSize, pageSize }) => {
|
|
|
4495
4066
|
}) }) })
|
|
4496
4067
|
] });
|
|
4497
4068
|
};
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4069
|
+
const PaginationContext = React__namespace.createContext({ activePage: 1, pageCount: 1 });
|
|
4070
|
+
const usePagination = () => React__namespace.useContext(PaginationContext);
|
|
4071
|
+
const Pagination = ({
|
|
4072
|
+
children,
|
|
4073
|
+
activePage,
|
|
4074
|
+
pageCount,
|
|
4075
|
+
label = "pagination"
|
|
4076
|
+
}) => {
|
|
4077
|
+
const paginationValue = React__namespace.useMemo(() => ({ activePage, pageCount }), [activePage, pageCount]);
|
|
4078
|
+
return /* @__PURE__ */ jsxRuntime.jsx(PaginationContext.Provider, { value: paginationValue, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "nav", "aria-label": label, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { tag: "ul", gap: 1, children }) }) });
|
|
4501
4079
|
};
|
|
4502
|
-
const PaginationContext = React.createContext({ activePage: 1, pageCount: 1 });
|
|
4503
|
-
const usePagination = () => React.useContext(PaginationContext);
|
|
4504
4080
|
const PaginationText = styledComponents.styled(designSystem.Typography)`
|
|
4505
4081
|
line-height: revert;
|
|
4506
4082
|
`;
|
|
4507
|
-
const
|
|
4083
|
+
const linkWrapperStyles = styledComponents.css`
|
|
4508
4084
|
padding: ${({ theme }) => theme.spaces[3]};
|
|
4509
4085
|
border-radius: ${({ theme }) => theme.borderRadius};
|
|
4510
4086
|
box-shadow: ${({ $active, theme }) => $active ? theme.shadows.filterShadow : void 0};
|
|
@@ -4541,8 +4117,14 @@ const LinkWrapper = styledComponents.styled.button`
|
|
|
4541
4117
|
}
|
|
4542
4118
|
}
|
|
4543
4119
|
`;
|
|
4544
|
-
|
|
4545
|
-
|
|
4120
|
+
const LinkWrapperButton = styledComponents.styled.button`
|
|
4121
|
+
${linkWrapperStyles}
|
|
4122
|
+
`;
|
|
4123
|
+
const LinkWrapperDiv = styledComponents.styled.div`
|
|
4124
|
+
${linkWrapperStyles}
|
|
4125
|
+
`;
|
|
4126
|
+
LinkWrapperButton.defaultProps = { type: "button" };
|
|
4127
|
+
const PageLinkWrapper = styledComponents.styled(LinkWrapperButton)`
|
|
4546
4128
|
color: ${({ theme, $active }) => $active ? theme.colors.primary700 : theme.colors.neutral800};
|
|
4547
4129
|
background: ${({ theme, $active }) => $active ? theme.colors.neutral0 : void 0};
|
|
4548
4130
|
|
|
@@ -4550,7 +4132,7 @@ const PageLinkWrapper = styledComponents.styled(LinkWrapper)`
|
|
|
4550
4132
|
box-shadow: ${({ theme }) => theme.shadows.filterShadow};
|
|
4551
4133
|
}
|
|
4552
4134
|
`;
|
|
4553
|
-
const ActionLinkWrapper = styledComponents.styled(
|
|
4135
|
+
const ActionLinkWrapper = styledComponents.styled(LinkWrapperButton)`
|
|
4554
4136
|
font-size: 1.1rem;
|
|
4555
4137
|
svg path {
|
|
4556
4138
|
fill: ${(p) => p["aria-disabled"] ? p.theme.colors.neutral300 : p.theme.colors.neutral600};
|
|
@@ -4567,7 +4149,7 @@ const ActionLinkWrapper = styledComponents.styled(LinkWrapper)`
|
|
|
4567
4149
|
pointer-events: none;
|
|
4568
4150
|
` : void 0}
|
|
4569
4151
|
`;
|
|
4570
|
-
const DotsWrapper = styledComponents.styled(
|
|
4152
|
+
const DotsWrapper = styledComponents.styled(LinkWrapperDiv)`
|
|
4571
4153
|
color: ${({ theme }) => theme.colors.neutral800};
|
|
4572
4154
|
`;
|
|
4573
4155
|
const PreviousLink = ({ children, ...props }) => {
|
|
@@ -4594,36 +4176,15 @@ const PageLink = ({ number, children, ...props }) => {
|
|
|
4594
4176
|
/* @__PURE__ */ jsxRuntime.jsx(PaginationText, { "aria-hidden": true, variant: "pi", fontWeight: isActive ? "bold" : "", children: number })
|
|
4595
4177
|
] }) });
|
|
4596
4178
|
};
|
|
4597
|
-
const Dots = ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(DotsWrapper, { ...props,
|
|
4179
|
+
const Dots = ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(DotsWrapper, { ...props, as: "div", children: [
|
|
4598
4180
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children }),
|
|
4599
4181
|
/* @__PURE__ */ jsxRuntime.jsx(PaginationText, { "aria-hidden": true, small: true, children: "…" })
|
|
4600
4182
|
] }) });
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
}
|
|
4605
|
-
|
|
4606
|
-
children: PropTypes__default.default.node.isRequired
|
|
4607
|
-
};
|
|
4608
|
-
NextLink.propTypes = sharedPropTypes;
|
|
4609
|
-
PreviousLink.propTypes = sharedPropTypes;
|
|
4610
|
-
Dots.propTypes = {
|
|
4611
|
-
children: PropTypes__default.default.node.isRequired
|
|
4612
|
-
};
|
|
4613
|
-
const Pagination = ({ children, label, activePage, pageCount }) => {
|
|
4614
|
-
const paginationValue = React.useMemo(() => ({ activePage, pageCount }), [activePage, pageCount]);
|
|
4615
|
-
return /* @__PURE__ */ jsxRuntime.jsx(PaginationContext.Provider, { value: paginationValue, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "nav", "aria-label": label, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { tag: "ul", gap: 1, children }) }) });
|
|
4616
|
-
};
|
|
4617
|
-
Pagination.defaultProps = {
|
|
4618
|
-
label: "pagination"
|
|
4619
|
-
};
|
|
4620
|
-
Pagination.propTypes = {
|
|
4621
|
-
activePage: PropTypes__default.default.number.isRequired,
|
|
4622
|
-
children: PropTypes__default.default.node.isRequired,
|
|
4623
|
-
label: PropTypes__default.default.string,
|
|
4624
|
-
pageCount: PropTypes__default.default.number.isRequired
|
|
4625
|
-
};
|
|
4626
|
-
const PaginationFooter = ({ activePage, onChangePage, pagination: { pageCount } }) => {
|
|
4183
|
+
const PaginationFooter = ({
|
|
4184
|
+
activePage,
|
|
4185
|
+
onChangePage,
|
|
4186
|
+
pagination: { pageCount }
|
|
4187
|
+
}) => {
|
|
4627
4188
|
const { formatMessage } = reactIntl.useIntl();
|
|
4628
4189
|
const previousActivePage = activePage - 1;
|
|
4629
4190
|
const nextActivePage = activePage + 1;
|
|
@@ -4663,7 +4224,7 @@ const PaginationFooter = ({ activePage, onChangePage, pagination: { pageCount }
|
|
|
4663
4224
|
] });
|
|
4664
4225
|
}
|
|
4665
4226
|
let firstLinksToCreate = [];
|
|
4666
|
-
|
|
4227
|
+
const lastLinks = [];
|
|
4667
4228
|
let lastLinksToCreate = [];
|
|
4668
4229
|
const middleLinks = [];
|
|
4669
4230
|
if (pageCount > 1) {
|
|
@@ -4760,21 +4321,16 @@ const PaginationFooter = ({ activePage, onChangePage, pagination: { pageCount }
|
|
|
4760
4321
|
}) })
|
|
4761
4322
|
] });
|
|
4762
4323
|
};
|
|
4763
|
-
|
|
4764
|
-
activePage: PropTypes__default.default.number.isRequired,
|
|
4765
|
-
onChangePage: PropTypes__default.default.func.isRequired,
|
|
4766
|
-
pagination: PropTypes__default.default.shape({ pageCount: PropTypes__default.default.number.isRequired }).isRequired
|
|
4767
|
-
};
|
|
4768
|
-
const SearchAsset = ({ onChangeSearch, queryValue }) => {
|
|
4324
|
+
const SearchAsset = ({ onChangeSearch, queryValue = null }) => {
|
|
4769
4325
|
const { formatMessage } = reactIntl.useIntl();
|
|
4770
4326
|
const { trackUsage } = strapiAdmin.useTracking();
|
|
4771
|
-
const [isOpen, setIsOpen] =
|
|
4772
|
-
const [value, setValue] =
|
|
4773
|
-
const wrapperRef =
|
|
4774
|
-
|
|
4327
|
+
const [isOpen, setIsOpen] = React__namespace.useState(!!queryValue);
|
|
4328
|
+
const [value, setValue] = React__namespace.useState(queryValue || "");
|
|
4329
|
+
const wrapperRef = React__namespace.useRef(null);
|
|
4330
|
+
React__namespace.useLayoutEffect(() => {
|
|
4775
4331
|
if (isOpen) {
|
|
4776
4332
|
setTimeout(() => {
|
|
4777
|
-
wrapperRef.current
|
|
4333
|
+
wrapperRef.current?.querySelector("input")?.focus();
|
|
4778
4334
|
}, 0);
|
|
4779
4335
|
}
|
|
4780
4336
|
}, [isOpen]);
|
|
@@ -4802,6 +4358,7 @@ const SearchAsset = ({ onChangeSearch, queryValue }) => {
|
|
|
4802
4358
|
id: getTrad("search.clear.label"),
|
|
4803
4359
|
defaultMessage: "Clear the search"
|
|
4804
4360
|
}),
|
|
4361
|
+
"aria-label": "search",
|
|
4805
4362
|
size: "S",
|
|
4806
4363
|
value,
|
|
4807
4364
|
placeholder: formatMessage({
|
|
@@ -4814,13 +4371,6 @@ const SearchAsset = ({ onChangeSearch, queryValue }) => {
|
|
|
4814
4371
|
}
|
|
4815
4372
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { label: "Search", onClick: handleToggle, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Search, {}) });
|
|
4816
4373
|
};
|
|
4817
|
-
SearchAsset.defaultProps = {
|
|
4818
|
-
queryValue: null
|
|
4819
|
-
};
|
|
4820
|
-
SearchAsset.propTypes = {
|
|
4821
|
-
onChangeSearch: PropTypes__default.default.func.isRequired,
|
|
4822
|
-
queryValue: PropTypes__default.default.string
|
|
4823
|
-
};
|
|
4824
4374
|
const isSelectable = (allowedTypes, mime = "") => {
|
|
4825
4375
|
if (!mime)
|
|
4826
4376
|
return false;
|
|
@@ -4838,12 +4388,12 @@ const ActionContainer = styledComponents.styled(designSystem.Box)`
|
|
|
4838
4388
|
}
|
|
4839
4389
|
`;
|
|
4840
4390
|
const BrowseStep = ({
|
|
4841
|
-
allowedTypes,
|
|
4391
|
+
allowedTypes = [],
|
|
4842
4392
|
assets: rawAssets,
|
|
4843
4393
|
canCreate,
|
|
4844
4394
|
canRead,
|
|
4845
|
-
folders,
|
|
4846
|
-
multiple,
|
|
4395
|
+
folders = [],
|
|
4396
|
+
multiple = false,
|
|
4847
4397
|
onAddAsset,
|
|
4848
4398
|
onChangeFilters,
|
|
4849
4399
|
onChangePage,
|
|
@@ -4874,7 +4424,7 @@ const BrowseStep = ({
|
|
|
4874
4424
|
isSelectable: isSelectable(singularTypes, asset?.mime),
|
|
4875
4425
|
type: "asset"
|
|
4876
4426
|
}));
|
|
4877
|
-
const breadcrumbs = !isCurrentFolderLoading
|
|
4427
|
+
const breadcrumbs = !isCurrentFolderLoading ? getBreadcrumbDataCM(currentFolder) : void 0;
|
|
4878
4428
|
const allAllowedAsset = getAllowedFiles(allowedTypes, assets);
|
|
4879
4429
|
const areAllAssetSelected = allAllowedAsset.length > 0 && selectedAssets.length > 0 && allAllowedAsset.every(
|
|
4880
4430
|
(asset) => selectedAssets.findIndex((currAsset) => currAsset.id === asset.id) !== -1
|
|
@@ -4883,7 +4433,7 @@ const BrowseStep = ({
|
|
|
4883
4433
|
(asset) => selectedAssets.findIndex((currAsset) => currAsset.id === asset.id) !== -1
|
|
4884
4434
|
);
|
|
4885
4435
|
const isSearching = !!queryObject?._q;
|
|
4886
|
-
const isFiltering = queryObject?.filters?.$and?.length > 0;
|
|
4436
|
+
const isFiltering = !!queryObject?.filters?.$and?.length && queryObject.filters.$and.length > 0;
|
|
4887
4437
|
const isSearchingOrFiltering = isSearching || isFiltering;
|
|
4888
4438
|
const assetCount = assets.length;
|
|
4889
4439
|
const folderCount = folders.length;
|
|
@@ -4943,11 +4493,10 @@ const BrowseStep = ({
|
|
|
4943
4493
|
/* @__PURE__ */ jsxRuntime.jsx(SearchAsset, { onChangeSearch, queryValue: queryObject._q || "" })
|
|
4944
4494
|
] })
|
|
4945
4495
|
] }) }),
|
|
4946
|
-
canRead && breadcrumbs?.length > 0 && currentFolder && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 3, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4496
|
+
canRead && breadcrumbs?.length && breadcrumbs.length > 0 && currentFolder && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 3, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4947
4497
|
Breadcrumbs,
|
|
4948
4498
|
{
|
|
4949
4499
|
onChangeFolder,
|
|
4950
|
-
tag: "nav",
|
|
4951
4500
|
label: formatMessage({
|
|
4952
4501
|
id: getTrad("header.breadcrumbs.nav.label"),
|
|
4953
4502
|
defaultMessage: "Folders navigation"
|
|
@@ -5066,8 +4615,8 @@ const BrowseStep = ({
|
|
|
5066
4615
|
defaultMessage: "{folderCount, plural, =0 {# folder} one {# folder} other {# folders}}, {filesCount, plural, =0 {# asset} one {# asset} other {# assets}}"
|
|
5067
4616
|
},
|
|
5068
4617
|
{
|
|
5069
|
-
folderCount: folder.children
|
|
5070
|
-
filesCount: folder.files
|
|
4618
|
+
folderCount: folder.children?.count,
|
|
4619
|
+
filesCount: folder.files?.count
|
|
5071
4620
|
}
|
|
5072
4621
|
)
|
|
5073
4622
|
}
|
|
@@ -5104,7 +4653,13 @@ const BrowseStep = ({
|
|
|
5104
4653
|
) })
|
|
5105
4654
|
] }),
|
|
5106
4655
|
pagination.pageCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", paddingTop: 4, children: [
|
|
5107
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4656
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4657
|
+
PageSize,
|
|
4658
|
+
{
|
|
4659
|
+
pageSize: queryObject.pageSize,
|
|
4660
|
+
onChangePageSize
|
|
4661
|
+
}
|
|
4662
|
+
),
|
|
5108
4663
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5109
4664
|
PaginationFooter,
|
|
5110
4665
|
{
|
|
@@ -5116,41 +4671,6 @@ const BrowseStep = ({
|
|
|
5116
4671
|
] })
|
|
5117
4672
|
] });
|
|
5118
4673
|
};
|
|
5119
|
-
BrowseStep.defaultProps = {
|
|
5120
|
-
allowedTypes: [],
|
|
5121
|
-
folders: [],
|
|
5122
|
-
multiple: false,
|
|
5123
|
-
onSelectAllAsset: void 0
|
|
5124
|
-
};
|
|
5125
|
-
BrowseStep.propTypes = {
|
|
5126
|
-
allowedTypes: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
|
|
5127
|
-
assets: PropTypes__default.default.arrayOf(AssetDefinition).isRequired,
|
|
5128
|
-
canCreate: PropTypes__default.default.bool.isRequired,
|
|
5129
|
-
canRead: PropTypes__default.default.bool.isRequired,
|
|
5130
|
-
folders: PropTypes__default.default.arrayOf(FolderDefinition),
|
|
5131
|
-
multiple: PropTypes__default.default.bool,
|
|
5132
|
-
onAddAsset: PropTypes__default.default.func.isRequired,
|
|
5133
|
-
onChangeFilters: PropTypes__default.default.func.isRequired,
|
|
5134
|
-
onChangeFolder: PropTypes__default.default.func.isRequired,
|
|
5135
|
-
onChangePage: PropTypes__default.default.func.isRequired,
|
|
5136
|
-
onChangePageSize: PropTypes__default.default.func.isRequired,
|
|
5137
|
-
onChangeSort: PropTypes__default.default.func.isRequired,
|
|
5138
|
-
onChangeSearch: PropTypes__default.default.func.isRequired,
|
|
5139
|
-
onEditAsset: PropTypes__default.default.func.isRequired,
|
|
5140
|
-
onEditFolder: PropTypes__default.default.func.isRequired,
|
|
5141
|
-
onSelectAsset: PropTypes__default.default.func.isRequired,
|
|
5142
|
-
onSelectAllAsset: PropTypes__default.default.func,
|
|
5143
|
-
queryObject: PropTypes__default.default.shape({
|
|
5144
|
-
filters: PropTypes__default.default.object,
|
|
5145
|
-
page: PropTypes__default.default.number.isRequired,
|
|
5146
|
-
pageSize: PropTypes__default.default.number.isRequired,
|
|
5147
|
-
_q: PropTypes__default.default.string,
|
|
5148
|
-
sort: PropTypes__default.default.string,
|
|
5149
|
-
folder: PropTypes__default.default.number
|
|
5150
|
-
}).isRequired,
|
|
5151
|
-
pagination: PropTypes__default.default.shape({ pageCount: PropTypes__default.default.number.isRequired }).isRequired,
|
|
5152
|
-
selectedAssets: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({})).isRequired
|
|
5153
|
-
};
|
|
5154
4674
|
const DialogFooter = ({ onClose, onValidate }) => {
|
|
5155
4675
|
const { formatMessage } = reactIntl.useIntl();
|
|
5156
4676
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
|
@@ -5158,17 +4678,14 @@ const DialogFooter = ({ onClose, onValidate }) => {
|
|
|
5158
4678
|
onValidate && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onValidate, children: formatMessage({ id: "global.finish", defaultMessage: "Finish" }) })
|
|
5159
4679
|
] });
|
|
5160
4680
|
};
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
onValidate: PropTypes__default.default.func
|
|
5167
|
-
};
|
|
5168
|
-
const SelectedStep = ({ selectedAssets, onSelectAsset, onReorderAsset }) => {
|
|
4681
|
+
const SelectedStep = ({
|
|
4682
|
+
selectedAssets,
|
|
4683
|
+
onSelectAsset,
|
|
4684
|
+
onReorderAsset
|
|
4685
|
+
}) => {
|
|
5169
4686
|
const { formatMessage } = reactIntl.useIntl();
|
|
5170
4687
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
|
|
5171
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 0, children: [
|
|
4688
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 0, direction: "column", alignItems: "start", children: [
|
|
5172
4689
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral800", children: formatMessage(
|
|
5173
4690
|
{
|
|
5174
4691
|
id: getTrad("list.assets.to-upload"),
|
|
@@ -5193,32 +4710,24 @@ const SelectedStep = ({ selectedAssets, onSelectAsset, onReorderAsset }) => {
|
|
|
5193
4710
|
)
|
|
5194
4711
|
] });
|
|
5195
4712
|
};
|
|
5196
|
-
SelectedStep.defaultProps = {
|
|
5197
|
-
onReorderAsset: void 0
|
|
5198
|
-
};
|
|
5199
|
-
SelectedStep.propTypes = {
|
|
5200
|
-
onSelectAsset: PropTypes__default.default.func.isRequired,
|
|
5201
|
-
selectedAssets: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({})).isRequired,
|
|
5202
|
-
onReorderAsset: PropTypes__default.default.func
|
|
5203
|
-
};
|
|
5204
4713
|
const LoadingBody = styledComponents.styled(designSystem.Flex)`
|
|
5205
4714
|
/* 80px are coming from the Tabs component that is not included in the ModalBody */
|
|
5206
4715
|
min-height: ${() => `calc(60vh + 8rem)`};
|
|
5207
4716
|
`;
|
|
5208
4717
|
const AssetContent = ({
|
|
5209
|
-
allowedTypes,
|
|
5210
|
-
folderId,
|
|
4718
|
+
allowedTypes = [],
|
|
4719
|
+
folderId = null,
|
|
5211
4720
|
onClose,
|
|
5212
4721
|
onAddAsset,
|
|
5213
4722
|
onAddFolder,
|
|
5214
4723
|
onChangeFolder,
|
|
5215
4724
|
onValidate,
|
|
5216
|
-
multiple,
|
|
5217
|
-
initiallySelectedAssets,
|
|
4725
|
+
multiple = false,
|
|
4726
|
+
initiallySelectedAssets = [],
|
|
5218
4727
|
trackedLocation
|
|
5219
4728
|
}) => {
|
|
5220
|
-
const [assetToEdit, setAssetToEdit] =
|
|
5221
|
-
const [folderToEdit, setFolderToEdit] =
|
|
4729
|
+
const [assetToEdit, setAssetToEdit] = React__namespace.useState(void 0);
|
|
4730
|
+
const [folderToEdit, setFolderToEdit] = React__namespace.useState(void 0);
|
|
5222
4731
|
const { formatMessage } = reactIntl.useIntl();
|
|
5223
4732
|
const {
|
|
5224
4733
|
canRead,
|
|
@@ -5340,7 +4849,9 @@ const AssetContent = ({
|
|
|
5340
4849
|
};
|
|
5341
4850
|
const handleFolderChange = (folderId2, folderPath) => {
|
|
5342
4851
|
onChangeFolder(folderId2);
|
|
5343
|
-
onChangeFolderParam
|
|
4852
|
+
if (onChangeFolderParam) {
|
|
4853
|
+
onChangeFolderParam(folderId2, folderPath);
|
|
4854
|
+
}
|
|
5344
4855
|
};
|
|
5345
4856
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5346
4857
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: formatMessage({
|
|
@@ -5399,11 +4910,11 @@ const AssetContent = ({
|
|
|
5399
4910
|
pagination,
|
|
5400
4911
|
queryObject,
|
|
5401
4912
|
onAddAsset,
|
|
5402
|
-
onChangeFilters,
|
|
4913
|
+
onChangeFilters: (filters) => onChangeFilters(filters),
|
|
5403
4914
|
onChangeFolder: handleFolderChange,
|
|
5404
4915
|
onChangePage,
|
|
5405
4916
|
onChangePageSize,
|
|
5406
|
-
onChangeSort,
|
|
4917
|
+
onChangeSort: (sort) => onChangeSort(sort),
|
|
5407
4918
|
onChangeSearch
|
|
5408
4919
|
}
|
|
5409
4920
|
) }),
|
|
@@ -5420,49 +4931,9 @@ const AssetContent = ({
|
|
|
5420
4931
|
/* @__PURE__ */ jsxRuntime.jsx(DialogFooter, { onClose, onValidate: () => onValidate(selectedAssets) })
|
|
5421
4932
|
] });
|
|
5422
4933
|
};
|
|
5423
|
-
|
|
5424
|
-
allowedTypes: [],
|
|
5425
|
-
folderId: null,
|
|
5426
|
-
initiallySelectedAssets: [],
|
|
5427
|
-
multiple: false,
|
|
5428
|
-
trackedLocation: void 0
|
|
5429
|
-
};
|
|
5430
|
-
AssetContent.propTypes = {
|
|
5431
|
-
allowedTypes: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
|
|
5432
|
-
folderId: PropTypes__default.default.number,
|
|
5433
|
-
initiallySelectedAssets: PropTypes__default.default.arrayOf(AssetDefinition),
|
|
5434
|
-
multiple: PropTypes__default.default.bool,
|
|
5435
|
-
onAddAsset: PropTypes__default.default.func.isRequired,
|
|
5436
|
-
onAddFolder: PropTypes__default.default.func.isRequired,
|
|
5437
|
-
onChangeFolder: PropTypes__default.default.func.isRequired,
|
|
5438
|
-
onClose: PropTypes__default.default.func.isRequired,
|
|
5439
|
-
onValidate: PropTypes__default.default.func.isRequired,
|
|
5440
|
-
trackedLocation: PropTypes__default.default.string
|
|
5441
|
-
};
|
|
5442
|
-
const AssetDialog = ({ open, onClose, ...restProps }) => {
|
|
4934
|
+
const AssetDialog = ({ open = false, onClose, ...restProps }) => {
|
|
5443
4935
|
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open, onOpenChange: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(AssetContent, { onClose, ...restProps }) }) });
|
|
5444
4936
|
};
|
|
5445
|
-
AssetDialog.defaultProps = {
|
|
5446
|
-
allowedTypes: [],
|
|
5447
|
-
folderId: null,
|
|
5448
|
-
initiallySelectedAssets: [],
|
|
5449
|
-
multiple: false,
|
|
5450
|
-
open: false,
|
|
5451
|
-
trackedLocation: void 0
|
|
5452
|
-
};
|
|
5453
|
-
AssetDialog.propTypes = {
|
|
5454
|
-
allowedTypes: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
|
|
5455
|
-
folderId: PropTypes__default.default.number,
|
|
5456
|
-
initiallySelectedAssets: PropTypes__default.default.arrayOf(AssetDefinition),
|
|
5457
|
-
multiple: PropTypes__default.default.bool,
|
|
5458
|
-
onAddAsset: PropTypes__default.default.func.isRequired,
|
|
5459
|
-
onAddFolder: PropTypes__default.default.func.isRequired,
|
|
5460
|
-
onChangeFolder: PropTypes__default.default.func.isRequired,
|
|
5461
|
-
open: PropTypes__default.default.bool,
|
|
5462
|
-
onClose: PropTypes__default.default.func.isRequired,
|
|
5463
|
-
onValidate: PropTypes__default.default.func.isRequired,
|
|
5464
|
-
trackedLocation: PropTypes__default.default.string
|
|
5465
|
-
};
|
|
5466
4937
|
const TabsRoot = styledComponents.styled(designSystem.Tabs.Root)`
|
|
5467
4938
|
display: flex;
|
|
5468
4939
|
flex-direction: column;
|
|
@@ -5485,10 +4956,14 @@ const OpaqueBox = styledComponents.styled(designSystem.Box)`
|
|
|
5485
4956
|
opacity: 0;
|
|
5486
4957
|
cursor: pointer;
|
|
5487
4958
|
`;
|
|
5488
|
-
const FromComputerForm = ({
|
|
4959
|
+
const FromComputerForm = ({
|
|
4960
|
+
onClose,
|
|
4961
|
+
onAddAssets,
|
|
4962
|
+
trackedLocation
|
|
4963
|
+
}) => {
|
|
5489
4964
|
const { formatMessage } = reactIntl.useIntl();
|
|
5490
|
-
const [dragOver, setDragOver] =
|
|
5491
|
-
const inputRef =
|
|
4965
|
+
const [dragOver, setDragOver] = React__namespace.useState(false);
|
|
4966
|
+
const inputRef = React__namespace.useRef(null);
|
|
5492
4967
|
const { trackUsage } = strapiAdmin.useTracking();
|
|
5493
4968
|
const handleDragOver = (event) => {
|
|
5494
4969
|
event.preventDefault();
|
|
@@ -5500,15 +4975,19 @@ const FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => {
|
|
|
5500
4975
|
const handleDragLeave = () => setDragOver(false);
|
|
5501
4976
|
const handleClick = (e) => {
|
|
5502
4977
|
e.preventDefault();
|
|
5503
|
-
inputRef.current
|
|
4978
|
+
inputRef.current?.click();
|
|
5504
4979
|
};
|
|
5505
4980
|
const handleChange = () => {
|
|
5506
|
-
const files2 = inputRef.current
|
|
4981
|
+
const files2 = inputRef.current?.files;
|
|
5507
4982
|
const assets = [];
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
4983
|
+
if (files2) {
|
|
4984
|
+
for (let i = 0; i < files2.length; i++) {
|
|
4985
|
+
const file = files2.item(i);
|
|
4986
|
+
if (file) {
|
|
4987
|
+
const asset = rawFileToAsset(file, AssetSource.Computer);
|
|
4988
|
+
assets.push(asset);
|
|
4989
|
+
}
|
|
4990
|
+
}
|
|
5512
4991
|
}
|
|
5513
4992
|
if (trackedLocation) {
|
|
5514
4993
|
trackUsage("didSelectFile", { source: "computer", location: trackedLocation });
|
|
@@ -5522,8 +5001,10 @@ const FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => {
|
|
|
5522
5001
|
const assets = [];
|
|
5523
5002
|
for (let i = 0; i < files2.length; i++) {
|
|
5524
5003
|
const file = files2.item(i);
|
|
5525
|
-
|
|
5526
|
-
|
|
5004
|
+
if (file) {
|
|
5005
|
+
const asset = rawFileToAsset(file, AssetSource.Computer);
|
|
5006
|
+
assets.push(asset);
|
|
5007
|
+
}
|
|
5527
5008
|
}
|
|
5528
5009
|
onAddAssets(assets);
|
|
5529
5010
|
}
|
|
@@ -5563,6 +5044,10 @@ const FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => {
|
|
|
5563
5044
|
type: "file",
|
|
5564
5045
|
multiple: true,
|
|
5565
5046
|
name: "files",
|
|
5047
|
+
"aria-label": formatMessage({
|
|
5048
|
+
id: getTrad("input.label"),
|
|
5049
|
+
defaultMessage: "Drag & Drop here or"
|
|
5050
|
+
}),
|
|
5566
5051
|
tabIndex: -1,
|
|
5567
5052
|
ref: inputRef,
|
|
5568
5053
|
zIndex: 1,
|
|
@@ -5582,17 +5067,9 @@ const FromComputerForm = ({ onClose, onAddAssets, trackedLocation }) => {
|
|
|
5582
5067
|
}) }) })
|
|
5583
5068
|
] });
|
|
5584
5069
|
};
|
|
5585
|
-
FromComputerForm.defaultProps = {
|
|
5586
|
-
trackedLocation: void 0
|
|
5587
|
-
};
|
|
5588
|
-
FromComputerForm.propTypes = {
|
|
5589
|
-
onClose: PropTypes__default.default.func.isRequired,
|
|
5590
|
-
onAddAssets: PropTypes__default.default.func.isRequired,
|
|
5591
|
-
trackedLocation: PropTypes__default.default.string
|
|
5592
|
-
};
|
|
5593
5070
|
const FromUrlForm = ({ onClose, onAddAsset, trackedLocation }) => {
|
|
5594
|
-
const [loading, setLoading] =
|
|
5595
|
-
const [error, setError] =
|
|
5071
|
+
const [loading, setLoading] = React__namespace.useState(false);
|
|
5072
|
+
const [error, setError] = React__namespace.useState(void 0);
|
|
5596
5073
|
const { formatMessage } = reactIntl.useIntl();
|
|
5597
5074
|
const { trackUsage } = strapiAdmin.useTracking();
|
|
5598
5075
|
const handleSubmit = async ({ urls }) => {
|
|
@@ -5647,14 +5124,6 @@ const FromUrlForm = ({ onClose, onAddAsset, trackedLocation }) => {
|
|
|
5647
5124
|
}
|
|
5648
5125
|
);
|
|
5649
5126
|
};
|
|
5650
|
-
FromUrlForm.defaultProps = {
|
|
5651
|
-
trackedLocation: void 0
|
|
5652
|
-
};
|
|
5653
|
-
FromUrlForm.propTypes = {
|
|
5654
|
-
onClose: PropTypes__default.default.func.isRequired,
|
|
5655
|
-
onAddAsset: PropTypes__default.default.func.isRequired,
|
|
5656
|
-
trackedLocation: PropTypes__default.default.string
|
|
5657
|
-
};
|
|
5658
5127
|
const AddAssetStep = ({ onClose, onAddAsset, trackedLocation }) => {
|
|
5659
5128
|
const { formatMessage } = reactIntl.useIntl();
|
|
5660
5129
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -5704,14 +5173,6 @@ const AddAssetStep = ({ onClose, onAddAsset, trackedLocation }) => {
|
|
|
5704
5173
|
] })
|
|
5705
5174
|
] });
|
|
5706
5175
|
};
|
|
5707
|
-
AddAssetStep.defaultProps = {
|
|
5708
|
-
trackedLocation: void 0
|
|
5709
|
-
};
|
|
5710
|
-
AddAssetStep.propTypes = {
|
|
5711
|
-
onClose: PropTypes__default.default.func.isRequired,
|
|
5712
|
-
onAddAsset: PropTypes__default.default.func.isRequired,
|
|
5713
|
-
trackedLocation: PropTypes__default.default.string
|
|
5714
|
-
};
|
|
5715
5176
|
const UploadProgressWrapper = styledComponents.styled.div`
|
|
5716
5177
|
height: 8.8rem;
|
|
5717
5178
|
width: 100%;
|
|
@@ -5724,7 +5185,7 @@ const UploadingAssetCard = ({
|
|
|
5724
5185
|
onCancel,
|
|
5725
5186
|
onStatusChange,
|
|
5726
5187
|
addUploadedFiles,
|
|
5727
|
-
folderId
|
|
5188
|
+
folderId = null
|
|
5728
5189
|
}) => {
|
|
5729
5190
|
const { upload, cancel, error, progress, status } = useUpload();
|
|
5730
5191
|
const { formatMessage } = reactIntl.useIntl();
|
|
@@ -5748,16 +5209,16 @@ const UploadingAssetCard = ({
|
|
|
5748
5209
|
defaultMessage: "Audio"
|
|
5749
5210
|
});
|
|
5750
5211
|
}
|
|
5751
|
-
|
|
5212
|
+
React__namespace.useEffect(() => {
|
|
5752
5213
|
const uploadFile = async () => {
|
|
5753
|
-
const files2 = await upload(asset, folderId);
|
|
5214
|
+
const files2 = await upload(asset, folderId ? Number(folderId) : null);
|
|
5754
5215
|
if (addUploadedFiles) {
|
|
5755
5216
|
addUploadedFiles(files2);
|
|
5756
5217
|
}
|
|
5757
5218
|
};
|
|
5758
5219
|
uploadFile();
|
|
5759
5220
|
}, []);
|
|
5760
|
-
|
|
5221
|
+
React__namespace.useEffect(() => {
|
|
5761
5222
|
onStatusChange(status);
|
|
5762
5223
|
}, [status, onStatusChange]);
|
|
5763
5224
|
const handleCancel = () => {
|
|
@@ -5766,19 +5227,26 @@ const UploadingAssetCard = ({
|
|
|
5766
5227
|
};
|
|
5767
5228
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
|
5768
5229
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Card, { borderColor: error ? "danger600" : "neutral150", children: [
|
|
5769
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(UploadProgressWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5230
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(UploadProgressWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5231
|
+
UploadProgress,
|
|
5232
|
+
{
|
|
5233
|
+
error: error || void 0,
|
|
5234
|
+
onCancel: handleCancel,
|
|
5235
|
+
progress
|
|
5236
|
+
}
|
|
5237
|
+
) }) }),
|
|
5770
5238
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardBody, { children: [
|
|
5771
5239
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.CardContent, { children: [
|
|
5772
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.
|
|
5240
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardTitle, { tag: "span", children: asset.name }) }) }),
|
|
5773
5241
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.CardSubtitle, { children: /* @__PURE__ */ jsxRuntime.jsx(Extension, { children: asset.ext }) })
|
|
5774
5242
|
] }),
|
|
5775
5243
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { paddingTop: 1, grow: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.CardBadge, { children: badgeContent }) })
|
|
5776
5244
|
] })
|
|
5777
5245
|
] }),
|
|
5778
5246
|
error ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "danger600", children: formatMessage(
|
|
5779
|
-
error?.
|
|
5780
|
-
id: getTrad(`apiError.${error.
|
|
5781
|
-
defaultMessage: error.
|
|
5247
|
+
error?.message ? {
|
|
5248
|
+
id: getTrad(`apiError.${error.message}`),
|
|
5249
|
+
defaultMessage: error.message
|
|
5782
5250
|
/* See issue: https://github.com/strapi/strapi/issues/13867
|
|
5783
5251
|
A proxy might return an error, before the request reaches Strapi
|
|
5784
5252
|
and therefore we need to handle errors gracefully.
|
|
@@ -5790,22 +5258,6 @@ const UploadingAssetCard = ({
|
|
|
5790
5258
|
) }) : void 0
|
|
5791
5259
|
] });
|
|
5792
5260
|
};
|
|
5793
|
-
UploadingAssetCard.defaultProps = {
|
|
5794
|
-
addUploadedFiles: void 0,
|
|
5795
|
-
folderId: null
|
|
5796
|
-
};
|
|
5797
|
-
UploadingAssetCard.propTypes = {
|
|
5798
|
-
addUploadedFiles: PropTypes__default.default.func,
|
|
5799
|
-
asset: PropTypes__default.default.shape({
|
|
5800
|
-
name: PropTypes__default.default.string,
|
|
5801
|
-
ext: PropTypes__default.default.string,
|
|
5802
|
-
rawFile: PropTypes__default.default.instanceOf(File),
|
|
5803
|
-
type: PropTypes__default.default.oneOf(Object.values(AssetType))
|
|
5804
|
-
}).isRequired,
|
|
5805
|
-
folderId: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
5806
|
-
onCancel: PropTypes__default.default.func.isRequired,
|
|
5807
|
-
onStatusChange: PropTypes__default.default.func.isRequired
|
|
5808
|
-
};
|
|
5809
5261
|
const Status = {
|
|
5810
5262
|
Idle: "IDLE",
|
|
5811
5263
|
Uploading: "UPLOADING",
|
|
@@ -5823,21 +5275,28 @@ const PendingAssetStep = ({
|
|
|
5823
5275
|
onUploadSucceed,
|
|
5824
5276
|
trackedLocation
|
|
5825
5277
|
}) => {
|
|
5826
|
-
const assetCountRef =
|
|
5278
|
+
const assetCountRef = React__namespace.useRef(0);
|
|
5827
5279
|
const { formatMessage } = reactIntl.useIntl();
|
|
5828
5280
|
const { trackUsage } = strapiAdmin.useTracking();
|
|
5829
|
-
const [uploadStatus, setUploadStatus] =
|
|
5281
|
+
const [uploadStatus, setUploadStatus] = React__namespace.useState(Status.Idle);
|
|
5830
5282
|
const handleSubmit = async (e) => {
|
|
5831
5283
|
e.preventDefault();
|
|
5832
5284
|
e.stopPropagation();
|
|
5833
|
-
const assetsCountByType = assets.reduce(
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
acc[type]
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5285
|
+
const assetsCountByType = assets.reduce(
|
|
5286
|
+
(acc, asset) => {
|
|
5287
|
+
const { type } = asset;
|
|
5288
|
+
if (type !== void 0 && !acc[type]) {
|
|
5289
|
+
acc[type] = 0;
|
|
5290
|
+
}
|
|
5291
|
+
if (type !== void 0) {
|
|
5292
|
+
const accType = acc[type];
|
|
5293
|
+
const currentCount = typeof accType === "string" ? accType : accType.toString();
|
|
5294
|
+
acc[type] = `${parseInt(currentCount, 10) + 1}`;
|
|
5295
|
+
}
|
|
5296
|
+
return acc;
|
|
5297
|
+
},
|
|
5298
|
+
{}
|
|
5299
|
+
);
|
|
5841
5300
|
trackUsage("willAddMediaLibraryAssets", {
|
|
5842
5301
|
location: trackedLocation,
|
|
5843
5302
|
...assetsCountByType
|
|
@@ -5923,40 +5382,24 @@ const PendingAssetStep = ({
|
|
|
5923
5382
|
] })
|
|
5924
5383
|
] });
|
|
5925
5384
|
};
|
|
5926
|
-
PendingAssetStep.defaultProps = {
|
|
5927
|
-
addUploadedFiles: void 0,
|
|
5928
|
-
folderId: null,
|
|
5929
|
-
trackedLocation: void 0
|
|
5930
|
-
};
|
|
5931
|
-
PendingAssetStep.propTypes = {
|
|
5932
|
-
addUploadedFiles: PropTypes__default.default.func,
|
|
5933
|
-
assets: PropTypes__default.default.arrayOf(AssetDefinition).isRequired,
|
|
5934
|
-
folderId: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
5935
|
-
onClose: PropTypes__default.default.func.isRequired,
|
|
5936
|
-
onEditAsset: PropTypes__default.default.func.isRequired,
|
|
5937
|
-
onRemoveAsset: PropTypes__default.default.func.isRequired,
|
|
5938
|
-
onClickAddAsset: PropTypes__default.default.func.isRequired,
|
|
5939
|
-
onUploadSucceed: PropTypes__default.default.func.isRequired,
|
|
5940
|
-
onCancelUpload: PropTypes__default.default.func.isRequired,
|
|
5941
|
-
trackedLocation: PropTypes__default.default.string
|
|
5942
|
-
};
|
|
5943
5385
|
const Steps = {
|
|
5944
5386
|
AddAsset: "AddAsset",
|
|
5945
5387
|
PendingAsset: "PendingAsset"
|
|
5946
5388
|
};
|
|
5947
5389
|
const UploadAssetDialog = ({
|
|
5948
5390
|
initialAssetsToAdd,
|
|
5949
|
-
folderId,
|
|
5950
|
-
onClose
|
|
5391
|
+
folderId = null,
|
|
5392
|
+
onClose = () => {
|
|
5393
|
+
},
|
|
5951
5394
|
addUploadedFiles,
|
|
5952
5395
|
trackedLocation,
|
|
5953
5396
|
open,
|
|
5954
5397
|
validateAssetsTypes = (_, cb) => cb()
|
|
5955
5398
|
}) => {
|
|
5956
5399
|
const { formatMessage } = reactIntl.useIntl();
|
|
5957
|
-
const [step, setStep] =
|
|
5958
|
-
const [assets, setAssets] =
|
|
5959
|
-
const [assetToEdit, setAssetToEdit] =
|
|
5400
|
+
const [step, setStep] = React__namespace.useState(initialAssetsToAdd ? Steps.PendingAsset : Steps.AddAsset);
|
|
5401
|
+
const [assets, setAssets] = React__namespace.useState(initialAssetsToAdd || []);
|
|
5402
|
+
const [assetToEdit, setAssetToEdit] = React__namespace.useState(void 0);
|
|
5960
5403
|
const handleAddToPendingAssets = (nextAssets) => {
|
|
5961
5404
|
validateAssetsTypes(nextAssets, () => {
|
|
5962
5405
|
setAssets((prevAssets) => prevAssets.concat(nextAssets));
|
|
@@ -5981,7 +5424,7 @@ const UploadAssetDialog = ({
|
|
|
5981
5424
|
}
|
|
5982
5425
|
};
|
|
5983
5426
|
const handleAssetEditValidation = (nextAsset) => {
|
|
5984
|
-
if (nextAsset) {
|
|
5427
|
+
if (nextAsset && typeof nextAsset !== "boolean") {
|
|
5985
5428
|
const nextAssets = assets.map((asset) => asset === assetToEdit ? nextAsset : asset);
|
|
5986
5429
|
setAssets(nextAssets);
|
|
5987
5430
|
}
|
|
@@ -6011,7 +5454,7 @@ const UploadAssetDialog = ({
|
|
|
6011
5454
|
AddAssetStep,
|
|
6012
5455
|
{
|
|
6013
5456
|
onClose,
|
|
6014
|
-
onAddAsset: handleAddToPendingAssets,
|
|
5457
|
+
onAddAsset: (assets2) => handleAddToPendingAssets(assets2),
|
|
6015
5458
|
trackedLocation
|
|
6016
5459
|
}
|
|
6017
5460
|
) }),
|
|
@@ -6044,32 +5487,18 @@ const UploadAssetDialog = ({
|
|
|
6044
5487
|
) })
|
|
6045
5488
|
] });
|
|
6046
5489
|
};
|
|
6047
|
-
UploadAssetDialog.defaultProps = {
|
|
6048
|
-
addUploadedFiles: void 0,
|
|
6049
|
-
folderId: null,
|
|
6050
|
-
initialAssetsToAdd: void 0,
|
|
6051
|
-
onClose() {
|
|
6052
|
-
},
|
|
6053
|
-
trackedLocation: void 0,
|
|
6054
|
-
validateAssetsTypes: void 0
|
|
6055
|
-
};
|
|
6056
|
-
UploadAssetDialog.propTypes = {
|
|
6057
|
-
addUploadedFiles: PropTypes__default.default.func,
|
|
6058
|
-
folderId: PropTypes__default.default.oneOfType([PropTypes__default.default.number, PropTypes__default.default.string]),
|
|
6059
|
-
initialAssetsToAdd: PropTypes__default.default.arrayOf(AssetDefinition),
|
|
6060
|
-
open: PropTypes__default.default.bool.isRequired,
|
|
6061
|
-
onClose: PropTypes__default.default.func,
|
|
6062
|
-
trackedLocation: PropTypes__default.default.string,
|
|
6063
|
-
validateAssetsTypes: PropTypes__default.default.func
|
|
6064
|
-
};
|
|
6065
5490
|
const STEPS$1 = {
|
|
6066
5491
|
AssetSelect: "SelectAsset",
|
|
6067
5492
|
AssetUpload: "UploadAsset",
|
|
6068
5493
|
FolderCreate: "FolderCreate"
|
|
6069
5494
|
};
|
|
6070
|
-
const MediaLibraryDialog = ({
|
|
6071
|
-
|
|
6072
|
-
|
|
5495
|
+
const MediaLibraryDialog = ({
|
|
5496
|
+
onClose,
|
|
5497
|
+
onSelectAssets,
|
|
5498
|
+
allowedTypes = ["files", "images", "videos", "audios"]
|
|
5499
|
+
}) => {
|
|
5500
|
+
const [step, setStep] = React__namespace.useState(STEPS$1.AssetSelect);
|
|
5501
|
+
const [folderId, setFolderId] = React__namespace.useState(null);
|
|
6073
5502
|
switch (step) {
|
|
6074
5503
|
case STEPS$1.AssetSelect:
|
|
6075
5504
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6099,14 +5528,6 @@ const MediaLibraryDialog = ({ onClose, onSelectAssets, allowedTypes }) => {
|
|
|
6099
5528
|
return /* @__PURE__ */ jsxRuntime.jsx(UploadAssetDialog, { open: true, onClose: () => setStep(STEPS$1.AssetSelect), folderId });
|
|
6100
5529
|
}
|
|
6101
5530
|
};
|
|
6102
|
-
MediaLibraryDialog.defaultProps = {
|
|
6103
|
-
allowedTypes: ["files", "images", "videos", "audios"]
|
|
6104
|
-
};
|
|
6105
|
-
MediaLibraryDialog.propTypes = {
|
|
6106
|
-
allowedTypes: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
|
|
6107
|
-
onClose: PropTypes__default.default.func.isRequired,
|
|
6108
|
-
onSelectAssets: PropTypes__default.default.func.isRequired
|
|
6109
|
-
};
|
|
6110
5531
|
const DocAsset = styledComponents.styled(designSystem.Flex)`
|
|
6111
5532
|
background: linear-gradient(180deg, #ffffff 0%, #f6f6f9 121.48%);
|
|
6112
5533
|
`;
|
|
@@ -6124,7 +5545,7 @@ const AudioPreviewWrapper = styledComponents.styled(designSystem.Box)`
|
|
|
6124
5545
|
}
|
|
6125
5546
|
`;
|
|
6126
5547
|
const CarouselAsset = ({ asset }) => {
|
|
6127
|
-
if (asset.mime
|
|
5548
|
+
if (asset.mime?.includes(AssetType.Video)) {
|
|
6128
5549
|
return /* @__PURE__ */ jsxRuntime.jsx(VideoPreviewWrapper, { height: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6129
5550
|
VideoPreview,
|
|
6130
5551
|
{
|
|
@@ -6134,10 +5555,16 @@ const CarouselAsset = ({ asset }) => {
|
|
|
6134
5555
|
}
|
|
6135
5556
|
) });
|
|
6136
5557
|
}
|
|
6137
|
-
if (asset.mime
|
|
6138
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AudioPreviewWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5558
|
+
if (asset.mime?.includes(AssetType.Audio)) {
|
|
5559
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AudioPreviewWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5560
|
+
AudioPreview,
|
|
5561
|
+
{
|
|
5562
|
+
url: createAssetUrl(asset, true),
|
|
5563
|
+
alt: asset.alternativeText || asset.name
|
|
5564
|
+
}
|
|
5565
|
+
) });
|
|
6139
5566
|
}
|
|
6140
|
-
if (asset.mime
|
|
5567
|
+
if (asset.mime?.includes(AssetType.Image)) {
|
|
6141
5568
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6142
5569
|
designSystem.Box,
|
|
6143
5570
|
{
|
|
@@ -6149,12 +5576,14 @@ const CarouselAsset = ({ asset }) => {
|
|
|
6149
5576
|
}
|
|
6150
5577
|
);
|
|
6151
5578
|
}
|
|
6152
|
-
return /* @__PURE__ */ jsxRuntime.jsx(DocAsset, { width: "100%", height: "100%", justifyContent: "center", hasRadius: true, children: asset.ext
|
|
6153
|
-
};
|
|
6154
|
-
CarouselAsset.propTypes = {
|
|
6155
|
-
asset: AssetDefinition.isRequired
|
|
5579
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DocAsset, { width: "100%", height: "100%", justifyContent: "center", hasRadius: true, children: asset.ext?.includes("pdf") ? /* @__PURE__ */ jsxRuntime.jsx(icons.FilePdf, { "aria-label": asset.alternativeText || asset.name, width: "24px", height: "32px" }) : /* @__PURE__ */ jsxRuntime.jsx(icons.File, { "aria-label": asset.alternativeText || asset.name, width: "24px", height: "32px" }) });
|
|
6156
5580
|
};
|
|
6157
|
-
const CarouselAssetActions = ({
|
|
5581
|
+
const CarouselAssetActions = ({
|
|
5582
|
+
asset,
|
|
5583
|
+
onDeleteAsset,
|
|
5584
|
+
onAddAsset,
|
|
5585
|
+
onEditAsset
|
|
5586
|
+
}) => {
|
|
6158
5587
|
const { formatMessage } = reactIntl.useIntl();
|
|
6159
5588
|
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.CarouselActions, { children: [
|
|
6160
5589
|
onAddAsset && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6193,23 +5622,16 @@ const CarouselAssetActions = ({ asset, onDeleteAsset, onAddAsset, onEditAsset })
|
|
|
6193
5622
|
)
|
|
6194
5623
|
] });
|
|
6195
5624
|
};
|
|
6196
|
-
CarouselAssetActions.defaultProps = {
|
|
6197
|
-
onAddAsset: void 0,
|
|
6198
|
-
onDeleteAsset: void 0,
|
|
6199
|
-
onEditAsset: void 0
|
|
6200
|
-
};
|
|
6201
|
-
CarouselAssetActions.propTypes = {
|
|
6202
|
-
asset: AssetDefinition.isRequired,
|
|
6203
|
-
onAddAsset: PropTypes__default.default.func,
|
|
6204
|
-
onEditAsset: PropTypes__default.default.func,
|
|
6205
|
-
onDeleteAsset: PropTypes__default.default.func
|
|
6206
|
-
};
|
|
6207
5625
|
const TextAlignTypography = styledComponents.styled(designSystem.Typography)`
|
|
6208
5626
|
align-items: center;
|
|
6209
5627
|
`;
|
|
6210
|
-
const EmptyStateAsset = ({
|
|
5628
|
+
const EmptyStateAsset = ({
|
|
5629
|
+
disabled = false,
|
|
5630
|
+
onClick,
|
|
5631
|
+
onDropAsset
|
|
5632
|
+
}) => {
|
|
6211
5633
|
const { formatMessage } = reactIntl.useIntl();
|
|
6212
|
-
const [dragOver, setDragOver] =
|
|
5634
|
+
const [dragOver, setDragOver] = React__namespace.useState(false);
|
|
6213
5635
|
const handleDragEnter = (e) => {
|
|
6214
5636
|
e.preventDefault();
|
|
6215
5637
|
setDragOver(true);
|
|
@@ -6229,8 +5651,10 @@ const EmptyStateAsset = ({ disabled, onClick, onDropAsset }) => {
|
|
|
6229
5651
|
const assets = [];
|
|
6230
5652
|
for (let i = 0; i < files2.length; i++) {
|
|
6231
5653
|
const file = files2.item(i);
|
|
6232
|
-
|
|
6233
|
-
|
|
5654
|
+
if (file) {
|
|
5655
|
+
const asset = rawFileToAsset(file, AssetSource.Computer);
|
|
5656
|
+
assets.push(asset);
|
|
5657
|
+
}
|
|
6234
5658
|
}
|
|
6235
5659
|
onDropAsset(assets);
|
|
6236
5660
|
}
|
|
@@ -6285,19 +5709,10 @@ const EmptyStateAsset = ({ disabled, onClick, onDropAsset }) => {
|
|
|
6285
5709
|
}
|
|
6286
5710
|
);
|
|
6287
5711
|
};
|
|
6288
|
-
|
|
6289
|
-
disabled: false,
|
|
6290
|
-
onDropAsset: void 0
|
|
6291
|
-
};
|
|
6292
|
-
EmptyStateAsset.propTypes = {
|
|
6293
|
-
disabled: PropTypes__default.default.bool,
|
|
6294
|
-
onClick: PropTypes__default.default.func.isRequired,
|
|
6295
|
-
onDropAsset: PropTypes__default.default.func
|
|
6296
|
-
};
|
|
6297
|
-
const CarouselAssets = React.forwardRef(
|
|
5712
|
+
const CarouselAssets = React__namespace.forwardRef(
|
|
6298
5713
|
({
|
|
6299
5714
|
assets,
|
|
6300
|
-
disabled,
|
|
5715
|
+
disabled = false,
|
|
6301
5716
|
error,
|
|
6302
5717
|
hint,
|
|
6303
5718
|
label,
|
|
@@ -6309,12 +5724,12 @@ const CarouselAssets = React.forwardRef(
|
|
|
6309
5724
|
onEditAsset,
|
|
6310
5725
|
onNext,
|
|
6311
5726
|
onPrevious,
|
|
6312
|
-
required,
|
|
5727
|
+
required = false,
|
|
6313
5728
|
selectedAssetIndex,
|
|
6314
5729
|
trackedLocation
|
|
6315
5730
|
}, forwardedRef) => {
|
|
6316
5731
|
const { formatMessage } = reactIntl.useIntl();
|
|
6317
|
-
const [isEditingAsset, setIsEditingAsset] =
|
|
5732
|
+
const [isEditingAsset, setIsEditingAsset] = React__namespace.useState(false);
|
|
6318
5733
|
const currentAsset = assets[selectedAssetIndex];
|
|
6319
5734
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6320
5735
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6357,9 +5772,16 @@ const CarouselAssets = React.forwardRef(
|
|
|
6357
5772
|
},
|
|
6358
5773
|
{ n: 1, m: 1 }
|
|
6359
5774
|
),
|
|
6360
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5775
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5776
|
+
EmptyStateAsset,
|
|
5777
|
+
{
|
|
5778
|
+
disabled,
|
|
5779
|
+
onClick: onAddAsset,
|
|
5780
|
+
onDropAsset
|
|
5781
|
+
}
|
|
5782
|
+
)
|
|
6361
5783
|
}
|
|
6362
|
-
) : assets.map((asset,
|
|
5784
|
+
) : assets.map((asset, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6363
5785
|
designSystem.CarouselSlide,
|
|
6364
5786
|
{
|
|
6365
5787
|
label: formatMessage(
|
|
@@ -6367,7 +5789,7 @@ const CarouselAssets = React.forwardRef(
|
|
|
6367
5789
|
id: getTrad("mediaLibraryInput.slideCount"),
|
|
6368
5790
|
defaultMessage: "{n} of {m} slides"
|
|
6369
5791
|
},
|
|
6370
|
-
{ n:
|
|
5792
|
+
{ n: index + 1, m: assets.length }
|
|
6371
5793
|
),
|
|
6372
5794
|
children: /* @__PURE__ */ jsxRuntime.jsx(CarouselAsset, { asset })
|
|
6373
5795
|
},
|
|
@@ -6384,8 +5806,8 @@ const CarouselAssets = React.forwardRef(
|
|
|
6384
5806
|
if (editedAsset === null) {
|
|
6385
5807
|
onDeleteAssetFromMediaLibrary();
|
|
6386
5808
|
}
|
|
6387
|
-
if (editedAsset) {
|
|
6388
|
-
onEditAsset(editedAsset);
|
|
5809
|
+
if (editedAsset && typeof editedAsset !== "boolean") {
|
|
5810
|
+
onEditAsset?.(editedAsset);
|
|
6389
5811
|
}
|
|
6390
5812
|
},
|
|
6391
5813
|
asset: currentAsset,
|
|
@@ -6398,50 +5820,31 @@ const CarouselAssets = React.forwardRef(
|
|
|
6398
5820
|
] });
|
|
6399
5821
|
}
|
|
6400
5822
|
);
|
|
6401
|
-
CarouselAssets.defaultProps = {
|
|
6402
|
-
disabled: false,
|
|
6403
|
-
error: void 0,
|
|
6404
|
-
hint: void 0,
|
|
6405
|
-
labelAction: void 0,
|
|
6406
|
-
onDropAsset: void 0,
|
|
6407
|
-
required: false,
|
|
6408
|
-
trackedLocation: void 0
|
|
6409
|
-
};
|
|
6410
|
-
CarouselAssets.propTypes = {
|
|
6411
|
-
assets: PropTypes__default.default.arrayOf(AssetDefinition).isRequired,
|
|
6412
|
-
disabled: PropTypes__default.default.bool,
|
|
6413
|
-
error: PropTypes__default.default.string,
|
|
6414
|
-
hint: PropTypes__default.default.string,
|
|
6415
|
-
label: PropTypes__default.default.string.isRequired,
|
|
6416
|
-
labelAction: PropTypes__default.default.node,
|
|
6417
|
-
onAddAsset: PropTypes__default.default.func.isRequired,
|
|
6418
|
-
onDeleteAsset: PropTypes__default.default.func.isRequired,
|
|
6419
|
-
onDeleteAssetFromMediaLibrary: PropTypes__default.default.func.isRequired,
|
|
6420
|
-
onDropAsset: PropTypes__default.default.func,
|
|
6421
|
-
onEditAsset: PropTypes__default.default.func.isRequired,
|
|
6422
|
-
onNext: PropTypes__default.default.func.isRequired,
|
|
6423
|
-
onPrevious: PropTypes__default.default.func.isRequired,
|
|
6424
|
-
required: PropTypes__default.default.bool,
|
|
6425
|
-
selectedAssetIndex: PropTypes__default.default.number.isRequired,
|
|
6426
|
-
trackedLocation: PropTypes__default.default.string
|
|
6427
|
-
};
|
|
6428
5823
|
const STEPS = {
|
|
6429
5824
|
AssetSelect: "SelectAsset",
|
|
6430
5825
|
AssetUpload: "UploadAsset",
|
|
6431
5826
|
FolderCreate: "FolderCreate"
|
|
6432
5827
|
};
|
|
6433
|
-
const MediaLibraryInput =
|
|
6434
|
-
({
|
|
5828
|
+
const MediaLibraryInput = React__namespace.forwardRef(
|
|
5829
|
+
({
|
|
5830
|
+
attribute: { allowedTypes = ["videos", "files", "images", "audios"], multiple = false },
|
|
5831
|
+
label,
|
|
5832
|
+
hint,
|
|
5833
|
+
disabled = false,
|
|
5834
|
+
labelAction = void 0,
|
|
5835
|
+
name: name2,
|
|
5836
|
+
required = false
|
|
5837
|
+
}, forwardedRef) => {
|
|
6435
5838
|
const { formatMessage } = reactIntl.useIntl();
|
|
6436
5839
|
const { onChange, value, error } = strapiAdmin.useField(name2);
|
|
6437
5840
|
const fieldAllowedTypes = allowedTypes || ["files", "images", "videos", "audios"];
|
|
6438
|
-
const [uploadedFiles, setUploadedFiles] =
|
|
6439
|
-
const [step, setStep] =
|
|
6440
|
-
const [selectedIndex, setSelectedIndex] =
|
|
6441
|
-
const [droppedAssets, setDroppedAssets] =
|
|
6442
|
-
const [folderId, setFolderId] =
|
|
5841
|
+
const [uploadedFiles, setUploadedFiles] = React__namespace.useState([]);
|
|
5842
|
+
const [step, setStep] = React__namespace.useState(void 0);
|
|
5843
|
+
const [selectedIndex, setSelectedIndex] = React__namespace.useState(0);
|
|
5844
|
+
const [droppedAssets, setDroppedAssets] = React__namespace.useState();
|
|
5845
|
+
const [folderId, setFolderId] = React__namespace.useState(null);
|
|
6443
5846
|
const { toggleNotification } = strapiAdmin.useNotification();
|
|
6444
|
-
|
|
5847
|
+
React__namespace.useEffect(() => {
|
|
6445
5848
|
if (step === void 0) {
|
|
6446
5849
|
setUploadedFiles([]);
|
|
6447
5850
|
}
|
|
@@ -6453,9 +5856,8 @@ const MediaLibraryInput = React.forwardRef(
|
|
|
6453
5856
|
selectedAssets = [value];
|
|
6454
5857
|
}
|
|
6455
5858
|
const handleValidation = (nextSelectedAssets) => {
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
});
|
|
5859
|
+
const value2 = multiple ? nextSelectedAssets : nextSelectedAssets[0];
|
|
5860
|
+
onChange(name2, value2);
|
|
6459
5861
|
setStep(void 0);
|
|
6460
5862
|
};
|
|
6461
5863
|
const handleDeleteAssetFromMediaLibrary = () => {
|
|
@@ -6468,9 +5870,8 @@ const MediaLibraryInput = React.forwardRef(
|
|
|
6468
5870
|
} else {
|
|
6469
5871
|
nextValue = null;
|
|
6470
5872
|
}
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
});
|
|
5873
|
+
const value2 = nextValue;
|
|
5874
|
+
onChange(name2, value2);
|
|
6474
5875
|
setSelectedIndex(0);
|
|
6475
5876
|
};
|
|
6476
5877
|
const handleDeleteAsset = (asset) => {
|
|
@@ -6481,18 +5882,14 @@ const MediaLibraryInput = React.forwardRef(
|
|
|
6481
5882
|
} else {
|
|
6482
5883
|
nextValue = null;
|
|
6483
5884
|
}
|
|
6484
|
-
onChange(
|
|
6485
|
-
target: { name: name2, value: nextValue }
|
|
6486
|
-
});
|
|
5885
|
+
onChange(name2, nextValue);
|
|
6487
5886
|
setSelectedIndex(0);
|
|
6488
5887
|
};
|
|
6489
5888
|
const handleAssetEdit = (asset) => {
|
|
6490
5889
|
const nextSelectedAssets = selectedAssets.map(
|
|
6491
5890
|
(prevAsset) => prevAsset.id === asset.id ? asset : prevAsset
|
|
6492
5891
|
);
|
|
6493
|
-
onChange(
|
|
6494
|
-
target: { name: name2, value: multiple ? nextSelectedAssets : nextSelectedAssets[0] }
|
|
6495
|
-
});
|
|
5892
|
+
onChange(name2, multiple ? nextSelectedAssets : nextSelectedAssets[0]);
|
|
6496
5893
|
};
|
|
6497
5894
|
const validateAssetsTypes = (assets, callback) => {
|
|
6498
5895
|
const allowedAssets = getAllowedFiles(fieldAllowedTypes, assets);
|
|
@@ -6534,7 +5931,10 @@ const MediaLibraryInput = React.forwardRef(
|
|
|
6534
5931
|
};
|
|
6535
5932
|
let initiallySelectedAssets = selectedAssets;
|
|
6536
5933
|
if (uploadedFiles.length > 0) {
|
|
6537
|
-
const allowedUploadedFiles = getAllowedFiles(
|
|
5934
|
+
const allowedUploadedFiles = getAllowedFiles(
|
|
5935
|
+
fieldAllowedTypes,
|
|
5936
|
+
uploadedFiles
|
|
5937
|
+
);
|
|
6538
5938
|
initiallySelectedAssets = multiple ? [...allowedUploadedFiles, ...selectedAssets] : [allowedUploadedFiles[0]];
|
|
6539
5939
|
}
|
|
6540
5940
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -6602,28 +6002,8 @@ const MediaLibraryInput = React.forwardRef(
|
|
|
6602
6002
|
] });
|
|
6603
6003
|
}
|
|
6604
6004
|
);
|
|
6605
|
-
MediaLibraryInput.defaultProps = {
|
|
6606
|
-
attribute: { allowedTypes: ["videos", "files", "images", "audios"], multiple: false },
|
|
6607
|
-
disabled: false,
|
|
6608
|
-
hint: void 0,
|
|
6609
|
-
label: void 0,
|
|
6610
|
-
labelAction: void 0,
|
|
6611
|
-
required: false
|
|
6612
|
-
};
|
|
6613
|
-
MediaLibraryInput.propTypes = {
|
|
6614
|
-
attribute: PropTypes__default.default.shape({
|
|
6615
|
-
allowedTypes: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
|
|
6616
|
-
multiple: PropTypes__default.default.bool
|
|
6617
|
-
}),
|
|
6618
|
-
disabled: PropTypes__default.default.bool,
|
|
6619
|
-
hint: PropTypes__default.default.string,
|
|
6620
|
-
label: PropTypes__default.default.string,
|
|
6621
|
-
labelAction: PropTypes__default.default.node,
|
|
6622
|
-
name: PropTypes__default.default.string.isRequired,
|
|
6623
|
-
required: PropTypes__default.default.bool
|
|
6624
|
-
};
|
|
6625
6005
|
const name = pluginPkg.strapi.name;
|
|
6626
|
-
const
|
|
6006
|
+
const admin = {
|
|
6627
6007
|
register(app) {
|
|
6628
6008
|
app.addMenuLink({
|
|
6629
6009
|
to: `plugins/${pluginId}`,
|
|
@@ -6633,21 +6013,32 @@ const index = {
|
|
|
6633
6013
|
defaultMessage: "Media Library"
|
|
6634
6014
|
},
|
|
6635
6015
|
permissions: PERMISSIONS.main,
|
|
6636
|
-
Component: () => Promise.resolve().then(() => require("./
|
|
6016
|
+
Component: () => Promise.resolve().then(() => require("./App-Dqqn78jO.js")).then((mod) => ({ default: mod.Upload })),
|
|
6637
6017
|
position: 4
|
|
6638
6018
|
});
|
|
6639
6019
|
app.addSettingsLink("global", {
|
|
6640
6020
|
id: "media-library-settings",
|
|
6021
|
+
to: "media-library",
|
|
6641
6022
|
intlLabel: {
|
|
6642
6023
|
id: getTrad("plugin.name"),
|
|
6643
6024
|
defaultMessage: "Media Library"
|
|
6644
6025
|
},
|
|
6645
|
-
|
|
6646
|
-
|
|
6026
|
+
async Component() {
|
|
6027
|
+
const { ProtectedSettingsPage } = await Promise.resolve().then(() => require("./SettingsPage-oDEVs3XV.js"));
|
|
6028
|
+
return { default: ProtectedSettingsPage };
|
|
6029
|
+
},
|
|
6647
6030
|
permissions: PERMISSIONS.settings
|
|
6648
6031
|
});
|
|
6649
|
-
app.addFields({
|
|
6650
|
-
|
|
6032
|
+
app.addFields({
|
|
6033
|
+
type: "media",
|
|
6034
|
+
Component: MediaLibraryInput
|
|
6035
|
+
});
|
|
6036
|
+
app.addComponents([
|
|
6037
|
+
{
|
|
6038
|
+
name: "media-library",
|
|
6039
|
+
Component: MediaLibraryDialog
|
|
6040
|
+
}
|
|
6041
|
+
]);
|
|
6651
6042
|
app.registerPlugin({
|
|
6652
6043
|
id: pluginId,
|
|
6653
6044
|
name
|
|
@@ -6672,10 +6063,8 @@ const index = {
|
|
|
6672
6063
|
return Promise.resolve(importedTrads);
|
|
6673
6064
|
}
|
|
6674
6065
|
};
|
|
6675
|
-
exports.AssetDefinition = AssetDefinition;
|
|
6676
6066
|
exports.AssetGridList = AssetGridList;
|
|
6677
6067
|
exports.Breadcrumbs = Breadcrumbs;
|
|
6678
|
-
exports.BreadcrumbsDefinition = BreadcrumbsDefinition;
|
|
6679
6068
|
exports.EditAssetDialog = EditAssetDialog;
|
|
6680
6069
|
exports.EditFolderDialog = EditFolderDialog;
|
|
6681
6070
|
exports.EmptyAssets = EmptyAssets;
|
|
@@ -6684,18 +6073,17 @@ exports.FilterPopover = FilterPopover;
|
|
|
6684
6073
|
exports.FolderCard = FolderCard;
|
|
6685
6074
|
exports.FolderCardBody = FolderCardBody;
|
|
6686
6075
|
exports.FolderCardBodyAction = FolderCardBodyAction;
|
|
6687
|
-
exports.FolderDefinition = FolderDefinition;
|
|
6688
6076
|
exports.FolderGridList = FolderGridList;
|
|
6689
6077
|
exports.PERMISSIONS = PERMISSIONS;
|
|
6690
6078
|
exports.SelectTree = SelectTree;
|
|
6691
6079
|
exports.SortPicker = SortPicker;
|
|
6692
6080
|
exports.TableList = TableList;
|
|
6693
6081
|
exports.UploadAssetDialog = UploadAssetDialog;
|
|
6082
|
+
exports.admin = admin;
|
|
6694
6083
|
exports.containsAssetFilter = containsAssetFilter;
|
|
6695
6084
|
exports.displayedFilters = displayedFilters;
|
|
6696
6085
|
exports.getFolderURL = getFolderURL;
|
|
6697
6086
|
exports.getTrad = getTrad;
|
|
6698
|
-
exports.index = index;
|
|
6699
6087
|
exports.localStorageKeys = localStorageKeys;
|
|
6700
6088
|
exports.normalizeAPIError = normalizeAPIError;
|
|
6701
6089
|
exports.pageSizes = pageSizes;
|
|
@@ -6712,4 +6100,4 @@ exports.useMediaLibraryPermissions = useMediaLibraryPermissions;
|
|
|
6712
6100
|
exports.usePersistentState = usePersistentState;
|
|
6713
6101
|
exports.useSelectionState = useSelectionState;
|
|
6714
6102
|
exports.viewOptions = viewOptions;
|
|
6715
|
-
//# sourceMappingURL=index-
|
|
6103
|
+
//# sourceMappingURL=index-B7NW5XiM.js.map
|