@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,188 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { LIST_VIEW_DATE_FORMAT, LOCAL_TIMEZONE, UPLOAD_FILE_IN_PROGRESS_WHITE_IMAGE, } from "../hocs/appConstants";
|
|
3
|
+
import { DriveModes, EntityType, InputTypes, SortByKeys, SortOrders, ThumbnailStatus, } from "../utilities/constants/interface";
|
|
4
|
+
import moment from "moment-timezone";
|
|
5
|
+
import { filter, get, groupBy, includes, map, reverse, sortBy, toLower, } from "lodash";
|
|
6
|
+
import LoadMoreItems from "../common/LoadMoreItems";
|
|
7
|
+
import FolderMenuOptions from "./FolderMenuOptions";
|
|
8
|
+
import { Image, Tooltip } from "antd";
|
|
9
|
+
import dayjs from "dayjs";
|
|
10
|
+
import isToday from "dayjs/plugin/isToday";
|
|
11
|
+
import isYesterday from "dayjs/plugin/isYesterday";
|
|
12
|
+
import { getFileOrFolderIcon } from "../common/folders/getFolderOrFileIcon";
|
|
13
|
+
import { formatBytes } from "../hocs/helpers";
|
|
14
|
+
import { FETCH_ENTITY_SCREEN, SUBFOLDERS_SCREEN, } from "../utilities/constants/routes";
|
|
15
|
+
import RenderThumbnail from "../common/RenderThumnail";
|
|
16
|
+
import FileMenuOptions from "./FileMenuOptions";
|
|
17
|
+
import ActionsBar from "./ActionBar";
|
|
18
|
+
import { useMemo, useRef, useState } from "react";
|
|
19
|
+
import FileDetails from "./fileDetails/FileDetails";
|
|
20
|
+
import { GrInProgress } from "react-icons/gr";
|
|
21
|
+
import useAppNavigate from "../utilities/useAppNavigate";
|
|
22
|
+
import useAppParams from "../utilities/useAppParams";
|
|
23
|
+
import { ArrowDownOutlined, ArrowUpOutlined } from "@ant-design/icons";
|
|
24
|
+
import { FaSort } from "react-icons/fa";
|
|
25
|
+
import { LuFilterX } from "react-icons/lu";
|
|
26
|
+
import SearchFilter from "./SearchFilter";
|
|
27
|
+
import { useTheme } from "../hocs/ThemeContext";
|
|
28
|
+
dayjs.extend(isToday);
|
|
29
|
+
dayjs.extend(isYesterday);
|
|
30
|
+
const ClearFilterIcon = LuFilterX;
|
|
31
|
+
const IconInprogress = GrInProgress;
|
|
32
|
+
const FaSortIcon = FaSort;
|
|
33
|
+
const formatGroupDate = (date) => {
|
|
34
|
+
const d = dayjs(date);
|
|
35
|
+
if (d.isToday())
|
|
36
|
+
return "Today";
|
|
37
|
+
if (d.isYesterday())
|
|
38
|
+
return "Yesterday";
|
|
39
|
+
return d.format(LIST_VIEW_DATE_FORMAT);
|
|
40
|
+
};
|
|
41
|
+
const FolderListView = ({ folders, foldersFetching, hasNextPage, fetchNextPage, selectedFileIds, selectedFolderIds, setSelectedItems, isImagePicker, setSelectedFile, setParentFolderId, selectedPickerFile, location, assets, sortByKey, sortOrder, setSortOrders, onSearch, searchKey, searchValue, metadataKey, metadataValue, }) => {
|
|
42
|
+
const navigate = useAppNavigate();
|
|
43
|
+
const [state, setState] = useState({
|
|
44
|
+
selectedFile: {},
|
|
45
|
+
showPreviewModal: false,
|
|
46
|
+
});
|
|
47
|
+
const theme = useTheme();
|
|
48
|
+
const { showPreviewModal, selectedFile } = state;
|
|
49
|
+
const { type } = useAppParams();
|
|
50
|
+
const clickTimer = useRef(null);
|
|
51
|
+
const assetIds = Array.from(new Set(folders
|
|
52
|
+
.filter((f) => get(f, "type") === EntityType.FILE)
|
|
53
|
+
.map((f) => get(f, "assetId"))
|
|
54
|
+
.filter(Boolean)));
|
|
55
|
+
// Meta fields as columns
|
|
56
|
+
const metaFields = useMemo(() => {
|
|
57
|
+
const allFields = assets
|
|
58
|
+
.filter((asset) => includes(assetIds, get(asset, "_id")))
|
|
59
|
+
.map((asset) => get(asset, "metadataFields", []))
|
|
60
|
+
.flat();
|
|
61
|
+
return allFields;
|
|
62
|
+
}, [assetIds, assets]);
|
|
63
|
+
const handleClick = (folder) => {
|
|
64
|
+
const id = get(folder, "_id");
|
|
65
|
+
const fileType = get(folder, "type", EntityType.FOLDER);
|
|
66
|
+
if (isImagePicker) {
|
|
67
|
+
if (fileType === EntityType.FILE) {
|
|
68
|
+
setSelectedFile === null || setSelectedFile === void 0 ? void 0 : setSelectedFile(folder);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
setParentFolderId === null || setParentFolderId === void 0 ? void 0 : setParentFolderId(id);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else if (type === DriveModes.FOLDERS) {
|
|
75
|
+
navigate(FETCH_ENTITY_SCREEN.replace(":id", id).replace(":type", fileType));
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
if (clickTimer.current) {
|
|
79
|
+
clearTimeout(clickTimer.current);
|
|
80
|
+
clickTimer.current = null;
|
|
81
|
+
if (fileType === EntityType.FOLDER) {
|
|
82
|
+
navigate(SUBFOLDERS_SCREEN.replace(":folderId", id));
|
|
83
|
+
}
|
|
84
|
+
if (fileType === EntityType.FILE && type !== DriveModes.TRASH) {
|
|
85
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { selectedFile: folder, showPreviewModal: true })));
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
clickTimer.current = setTimeout(() => {
|
|
90
|
+
if (fileType === EntityType.FILE) {
|
|
91
|
+
const alreadySelected = includes(selectedFileIds, id);
|
|
92
|
+
setSelectedItems({
|
|
93
|
+
fileIds: alreadySelected
|
|
94
|
+
? filter(selectedFileIds, (fid) => fid !== id)
|
|
95
|
+
: [...selectedFileIds, id],
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const alreadySelected = includes(selectedFolderIds, id);
|
|
100
|
+
setSelectedItems({
|
|
101
|
+
folderIds: alreadySelected
|
|
102
|
+
? filter(selectedFolderIds, (fid) => fid !== id)
|
|
103
|
+
: [...selectedFolderIds, id],
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
clickTimer.current = null;
|
|
107
|
+
}, 250);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const sortedFolders = useMemo(() => {
|
|
111
|
+
let result = [];
|
|
112
|
+
if (sortByKey === SortByKeys.NAME) {
|
|
113
|
+
result = sortBy(folders, (f) => toLower(get(f, "name", "")));
|
|
114
|
+
}
|
|
115
|
+
else if (sortByKey === SortByKeys.UPDATED_AT) {
|
|
116
|
+
result = sortBy(folders, (f) => moment.utc(get(f, "updatedAt")).valueOf());
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
result = sortBy(folders, (f) => get(f, "size", ""));
|
|
120
|
+
}
|
|
121
|
+
if (sortOrder === SortOrders.DESCEND) {
|
|
122
|
+
result = reverse(result);
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
125
|
+
}, [folders, sortByKey, sortOrder]);
|
|
126
|
+
const grouped = useMemo(() => {
|
|
127
|
+
if (sortByKey === SortByKeys.NAME) {
|
|
128
|
+
return { All: sortedFolders };
|
|
129
|
+
}
|
|
130
|
+
return groupBy(sortedFolders, (folder) => formatGroupDate(get(folder, "updatedAt")));
|
|
131
|
+
}, [sortedFolders, sortByKey]);
|
|
132
|
+
return (_jsxs("div", { className: "md-lib-space-y-6 md-lib-relative ", children: [_jsxs("div", { className: "md-lib-flex md-lib-justify-between md-lib-items-center md-lib-px-2 md-lib-min-w-fit md-lib-gap-2", children: [!isImagePicker && type !== DriveModes.FOLDERS && (_jsx("div", { className: "md-lib-w-6", children: ((searchKey && searchValue) || (metadataKey && metadataValue)) && (_jsx("div", { className: "md-lib-p-1 md-lib-border md-lib-rounded md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-cursor-pointer", children: _jsx(Tooltip, { title: "Clear filter", children: _jsx(ClearFilterIcon, { fill: get(theme, "variables.primaryColor"), onClick: () => {
|
|
133
|
+
onSearch({
|
|
134
|
+
searchKey: "",
|
|
135
|
+
searchValue: "",
|
|
136
|
+
metadataKey: "",
|
|
137
|
+
metadataValue: "",
|
|
138
|
+
});
|
|
139
|
+
}, className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-w-4 md-lib-h-4 " }) }) })) })), _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-min-w-[280px] md-lib-font-medium md-lib-text-textColor dark:md-lib-text-darkTextColor", children: ["Name", _jsxs("span", { className: "md-lib-cursor-pointer", onClick: () => setSortOrders(SortByKeys.NAME, sortOrder === SortOrders.ASCEND
|
|
140
|
+
? SortOrders.DESCEND
|
|
141
|
+
: SortOrders.ASCEND), children: [sortByKey === SortByKeys.NAME &&
|
|
142
|
+
(sortOrder === SortOrders.ASCEND ? (_jsx(ArrowUpOutlined, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-w-4 md-lib-h-4" })) : (_jsx(ArrowDownOutlined, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-w-4 md-lib-h-4" }))), sortByKey !== SortByKeys.NAME && (_jsx(FaSortIcon, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-w-4 md-lib-h-4" }))] }), _jsx(SearchFilter, { onSearch: onSearch, type: InputTypes.TEXT, name: "name", isMetadata: false, isSelected: searchKey === "name", searchValue: searchValue })] }), _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-min-w-[120px] md-lib-font-medium md-lib-text-textColor dark:md-lib-text-darkTextColor", children: ["Modified At", _jsxs("span", { className: "md-lib-cursor-pointer", onClick: () => setSortOrders(SortByKeys.UPDATED_AT, sortOrder === SortOrders.ASCEND
|
|
143
|
+
? SortOrders.DESCEND
|
|
144
|
+
: SortOrders.ASCEND), children: [sortByKey === SortByKeys.UPDATED_AT &&
|
|
145
|
+
(sortOrder === SortOrders.ASCEND ? (_jsx(ArrowUpOutlined, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-w-4 md-lib-h-4" })) : (_jsx(ArrowDownOutlined, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-w-4 md-lib-h-4" }))), sortByKey !== SortByKeys.UPDATED_AT && (_jsx(FaSortIcon, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-w-4 md-lib-h-4" }))] })] }), _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-font-medium md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-text-sm md-lib-w-[100px] ", children: ["File size", _jsxs("span", { className: "md-lib-cursor-pointer", onClick: () => setSortOrders(SortByKeys.SIZE, sortOrder === SortOrders.ASCEND
|
|
146
|
+
? SortOrders.DESCEND
|
|
147
|
+
: SortOrders.ASCEND), children: [sortByKey === SortByKeys.SIZE &&
|
|
148
|
+
(sortOrder === SortOrders.ASCEND ? (_jsx(ArrowUpOutlined, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-w-4 md-lib-h-4" })) : (_jsx(ArrowDownOutlined, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-w-4 md-lib-h-4" }))), sortByKey !== SortByKeys.SIZE && (_jsx(FaSortIcon, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-w-4 md-lib-h-4" }))] })] }), _jsxs("div", { className: "md-lib-font-medium md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-flex md-lib-items-center md-lib-gap-1 md-lib-text-sm md-lib-w-[100px] ", children: ["File type", _jsx(SearchFilter, { onSearch: onSearch, type: InputTypes.TEXT, name: "extensionType", isMetadata: false, isSelected: searchKey === "extensionType", searchValue: searchValue })] }), _jsxs("div", { className: "md-lib-font-medium md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-flex md-lib-items-center md-lib-gap-1 md-lib-text-sm md-lib-w-[120px] ", children: ["Asset Template", _jsx(SearchFilter, { onSearch: onSearch, type: InputTypes.TEXT, name: "assetName", isMetadata: false, isSelected: searchKey === "assetName", searchValue: searchValue })] }), metaFields.map((field) => {
|
|
149
|
+
return (_jsxs("div", { className: "md-lib-font-medium md-lib-block md-lib-truncate md-lib-text-textColor md-lib-gap-2 md-lib-flex md-lib-items-center md-lib-gap-1 dark:md-lib-text-darkTextColor md-lib-text-sm md-lib-w-[120px] ", children: [field.name, _jsx(SearchFilter, { onSearch: onSearch, type: field.defaultName, name: field._id, isMetadata: true, isSelected: metadataKey === field._id, searchValue: metadataValue })] }));
|
|
150
|
+
})] }), map(grouped, (folderGroup, dateLabel) => (_jsxs("div", { children: [_jsx("div", { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-font-semibold md-lib-text-sm md-lib-mb-2 md-lib-px-2", children: dateLabel }), _jsx("div", { children: map(folderGroup, (folder) => {
|
|
151
|
+
var _a;
|
|
152
|
+
const name = get(folder, "name", "N/A");
|
|
153
|
+
const updatedAt = get(folder, "updatedAt");
|
|
154
|
+
const id = get(folder, "_id");
|
|
155
|
+
const fileType = get(folder, "type");
|
|
156
|
+
const isSelected = (fileType === EntityType.FILE &&
|
|
157
|
+
includes(selectedFileIds, id)) ||
|
|
158
|
+
(fileType === EntityType.FOLDER &&
|
|
159
|
+
includes(selectedFolderIds, id)) ||
|
|
160
|
+
get(selectedPickerFile, "_id") === id;
|
|
161
|
+
const currentAsset = assets.find((asset) => asset._id === get(folder, "assetId"));
|
|
162
|
+
return (_jsxs("div", { onClick: () => handleClick(folder), className: `md-lib-flex md-lib-justify-between md-lib-gap-2 md-lib-items-center md-lib-min-w-fit md-lib-py-3 md-lib-px-2 md-lib-rounded-xl md-lib-cursor-pointer hover:md-lib-bg-borderColor dark:hover:md-lib-bg-darkSecondaryBg ${isSelected
|
|
163
|
+
? "md-lib-bg-borderColor dark:md-lib-bg-darkSecondaryBg"
|
|
164
|
+
: ""}`, children: [" ", !isImagePicker && type !== DriveModes.FOLDERS && (_jsx("div", { className: "md-lib-w-6", onClick: (e) => e.stopPropagation(), children: get(folder, "type") === EntityType.FILE ? (get(folder, "fileUploadStatus") ===
|
|
165
|
+
ThumbnailStatus.PENDING ? (_jsx(_Fragment, {})) : (_jsx(FileMenuOptions, { file: folder }))) : (_jsx(FolderMenuOptions, { folder: folder })) })), _jsx("div", { className: "md-lib-flex md-lib-items-center md-lib-justify-between md-lib-w-[280px] md-lib-text-[15px] md-lib-text-textColor dark:md-lib-text-darkTextColor", title: name, children: _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-overflow-hidden", children: [_jsx("div", { children: get(folder, "type") === EntityType.FILE ? (get(folder, "fileUploadStatus") ===
|
|
166
|
+
ThumbnailStatus.PENDING ? (
|
|
167
|
+
// <IconInprogress className="text-imagesColor text-[20px]" />
|
|
168
|
+
_jsx(Image, { src: UPLOAD_FILE_IN_PROGRESS_WHITE_IMAGE, width: 20, height: 20 })) : (_jsx(RenderThumbnail, { url: get(folder, "thumbnailUrl"), alt: get(folder, "name", "N/A") }))) : (getFileOrFolderIcon(get(folder, "type", EntityType.FOLDER), get(folder, "mimetype"))) }), _jsx("span", { className: "md-lib-truncate md-lib-w-[calc(100%-5px)]", title: name, children: name })] }) }), _jsx("div", { className: "md-lib-text-xs md-lib-text-secondaryTextColor md-lib-w-[120px] dark:md-lib-text-darkSecondaryTextColor md-lib-whitespace-nowrap md-lib-pl-4", children: updatedAt
|
|
169
|
+
? moment
|
|
170
|
+
.utc(updatedAt)
|
|
171
|
+
.tz(LOCAL_TIMEZONE)
|
|
172
|
+
.format(LIST_VIEW_DATE_FORMAT)
|
|
173
|
+
: "—" }), _jsx("div", { className: "md-lib-text-sm md-lib-text-secondaryTextColor dark:md-lib-text-darkSecondaryTextColor md-lib-w-[100px] ", children: get(folder, "type") === EntityType.FILE
|
|
174
|
+
? formatBytes(get(folder, "size", 0))
|
|
175
|
+
: "-" }), _jsx("div", { className: "md-lib-text-sm md-lib-text-secondaryTextColor dark:md-lib-text-darkSecondaryTextColor md-lib-w-[100px] ", children: ((_a = get(folder, "extensionType", "").split(".")) === null || _a === void 0 ? void 0 : _a[1]) || "-" }), _jsx("div", { className: "md-lib-text-sm md-lib-text-secondaryTextColor dark:md-lib-text-darkSecondaryTextColor md-lib-w-[120px]", title: get(folder, "type") === EntityType.FILE
|
|
176
|
+
? currentAsset === null || currentAsset === void 0 ? void 0 : currentAsset.name
|
|
177
|
+
: "-", children: get(folder, "type") === EntityType.FILE
|
|
178
|
+
? currentAsset === null || currentAsset === void 0 ? void 0 : currentAsset.name
|
|
179
|
+
: "-" }), metaFields.map((field) => {
|
|
180
|
+
const value = get(folder, `metadata.${field._id}`);
|
|
181
|
+
return (_jsx("div", { title: value || "-", className: "md-lib-text-secondaryTextColor dark:md-lib-text-darkTextColor md-lib-block md-lib-truncate md-lib-text-sm md-lib-w-[120px] md-lib-gap-2", children: value || "-" }));
|
|
182
|
+
})] }, get(folder, "_id", name)));
|
|
183
|
+
}) })] }, dateLabel))), _jsx(LoadMoreItems, { hasNextPage: hasNextPage, isItemsFetching: foldersFetching, fetchNextPage: fetchNextPage }), (!!get(selectedFileIds, "length") ||
|
|
184
|
+
!!get(selectedFolderIds, "length")) && (_jsx(ActionsBar, { fileIds: selectedFileIds, folderIds: selectedFolderIds, onCloseSelection: () => setSelectedItems({ fileIds: [], folderIds: [] }) })), showPreviewModal && (_jsx(FileDetails, { open: showPreviewModal, handleClose: () => {
|
|
185
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { showPreviewModal: false, selectedFile: {} })));
|
|
186
|
+
}, file: selectedFile }))] }));
|
|
187
|
+
};
|
|
188
|
+
export default FolderListView;
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Dropdown } from "antd";
|
|
3
|
+
import { BsThreeDotsVertical } from "react-icons/bs";
|
|
4
|
+
import { EditOutlined, DeleteOutlined, DownloadOutlined, UserAddOutlined, InfoCircleOutlined, } from "@ant-design/icons";
|
|
5
|
+
import { IoArchiveOutline, IoDuplicateOutline } from "react-icons/io5";
|
|
6
|
+
import { useMemo, useState } from "react";
|
|
7
|
+
import { DriveModes, NotificationStatus, } from "../utilities/constants/interface";
|
|
8
|
+
import { DeleteConfirmationModal } from "../common/CustomElements";
|
|
9
|
+
import { ADDED_TO_FAV_MSG, ARCHIVE_OK_TEXT, ARCHIVE_SUCCESS, DELETE_CONFIRMATION_MESSAGE, DELETE_MESSAGE_DESCRIPTION, DELETE_OK_TEXT, DELETE_SUCCESS, DUPLICATE_SUCCESS, INVALID_URL, REMOVED_FROM_FAV_MSG, RESTORE_SUCCESS, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
|
|
10
|
+
import { filter, get, includes } from "lodash";
|
|
11
|
+
import { useMutation, useQueryClient } from "react-query";
|
|
12
|
+
import { addToFavFolders, archiveFolders, deleteFolders, duplicateFolder, removeFromFavFolders, restoreFolders, unarchiveFolders, } from "../react-query/services/folder-services";
|
|
13
|
+
import { showNotification } from "../common/notifications";
|
|
14
|
+
import AddFolder from "./AddFolder";
|
|
15
|
+
import { updateFoldersCacheOnDeleteFolder } from "../react-query/hooks/folder-hooks";
|
|
16
|
+
import { generateFoldersQueryKey, invalidateData, } from "../utilities/constants/queryKeys";
|
|
17
|
+
import CustomLoader from "../common/loader/CustomLoader";
|
|
18
|
+
import { MdDriveFileMoveOutline, MdOutlineUnarchive } from "react-icons/md";
|
|
19
|
+
import { TbStar, TbStarOff } from "react-icons/tb";
|
|
20
|
+
import MoveToAnotherFolder from "./files/MoveToAnotherFolder";
|
|
21
|
+
import { AllowedFolderActions, FileActionsList, MyDriveFolderActions, } from "../hocs/appConstants";
|
|
22
|
+
import { downloadFiles } from "../react-query/services/file-services";
|
|
23
|
+
import InviteTeamModal from "../settings/InviteTeamModal";
|
|
24
|
+
import { FETCH_ENTITY_SCREEN } from "../utilities/constants/routes";
|
|
25
|
+
import ManageFile from "./fileDetails/ManageFile";
|
|
26
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
27
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
28
|
+
import useAppParams from "../utilities/useAppParams";
|
|
29
|
+
import FileDownloadHistory from "./FileDownloadHistory";
|
|
30
|
+
import { AiOutlineHistory } from "react-icons/ai";
|
|
31
|
+
const TbStarOffIcon = TbStarOff;
|
|
32
|
+
const MdOutlineUnarchiveIcon = MdOutlineUnarchive;
|
|
33
|
+
const TbStarIcon = TbStar;
|
|
34
|
+
const IoDuplicateOutlineIcon = IoDuplicateOutline;
|
|
35
|
+
const MdDriveFileMoveOutlineIcon = MdDriveFileMoveOutline;
|
|
36
|
+
const IoArchiveOutlineIcon = IoArchiveOutline;
|
|
37
|
+
const BsThreeDotsVerticalIcon = BsThreeDotsVertical;
|
|
38
|
+
const AiOutlineHistoryIcon = AiOutlineHistory;
|
|
39
|
+
function FolderMenuOptions({ folder }) {
|
|
40
|
+
const { folderId, type } = useAppParams();
|
|
41
|
+
const damConfig = useDamConfig();
|
|
42
|
+
const { rootFolderId, appType, isAdmin } = damConfig;
|
|
43
|
+
const queryClient = useQueryClient();
|
|
44
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
45
|
+
const [state, setState] = useState({
|
|
46
|
+
actionType: "",
|
|
47
|
+
showConfirmModal: false,
|
|
48
|
+
showUpdateModal: false,
|
|
49
|
+
showMoveFolder: false,
|
|
50
|
+
showShareModal: false,
|
|
51
|
+
showFileAccess: false,
|
|
52
|
+
showLogs: false,
|
|
53
|
+
});
|
|
54
|
+
const { showConfirmModal, actionType, showUpdateModal, showMoveFolder, showShareModal, showFileAccess, showLogs, } = state;
|
|
55
|
+
const toggleLogsModal = () => setState((prevState) => (Object.assign(Object.assign({}, prevState), { showLogs: !prevState.showLogs })));
|
|
56
|
+
const toggleFileAccess = () => {
|
|
57
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { showFileAccess: !prevState.showFileAccess })));
|
|
58
|
+
};
|
|
59
|
+
const link = useMemo(() => {
|
|
60
|
+
return (`${appType == "reactJs"
|
|
61
|
+
? process.env.REACT_APP_MIXDRIVE_SITE_URL
|
|
62
|
+
: process.env.NEXT_PUBLIC_MIXDRIVE_SITE_URL}` +
|
|
63
|
+
FETCH_ENTITY_SCREEN.replace(":type", DriveModes.FOLDERS).replace(":id", get(folder, "_id")));
|
|
64
|
+
}, [folder]);
|
|
65
|
+
const toggleShareModal = () => {
|
|
66
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { showShareModal: !prevState.showShareModal })));
|
|
67
|
+
};
|
|
68
|
+
const toggleShowMoveFolder = () => {
|
|
69
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { showMoveFolder: !prevState.showMoveFolder })));
|
|
70
|
+
};
|
|
71
|
+
const toggleConfirmPopup = (actionType = "") => {
|
|
72
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { actionType, showConfirmModal: !prevState.showConfirmModal })));
|
|
73
|
+
};
|
|
74
|
+
const toggleUpdateModal = () => {
|
|
75
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { showUpdateModal: !prevState.showUpdateModal })));
|
|
76
|
+
};
|
|
77
|
+
const onFailure = (message) => {
|
|
78
|
+
showNotification(message, NotificationStatus.ERROR);
|
|
79
|
+
};
|
|
80
|
+
const onDeleteSuccess = (message) => {
|
|
81
|
+
updateFoldersCacheOnDeleteFolder(queryClient, folderId ? folderId : rootFolderId, get(folder, "_id"), generateFoldersQueryKey(type));
|
|
82
|
+
showNotification(message, NotificationStatus.SUCCESS);
|
|
83
|
+
};
|
|
84
|
+
const deleteFolderMutation = useMutation({
|
|
85
|
+
mutationFn: deleteFolders,
|
|
86
|
+
onSuccess: (response) => {
|
|
87
|
+
toggleConfirmPopup();
|
|
88
|
+
onDeleteSuccess(get(response, "data.message", DELETE_SUCCESS));
|
|
89
|
+
},
|
|
90
|
+
onError: (error) => {
|
|
91
|
+
onFailure(get(error, "message", SOMETHING_WENT_WRONG));
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
const onDeleteFolder = () => {
|
|
95
|
+
deleteFolderMutation.mutate({
|
|
96
|
+
folderIds: [get(folder, "_id")],
|
|
97
|
+
api,
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
const archiveFolderMutation = useMutation({
|
|
101
|
+
mutationFn: archiveFolders,
|
|
102
|
+
onSuccess: (response) => {
|
|
103
|
+
toggleConfirmPopup();
|
|
104
|
+
onDeleteSuccess(get(response, "data.message", ARCHIVE_SUCCESS));
|
|
105
|
+
},
|
|
106
|
+
onError: (error) => {
|
|
107
|
+
onFailure(get(error, "message", SOMETHING_WENT_WRONG));
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
const onArchiveFolder = () => {
|
|
111
|
+
archiveFolderMutation.mutate({
|
|
112
|
+
folderIds: [get(folder, "_id")],
|
|
113
|
+
api,
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
const duplicateFolderMutation = useMutation({
|
|
117
|
+
mutationFn: duplicateFolder,
|
|
118
|
+
onSuccess: (response) => {
|
|
119
|
+
invalidateData(queryClient, generateFoldersQueryKey(type), folderId ? folderId : rootFolderId);
|
|
120
|
+
showNotification(get(response, "data.message", DUPLICATE_SUCCESS), NotificationStatus.SUCCESS);
|
|
121
|
+
},
|
|
122
|
+
onError: (error) => {
|
|
123
|
+
onFailure(get(error, "message", SOMETHING_WENT_WRONG));
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
const onDuplicateFolder = () => {
|
|
127
|
+
duplicateFolderMutation.mutate({
|
|
128
|
+
folderId: get(folder, "_id"),
|
|
129
|
+
api,
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
const restoreFolderMutation = useMutation({
|
|
133
|
+
mutationFn: restoreFolders,
|
|
134
|
+
onSuccess: (response) => {
|
|
135
|
+
onDeleteSuccess(get(response, "data.message", RESTORE_SUCCESS));
|
|
136
|
+
},
|
|
137
|
+
onError: (error) => {
|
|
138
|
+
onFailure(get(error, "message", SOMETHING_WENT_WRONG));
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
const onRestoreFolder = () => {
|
|
142
|
+
restoreFolderMutation.mutate({
|
|
143
|
+
folderIds: [get(folder, "_id")],
|
|
144
|
+
api,
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
const unarchiveFolderMutation = useMutation({
|
|
148
|
+
mutationFn: unarchiveFolders,
|
|
149
|
+
onSuccess: (response) => {
|
|
150
|
+
onDeleteSuccess(get(response, "data.message", RESTORE_SUCCESS));
|
|
151
|
+
},
|
|
152
|
+
onError: (error) => {
|
|
153
|
+
onFailure(get(error, "message", SOMETHING_WENT_WRONG));
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
const onUnArchiveFolder = () => {
|
|
157
|
+
unarchiveFolderMutation.mutate({
|
|
158
|
+
folderIds: [get(folder, "_id")],
|
|
159
|
+
api,
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
const onFavSuccess = (message) => {
|
|
163
|
+
invalidateData(queryClient, generateFoldersQueryKey(type), folderId ? folderId : rootFolderId);
|
|
164
|
+
showNotification(message, NotificationStatus.SUCCESS);
|
|
165
|
+
};
|
|
166
|
+
const favouriteFolderMutation = useMutation({
|
|
167
|
+
mutationFn: addToFavFolders,
|
|
168
|
+
onSuccess: (response) => {
|
|
169
|
+
onFavSuccess(get(response, "data.message", ADDED_TO_FAV_MSG));
|
|
170
|
+
},
|
|
171
|
+
onError: (error) => {
|
|
172
|
+
onFailure(get(error, "message", SOMETHING_WENT_WRONG));
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
const onFavouriteFolder = () => {
|
|
176
|
+
favouriteFolderMutation.mutate({
|
|
177
|
+
payload: {
|
|
178
|
+
folderIds: [get(folder, "_id")],
|
|
179
|
+
fileIds: [],
|
|
180
|
+
},
|
|
181
|
+
api,
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
const removeFavFolderMutation = useMutation({
|
|
185
|
+
mutationFn: removeFromFavFolders,
|
|
186
|
+
onSuccess: (response) => {
|
|
187
|
+
onFavSuccess(get(response, "data.message", REMOVED_FROM_FAV_MSG));
|
|
188
|
+
},
|
|
189
|
+
onError: (error) => {
|
|
190
|
+
onFailure(get(error, "message", SOMETHING_WENT_WRONG));
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
const onUnStarFolder = () => {
|
|
194
|
+
removeFavFolderMutation.mutate({
|
|
195
|
+
payload: {
|
|
196
|
+
folderIds: [get(folder, "_id")],
|
|
197
|
+
fileIds: [],
|
|
198
|
+
},
|
|
199
|
+
api,
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
const downloadFolderMutation = useMutation({
|
|
203
|
+
mutationFn: downloadFiles,
|
|
204
|
+
onSuccess: (response) => {
|
|
205
|
+
const url = get(response, "data");
|
|
206
|
+
if (url) {
|
|
207
|
+
window.open(url, "_blank");
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
onFailure(INVALID_URL);
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
onError: (error) => {
|
|
214
|
+
onFailure(get(error, "message", SOMETHING_WENT_WRONG));
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
const onDownloadFile = () => {
|
|
218
|
+
downloadFolderMutation.mutate({
|
|
219
|
+
folderIds: [get(folder, "_id")],
|
|
220
|
+
fileIds: [],
|
|
221
|
+
api,
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
const favItems = [
|
|
225
|
+
{
|
|
226
|
+
key: FileActionsList.UNSTAR,
|
|
227
|
+
label: "Unstar",
|
|
228
|
+
icon: removeFavFolderMutation.isLoading ? (_jsx(CustomLoader, {})) : (_jsx(TbStarOffIcon, {})),
|
|
229
|
+
onClick: () => onUnStarFolder(),
|
|
230
|
+
},
|
|
231
|
+
];
|
|
232
|
+
const archiveItems = [
|
|
233
|
+
{
|
|
234
|
+
key: FileActionsList.UNARCHIVE,
|
|
235
|
+
label: "Unarchive",
|
|
236
|
+
icon: unarchiveFolderMutation.isLoading ? (_jsx(CustomLoader, {})) : (_jsx(MdOutlineUnarchiveIcon, {})),
|
|
237
|
+
onClick: () => onUnArchiveFolder(),
|
|
238
|
+
},
|
|
239
|
+
];
|
|
240
|
+
const editableItems = isAdmin
|
|
241
|
+
? [
|
|
242
|
+
{
|
|
243
|
+
key: FileActionsList.RENAME,
|
|
244
|
+
label: "Edit",
|
|
245
|
+
icon: _jsx(EditOutlined, {}),
|
|
246
|
+
onClick: () => toggleUpdateModal(),
|
|
247
|
+
},
|
|
248
|
+
// {
|
|
249
|
+
// key: FileActionsList.COPY,
|
|
250
|
+
// label: "Copy",
|
|
251
|
+
// icon: <LinkOutlined />,
|
|
252
|
+
// onClick: () => handleCopy(link!),
|
|
253
|
+
// },
|
|
254
|
+
{
|
|
255
|
+
key: FileActionsList.SHARE,
|
|
256
|
+
label: "Share",
|
|
257
|
+
icon: _jsx(UserAddOutlined, {}),
|
|
258
|
+
onClick: toggleShareModal,
|
|
259
|
+
},
|
|
260
|
+
]
|
|
261
|
+
: [];
|
|
262
|
+
const duplicateItems = isAdmin
|
|
263
|
+
? [
|
|
264
|
+
// {
|
|
265
|
+
// key: FileActionsList.DUPLICATE,
|
|
266
|
+
// label: "Duplicate",
|
|
267
|
+
// icon: duplicateFolderMutation.isLoading ? (
|
|
268
|
+
// <CustomLoader />
|
|
269
|
+
// ) : (
|
|
270
|
+
// <IoDuplicateOutlineIcon />
|
|
271
|
+
// ),
|
|
272
|
+
// onClick: () => onDuplicateFolder(),
|
|
273
|
+
// },
|
|
274
|
+
{
|
|
275
|
+
key: FileActionsList.DELETE,
|
|
276
|
+
label: "Delete",
|
|
277
|
+
icon: _jsx(DeleteOutlined, {}),
|
|
278
|
+
onClick: () => toggleConfirmPopup("delete"),
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
key: FileActionsList.SHOW_DOWNLOADS,
|
|
282
|
+
label: "Download history",
|
|
283
|
+
icon: _jsx(AiOutlineHistoryIcon, {}),
|
|
284
|
+
onClick: toggleLogsModal,
|
|
285
|
+
},
|
|
286
|
+
]
|
|
287
|
+
: [];
|
|
288
|
+
const items = [
|
|
289
|
+
...editableItems,
|
|
290
|
+
// ...(get(folder, "isFavourite") || type === DriveModes.STARRED
|
|
291
|
+
// ? favItems
|
|
292
|
+
// : [
|
|
293
|
+
// {
|
|
294
|
+
// key: FileActionsList.STAR,
|
|
295
|
+
// label: "Add to starred",
|
|
296
|
+
// icon: favouriteFolderMutation.isLoading ? (
|
|
297
|
+
// <CustomLoader />
|
|
298
|
+
// ) : (
|
|
299
|
+
// <TbStarIcon />
|
|
300
|
+
// ),
|
|
301
|
+
// onClick: () => onFavouriteFolder(),
|
|
302
|
+
// },
|
|
303
|
+
// ]),
|
|
304
|
+
{
|
|
305
|
+
key: FileActionsList.DOWNLOAD,
|
|
306
|
+
label: "Download",
|
|
307
|
+
icon: downloadFolderMutation.isLoading ? (_jsx(CustomLoader, {})) : (_jsx(DownloadOutlined, {})),
|
|
308
|
+
onClick: onDownloadFile,
|
|
309
|
+
},
|
|
310
|
+
...duplicateItems,
|
|
311
|
+
// {
|
|
312
|
+
// key: FileActionsList.MOVE,
|
|
313
|
+
// label: "Move",
|
|
314
|
+
// icon: <MdDriveFileMoveOutlineIcon />,
|
|
315
|
+
// onClick: () => toggleShowMoveFolder(),
|
|
316
|
+
// },
|
|
317
|
+
// ...(get(folder, "isFavourite") || type === DriveModes.ARCHIVES
|
|
318
|
+
// ? archiveItems
|
|
319
|
+
// : [
|
|
320
|
+
// {
|
|
321
|
+
// key: FileActionsList.ARCHIVE,
|
|
322
|
+
// label: "Archive",
|
|
323
|
+
// icon: <IoArchiveOutlineIcon />,
|
|
324
|
+
// onClick: () => toggleConfirmPopup("archive"),
|
|
325
|
+
// },
|
|
326
|
+
// ]),
|
|
327
|
+
{
|
|
328
|
+
key: FileActionsList.FILE_INFO,
|
|
329
|
+
label: "File information",
|
|
330
|
+
icon: _jsx(InfoCircleOutlined, {}),
|
|
331
|
+
onClick: toggleFileAccess,
|
|
332
|
+
},
|
|
333
|
+
// {
|
|
334
|
+
// key: FileActionsList.RESTORE,
|
|
335
|
+
// label: "Restore",
|
|
336
|
+
// icon: restoreFolderMutation.isLoading ? (
|
|
337
|
+
// <CustomLoader />
|
|
338
|
+
// ) : (
|
|
339
|
+
// <RedoOutlined />
|
|
340
|
+
// ),
|
|
341
|
+
// onClick: () => onRestoreFolder(),
|
|
342
|
+
// },
|
|
343
|
+
];
|
|
344
|
+
const filterActions = (menuItems, allowedActions = MyDriveFolderActions) => filter(menuItems, (item) => includes(allowedActions, item === null || item === void 0 ? void 0 : item.key));
|
|
345
|
+
const currentMenuItems = useMemo(() => {
|
|
346
|
+
return filterActions(items, get(AllowedFolderActions, type));
|
|
347
|
+
}, [type, items]);
|
|
348
|
+
return (_jsxs(_Fragment, { children: [_jsx(Dropdown, { menu: { items: currentMenuItems }, trigger: ["click"], children: _jsx(BsThreeDotsVerticalIcon, { size: 20, className: "md-lib-cursor-pointer", onClick: (e) => e.stopPropagation() }) }), _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", get(folder, "name", "this folder")), subHeading: actionType === "archive" ? "" : DELETE_MESSAGE_DESCRIPTION, onOk: actionType === "archive" ? onArchiveFolder : onDeleteFolder, loading: deleteFolderMutation.isLoading || archiveFolderMutation.isLoading }), _jsx(AddFolder, { open: showUpdateModal, handleCancel: toggleUpdateModal, folder: folder }), showMoveFolder && (_jsx(MoveToAnotherFolder, { open: showMoveFolder, handleCancel: toggleShowMoveFolder, folderIds: [get(folder, "_id")], entity: folder })), showShareModal && (_jsx(InviteTeamModal, { open: showShareModal, onClose: toggleShareModal, onFetchInvitations: () => { }, shareModal: true, fileIds: [], folderIds: [get(folder, "_id")], inviteType: DriveModes.FOLDERS, file: folder })), showFileAccess && folder && (_jsx(ManageFile, { open: showFileAccess, onClose: toggleFileAccess, file: folder })), showLogs && (_jsx(FileDownloadHistory, { file: folder, open: showLogs, onClose: toggleLogsModal }))] }));
|
|
349
|
+
}
|
|
350
|
+
export default FolderMenuOptions;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type FolderTypes = {
|
|
2
|
+
_id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
hasSubFolders?: boolean;
|
|
5
|
+
children?: FolderTypes[] | FolderTypes;
|
|
6
|
+
};
|
|
7
|
+
declare function FolderTree({ currentRootId, expandedKeys, selectedKeys, handleExpand, setSelectedKeys, folders, setFolders, setExpandedKeys, setGlobalSearch, globalSearch, }: any): JSX.Element;
|
|
8
|
+
export default FolderTree;
|