@bindu-dashing/dam-solution-v2 5.8.6
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/README.md +53 -0
- package/build/AssetType/AddFieldProperties.d.ts +9 -0
- package/build/AssetType/AddFieldProperties.js +197 -0
- package/build/AssetType/AssetTemplatesTable.d.ts +10 -0
- package/build/AssetType/AssetTemplatesTable.js +153 -0
- package/build/AssetType/CreateAssetTemplate.d.ts +3 -0
- package/build/AssetType/CreateAssetTemplate.js +68 -0
- package/build/AssetType/CreateOrEditAssetTemplate.d.ts +1 -0
- package/build/AssetType/CreateOrEditAssetTemplate.js +77 -0
- package/build/AssetType/DraggedField.d.ts +14 -0
- package/build/AssetType/DraggedField.js +40 -0
- package/build/AssetType/EditAssetTemplate.d.ts +5 -0
- package/build/AssetType/EditAssetTemplate.js +179 -0
- package/build/AssetType/FieldsSection.d.ts +14 -0
- package/build/AssetType/FieldsSection.js +239 -0
- package/build/AssetType/assetTemplatesContainer.d.ts +2 -0
- package/build/AssetType/assetTemplatesContainer.js +71 -0
- package/build/AssetType/fieldProperties/DateField.d.ts +5 -0
- package/build/AssetType/fieldProperties/DateField.js +23 -0
- package/build/AssetType/fieldProperties/NumberField.d.ts +5 -0
- package/build/AssetType/fieldProperties/NumberField.js +91 -0
- package/build/AssetType/fieldProperties/OptionsField.d.ts +6 -0
- package/build/AssetType/fieldProperties/OptionsField.js +55 -0
- package/build/AssetType/fieldProperties/TextField.d.ts +5 -0
- package/build/AssetType/fieldProperties/TextField.js +92 -0
- package/build/AssetType/index.d.ts +11 -0
- package/build/AssetType/index.js +24 -0
- package/build/AssetType/routes.d.ts +3 -0
- package/build/AssetType/routes.js +17 -0
- package/build/BookView/ProductDescription.d.ts +4 -0
- package/build/BookView/ProductDescription.js +20 -0
- package/build/BookView/bookDetail.d.ts +4 -0
- package/build/BookView/bookDetail.js +106 -0
- package/build/BookView/bookInfo.d.ts +4 -0
- package/build/BookView/bookInfo.js +17 -0
- package/build/BookView/description.d.ts +4 -0
- package/build/BookView/description.js +5 -0
- package/build/BookView/index.d.ts +10 -0
- package/build/BookView/index.js +23 -0
- package/build/CreateClient/CreateClientBtn.d.ts +8 -0
- package/build/CreateClient/CreateClientBtn.js +12 -0
- package/build/CreateClient/CreateClientForm.d.ts +9 -0
- package/build/CreateClient/CreateClientForm.js +165 -0
- package/build/CreateClient/index.d.ts +14 -0
- package/build/CreateClient/index.js +18 -0
- package/build/ImagePicker/MetaFieldOptions.d.ts +14 -0
- package/build/ImagePicker/MetaFieldOptions.js +75 -0
- package/build/ImagePicker/TestImagePickerModal.d.ts +8 -0
- package/build/ImagePicker/TestImagePickerModal.js +61 -0
- package/build/ImagePicker/TestImgFromMetaData.d.ts +7 -0
- package/build/ImagePicker/TestImgFromMetaData.js +82 -0
- package/build/ImagePicker/imagePickerComponent.d.ts +6 -0
- package/build/ImagePicker/imagePickerComponent.js +63 -0
- package/build/ImagePicker/index.d.ts +13 -0
- package/build/ImagePicker/index.js +24 -0
- package/build/ImagePicker/routes.d.ts +6 -0
- package/build/ImagePicker/routes.js +17 -0
- package/build/ImagePickerFilters/ImagePickerFiltersComponent.d.ts +8 -0
- package/build/ImagePickerFilters/ImagePickerFiltersComponent.js +223 -0
- package/build/ImagePickerFilters/index.d.ts +12 -0
- package/build/ImagePickerFilters/index.js +19 -0
- package/build/MyDrive/ActionBar.d.ts +6 -0
- package/build/MyDrive/ActionBar.js +165 -0
- package/build/MyDrive/AddDrive.d.ts +3 -0
- package/build/MyDrive/AddDrive.js +169 -0
- package/build/MyDrive/AddFolder.d.ts +10 -0
- package/build/MyDrive/AddFolder.js +150 -0
- package/build/MyDrive/BreadCrumbList.d.ts +9 -0
- package/build/MyDrive/BreadCrumbList.js +86 -0
- package/build/MyDrive/BulkUploadModal.d.ts +2 -0
- package/build/MyDrive/BulkUploadModal.js +279 -0
- package/build/MyDrive/DriveContainer.d.ts +13 -0
- package/build/MyDrive/DriveContainer.js +276 -0
- package/build/MyDrive/FileDownloadHistory.d.ts +7 -0
- package/build/MyDrive/FileDownloadHistory.js +94 -0
- package/build/MyDrive/FileMenuOptions.d.ts +11 -0
- package/build/MyDrive/FileMenuOptions.js +397 -0
- package/build/MyDrive/FilesGridView.d.ts +9 -0
- package/build/MyDrive/FilesGridView.js +25 -0
- package/build/MyDrive/FolderGridView.d.ts +19 -0
- package/build/MyDrive/FolderGridView.js +91 -0
- package/build/MyDrive/FolderListView.d.ts +25 -0
- package/build/MyDrive/FolderListView.js +188 -0
- package/build/MyDrive/FolderMenuOptions.d.ts +5 -0
- package/build/MyDrive/FolderMenuOptions.js +350 -0
- package/build/MyDrive/FolderTree.d.ts +8 -0
- package/build/MyDrive/FolderTree.js +342 -0
- package/build/MyDrive/ImageEditor/EditImage.d.ts +6 -0
- package/build/MyDrive/ImageEditor/EditImage.js +97 -0
- package/build/MyDrive/ImageEditor/EditImageModal.d.ts +8 -0
- package/build/MyDrive/ImageEditor/EditImageModal.js +30 -0
- package/build/MyDrive/ImageEditor/TuiImageEditor.d.ts +10 -0
- package/build/MyDrive/ImageEditor/TuiImageEditor.js +99 -0
- package/build/MyDrive/ImagePickerBreadCrumbList.d.ts +8 -0
- package/build/MyDrive/ImagePickerBreadCrumbList.js +35 -0
- package/build/MyDrive/ImagePickerDrive.d.ts +1 -0
- package/build/MyDrive/ImagePickerDrive.js +41 -0
- package/build/MyDrive/MyDriveMainContainer.d.ts +1 -0
- package/build/MyDrive/MyDriveMainContainer.js +32 -0
- package/build/MyDrive/SearchFilter.d.ts +8 -0
- package/build/MyDrive/SearchFilter.js +73 -0
- package/build/MyDrive/ShareBtn.d.ts +5 -0
- package/build/MyDrive/ShareBtn.js +19 -0
- package/build/MyDrive/ToggleView.d.ts +4 -0
- package/build/MyDrive/ToggleView.js +12 -0
- package/build/MyDrive/UploadStatusModal.d.ts +12 -0
- package/build/MyDrive/UploadStatusModal.js +40 -0
- package/build/MyDrive/fileDetails/CommentEntity.d.ts +8 -0
- package/build/MyDrive/fileDetails/CommentEntity.js +102 -0
- package/build/MyDrive/fileDetails/Comments.d.ts +6 -0
- package/build/MyDrive/fileDetails/Comments.js +65 -0
- package/build/MyDrive/fileDetails/Compliance.d.ts +2 -0
- package/build/MyDrive/fileDetails/Compliance.js +18 -0
- package/build/MyDrive/fileDetails/CreateComment.d.ts +7 -0
- package/build/MyDrive/fileDetails/CreateComment.js +48 -0
- package/build/MyDrive/fileDetails/Editor.d.ts +6 -0
- package/build/MyDrive/fileDetails/Editor.js +55 -0
- package/build/MyDrive/fileDetails/EmojiPicker.d.ts +5 -0
- package/build/MyDrive/fileDetails/EmojiPicker.js +6 -0
- package/build/MyDrive/fileDetails/FileDetails.d.ts +10 -0
- package/build/MyDrive/fileDetails/FileDetails.js +78 -0
- package/build/MyDrive/fileDetails/FileHeader.d.ts +7 -0
- package/build/MyDrive/fileDetails/FileHeader.js +25 -0
- package/build/MyDrive/fileDetails/FileViewer.d.ts +10 -0
- package/build/MyDrive/fileDetails/FileViewer.js +31 -0
- package/build/MyDrive/fileDetails/ImageOptions.d.ts +2 -0
- package/build/MyDrive/fileDetails/ImageOptions.js +44 -0
- package/build/MyDrive/fileDetails/ImageViewer.d.ts +5 -0
- package/build/MyDrive/fileDetails/ImageViewer.js +16 -0
- package/build/MyDrive/fileDetails/ManageFile.d.ts +7 -0
- package/build/MyDrive/fileDetails/ManageFile.js +34 -0
- package/build/MyDrive/fileDetails/MetaForm.d.ts +15 -0
- package/build/MyDrive/fileDetails/MetaForm.js +195 -0
- package/build/MyDrive/fileDetails/Metadata.d.ts +8 -0
- package/build/MyDrive/fileDetails/Metadata.js +52 -0
- package/build/MyDrive/fileDetails/PdfOptions.d.ts +9 -0
- package/build/MyDrive/fileDetails/PdfOptions.js +35 -0
- package/build/MyDrive/fileDetails/PdfViewer.d.ts +8 -0
- package/build/MyDrive/fileDetails/PdfViewer.js +18 -0
- package/build/MyDrive/fileDetails/Previewdetails.d.ts +9 -0
- package/build/MyDrive/fileDetails/Previewdetails.js +53 -0
- package/build/MyDrive/fileDetails/VideoPlayer.d.ts +4 -0
- package/build/MyDrive/fileDetails/VideoPlayer.js +21 -0
- package/build/MyDrive/files/AssetSelectionFormItem.d.ts +7 -0
- package/build/MyDrive/files/AssetSelectionFormItem.js +14 -0
- package/build/MyDrive/files/FolderTabs.d.ts +6 -0
- package/build/MyDrive/files/FolderTabs.js +83 -0
- package/build/MyDrive/files/MapFile.d.ts +8 -0
- package/build/MyDrive/files/MapFile.js +217 -0
- package/build/MyDrive/files/MoveToAnotherFolder.d.ts +9 -0
- package/build/MyDrive/files/MoveToAnotherFolder.js +53 -0
- package/build/MyDrive/filesListView.d.ts +2 -0
- package/build/MyDrive/filesListView.js +57 -0
- package/build/MyDrive/index.d.ts +10 -0
- package/build/MyDrive/index.js +35 -0
- package/build/MyDrive/routes.d.ts +7 -0
- package/build/MyDrive/routes.js +17 -0
- package/build/PenView/PenDetails.d.ts +4 -0
- package/build/PenView/PenDetails.js +114 -0
- package/build/PenView/ProductDescription.d.ts +5 -0
- package/build/PenView/ProductDescription.js +51 -0
- package/build/PenView/index.d.ts +10 -0
- package/build/PenView/index.js +23 -0
- package/build/RefreshKey/RefreshKeyBtn.d.ts +1 -0
- package/build/RefreshKey/RefreshKeyBtn.js +42 -0
- package/build/RefreshKey/index.d.ts +9 -0
- package/build/RefreshKey/index.js +23 -0
- package/build/ShoesView/ProductDescription.d.ts +4 -0
- package/build/ShoesView/ProductDescription.js +25 -0
- package/build/ShoesView/ShoeDetails.d.ts +4 -0
- package/build/ShoesView/ShoeDetails.js +96 -0
- package/build/ShoesView/index.d.ts +10 -0
- package/build/ShoesView/index.js +23 -0
- package/build/common/Button.d.ts +2 -0
- package/build/common/Button.js +18 -0
- package/build/common/CustomElements.d.ts +98 -0
- package/build/common/CustomElements.js +77 -0
- package/build/common/LoadMoreItems.d.ts +7 -0
- package/build/common/LoadMoreItems.js +33 -0
- package/build/common/RenderFormItem.d.ts +42 -0
- package/build/common/RenderFormItem.js +98 -0
- package/build/common/RenderThumnail.d.ts +7 -0
- package/build/common/RenderThumnail.js +6 -0
- package/build/common/deleteModal.d.ts +1 -0
- package/build/common/deleteModal.js +12 -0
- package/build/common/folders/TypeAndDateFilters.d.ts +10 -0
- package/build/common/folders/TypeAndDateFilters.js +59 -0
- package/build/common/folders/getFolderOrFileIcon.d.ts +2 -0
- package/build/common/folders/getFolderOrFileIcon.js +41 -0
- package/build/common/loader/CustomLoader.d.ts +7 -0
- package/build/common/loader/CustomLoader.js +8 -0
- package/build/common/loader/loader.d.ts +1 -0
- package/build/common/loader/loader.js +6 -0
- package/build/common/notifications.d.ts +2 -0
- package/build/common/notifications.js +30 -0
- package/build/common/steps.d.ts +4 -0
- package/build/common/steps.js +7 -0
- package/build/hocs/AppProvider.d.ts +3 -0
- package/build/hocs/AppProvider.js +11 -0
- package/build/hocs/DamConfigContext.d.ts +2 -0
- package/build/hocs/DamConfigContext.js +108 -0
- package/build/hocs/ThemeContext.d.ts +15 -0
- package/build/hocs/ThemeContext.js +131 -0
- package/build/hocs/ToastProvider.d.ts +2 -0
- package/build/hocs/ToastProvider.js +6 -0
- package/build/hocs/appConstants.d.ts +124 -0
- package/build/hocs/appConstants.js +211 -0
- package/build/hocs/configureAxios.d.ts +2 -0
- package/build/hocs/configureAxios.js +65 -0
- package/build/hocs/helpers.d.ts +15 -0
- package/build/hocs/helpers.js +177 -0
- package/build/index.d.ts +11 -0
- package/build/index.js +11 -0
- package/build/react-query/hooks/brand-hooks.d.ts +3 -0
- package/build/react-query/hooks/brand-hooks.js +10 -0
- package/build/react-query/hooks/folder-hooks.d.ts +7 -0
- package/build/react-query/hooks/folder-hooks.js +119 -0
- package/build/react-query/services/brand-services.d.ts +3 -0
- package/build/react-query/services/brand-services.js +30 -0
- package/build/react-query/services/file-services.d.ts +43 -0
- package/build/react-query/services/file-services.js +69 -0
- package/build/react-query/services/folder-services.d.ts +44 -0
- package/build/react-query/services/folder-services.js +87 -0
- package/build/react-query/services/image-picker-services.d.ts +5 -0
- package/build/react-query/services/image-picker-services.js +48 -0
- package/build/settings/InviteTeamModal.d.ts +12 -0
- package/build/settings/InviteTeamModal.js +174 -0
- package/build/settings/UpdateInvitationAccessType.d.ts +9 -0
- package/build/settings/UpdateInvitationAccessType.js +96 -0
- package/build/settings/getUserAvatar.d.ts +7 -0
- package/build/settings/getUserAvatar.js +11 -0
- package/build/style.css +1 -0
- package/build/types/assetType.d.ts +8 -0
- package/build/types/assetType.js +1 -0
- package/build/ui/pageTitle.d.ts +3 -0
- package/build/ui/pageTitle.js +4 -0
- package/build/utilities/FoldersContext.d.ts +14 -0
- package/build/utilities/FoldersContext.js +10 -0
- package/build/utilities/NavigatorProvider.d.ts +2 -0
- package/build/utilities/NavigatorProvider.js +10 -0
- package/build/utilities/constants/apiUrls.d.ts +95 -0
- package/build/utilities/constants/apiUrls.js +115 -0
- package/build/utilities/constants/imageUrls.d.ts +6 -0
- package/build/utilities/constants/imageUrls.js +6 -0
- package/build/utilities/constants/interface.d.ts +371 -0
- package/build/utilities/constants/interface.js +142 -0
- package/build/utilities/constants/messages.d.ts +54 -0
- package/build/utilities/constants/messages.js +54 -0
- package/build/utilities/constants/queryKeys.d.ts +16 -0
- package/build/utilities/constants/queryKeys.js +33 -0
- package/build/utilities/constants/routes.d.ts +22 -0
- package/build/utilities/constants/routes.js +22 -0
- package/build/utilities/helpers/validators.d.ts +12 -0
- package/build/utilities/helpers/validators.js +89 -0
- package/build/utilities/useAppNavigate.d.ts +2 -0
- package/build/utilities/useAppNavigate.js +19 -0
- package/build/utilities/useAppParams.d.ts +6 -0
- package/build/utilities/useAppParams.js +27 -0
- package/package.json +93 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
import { NotificationStatus } from "../utilities/constants/interface";
|
|
12
|
+
import { get } from "lodash";
|
|
13
|
+
import { useEffect, useMemo, useState } from "react";
|
|
14
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
15
|
+
import { FETCH_ASSET_URL, FETCH_IMAGEPICKER_URL, FETCH_META_FIELD_FILES_URL, FETCH_META_FIELD_OPTIONS_URL, } from "../utilities/constants/apiUrls";
|
|
16
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
17
|
+
import { Empty, Form, Select, Spin } from "antd";
|
|
18
|
+
import { showNotification } from "../common/notifications";
|
|
19
|
+
import { SOMETHING_WENT_WRONG } from "../utilities/constants/messages";
|
|
20
|
+
import { getFormattedValue } from "../hocs/helpers";
|
|
21
|
+
function ImagePickerFiltersComponent({ id, onSelect, url, value, fileId, }) {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
const damConfig = useDamConfig();
|
|
24
|
+
const { brand } = damConfig;
|
|
25
|
+
const [state, setState] = useState({
|
|
26
|
+
assetType: null,
|
|
27
|
+
imagePicker: {},
|
|
28
|
+
loading: false,
|
|
29
|
+
fieldOptions: {},
|
|
30
|
+
filters: {},
|
|
31
|
+
fieldName: "",
|
|
32
|
+
files: [],
|
|
33
|
+
selectedFileUrl: null,
|
|
34
|
+
selectedFileId: null,
|
|
35
|
+
loaderType: "",
|
|
36
|
+
selectedFieldName: "",
|
|
37
|
+
});
|
|
38
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (id && brand) {
|
|
41
|
+
getImagePicker();
|
|
42
|
+
}
|
|
43
|
+
}, [id, brand]);
|
|
44
|
+
const getImagePicker = () => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
try {
|
|
46
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true, loaderType: "IMAGE_PICKER" })));
|
|
47
|
+
const response = yield api.get(FETCH_IMAGEPICKER_URL.replace(":id", id));
|
|
48
|
+
const assetId = get(response, "data.assetId", "");
|
|
49
|
+
const assetTemplateResponse = yield api.get(FETCH_ASSET_URL.replace(":assetId", assetId || ""));
|
|
50
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false, loaderType: "", imagePicker: get(response, "data", {}), assetType: get(assetTemplateResponse, "data", {}) })));
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
console.log("Error while fetching image picker", err);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const fields = ((_a = state === null || state === void 0 ? void 0 : state.assetType) === null || _a === void 0 ? void 0 : _a.metadataFields) || [];
|
|
57
|
+
const onFilter = (filters_1, fieldOptions_1, nextField_1, ...args_1) => __awaiter(this, [filters_1, fieldOptions_1, nextField_1, ...args_1], void 0, function* (filters, fieldOptions, nextField, fromValue = false) {
|
|
58
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
59
|
+
const filtersObj = Object.keys(filters).reduce((acc, key) => {
|
|
60
|
+
const value = (filters === null || filters === void 0 ? void 0 : filters[key]) || "";
|
|
61
|
+
if (value) {
|
|
62
|
+
acc = Object.assign(Object.assign({}, acc), { [key]: value });
|
|
63
|
+
}
|
|
64
|
+
return acc;
|
|
65
|
+
}, {});
|
|
66
|
+
setState((prevState) => {
|
|
67
|
+
return Object.assign(Object.assign({}, prevState), { filters,
|
|
68
|
+
fieldOptions, loading: true, fieldName: nextField, selectedFieldName: null });
|
|
69
|
+
});
|
|
70
|
+
try {
|
|
71
|
+
const payload = {
|
|
72
|
+
distinctValuesKey: nextField,
|
|
73
|
+
filters: filtersObj,
|
|
74
|
+
};
|
|
75
|
+
const response = !nextField
|
|
76
|
+
? yield api.put(FETCH_META_FIELD_FILES_URL.replace(":id", get(state, "imagePicker._id")), { filters })
|
|
77
|
+
: yield api.put(FETCH_META_FIELD_OPTIONS_URL.replace(":id", get(state, "imagePicker._id")), payload);
|
|
78
|
+
// console.log(response, nextField);
|
|
79
|
+
const filesResponse = ((_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b.length) == 0
|
|
80
|
+
? yield api.put(FETCH_META_FIELD_FILES_URL.replace(":id", get(state, "imagePicker._id")), { filters })
|
|
81
|
+
: null;
|
|
82
|
+
const currentFieldOptions = Object.assign(Object.assign({}, fieldOptions), { [nextField]: ((_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.values) || [] });
|
|
83
|
+
const finalState = !nextField || ((_e = (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.values) === null || _e === void 0 ? void 0 : _e.length) == 0
|
|
84
|
+
? {
|
|
85
|
+
files: ((_g = (_f = response === null || response === void 0 ? void 0 : response.data) === null || _f === void 0 ? void 0 : _f.values) === null || _g === void 0 ? void 0 : _g.length) == 0
|
|
86
|
+
? (filesResponse === null || filesResponse === void 0 ? void 0 : filesResponse.data) || []
|
|
87
|
+
: !nextField
|
|
88
|
+
? (response === null || response === void 0 ? void 0 : response.data) || []
|
|
89
|
+
: [],
|
|
90
|
+
loading: false,
|
|
91
|
+
}
|
|
92
|
+
: {
|
|
93
|
+
fieldOptions: currentFieldOptions,
|
|
94
|
+
loading: false,
|
|
95
|
+
fieldName: "",
|
|
96
|
+
};
|
|
97
|
+
if (!fromValue) {
|
|
98
|
+
finalState["selectedFileId"] = null;
|
|
99
|
+
finalState["selectedFileUrl"] = null;
|
|
100
|
+
}
|
|
101
|
+
else if (nextField == "") {
|
|
102
|
+
const selectedFile = (_h = response === null || response === void 0 ? void 0 : response.data) === null || _h === void 0 ? void 0 : _h.find((item) => item._id == fileId);
|
|
103
|
+
finalState["selectedFileId"] = selectedFile === null || selectedFile === void 0 ? void 0 : selectedFile._id;
|
|
104
|
+
finalState["selectedFileUrl"] = selectedFile === null || selectedFile === void 0 ? void 0 : selectedFile.thumbnailUrl;
|
|
105
|
+
}
|
|
106
|
+
setState((prevState) => {
|
|
107
|
+
return Object.assign(Object.assign({}, prevState), finalState);
|
|
108
|
+
});
|
|
109
|
+
if (fromValue && nextField !== "") {
|
|
110
|
+
const index = fields === null || fields === void 0 ? void 0 : fields.findIndex((field) => {
|
|
111
|
+
return field._id == nextField;
|
|
112
|
+
});
|
|
113
|
+
const nextNextField = fields.length !== index + 1 ? ((_j = fields === null || fields === void 0 ? void 0 : fields[index + 1]) === null || _j === void 0 ? void 0 : _j._id) || "" : "";
|
|
114
|
+
const prevFields = fields.slice(0, index + 1);
|
|
115
|
+
const allFilters = {};
|
|
116
|
+
const allFieldOptions = {};
|
|
117
|
+
prevFields.forEach((item) => {
|
|
118
|
+
allFilters[item._id] = filters === null || filters === void 0 ? void 0 : filters[item._id];
|
|
119
|
+
allFieldOptions[item._id] = currentFieldOptions === null || currentFieldOptions === void 0 ? void 0 : currentFieldOptions[item._id];
|
|
120
|
+
});
|
|
121
|
+
allFilters[nextField] = value === null || value === void 0 ? void 0 : value[nextField];
|
|
122
|
+
if (((_k = response === null || response === void 0 ? void 0 : response.data) === null || _k === void 0 ? void 0 : _k.length) == 0) {
|
|
123
|
+
onFilter(allFilters, allFieldOptions, nextNextField, true);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
showNotification(get(err, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
129
|
+
setState((prevState) => {
|
|
130
|
+
return Object.assign(Object.assign({}, prevState), { loading: false, fieldName: "" });
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
var _a, _b;
|
|
136
|
+
try {
|
|
137
|
+
if (fields.length > 0) {
|
|
138
|
+
if (value) {
|
|
139
|
+
const fieldName = ((_a = fields === null || fields === void 0 ? void 0 : fields[0]) === null || _a === void 0 ? void 0 : _a._id) || "";
|
|
140
|
+
const currentFilters = {
|
|
141
|
+
[fieldName]: "",
|
|
142
|
+
};
|
|
143
|
+
onFilter(currentFilters, {}, fieldName, true);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const fieldName = ((_b = fields === null || fields === void 0 ? void 0 : fields[0]) === null || _b === void 0 ? void 0 : _b._id) || "";
|
|
147
|
+
const currentFilters = {
|
|
148
|
+
[fieldName]: "",
|
|
149
|
+
};
|
|
150
|
+
onFilter(currentFilters, {}, fieldName);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
console.log(err);
|
|
156
|
+
}
|
|
157
|
+
}, [fields, value]);
|
|
158
|
+
// console.log(
|
|
159
|
+
// state?.filters,
|
|
160
|
+
// state?.selectedFileUrl,
|
|
161
|
+
// state?.fieldOptions,
|
|
162
|
+
// state?.imagePicker,
|
|
163
|
+
// state
|
|
164
|
+
// );
|
|
165
|
+
return (_jsx("div", { className: "image-picker-filters", style: { width: "100%" }, children: (state === null || state === void 0 ? void 0 : state.loading) && (state === null || state === void 0 ? void 0 : state.loaderType) == "IMAGE_PICKER" ? (_jsx("div", { className: "md-lib-h-full md-lib-flex md-lib-items-center md-lib-justify-center", children: _jsx(Spin, {}) })) : (_jsx("div", { className: "md-lib-border md-lib-p-4 md-lib-rounded", children: !(state === null || state === void 0 ? void 0 : state.assetType) ? (_jsx(Empty, { description: "Asset Type not found", image: Empty.PRESENTED_IMAGE_SIMPLE })) : (_jsxs(_Fragment, { children: [_jsx("h2", { className: "md-lib-text-xl md-lib-font-semibold", children: (_b = state === null || state === void 0 ? void 0 : state.imagePicker) === null || _b === void 0 ? void 0 : _b.name }), _jsx("br", {}), _jsxs(Form, { layout: "vertical", children: [fields === null || fields === void 0 ? void 0 : fields.map((field, index) => {
|
|
166
|
+
var _a, _b, _c, _d;
|
|
167
|
+
// console.log(field);
|
|
168
|
+
const fieldName = (field === null || field === void 0 ? void 0 : field._id) || "";
|
|
169
|
+
const fieldLabel = (field === null || field === void 0 ? void 0 : field.name) || "";
|
|
170
|
+
const nextField = fields.length !== index + 1
|
|
171
|
+
? ((_a = fields === null || fields === void 0 ? void 0 : fields[index + 1]) === null || _a === void 0 ? void 0 : _a._id) || ""
|
|
172
|
+
: "";
|
|
173
|
+
return (_jsx(Form.Item, { label: fieldLabel, children: _jsx(Select, { placeholder: fieldLabel, style: { width: "100%" }, options: (_c = (((_b = state === null || state === void 0 ? void 0 : state.fieldOptions) === null || _b === void 0 ? void 0 : _b[fieldName]) || [])) === null || _c === void 0 ? void 0 : _c.map((option) => {
|
|
174
|
+
return {
|
|
175
|
+
label: option,
|
|
176
|
+
value: option,
|
|
177
|
+
};
|
|
178
|
+
}), showSearch: true, value: ((_d = state === null || state === void 0 ? void 0 : state.filters) === null || _d === void 0 ? void 0 : _d[fieldName]) || null, onChange: (val) => {
|
|
179
|
+
const prevFields = fields.slice(0, index + 1);
|
|
180
|
+
const allFilters = {};
|
|
181
|
+
const allFieldOptions = {};
|
|
182
|
+
// console.log("onChange", val, prevFields);
|
|
183
|
+
prevFields.forEach((item) => {
|
|
184
|
+
var _a, _b;
|
|
185
|
+
allFilters[item._id] = (_a = state === null || state === void 0 ? void 0 : state.filters) === null || _a === void 0 ? void 0 : _a[item._id];
|
|
186
|
+
allFieldOptions[item._id] =
|
|
187
|
+
(_b = state === null || state === void 0 ? void 0 : state.fieldOptions) === null || _b === void 0 ? void 0 : _b[item._id];
|
|
188
|
+
});
|
|
189
|
+
allFilters[fieldName] = val;
|
|
190
|
+
onFilter(allFilters, allFieldOptions, nextField);
|
|
191
|
+
}, loading: (state === null || state === void 0 ? void 0 : state.loading) && (state === null || state === void 0 ? void 0 : state.fieldName) == fieldName }, fieldName) }, fieldName));
|
|
192
|
+
}), _jsxs(Form.Item, { label: "Image", children: [_jsx(Select, { placeholder: "Select Image", style: { width: "100%" }, loading: (state === null || state === void 0 ? void 0 : state.loading) && (state === null || state === void 0 ? void 0 : state.fieldName) == "", showSearch: true, options: (_c = state === null || state === void 0 ? void 0 : state.files) === null || _c === void 0 ? void 0 : _c.map((file) => {
|
|
193
|
+
return {
|
|
194
|
+
label: file === null || file === void 0 ? void 0 : file.name,
|
|
195
|
+
value: file === null || file === void 0 ? void 0 : file._id,
|
|
196
|
+
file,
|
|
197
|
+
};
|
|
198
|
+
}), optionLabelProp: "label", value: state === null || state === void 0 ? void 0 : state.selectedFileId, onChange: (val, option) => {
|
|
199
|
+
if (onSelect) {
|
|
200
|
+
const file = get(option, "file", {});
|
|
201
|
+
const imagePickerOutputFormat = get(state === null || state === void 0 ? void 0 : state.assetType, "imagePickerOutputFormat", []);
|
|
202
|
+
const metadataFields = get(state === null || state === void 0 ? void 0 : state.assetType, "metadataFields", []);
|
|
203
|
+
// console.log(imagePickerOutputFormat);
|
|
204
|
+
const formattedOutputFormat = imagePickerOutputFormat.map((field) => {
|
|
205
|
+
// console.log("field", field);
|
|
206
|
+
const metaField = metadataFields.find((item) => (item === null || item === void 0 ? void 0 : item.name) == (field === null || field === void 0 ? void 0 : field.name));
|
|
207
|
+
return Object.assign(Object.assign({}, field), { fieldId: get(metaField, "_id") });
|
|
208
|
+
});
|
|
209
|
+
// console.log(formattedOutputFormat);
|
|
210
|
+
const value = getFormattedValue(formattedOutputFormat, file === null || file === void 0 ? void 0 : file.s3Url, get(file, "metadata", {}));
|
|
211
|
+
// console.log(val, value);
|
|
212
|
+
onSelect(val, value);
|
|
213
|
+
}
|
|
214
|
+
setState((prevState) => {
|
|
215
|
+
var _a;
|
|
216
|
+
return Object.assign(Object.assign({}, prevState), { selectedFileId: val, selectedFileUrl: (_a = option === null || option === void 0 ? void 0 : option.file) === null || _a === void 0 ? void 0 : _a.thumbnailUrl, selectedFieldName: "" });
|
|
217
|
+
});
|
|
218
|
+
} }, "IMAGE_THUMBNAIL"), (state === null || state === void 0 ? void 0 : state.selectedFileUrl) && (_jsx("img", { src: state === null || state === void 0 ? void 0 : state.selectedFileUrl, width: 200, style: {
|
|
219
|
+
borderRadius: "10px",
|
|
220
|
+
marginTop: "10px",
|
|
221
|
+
}, alt: "Selected file preview" }, state === null || state === void 0 ? void 0 : state.selectedFileUrl))] })] })] })) })) }));
|
|
222
|
+
}
|
|
223
|
+
export default ImagePickerFiltersComponent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare function App(props: {
|
|
2
|
+
accessKey?: string;
|
|
3
|
+
secretKey?: string;
|
|
4
|
+
subdomain?: string;
|
|
5
|
+
teamIds?: string[];
|
|
6
|
+
styles?: any;
|
|
7
|
+
appType?: string;
|
|
8
|
+
id: string;
|
|
9
|
+
onSelect?: (url: string, value: any) => void;
|
|
10
|
+
url?: string;
|
|
11
|
+
}): JSX.Element;
|
|
12
|
+
export default App;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DamConfigProvider } from "../hocs/DamConfigContext";
|
|
3
|
+
import { ThemeProvider } from "../hocs/ThemeContext";
|
|
4
|
+
import { ThemeModes } from "../utilities/constants/interface";
|
|
5
|
+
import AppProvider from "../hocs/AppProvider";
|
|
6
|
+
import ToastProvider from "../hocs/ToastProvider";
|
|
7
|
+
import ImagePickerFiltersComponent from "./ImagePickerFiltersComponent";
|
|
8
|
+
function App(props) {
|
|
9
|
+
const config = {
|
|
10
|
+
damAccessKey: props === null || props === void 0 ? void 0 : props.accessKey,
|
|
11
|
+
secretKey: props === null || props === void 0 ? void 0 : props.secretKey,
|
|
12
|
+
subdomain: props === null || props === void 0 ? void 0 : props.subdomain,
|
|
13
|
+
teamIds: props === null || props === void 0 ? void 0 : props.teamIds,
|
|
14
|
+
styles: props === null || props === void 0 ? void 0 : props.styles,
|
|
15
|
+
appType: props === null || props === void 0 ? void 0 : props.appType,
|
|
16
|
+
};
|
|
17
|
+
return (_jsx(DamConfigProvider, { config: config, children: _jsx(ThemeProvider, { styles: props === null || props === void 0 ? void 0 : props.styles, sessionTheme: ThemeModes.LIGHT, children: _jsxs(AppProvider, { children: [_jsx(ImagePickerFiltersComponent, { id: props.id, onSelect: props === null || props === void 0 ? void 0 : props.onSelect, url: props === null || props === void 0 ? void 0 : props.url }), _jsx(ToastProvider, {})] }) }) }));
|
|
18
|
+
}
|
|
19
|
+
export default App;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from "react";
|
|
3
|
+
import { Button, Tag, Tooltip } from "antd";
|
|
4
|
+
import { FiUpload, FiDownload, FiFolderPlus, FiTrash2, FiX, } from "react-icons/fi";
|
|
5
|
+
import { IoArchiveOutline, IoLinkOutline } from "react-icons/io5";
|
|
6
|
+
import { concat, find, first, get, join, map } from "lodash";
|
|
7
|
+
import MoveToAnotherFolder from "./files/MoveToAnotherFolder";
|
|
8
|
+
import { useMutation, useQueryClient } from "react-query";
|
|
9
|
+
import { deleteFiles, downloadFiles, restoreFiles, } from "../react-query/services/file-services";
|
|
10
|
+
import { DeleteConfirmationModal } from "../common/CustomElements";
|
|
11
|
+
import { DeleteOutlined, RedoOutlined } from "@ant-design/icons";
|
|
12
|
+
import { generateFoldersQueryKey, invalidateData, } from "../utilities/constants/queryKeys";
|
|
13
|
+
import { DriveModes, NotificationStatus, } from "../utilities/constants/interface";
|
|
14
|
+
import { ARCHIVE_OK_TEXT, DELETE_CONFIRMATION_MESSAGE, DELETE_MESSAGE_DESCRIPTION, DELETE_OK_TEXT, DELETE_SUCCESS, INVALID_URL, RESTORE_SUCCESS, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
|
|
15
|
+
import { showNotification } from "../common/notifications";
|
|
16
|
+
import FileMenuOptions from "./FileMenuOptions";
|
|
17
|
+
import { getFolderData } from "../react-query/hooks/folder-hooks";
|
|
18
|
+
// import InviteTeamModal from "../settings/InviteTeamModal";
|
|
19
|
+
import { FETCH_ENTITY_SCREEN } from "../utilities/constants/routes";
|
|
20
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
21
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
22
|
+
import useAppParams from "../utilities/useAppParams";
|
|
23
|
+
const FiUploadIcon = FiUpload;
|
|
24
|
+
const FiDownloadIcon = FiDownload;
|
|
25
|
+
const FiFolderPlusIcon = FiFolderPlus;
|
|
26
|
+
const IoLinkOutlineIcon = IoLinkOutline;
|
|
27
|
+
const FiTrash2Icon = FiTrash2;
|
|
28
|
+
const FiXIcon = FiX;
|
|
29
|
+
const IoArchiveOutlineIcon = IoArchiveOutline;
|
|
30
|
+
const ActionsBar = ({ fileIds, folderIds, onCloseSelection, }) => {
|
|
31
|
+
const { appType } = useDamConfig();
|
|
32
|
+
const { folderId, type } = useAppParams();
|
|
33
|
+
const queryClient = useQueryClient();
|
|
34
|
+
const damConfig = useDamConfig();
|
|
35
|
+
const { rootFolderId, isAdmin } = damConfig;
|
|
36
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
37
|
+
const [state, setState] = useState({
|
|
38
|
+
showMoveFolder: false,
|
|
39
|
+
showConfirmModal: false,
|
|
40
|
+
actionType: "",
|
|
41
|
+
showShareModal: false,
|
|
42
|
+
});
|
|
43
|
+
const { showMoveFolder, showConfirmModal, actionType, showShareModal } = state;
|
|
44
|
+
const toggleShareModal = () => {
|
|
45
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { showShareModal: !prevState.showShareModal })));
|
|
46
|
+
};
|
|
47
|
+
const folders = getFolderData(queryClient, folderId ? folderId : rootFolderId, generateFoldersQueryKey(type));
|
|
48
|
+
const selectedFolder = useMemo(() => {
|
|
49
|
+
if (get(folderIds, "length") === 1) {
|
|
50
|
+
return find(folders, (folder) => get(folder, "_id") === first(folderIds));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}, [folderIds, folders]);
|
|
56
|
+
const selectedFile = useMemo(() => {
|
|
57
|
+
if (get(fileIds, "length") === 1) {
|
|
58
|
+
return find(folders, (folder) => get(folder, "_id") === first(fileIds));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}, [fileIds, folders]);
|
|
64
|
+
const toggleConfirmPopup = (actionType = "") => {
|
|
65
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { actionType, showConfirmModal: !prevState.showConfirmModal })));
|
|
66
|
+
};
|
|
67
|
+
const toggleShowMoveFolder = () => {
|
|
68
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { showMoveFolder: !prevState.showMoveFolder })));
|
|
69
|
+
};
|
|
70
|
+
const onSuccess = (message) => {
|
|
71
|
+
invalidateData(queryClient, generateFoldersQueryKey(type), folderId ? folderId : rootFolderId);
|
|
72
|
+
showNotification(message, NotificationStatus.SUCCESS);
|
|
73
|
+
};
|
|
74
|
+
const onFailure = (message) => {
|
|
75
|
+
showNotification(message, NotificationStatus.ERROR);
|
|
76
|
+
};
|
|
77
|
+
const deleteFileMutation = useMutation({
|
|
78
|
+
mutationFn: deleteFiles,
|
|
79
|
+
onSuccess: (response) => {
|
|
80
|
+
toggleConfirmPopup();
|
|
81
|
+
onCloseSelection();
|
|
82
|
+
onSuccess(get(response, "data.message", DELETE_SUCCESS));
|
|
83
|
+
},
|
|
84
|
+
onError: (error) => {
|
|
85
|
+
onFailure(get(error, "message", SOMETHING_WENT_WRONG));
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
const onDeleteFile = () => {
|
|
89
|
+
deleteFileMutation.mutate({
|
|
90
|
+
fileIds,
|
|
91
|
+
folderIds,
|
|
92
|
+
api,
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
const restoreFileMutation = useMutation({
|
|
96
|
+
mutationFn: restoreFiles,
|
|
97
|
+
onSuccess: (response) => {
|
|
98
|
+
onCloseSelection();
|
|
99
|
+
onSuccess(get(response, "data.message", RESTORE_SUCCESS));
|
|
100
|
+
},
|
|
101
|
+
onError: (error) => {
|
|
102
|
+
onFailure(get(error, "message", SOMETHING_WENT_WRONG));
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
const onRestoreFiles = () => {
|
|
106
|
+
restoreFileMutation.mutate({
|
|
107
|
+
fileIds,
|
|
108
|
+
folderIds,
|
|
109
|
+
api,
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
const downloadFileMutation = useMutation({
|
|
113
|
+
mutationFn: downloadFiles,
|
|
114
|
+
onSuccess: (response) => {
|
|
115
|
+
const url = get(response, "data");
|
|
116
|
+
if (url) {
|
|
117
|
+
window.open(url, "_blank");
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
onFailure(INVALID_URL);
|
|
121
|
+
}
|
|
122
|
+
onCloseSelection();
|
|
123
|
+
},
|
|
124
|
+
onError: (error) => {
|
|
125
|
+
onFailure(get(error, "message", SOMETHING_WENT_WRONG));
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
const onDownloadFiles = () => {
|
|
129
|
+
downloadFileMutation.mutate({
|
|
130
|
+
fileIds,
|
|
131
|
+
folderIds,
|
|
132
|
+
api,
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
const fileLinks = useMemo(() => {
|
|
136
|
+
return map(fileIds, (id) => `${appType == "reactJs"
|
|
137
|
+
? process.env.REACT_APP_MIXDRIVE_SITE_URL
|
|
138
|
+
: process.env.NEXT_PUBLIC_MIXDRIVE_SITE_URL}` +
|
|
139
|
+
FETCH_ENTITY_SCREEN.replace(":type", DriveModes.FILE).replace(":id", id));
|
|
140
|
+
}, [fileIds]);
|
|
141
|
+
const folderLinks = useMemo(() => {
|
|
142
|
+
return map(folderIds, (id) => `${appType == "reactJs"
|
|
143
|
+
? process.env.REACT_APP_MIXDRIVE_SITE_URL
|
|
144
|
+
: process.env.NEXT_PUBLIC_MIXDRIVE_SITE_URL}` +
|
|
145
|
+
FETCH_ENTITY_SCREEN.replace(":type", DriveModes.FOLDERS).replace(":id", id));
|
|
146
|
+
}, [folderIds]);
|
|
147
|
+
const link = useMemo(() => {
|
|
148
|
+
if (get(concat(fileLinks, folderLinks), "length")) {
|
|
149
|
+
return get(concat(fileLinks, folderLinks), "length") > 1
|
|
150
|
+
? join(concat(fileLinks, folderLinks), ", ")
|
|
151
|
+
: first(concat(fileLinks, folderLinks));
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
return `${appType == "reactJs"
|
|
155
|
+
? process.env.REACT_APP_MIXDRIVE_SITE_URL
|
|
156
|
+
: process.env.NEXT_PUBLIC_MIXDRIVE_SITE_URL}`;
|
|
157
|
+
}
|
|
158
|
+
}, [fileLinks, folderLinks]);
|
|
159
|
+
const isTrashPage = useMemo(() => type === DriveModes.TRASH, [type]);
|
|
160
|
+
return (_jsxs("div", { className: "md-lib-fixed md-lib-bottom-6 md-lib-left-1/2 md-lib-transform -md-lib-translate-x-1/2 md-lib-w-80 md:md-lib-w-[720px] md-lib-max-w-3xl md-lib-bg-textColorActive md-lib-border dark:md-lib-bg-darkPrimary dark:md-lib-border-darkBorderColor md-lib-border-secondaryHoverColor md-lib-rounded-xl md-lib-shadow-md md-lib-flex md-lib-items-center md-lib-justify-between md-lib-px-4 md-lib-py-2 md-lib-z-50", children: [_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-5 md-lib-pl-2", children: [_jsx(Button, { type: "text", size: "large", icon: _jsx(FiDownloadIcon, { size: 24, className: "" }), disabled: isTrashPage, onClick: onDownloadFiles, loading: downloadFileMutation.isLoading }), isTrashPage ? (_jsx(Tooltip, { title: "Restore", children: _jsx(Button, { type: "text", size: "large", icon: _jsx(RedoOutlined, { className: "" }), onClick: () => onRestoreFiles(), disabled: !isTrashPage }) })) : (_jsx(_Fragment, { children: isAdmin && (_jsx(Tooltip, { title: "Delete", children: _jsx(Button, { type: "text", size: "large", icon: _jsx(FiTrash2Icon, { size: 24, className: "" }), onClick: () => toggleConfirmPopup("delete"), disabled: isTrashPage }) })) })), _jsx(FileMenuOptions, { file: selectedFile || null, fileIds: fileIds, folderIds: folderIds, folder: selectedFolder || null, onCloseSelection: onCloseSelection, readOnly: isTrashPage })] }), _jsx("div", { className: "md-lib-flex md-lib-items-center", children: _jsxs(Tag, { className: "md-lib-bg-[#DEE4ED] dark:md-lib-bg-darkPrimaryHoverColor !md-lib-rounded-lg !md-lib-px-4 h-[38px] md-lib-text-sm md-lib-items-center md-lib-font-medium md-lib-flex md-lib-gap-2 md-lib-text-textColor dark:md-lib-text-darkTextColor", closable: true, closeIcon: _jsx(FiXIcon, { onClick: onCloseSelection, className: "md-lib-cursor-pointer" }), children: [get(fileIds, "length", 0) + get(folderIds, "length", 0), " Selected"] }) }), showMoveFolder && (_jsx(MoveToAnotherFolder, { open: showMoveFolder, handleCancel: () => {
|
|
161
|
+
toggleShowMoveFolder();
|
|
162
|
+
onCloseSelection();
|
|
163
|
+
}, folderIds: folderIds, fileIds: folderIds, entity: null })), _jsx(DeleteConfirmationModal, { showDeleteModal: showConfirmModal, toggleDeleteModal: toggleConfirmPopup, icon: actionType === "archive" ? (_jsx(IoArchiveOutlineIcon, {})) : (_jsx(DeleteOutlined, {})), okText: actionType === "archive" ? ARCHIVE_OK_TEXT : DELETE_OK_TEXT, description: DELETE_CONFIRMATION_MESSAGE.replace(":action", actionType).replace(" :entity", ""), subHeading: actionType === "archive" ? "" : DELETE_MESSAGE_DESCRIPTION, onOk: actionType === "archive" ? () => { } : onDeleteFile, loading: deleteFileMutation.isLoading })] }));
|
|
164
|
+
};
|
|
165
|
+
export default ActionsBar;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
import { useMemo, useRef, useState } from "react";
|
|
12
|
+
import { Button, Dropdown } from "antd";
|
|
13
|
+
import { MdKeyboardArrowDown } from "react-icons/md";
|
|
14
|
+
import { BsUpload } from "react-icons/bs";
|
|
15
|
+
import { PiFolderPlusLight } from "react-icons/pi";
|
|
16
|
+
import { GoPlus } from "react-icons/go";
|
|
17
|
+
import AddFolder from "./AddFolder";
|
|
18
|
+
import MapFile from "./files/MapFile";
|
|
19
|
+
import { showNotification } from "../common/notifications";
|
|
20
|
+
import { SOMETHING_WENT_WRONG, UPLOAD_SUCCESS, } from "../utilities/constants/messages";
|
|
21
|
+
import { FileUploadStatus, NotificationStatus, } from "../utilities/constants/interface";
|
|
22
|
+
import { get, keyBy, map, merge, values } from "lodash";
|
|
23
|
+
import { DELETE_S3_FILE_URL, FILE_UPLOAD_URL, } from "../utilities/constants/apiUrls";
|
|
24
|
+
import CustomLoader from "../common/loader/CustomLoader";
|
|
25
|
+
import axios from "axios";
|
|
26
|
+
import UploadStatusModal from "./UploadStatusModal";
|
|
27
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
28
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
29
|
+
import BulkUploadModal from "./BulkUploadModal";
|
|
30
|
+
import useAppParams from "../utilities/useAppParams";
|
|
31
|
+
import CustomButton from "../common/Button";
|
|
32
|
+
import { RiGalleryLine } from "react-icons/ri";
|
|
33
|
+
const extensionToMime = {
|
|
34
|
+
ai: "application/postscript",
|
|
35
|
+
psd: "image/vnd.adobe.photoshop",
|
|
36
|
+
indd: "application/x-indesign",
|
|
37
|
+
};
|
|
38
|
+
const RiGalleryLineIcon = RiGalleryLine;
|
|
39
|
+
const BsUploadIcon = BsUpload;
|
|
40
|
+
const PiFolderPlusLightIcon = PiFolderPlusLight;
|
|
41
|
+
const GoPlusIcon = GoPlus;
|
|
42
|
+
const MdKeyboardArrowDownIconIcon = MdKeyboardArrowDown;
|
|
43
|
+
const AddDrive = () => {
|
|
44
|
+
const damConfig = useDamConfig();
|
|
45
|
+
const { brand, rootFolderId } = damConfig;
|
|
46
|
+
const brandId = get(brand, "_id");
|
|
47
|
+
const { folderId } = useAppParams();
|
|
48
|
+
const fileInputRef = useRef(null);
|
|
49
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
50
|
+
const [state, setState] = useState({
|
|
51
|
+
openFolderModal: false,
|
|
52
|
+
openMapFile: false,
|
|
53
|
+
uploading: false,
|
|
54
|
+
filesList: [],
|
|
55
|
+
showUploadStatus: false,
|
|
56
|
+
uploadStatusList: [],
|
|
57
|
+
openBlukUploadModal: false,
|
|
58
|
+
showGenerateThumbnails: false,
|
|
59
|
+
});
|
|
60
|
+
const { openFolderModal, openMapFile, uploading, filesList, showUploadStatus, uploadStatusList, openBlukUploadModal, showGenerateThumbnails, } = state;
|
|
61
|
+
const toggleOpenMapFile = (files = []) => {
|
|
62
|
+
if (openMapFile) {
|
|
63
|
+
try {
|
|
64
|
+
api.delete(DELETE_S3_FILE_URL.replace(":path", filesList === null || filesList === void 0 ? void 0 : filesList[0].filePath));
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
console.log("Error while deleting file in s3", err);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { openMapFile: !prevState.openMapFile, filesList: files, showUploadStatus: false })));
|
|
71
|
+
};
|
|
72
|
+
const toggleFolderModal = () => {
|
|
73
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { openFolderModal: !prevState.openFolderModal })));
|
|
74
|
+
};
|
|
75
|
+
const toggleFolderBulkModal = () => {
|
|
76
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { openBlukUploadModal: !prevState.openBlukUploadModal })));
|
|
77
|
+
};
|
|
78
|
+
const updateFileStatus = (fileName, status) => {
|
|
79
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { uploadStatusList: map(prevState.uploadStatusList, (f) => get(f, "name") === fileName ? Object.assign(Object.assign({}, f), { status }) : f) })));
|
|
80
|
+
};
|
|
81
|
+
const handleNativeFileUpload = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
+
const selectedFiles = get(event, "target.files", []);
|
|
83
|
+
if (!selectedFiles || selectedFiles.length === 0)
|
|
84
|
+
return;
|
|
85
|
+
const files = map(Array.from(selectedFiles), (file) => {
|
|
86
|
+
var _a;
|
|
87
|
+
const name = get(file, "name", "");
|
|
88
|
+
const ext = ((_a = name.split(".").pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || "";
|
|
89
|
+
const mimetype = get(file, "type") ||
|
|
90
|
+
get(extensionToMime, ext) ||
|
|
91
|
+
"application/octet-stream";
|
|
92
|
+
return {
|
|
93
|
+
name,
|
|
94
|
+
size: get(file, "size"),
|
|
95
|
+
mimetype,
|
|
96
|
+
file,
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { uploading: true, showUploadStatus: true, uploadStatusList: map(files, (f) => ({
|
|
100
|
+
name: get(f, "name"),
|
|
101
|
+
status: FileUploadStatus.PENDING,
|
|
102
|
+
})) })));
|
|
103
|
+
try {
|
|
104
|
+
const response = yield api.post(FILE_UPLOAD_URL, {
|
|
105
|
+
brandId,
|
|
106
|
+
folderId: folderId || rootFolderId,
|
|
107
|
+
files: map(files, (file) => ({
|
|
108
|
+
name: get(file, "name"),
|
|
109
|
+
size: get(file, "size"),
|
|
110
|
+
})),
|
|
111
|
+
});
|
|
112
|
+
const uploadData = get(response, "data", []);
|
|
113
|
+
const uploadMap = keyBy(uploadData, "name");
|
|
114
|
+
for (const file of files) {
|
|
115
|
+
const fileUrl = get(uploadMap, [get(file, "name"), "url"]);
|
|
116
|
+
if (!fileUrl) {
|
|
117
|
+
updateFileStatus(get(file, "name"), FileUploadStatus.ERROR);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
yield axios.put(fileUrl, file.file, {
|
|
122
|
+
headers: {
|
|
123
|
+
"Content-Type": get(file, "mimetype"),
|
|
124
|
+
"Access-Control-Allow-Origin": "*",
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
updateFileStatus(get(file, "name"), FileUploadStatus.SUCCESS);
|
|
128
|
+
}
|
|
129
|
+
catch (_a) {
|
|
130
|
+
updateFileStatus(get(file, "name"), FileUploadStatus.ERROR);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
showNotification(get(response, "data.message", UPLOAD_SUCCESS), NotificationStatus.SUCCESS);
|
|
134
|
+
toggleOpenMapFile(values(merge({}, keyBy(files, "name"), keyBy(uploadData, "name"))));
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { uploading: false })));
|
|
141
|
+
if (fileInputRef.current)
|
|
142
|
+
fileInputRef.current.value = "";
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
const items = [
|
|
146
|
+
{
|
|
147
|
+
key: "0",
|
|
148
|
+
label: "Upload file",
|
|
149
|
+
icon: uploading ? _jsx(CustomLoader, {}) : _jsx(BsUploadIcon, { size: 16 }),
|
|
150
|
+
disabled: uploading,
|
|
151
|
+
onClick: () => { var _a; return (_a = get(fileInputRef, "current")) === null || _a === void 0 ? void 0 : _a.click(); },
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
key: "2",
|
|
155
|
+
icon: _jsx(PiFolderPlusLightIcon, { size: 20 }),
|
|
156
|
+
label: "Create folder",
|
|
157
|
+
onClick: () => toggleFolderModal(),
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
key: "3",
|
|
161
|
+
icon: _jsx(BsUploadIcon, { size: 20 }),
|
|
162
|
+
label: "Bulk Upload",
|
|
163
|
+
onClick: () => toggleFolderBulkModal(),
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
const toggleGenerateThumbnails = () => setState((prevState) => (Object.assign(Object.assign({}, prevState), { showGenerateThumbnails: !prevState.showGenerateThumbnails })));
|
|
167
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "md-lib-flex md-lib-gap-3", children: [_jsx(CustomButton, { label: "Generate Thumbnails", icon: _jsx(RiGalleryLineIcon, {}), size: "large", onClick: toggleGenerateThumbnails }), _jsx(Dropdown, { menu: { items }, trigger: ["click"], placement: "bottomRight", children: _jsxs(Button, { icon: _jsx(GoPlusIcon, { size: 16 }), type: "primary", size: "large", children: ["Add ", _jsx(MdKeyboardArrowDownIconIcon, {})] }) })] }), _jsx("input", { ref: fileInputRef, type: "file", className: "hidden", onChange: handleNativeFileUpload }), openFolderModal && (_jsx(AddFolder, { open: openFolderModal, handleCancel: toggleFolderModal })), openMapFile && (_jsx(MapFile, { open: openMapFile, handleCancel: toggleOpenMapFile, filesList: filesList, fromUpload: true })), showUploadStatus && (_jsx(UploadStatusModal, { open: showUploadStatus, statusList: uploadStatusList, onClose: () => setState((prevState) => (Object.assign(Object.assign({}, prevState), { showUploadStatus: false }))) })), openBlukUploadModal && (_jsx(BulkUploadModal, { toggleUpload: toggleFolderBulkModal, folderId: folderId !== null && folderId !== void 0 ? folderId : rootFolderId })), showGenerateThumbnails && (_jsx(BulkUploadModal, { toggleUpload: toggleGenerateThumbnails, thumbnailsOnly: true, folderId: folderId !== null && folderId !== void 0 ? folderId : rootFolderId }))] }));
|
|
168
|
+
};
|
|
169
|
+
export default AddDrive;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FileEntity, FolderEntity } from "../utilities/constants/interface";
|
|
2
|
+
declare function AddFolder({ open, handleCancel, folder, file, onCloseSelection, fileModal, }: {
|
|
3
|
+
open: boolean;
|
|
4
|
+
handleCancel: () => void;
|
|
5
|
+
folder?: FolderEntity;
|
|
6
|
+
file?: FileEntity;
|
|
7
|
+
onCloseSelection?: () => void;
|
|
8
|
+
fileModal?: boolean;
|
|
9
|
+
}): JSX.Element;
|
|
10
|
+
export default AddFolder;
|