@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,342 @@
|
|
|
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 { Button, Dropdown, Grid, Input, Select, Tooltip, Tree } from "antd";
|
|
12
|
+
import { useEffect, useMemo, useState } from "react";
|
|
13
|
+
import { get, map, isArray, isObject, cloneDeep, first, sortBy, } from "lodash";
|
|
14
|
+
import { FaAngleLeft, FaAngleRight } from "react-icons/fa";
|
|
15
|
+
import { deleteFolders, } from "../react-query/services/folder-services";
|
|
16
|
+
import { generateFoldersQueryKey, invalidateData, } from "../utilities/constants/queryKeys";
|
|
17
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
18
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
19
|
+
import { MY_DRIVE_SCREEN, SUBFOLDERS_SCREEN, } from "../utilities/constants/routes";
|
|
20
|
+
import useAppNavigate from "../utilities/useAppNavigate";
|
|
21
|
+
import { AiOutlineSortDescending } from "react-icons/ai";
|
|
22
|
+
import { AiOutlineSortAscending } from "react-icons/ai";
|
|
23
|
+
import CustomLoader from "../common/loader/CustomLoader";
|
|
24
|
+
import { useMutation, useQueryClient } from "react-query";
|
|
25
|
+
import { DeleteOutlined, EditOutlined, MoreOutlined } from "@ant-design/icons";
|
|
26
|
+
import { DeleteConfirmationModal } from "../common/CustomElements";
|
|
27
|
+
import { DELETE_CONFIRMATION_MESSAGE, DELETE_OK_TEXT, DELETE_SUCCESS, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
|
|
28
|
+
import { NotificationStatus, } from "../utilities/constants/interface";
|
|
29
|
+
import { showNotification } from "../common/notifications";
|
|
30
|
+
import { useParams } from "react-router-dom";
|
|
31
|
+
import AddFolder from "./AddFolder";
|
|
32
|
+
import { FETCH_FOLDER_URL, SORT_FOLDERS_URL, } from "../utilities/constants/apiUrls";
|
|
33
|
+
import { RiDraggable } from "react-icons/ri";
|
|
34
|
+
import { FaShuffle } from "react-icons/fa6";
|
|
35
|
+
import { IoIosSearch } from "react-icons/io";
|
|
36
|
+
const { DirectoryTree } = Tree;
|
|
37
|
+
const { Option } = Select;
|
|
38
|
+
const FaAngleLeftbtn = FaAngleLeft;
|
|
39
|
+
const FaAngleRightbtn = FaAngleRight;
|
|
40
|
+
const RiDraggablebtn = RiDraggable;
|
|
41
|
+
const AiOutlineSortDescendingbtn = AiOutlineSortDescending;
|
|
42
|
+
const AiOutlineSortAscendingbtn = AiOutlineSortAscending;
|
|
43
|
+
const GrSortIcon = FaShuffle;
|
|
44
|
+
const IoIosSearchIcon = IoIosSearch;
|
|
45
|
+
// ✅ Helper to insert children into the correct folder recursively
|
|
46
|
+
const insertSubfolders = (tree, parentId, childrenToInsert) => {
|
|
47
|
+
const newTree = map(tree, (node) => {
|
|
48
|
+
if (node._id === parentId) {
|
|
49
|
+
return Object.assign(Object.assign({}, node), { children: childrenToInsert });
|
|
50
|
+
}
|
|
51
|
+
if (isArray(node.children)) {
|
|
52
|
+
return Object.assign(Object.assign({}, node), { children: insertSubfolders(node.children, parentId, childrenToInsert) });
|
|
53
|
+
}
|
|
54
|
+
return node;
|
|
55
|
+
});
|
|
56
|
+
return newTree;
|
|
57
|
+
};
|
|
58
|
+
const sortFoldersRecursively = (folders, sortByField, // ✅ which field to sort
|
|
59
|
+
order = "asc") => {
|
|
60
|
+
if (!folders)
|
|
61
|
+
return [];
|
|
62
|
+
const sorted = sortBy(folders, (f) => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
if (sortByField === "name") {
|
|
65
|
+
return (_b = (_a = f.name) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
66
|
+
}
|
|
67
|
+
if (sortByField === "createdAt") {
|
|
68
|
+
return new Date(f.createdAt).getTime();
|
|
69
|
+
}
|
|
70
|
+
return f.name; // fallback
|
|
71
|
+
});
|
|
72
|
+
const result = order === "desc" ? [...sorted].reverse() : sorted;
|
|
73
|
+
return result.map((f) => (Object.assign(Object.assign({}, f), { children: isArray(f.children)
|
|
74
|
+
? sortFoldersRecursively(f.children, sortByField, order)
|
|
75
|
+
: f.children })));
|
|
76
|
+
};
|
|
77
|
+
function FolderTree({ currentRootId, expandedKeys, selectedKeys, handleExpand, setSelectedKeys, folders, setFolders, setExpandedKeys, setGlobalSearch, globalSearch, }) {
|
|
78
|
+
const { folderId, id, type } = useParams();
|
|
79
|
+
const damConfig = useDamConfig();
|
|
80
|
+
const { rootFolderId } = damConfig;
|
|
81
|
+
const navigate = useAppNavigate();
|
|
82
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
83
|
+
const { useBreakpoint } = Grid;
|
|
84
|
+
const [collapse, setCollapse] = useState(false);
|
|
85
|
+
const screens = useBreakpoint();
|
|
86
|
+
const queryClient = useQueryClient();
|
|
87
|
+
const [state, setState] = useState({
|
|
88
|
+
showConfirmationModal: false,
|
|
89
|
+
showEditModal: false,
|
|
90
|
+
selectedFolder: {},
|
|
91
|
+
loading: false,
|
|
92
|
+
isSorting: false,
|
|
93
|
+
enableDrag: false,
|
|
94
|
+
sortMode: "name",
|
|
95
|
+
sortOrder: "asc",
|
|
96
|
+
tempFolders: [],
|
|
97
|
+
parentFolder: {},
|
|
98
|
+
globalSearchValue: "",
|
|
99
|
+
});
|
|
100
|
+
const { showConfirmationModal, showEditModal, selectedFolder, loading, isSorting, enableDrag, sortMode, sortOrder, tempFolders, parentFolder, globalSearchValue, } = state;
|
|
101
|
+
const fetchFolders = (fid) => __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
try {
|
|
103
|
+
setState((prevState) => {
|
|
104
|
+
return Object.assign(Object.assign({}, prevState), { loading: true });
|
|
105
|
+
});
|
|
106
|
+
const response = yield api.get(`${FETCH_FOLDER_URL.replace(":folderId", fid)}?isPagination=false&includeFiles=false&includeSubFoldersCount=true&fetchMainFolders=true&globalSearch=${fid == rootFolderId ? globalSearch : ""}`);
|
|
107
|
+
const newFolders = get(response, "data.folders", []);
|
|
108
|
+
if (fid === rootFolderId) {
|
|
109
|
+
setFolders(sortFoldersRecursively(newFolders, "name", sortOrder));
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
setFolders((prev) => {
|
|
113
|
+
const cloned = cloneDeep(prev);
|
|
114
|
+
const sorted = sortFoldersRecursively(newFolders, "name", sortOrder);
|
|
115
|
+
return insertSubfolders(cloned, fid, sorted);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
setState((prevState) => {
|
|
119
|
+
return Object.assign(Object.assign({}, prevState), { parentFolder: get(response, "data.folder", {}), loading: false, globalSearchValue: globalSearch || "" });
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
124
|
+
setState((prevState) => {
|
|
125
|
+
return Object.assign(Object.assign({}, prevState), { loading: false });
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
// ✅ Load on mount & when currentRootId changes
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (currentRootId) {
|
|
132
|
+
fetchFolders(currentRootId);
|
|
133
|
+
}
|
|
134
|
+
}, [currentRootId, globalSearch]);
|
|
135
|
+
// ✅ Handle sort dropdown
|
|
136
|
+
const handleSortChange = (value) => {
|
|
137
|
+
setState((prevState) => {
|
|
138
|
+
return Object.assign(Object.assign({}, prevState), { sortMode: value });
|
|
139
|
+
});
|
|
140
|
+
if (value === "custom") {
|
|
141
|
+
const customSorted = sortBy(folders, (f) => { var _a; return (_a = f.sortOrder) !== null && _a !== void 0 ? _a : 0; });
|
|
142
|
+
setState((prevState) => {
|
|
143
|
+
return Object.assign(Object.assign({}, prevState), { tempFolders: cloneDeep(customSorted) });
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
setFolders((prev) => sortFoldersRecursively([...prev], value, sortOrder));
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const handleSortOrderChange = (value) => {
|
|
151
|
+
setState((prevState) => {
|
|
152
|
+
return Object.assign(Object.assign({}, prevState), { sortOrder: value });
|
|
153
|
+
});
|
|
154
|
+
setFolders((prev) => sortFoldersRecursively([...prev], sortMode, value));
|
|
155
|
+
};
|
|
156
|
+
const toggleEnableDrag = () => {
|
|
157
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { enableDrag: true })));
|
|
158
|
+
};
|
|
159
|
+
const toggleEditModal = (folder = {}) => setState((prev) => (Object.assign(Object.assign({}, prev), { selectedFolder: folder, showEditModal: !prev.showEditModal })));
|
|
160
|
+
const toggleDeleteModal = (folder = {}) => setState((prev) => (Object.assign(Object.assign({}, prev), { selectedFolder: folder, showConfirmationModal: !prev.showConfirmationModal })));
|
|
161
|
+
const getFoldersTree = (folders = []) => {
|
|
162
|
+
const transform = (tree = []) => map(tree, (folder) => {
|
|
163
|
+
const key = get(folder, "_id", "");
|
|
164
|
+
const name = get(folder, "name", "");
|
|
165
|
+
const menuItems = [
|
|
166
|
+
{
|
|
167
|
+
key: "rename",
|
|
168
|
+
icon: _jsx(EditOutlined, {}),
|
|
169
|
+
label: "Rename",
|
|
170
|
+
onClick: (e) => {
|
|
171
|
+
e.domEvent.stopPropagation();
|
|
172
|
+
toggleEditModal(folder);
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
key: "delete",
|
|
177
|
+
icon: _jsx(DeleteOutlined, {}),
|
|
178
|
+
danger: true,
|
|
179
|
+
label: "Delete",
|
|
180
|
+
onClick: (e) => {
|
|
181
|
+
e.domEvent.stopPropagation();
|
|
182
|
+
toggleDeleteModal(folder);
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
];
|
|
186
|
+
const title = (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-justify-between md-lib-h-[33px]", children: [sortMode === "custom" && enableDrag && _jsx(RiDraggablebtn, {}), _jsx(Tooltip, { title: name, children: _jsx("span", { className: "md-lib-truncate md-lib-max-w-[180px] md-lib-cursor-pointer md-lib-ml-2", children: name }) }), _jsx(Dropdown, { menu: { items: menuItems }, trigger: ["click"], children: _jsx(MoreOutlined, { className: "md-lib-cursor-pointer md-lib-ml-1 md-lib-mt-[3px]", onClick: (e) => {
|
|
187
|
+
e.stopPropagation(); // prevent folder select
|
|
188
|
+
} }) })] }));
|
|
189
|
+
let children = null;
|
|
190
|
+
const rawChildren = get(folder, "children");
|
|
191
|
+
if (isArray(rawChildren)) {
|
|
192
|
+
children = transform(rawChildren);
|
|
193
|
+
}
|
|
194
|
+
else if (isObject(rawChildren)) {
|
|
195
|
+
children = transform([rawChildren]);
|
|
196
|
+
}
|
|
197
|
+
return { key, title, children };
|
|
198
|
+
});
|
|
199
|
+
return transform(folders);
|
|
200
|
+
};
|
|
201
|
+
const toggleMenu = () => {
|
|
202
|
+
setCollapse(!collapse);
|
|
203
|
+
};
|
|
204
|
+
const tree = useMemo(() => {
|
|
205
|
+
return map(get(parentFolder, "tree", []), (item) => get(item, "_id")).filter((item) => {
|
|
206
|
+
return get(item, "_id") !== rootFolderId;
|
|
207
|
+
});
|
|
208
|
+
}, [parentFolder]);
|
|
209
|
+
const handleSelect = (keys) => {
|
|
210
|
+
// console.log("keys", keys);
|
|
211
|
+
const selected = map(keys, (k) => k.toString());
|
|
212
|
+
// console.log("selected", selected);
|
|
213
|
+
setSelectedKeys(selected);
|
|
214
|
+
if (get(selected, "length") > 0) {
|
|
215
|
+
const selectedId = selected[get(selected, "length", 0) - 1];
|
|
216
|
+
navigate(SUBFOLDERS_SCREEN.replace(":folderId", selectedId));
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
// console.log(tree);
|
|
221
|
+
setExpandedKeys(tree);
|
|
222
|
+
}, [tree]);
|
|
223
|
+
// console.log("tree", tree, selectedKeys, treeData);
|
|
224
|
+
const onDeleteSuccess = (message, deletedId) => {
|
|
225
|
+
setFolders((prevFolders) => {
|
|
226
|
+
const removeFolderRecursively = (folders) => {
|
|
227
|
+
return folders
|
|
228
|
+
.map((f) => {
|
|
229
|
+
// recurse into children first
|
|
230
|
+
const updatedChildren = Array.isArray(f.children)
|
|
231
|
+
? removeFolderRecursively(f.children)
|
|
232
|
+
: f.children;
|
|
233
|
+
return Object.assign(Object.assign({}, f), { children: updatedChildren });
|
|
234
|
+
})
|
|
235
|
+
.filter((f) => f._id !== deletedId); // filter AFTER recursion
|
|
236
|
+
};
|
|
237
|
+
return removeFolderRecursively(prevFolders);
|
|
238
|
+
});
|
|
239
|
+
invalidateData(queryClient, generateFoldersQueryKey(type), folderId ? folderId : id ? id : rootFolderId);
|
|
240
|
+
if (deletedId === folderId || deletedId === id) {
|
|
241
|
+
navigate(MY_DRIVE_SCREEN);
|
|
242
|
+
}
|
|
243
|
+
showNotification(message, NotificationStatus.SUCCESS);
|
|
244
|
+
};
|
|
245
|
+
const onFailure = (message) => {
|
|
246
|
+
showNotification(message, NotificationStatus.ERROR);
|
|
247
|
+
};
|
|
248
|
+
useEffect(() => {
|
|
249
|
+
if (!folderId || folderId === rootFolderId) {
|
|
250
|
+
setSelectedKeys([]);
|
|
251
|
+
setExpandedKeys([]);
|
|
252
|
+
}
|
|
253
|
+
}, [folderId]);
|
|
254
|
+
const deleteFolderMutation = useMutation({
|
|
255
|
+
mutationFn: deleteFolders,
|
|
256
|
+
onSuccess: (response, variables) => {
|
|
257
|
+
toggleDeleteModal();
|
|
258
|
+
onDeleteSuccess(get(response, "data.message", DELETE_SUCCESS), first(get(variables, "folderIds", [])));
|
|
259
|
+
},
|
|
260
|
+
onError: (error) => {
|
|
261
|
+
onFailure(get(error, "message", SOMETHING_WENT_WRONG));
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
const onDeleteFolder = () => {
|
|
265
|
+
deleteFolderMutation.mutate({
|
|
266
|
+
folderIds: [get(selectedFolder, "_id")],
|
|
267
|
+
api,
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
// ✅ Drag & drop for parent only
|
|
271
|
+
const onDrop = (info) => {
|
|
272
|
+
const dragKey = info.dragNode.key;
|
|
273
|
+
const dropKey = info.node.key;
|
|
274
|
+
const newData = [...tempFolders];
|
|
275
|
+
const dragIndex = newData.findIndex((f) => f._id === dragKey);
|
|
276
|
+
const dropIndex = newData.findIndex((f) => f._id === dropKey);
|
|
277
|
+
if (dragIndex === -1 || dropIndex === -1)
|
|
278
|
+
return;
|
|
279
|
+
const dragged = newData[dragIndex];
|
|
280
|
+
newData.splice(dragIndex, 1);
|
|
281
|
+
newData.splice(dropIndex, 0, dragged);
|
|
282
|
+
// console.log("sorted data", newData);
|
|
283
|
+
setState((prevState) => {
|
|
284
|
+
return Object.assign(Object.assign({}, prevState), { tempFolders: newData });
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
// ✅ Save custom order
|
|
288
|
+
const handleSave = () => __awaiter(this, void 0, void 0, function* () {
|
|
289
|
+
setState((prevState) => {
|
|
290
|
+
return Object.assign(Object.assign({}, prevState), { isSorting: true });
|
|
291
|
+
});
|
|
292
|
+
try {
|
|
293
|
+
const response = yield api.put(SORT_FOLDERS_URL, {
|
|
294
|
+
folders: tempFolders.map((f, i) => ({
|
|
295
|
+
folderId: f._id,
|
|
296
|
+
sortOrder: i + 1,
|
|
297
|
+
})),
|
|
298
|
+
});
|
|
299
|
+
setFolders(tempFolders.map((f, i) => (Object.assign(Object.assign({}, f), { sortOrder: i + 1 }))));
|
|
300
|
+
if (response) {
|
|
301
|
+
showNotification(get(response, "data.message", ""), NotificationStatus.SUCCESS);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
catch (e) {
|
|
305
|
+
console.error(e);
|
|
306
|
+
if (e === null || e === void 0 ? void 0 : e.message) {
|
|
307
|
+
showNotification(e === null || e === void 0 ? void 0 : e.message, NotificationStatus.ERROR);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
finally {
|
|
311
|
+
setState((prevState) => {
|
|
312
|
+
return Object.assign(Object.assign({}, prevState), { isSorting: false, enableDrag: false });
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
const handleCancel = () => {
|
|
317
|
+
setState((prevState) => {
|
|
318
|
+
const customSorted = sortBy(folders, (f) => { var _a; return (_a = f.sortOrder) !== null && _a !== void 0 ? _a : 0; });
|
|
319
|
+
return Object.assign(Object.assign({}, prevState), { tempFolders: cloneDeep(customSorted), sortMode: "custom", enableDrag: false });
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
return (_jsxs(_Fragment, { children: [!screens.md && collapse && (_jsxs("div", { className: `md-lib-bg-textColorActive dark:md-lib-bg-darkSecondaryColor md-lib-p-1 md-lib-rounded md-lib-absolute md-lib-top-16 md-lib-left-1`, children: [" ", _jsx(FaAngleRightbtn, { size: 24, className: "md-lib-text-textColor dark:md-lib-text-darkTextColor", onClick: toggleMenu })] })), _jsxs("div", { className: `md-lib-border-r md-lib-inline-table md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor md-lib-px-2 md-lib-pt-1 md-lib-max-h-[calc(100%-76px)] md-lib-overflow-x-auto ${!screens.md &&
|
|
323
|
+
"md-lib-absolute md-lib-left-0 md-lib-z-30 md-lib-h-full"} ${!screens.md && collapse && "!-md-lib-left-full"}`, children: [!screens.md && !collapse && (_jsxs("div", { className: `md-lib-bg-textColorActive dark:md-lib-bg-darkSecondaryColor md-lib-p-1 md-lib-rounded md-lib-absolute md-lib-top-1 md-lib-right-1 md-lib-z-50`, children: [" ", _jsx(FaAngleLeftbtn, { size: 24, className: "md-lib-text-textColor dark:md-lib-text-darkTextColor", onClick: toggleMenu })] })), _jsx("div", { className: "md-lib-mb-2", children: _jsx(Input, { placeholder: "Search files (min. 2 characters required)", onChange: (e) => setState((prevState) => {
|
|
324
|
+
return Object.assign(Object.assign({}, prevState), { globalSearchValue: e.target.value });
|
|
325
|
+
}), value: globalSearchValue, prefix: _jsx(IoIosSearchIcon, {}), onPressEnter: () => {
|
|
326
|
+
if (globalSearchValue.length >= 2 || !globalSearchValue) {
|
|
327
|
+
setGlobalSearch(globalSearchValue);
|
|
328
|
+
navigate(MY_DRIVE_SCREEN);
|
|
329
|
+
}
|
|
330
|
+
} }) }), !enableDrag && (_jsx("p", { className: "md-lib-text-xs md-lib-text-secondaryTextColor md-lib-mb-1 md-lib-font-400", children: "Sort By:" })), _jsxs("div", { className: "md-lib-flex md-lib-justify-between md-lib-items-center md-lib-mb-3 md-lib-gap-2", children: [!enableDrag && (_jsxs(Select, { value: sortMode, onChange: handleSortChange, style: { width: 200 }, children: [_jsx(Option, { value: "name", children: "Name" }), _jsx(Option, { value: "createdAt", children: "Created At" }), _jsx(Option, { value: "custom", children: "Custom Order" })] })), sortMode !== "custom" && (_jsx(Tooltip, { title: sortOrder === "desc" ? "Ascending" : "Descending", children: _jsx(Button, { onClick: () => {
|
|
331
|
+
if (sortOrder === "desc") {
|
|
332
|
+
handleSortOrderChange("asc");
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
handleSortOrderChange("desc");
|
|
336
|
+
}
|
|
337
|
+
}, icon: sortOrder == "desc" ? (_jsx(AiOutlineSortAscendingbtn, { className: "md-lib-cursor-pointer" })) : (_jsx(AiOutlineSortDescendingbtn, { className: "md-lib-cursor-pointer" })) }) })), sortMode === "custom" && !enableDrag && !globalSearch && (_jsx(Tooltip, { title: "Enable Drag", children: _jsx(Button, { icon: _jsx(GrSortIcon, {}), onClick: toggleEnableDrag }) })), enableDrag && (_jsxs("div", { className: "md-lib-flex md-lib-gap-2 md-lib-ml-2", children: [_jsx(Button, { type: "primary", onClick: handleSave, loading: isSorting, children: "Save" }), _jsx(Button, { onClick: handleCancel, children: "Cancel" })] })), loading && _jsx(CustomLoader, {})] }), _jsx(DirectoryTree, { treeData: getFoldersTree(sortMode === "custom" ? tempFolders : folders), draggable: {
|
|
338
|
+
icon: true,
|
|
339
|
+
nodeDraggable: (node) => sortMode === "custom" && enableDrag ? !(node === null || node === void 0 ? void 0 : node.parentId) : false,
|
|
340
|
+
}, onDrop: sortMode === "custom" && enableDrag ? onDrop : undefined, blockNode: true, showIcon: false, selectable: !enableDrag, selectedKeys: isArray(selectedKeys) ? selectedKeys : [selectedKeys], expandedKeys: expandedKeys, onSelect: handleSelect, onExpand: handleExpand })] }), showConfirmationModal && (_jsx(DeleteConfirmationModal, { showDeleteModal: showConfirmationModal, toggleDeleteModal: toggleDeleteModal, okText: DELETE_OK_TEXT, description: DELETE_CONFIRMATION_MESSAGE.replace(":action", "delete").replace(":entity", get(selectedFolder, "name", "this folder")), onOk: onDeleteFolder, loading: loading })), showEditModal && (_jsx(AddFolder, { open: showEditModal, handleCancel: toggleEditModal, folder: selectedFolder }))] }));
|
|
341
|
+
}
|
|
342
|
+
export default FolderTree;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
+
import { GoArrowLeft } from "react-icons/go";
|
|
13
|
+
import { PiFloppyDisk } from "react-icons/pi";
|
|
14
|
+
import TuiImageEditor from "./TuiImageEditor";
|
|
15
|
+
import { useMemo, useRef, useState } from "react";
|
|
16
|
+
import { NotificationStatus, } from "../../utilities/constants/interface";
|
|
17
|
+
import { get } from "lodash";
|
|
18
|
+
import CustomButton from "../../common/Button";
|
|
19
|
+
import { showNotification } from "../../common/notifications";
|
|
20
|
+
import { FILE_UPLOAD_ERROR, SOMETHING_WENT_WRONG, UPDATE_SUCCESS, } from "../../utilities/constants/messages";
|
|
21
|
+
import { SAVE_EDITED_FILE_THUMBNAIL_URL, SAVE_EDITED_FILE_URL, } from "../../utilities/constants/apiUrls";
|
|
22
|
+
import axios from "axios";
|
|
23
|
+
import { generateFoldersQueryKey, invalidateData, QueryKeys, } from "../../utilities/constants/queryKeys";
|
|
24
|
+
import { useQueryClient } from "react-query";
|
|
25
|
+
import { useDamConfig } from "../../hocs/DamConfigContext";
|
|
26
|
+
import { createApiClient } from "../../hocs/configureAxios";
|
|
27
|
+
import useAppParams from "../../utilities/useAppParams";
|
|
28
|
+
const GoArrowLeftIcon = GoArrowLeft;
|
|
29
|
+
const PiFloppyDiskIcon = PiFloppyDisk;
|
|
30
|
+
const ImageEditorComponent = ({ file, handleClose, }) => {
|
|
31
|
+
const queryClient = useQueryClient();
|
|
32
|
+
const damConfig = useDamConfig();
|
|
33
|
+
const { rootFolderId } = damConfig;
|
|
34
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
35
|
+
const { type, folderId } = useAppParams();
|
|
36
|
+
const [state, setState] = useState({
|
|
37
|
+
loading: false,
|
|
38
|
+
});
|
|
39
|
+
const { loading } = state;
|
|
40
|
+
const editorRef = useRef(null);
|
|
41
|
+
const handleSave = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
var _a;
|
|
43
|
+
const editedFile = yield ((_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.getEditedFile());
|
|
44
|
+
if (editedFile) {
|
|
45
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true })));
|
|
46
|
+
try {
|
|
47
|
+
const response = yield api.put(SAVE_EDITED_FILE_URL, {
|
|
48
|
+
path: get(file, "s3Path"),
|
|
49
|
+
});
|
|
50
|
+
const url = get(response, "data");
|
|
51
|
+
if (url) {
|
|
52
|
+
try {
|
|
53
|
+
const response = yield axios.put(url, editedFile, {
|
|
54
|
+
headers: {
|
|
55
|
+
"Content-Type": get(editedFile, "mimetype"),
|
|
56
|
+
"Access-Control-Allow-Origin": "*",
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
if (get(response, "status") === 200) {
|
|
60
|
+
try {
|
|
61
|
+
const result = yield api.put(SAVE_EDITED_FILE_THUMBNAIL_URL.replace(":fileId", get(file, "_id")), {});
|
|
62
|
+
invalidateData(queryClient, generateFoldersQueryKey(type), folderId ? folderId : rootFolderId);
|
|
63
|
+
invalidateData(queryClient, QueryKeys.FILE, get(file, "_id"));
|
|
64
|
+
showNotification(UPDATE_SUCCESS, NotificationStatus.SUCCESS);
|
|
65
|
+
handleClose();
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
showNotification(get(error, "message", FILE_UPLOAD_ERROR), NotificationStatus.ERROR);
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false })));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
showNotification(get(error, "message", FILE_UPLOAD_ERROR), NotificationStatus.ERROR);
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false })));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
showNotification(FILE_UPLOAD_ERROR, NotificationStatus.ERROR);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
88
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false })));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
showNotification("Error while saving image", NotificationStatus.ERROR);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "md-lib-bg-darkPrimaryBg md-lib-py-3 md-lib-px-5 md-lib-flex md-lib-justify-between md-lib-items-center", children: [_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-5", children: [_jsx(GoArrowLeftIcon, { className: "md-lib-text-darkTextColor", size: 24, onClick: handleClose }), _jsx("h4", { className: "md-lib-font-semibold md-lib-text-darkTextColor md-lib-text-base md-lib-truncate md-lib-w-96", title: get(file, "name", "N/A"), children: get(file, "name", "N/A") })] }), _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-4", children: [_jsx(CustomButton, { size: "large", onClick: handleClose, label: "Cancel", type: "default", className: "md-lib-bg-secondaryColor md-lib-hover:bg-secondaryHoverColor md-lib-border-none" }), _jsx(CustomButton, { size: "large", type: "primary", icon: _jsx(PiFloppyDiskIcon, { size: 24 }), onClick: handleSave, label: "Save", loading: loading })] })] }), _jsx(TuiImageEditor, { ref: editorRef, file: file, path: get(file, "s3Path") })] }));
|
|
96
|
+
};
|
|
97
|
+
export default ImageEditorComponent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FileEntity } from "../../utilities/constants/interface";
|
|
3
|
+
declare const EditImageModal: ({ open, handleClose, file, }: {
|
|
4
|
+
handleClose: () => void;
|
|
5
|
+
open: boolean;
|
|
6
|
+
file: FileEntity;
|
|
7
|
+
}) => React.ReactPortal | null;
|
|
8
|
+
export default EditImageModal;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import ReactDOM from "react-dom";
|
|
4
|
+
import ImageEditorComponent from "./EditImage";
|
|
5
|
+
import useAppParams from "../../utilities/useAppParams";
|
|
6
|
+
const EditImageModal = ({ open, handleClose, file, }) => {
|
|
7
|
+
const { id } = useAppParams();
|
|
8
|
+
const [state, setState] = useState({
|
|
9
|
+
visible: false,
|
|
10
|
+
});
|
|
11
|
+
const { visible } = state;
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (open) {
|
|
14
|
+
setTimeout(() => setState((prevState) => (Object.assign(Object.assign({}, prevState), { visible: true }))), 10);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { visible: false })));
|
|
18
|
+
}
|
|
19
|
+
}, [open]);
|
|
20
|
+
if (!open && !visible)
|
|
21
|
+
return null;
|
|
22
|
+
const modalContent = (_jsx("div", { className: `md-lib-fixed md-lib-inset-0 md-lib-z-[1001] md-lib-w-screen md-lib-h-screen md-lib-bg-white dark:md-lib-bg-darkPrimary md-lib-text-black dark:md-lib-text-white md-lib-overflow-auto md-lib-transform md-lib-transition-all md-lib-duration-300 md-lib-ease-in-out ${open && visible
|
|
23
|
+
? "md-lib-opacity-100 md-lib-translate-y-0"
|
|
24
|
+
: "md-lib-opacity-0 md-lib-translate-y-4"}`, onTransitionEnd: () => {
|
|
25
|
+
if (!open)
|
|
26
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { visible: false })));
|
|
27
|
+
}, children: _jsx(ImageEditorComponent, { file: file, handleClose: handleClose }) }));
|
|
28
|
+
return ReactDOM.createPortal(modalContent, document.body);
|
|
29
|
+
};
|
|
30
|
+
export default EditImageModal;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FileEntity } from "../../utilities/constants/interface";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import "tui-image-editor/dist/tui-image-editor.css";
|
|
4
|
+
declare const TuiImageEditor: React.ForwardRefExoticComponent<{
|
|
5
|
+
file: FileEntity;
|
|
6
|
+
path: string;
|
|
7
|
+
} & React.RefAttributes<{
|
|
8
|
+
getEditedFile: () => Promise<File | null>;
|
|
9
|
+
}>>;
|
|
10
|
+
export default TuiImageEditor;
|
|
@@ -0,0 +1,99 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
11
|
+
import { get } from "lodash";
|
|
12
|
+
import { useEffect, useRef, forwardRef, useImperativeHandle, useMemo, useState, } from "react";
|
|
13
|
+
import ImageEditor from "tui-image-editor";
|
|
14
|
+
import "tui-image-editor/dist/tui-image-editor.css";
|
|
15
|
+
import { useDamConfig } from "../../hocs/DamConfigContext";
|
|
16
|
+
import { createApiClient } from "../../hocs/configureAxios";
|
|
17
|
+
import { GET_BASE64_USING_PATH_URL } from "../../utilities/constants/apiUrls";
|
|
18
|
+
const TuiImageEditor = forwardRef(({ file, path }, ref) => {
|
|
19
|
+
const editorRef = useRef(null);
|
|
20
|
+
const editorInstance = useRef(null);
|
|
21
|
+
const damConfig = useDamConfig();
|
|
22
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
23
|
+
const [base64, setBase64] = useState("");
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (path) {
|
|
26
|
+
getBase64();
|
|
27
|
+
}
|
|
28
|
+
}, [path]);
|
|
29
|
+
const getBase64 = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
try {
|
|
31
|
+
const response = yield api.get(`${GET_BASE64_USING_PATH_URL}?key=${path}`);
|
|
32
|
+
// console.log(response);
|
|
33
|
+
const base64 = get(response, "base64", "");
|
|
34
|
+
const mimeType = get(response, "contentType", "image/png");
|
|
35
|
+
setBase64(`data:${mimeType};base64,${base64}`);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
console.log("Error while fetching file base64", err);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!editorRef.current)
|
|
43
|
+
return;
|
|
44
|
+
editorInstance.current = new ImageEditor(editorRef.current, {
|
|
45
|
+
includeUI: {
|
|
46
|
+
loadImage: {
|
|
47
|
+
path: base64,
|
|
48
|
+
name: get(file, "name", "N/A"),
|
|
49
|
+
},
|
|
50
|
+
theme: {
|
|
51
|
+
"loadButton.display": "none",
|
|
52
|
+
},
|
|
53
|
+
menu: [
|
|
54
|
+
"crop",
|
|
55
|
+
"flip",
|
|
56
|
+
"rotate",
|
|
57
|
+
"draw",
|
|
58
|
+
"shape",
|
|
59
|
+
"icon",
|
|
60
|
+
"text",
|
|
61
|
+
"mask",
|
|
62
|
+
"filter",
|
|
63
|
+
],
|
|
64
|
+
initMenu: "filter",
|
|
65
|
+
uiSize: {
|
|
66
|
+
width: "100%",
|
|
67
|
+
height: "700px",
|
|
68
|
+
},
|
|
69
|
+
menuBarPosition: "bottom",
|
|
70
|
+
},
|
|
71
|
+
cssMaxWidth: 700,
|
|
72
|
+
cssMaxHeight: 500,
|
|
73
|
+
selectionStyle: {
|
|
74
|
+
cornerSize: 20,
|
|
75
|
+
rotatingPointOffset: 70,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
return () => {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
(_b = (_a = editorInstance.current) === null || _a === void 0 ? void 0 : _a.destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
81
|
+
};
|
|
82
|
+
}, [base64]);
|
|
83
|
+
useImperativeHandle(ref, () => ({
|
|
84
|
+
getEditedFile() {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
if (!editorInstance.current)
|
|
87
|
+
return null;
|
|
88
|
+
const dataURL = editorInstance.current.toDataURL();
|
|
89
|
+
const blob = yield (yield fetch(dataURL)).blob();
|
|
90
|
+
return new File([blob], get(file, "name", "edited-image.png"), {
|
|
91
|
+
type: get(file, "mimetype", blob.type),
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
}));
|
|
96
|
+
return (_jsx("div", { className: "md-lib-w-full", children: _jsx("div", { ref: editorRef, className: "mb-4" }) }));
|
|
97
|
+
});
|
|
98
|
+
TuiImageEditor.displayName = "TuiImageEditor";
|
|
99
|
+
export default TuiImageEditor;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FolderEntity } from "../utilities/constants/interface";
|
|
2
|
+
declare function ImagePickerBreadCrumbList({ folder, parentFolderId, setParentFolderId, pickerFolderId, }: {
|
|
3
|
+
folder: FolderEntity;
|
|
4
|
+
parentFolderId?: string;
|
|
5
|
+
setParentFolderId?: (id: string) => void;
|
|
6
|
+
pickerFolderId?: string;
|
|
7
|
+
}): JSX.Element;
|
|
8
|
+
export default ImagePickerBreadCrumbList;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Breadcrumb, Tooltip } from "antd";
|
|
3
|
+
import { findIndex, get, last, map, slice } from "lodash";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { FaChevronRight } from "react-icons/fa";
|
|
6
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
7
|
+
const FaChevronRightIcon = FaChevronRight;
|
|
8
|
+
function ImagePickerBreadCrumbList({ folder, parentFolderId, setParentFolderId, pickerFolderId, }) {
|
|
9
|
+
const damConfig = useDamConfig();
|
|
10
|
+
const { rootFolderId } = damConfig;
|
|
11
|
+
const tree = useMemo(() => {
|
|
12
|
+
const fullTree = get(folder, "tree", []);
|
|
13
|
+
if (pickerFolderId) {
|
|
14
|
+
const pickerIndex = findIndex(fullTree, (item) => get(item, "_id") === pickerFolderId);
|
|
15
|
+
const parentIndex = findIndex(fullTree, (item) => get(item, "_id") === parentFolderId);
|
|
16
|
+
if (pickerIndex !== -1) {
|
|
17
|
+
const end = parentIndex !== -1 ? parentIndex + 1 : get(fullTree, "length");
|
|
18
|
+
return slice(fullTree, pickerIndex, end);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return fullTree;
|
|
22
|
+
}, [folder, pickerFolderId, parentFolderId]);
|
|
23
|
+
return (_jsx(Breadcrumb, { className: "md-lib-font-semibold md-lib-text-[22px] md-lib-truncate", separator: _jsx(FaChevronRightIcon, { className: "md-lib-mt-2" }), children: map(tree, (item) => {
|
|
24
|
+
const treeId = get(item, "_id");
|
|
25
|
+
const name = get(item, "name", "N/A");
|
|
26
|
+
const isLast = treeId === get(last(tree), "_id");
|
|
27
|
+
const handleClick = () => {
|
|
28
|
+
if (pickerFolderId && setParentFolderId && !isLast) {
|
|
29
|
+
setParentFolderId(treeId);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return (_jsx(Breadcrumb.Item, { onClick: handleClick, className: "md-lib-h-auto md-lib-cursor-pointer", children: _jsx(Tooltip, { title: name, children: _jsx("p", { className: "md-lib-max-w-28 md-lib-truncate md-lib-font-semibold md-lib-text-[22px]", children: name }) }) }, treeId));
|
|
33
|
+
}) }));
|
|
34
|
+
}
|
|
35
|
+
export default ImagePickerBreadCrumbList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ImagePickerDrive(): JSX.Element;
|