@bindu-dashing/dam-solution-v2 5.8.100 → 5.8.102
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/build/MyDrive/ActionBar.d.ts +3 -1
- package/build/MyDrive/ActionBar.js +14 -3
- package/build/MyDrive/FileMenuOptions.js +20 -7
- package/build/MyDrive/FolderGridView.js +2 -1
- package/build/MyDrive/FolderListView.js +2 -1
- package/build/MyDrive/fileDetails/FileDetails.js +0 -1
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { FileEntity, FolderEntity } from "../utilities/constants/interface";
|
|
2
|
+
declare const ActionsBar: ({ fileIds, folderIds, onCloseSelection, selectedFilesData, }: {
|
|
2
3
|
fileIds: string[];
|
|
3
4
|
folderIds: string[];
|
|
4
5
|
onCloseSelection: () => void;
|
|
6
|
+
selectedFilesData?: (FileEntity | FolderEntity)[];
|
|
5
7
|
}) => JSX.Element;
|
|
6
8
|
export default ActionsBar;
|
|
@@ -27,7 +27,7 @@ const IoLinkOutlineIcon = IoLinkOutline;
|
|
|
27
27
|
const FiTrash2Icon = FiTrash2;
|
|
28
28
|
const FiXIcon = FiX;
|
|
29
29
|
const IoArchiveOutlineIcon = IoArchiveOutline;
|
|
30
|
-
const ActionsBar = ({ fileIds, folderIds, onCloseSelection, }) => {
|
|
30
|
+
const ActionsBar = ({ fileIds, folderIds, onCloseSelection, selectedFilesData = [], }) => {
|
|
31
31
|
const { appType } = useDamConfig();
|
|
32
32
|
const { folderId, type } = useAppParams();
|
|
33
33
|
const queryClient = useQueryClient();
|
|
@@ -45,22 +45,33 @@ const ActionsBar = ({ fileIds, folderIds, onCloseSelection, }) => {
|
|
|
45
45
|
setState((prevState) => (Object.assign(Object.assign({}, prevState), { showShareModal: !prevState.showShareModal })));
|
|
46
46
|
};
|
|
47
47
|
const folders = getFolderData(queryClient, folderId ? folderId : rootFolderId, generateFoldersQueryKey(type));
|
|
48
|
+
// Use selectedFilesData if provided, otherwise fall back to cache lookup
|
|
48
49
|
const selectedFolder = useMemo(() => {
|
|
49
50
|
if (get(folderIds, "length") === 1) {
|
|
51
|
+
// First try from selectedFilesData
|
|
52
|
+
const fromData = find(selectedFilesData, (item) => get(item, "_id") === first(folderIds));
|
|
53
|
+
if (fromData)
|
|
54
|
+
return fromData;
|
|
55
|
+
// Fall back to cache lookup
|
|
50
56
|
return find(folders, (folder) => get(folder, "_id") === first(folderIds));
|
|
51
57
|
}
|
|
52
58
|
else {
|
|
53
59
|
return null;
|
|
54
60
|
}
|
|
55
|
-
}, [folderIds, folders]);
|
|
61
|
+
}, [folderIds, folders, selectedFilesData]);
|
|
56
62
|
const selectedFile = useMemo(() => {
|
|
57
63
|
if (get(fileIds, "length") === 1) {
|
|
64
|
+
// First try from selectedFilesData
|
|
65
|
+
const fromData = find(selectedFilesData, (item) => get(item, "_id") === first(fileIds));
|
|
66
|
+
if (fromData)
|
|
67
|
+
return fromData;
|
|
68
|
+
// Fall back to cache lookup
|
|
58
69
|
return find(folders, (folder) => get(folder, "_id") === first(fileIds));
|
|
59
70
|
}
|
|
60
71
|
else {
|
|
61
72
|
return null;
|
|
62
73
|
}
|
|
63
|
-
}, [fileIds, folders]);
|
|
74
|
+
}, [fileIds, folders, selectedFilesData]);
|
|
64
75
|
const toggleConfirmPopup = (actionType = "") => {
|
|
65
76
|
setState((prevState) => (Object.assign(Object.assign({}, prevState), { actionType, showConfirmModal: !prevState.showConfirmModal })));
|
|
66
77
|
};
|
|
@@ -12,7 +12,7 @@ import CustomLoader from "../common/loader/CustomLoader";
|
|
|
12
12
|
import { DownloadOutlined, } from "@ant-design/icons";
|
|
13
13
|
import AddFolder from "./AddFolder";
|
|
14
14
|
import { useMutation, useQueryClient } from "react-query";
|
|
15
|
-
import { archiveFiles, deleteFiles, downloadFiles, duplicateFiles, restoreFiles, unarchiveFiles, } from "../react-query/services/file-services";
|
|
15
|
+
import { archiveFiles, deleteFiles, downloadFiles, duplicateFiles, restoreFiles, unarchiveFiles, useFile, } from "../react-query/services/file-services";
|
|
16
16
|
import { ADDED_TO_FAV_MSG, ARCHIVE_OK_TEXT, ARCHIVE_SUCCESS, CREATE_SUCCESS, DELETE_CONFIRMATION_MESSAGE, DELETE_MESSAGE_DESCRIPTION, DELETE_OK_TEXT, DELETE_SUCCESS, INVALID_URL, REMOVED_FROM_FAV_MSG, RESTORE_SUCCESS, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
|
|
17
17
|
import { getSelectedFiles, } from "../react-query/hooks/folder-hooks";
|
|
18
18
|
import { generateFoldersQueryKey, invalidateData, QueryKeys, } from "../utilities/constants/queryKeys";
|
|
@@ -39,13 +39,25 @@ const TbStarIcon = TbStar;
|
|
|
39
39
|
const BsThreeDotsVerticalIcon = BsThreeDotsVertical;
|
|
40
40
|
const AiOutlineHistoryIcon = AiOutlineHistory;
|
|
41
41
|
function FileMenuOptions({ file, folderIds = [], fileIds = [], folder, onCloseSelection, readOnly = false, fileModal = false, }) {
|
|
42
|
-
// Debug: log props to trace where file becomes undefined
|
|
43
|
-
console.log("## FileMenuOptions render - file:", file, "fileIds:", fileIds, "folderIds:", folderIds);
|
|
44
42
|
const damConfig = useDamConfig();
|
|
45
43
|
const { rootFolderId, appType, isAdmin } = damConfig;
|
|
46
44
|
const { folderId, type } = useAppParams();
|
|
47
45
|
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
48
46
|
const queryClient = useQueryClient();
|
|
47
|
+
// Fetch file data from API if file is null but we have a single fileId (no folders)
|
|
48
|
+
const singleFileId = useMemo(() => {
|
|
49
|
+
if (file)
|
|
50
|
+
return ""; // Already have file data, no need to fetch
|
|
51
|
+
if (get(fileIds, "length") === 1 && get(folderIds, "length") === 0) {
|
|
52
|
+
return first(fileIds) || "";
|
|
53
|
+
}
|
|
54
|
+
return "";
|
|
55
|
+
}, [file, fileIds, folderIds]);
|
|
56
|
+
const { data: fetchedFileData } = useFile(api, singleFileId);
|
|
57
|
+
// Use fetched file data if file prop is null
|
|
58
|
+
const effectiveFile = useMemo(() => {
|
|
59
|
+
return file || fetchedFileData || null;
|
|
60
|
+
}, [file, fetchedFileData]);
|
|
49
61
|
const isBulkAction = useMemo(() => !!get(folderIds, "length", 0) || !!get(fileIds, "length", 0), [folderIds, fileIds]);
|
|
50
62
|
const isMultiSelection = useMemo(() => get(folderIds, "length", 0) + get(fileIds, "length", 0) > DEFAULT_PAGE, [folderIds, fileIds]);
|
|
51
63
|
const [state, setState] = useState({
|
|
@@ -196,12 +208,13 @@ function FileMenuOptions({ file, folderIds = [], fileIds = [], folder, onCloseSe
|
|
|
196
208
|
},
|
|
197
209
|
});
|
|
198
210
|
const onDownloadFile = () => {
|
|
199
|
-
//
|
|
211
|
+
// Use effectiveFile which includes fetched data from API
|
|
212
|
+
const fileToUse = effectiveFile;
|
|
200
213
|
// Build fileIds list - use file._id if file exists, otherwise use fileIds prop
|
|
201
|
-
const fileIdsList =
|
|
202
|
-
const downloadUrl = get(
|
|
214
|
+
const fileIdsList = fileToUse && get(fileToUse, "_id") ? [get(fileToUse, "_id")] : fileIds;
|
|
215
|
+
const downloadUrl = get(fileToUse, "downloadUrl") || get(fileToUse, "s3Url") || get(fileToUse, "thumbnailUrl");
|
|
203
216
|
const isSingleFile = get(fileIdsList, "length", 0) === 1 && get(folderIds, "length", 0) === 0;
|
|
204
|
-
console.log("## onDownloadFile -
|
|
217
|
+
console.log("## onDownloadFile - effectiveFile:", fileToUse, "downloadUrl:", downloadUrl, "isSingleFile:", isSingleFile);
|
|
205
218
|
// If single file with downloadUrl available, open directly in new tab
|
|
206
219
|
if (isSingleFile && downloadUrl) {
|
|
207
220
|
window.open(downloadUrl, "_blank");
|
|
@@ -98,7 +98,8 @@ const FolderGridView = ({ folders, foldersFetching, hasNextPage, fetchNextPage,
|
|
|
98
98
|
get(selectedPickerFile, "_id") === get(folder, "_id");
|
|
99
99
|
return (_jsxs("div", { className: `md-lib-border md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-rounded-lg md-lib-px-5 md-lib-h-16 md-lib-flex md-lib-items-center md-lib-justify-between md-lib-cursor-pointer ${isSelected ? "md-lib-bg-borderColor dark:md-lib-bg-darkSecondaryBg" : ""}`, onClick: () => handleClick(folder), children: [_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-w-[calc(100%-20px)]", children: [_jsxs("div", { children: [" ", _jsx(FaFolderIcon, { className: "md-lib-text-primaryColor", size: 32 })] }), _jsx("p", { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-truncate", title: get(folder, "name", "N/A"), children: get(folder, "name") })] }), !isImagePicker && type !== DriveModes.FOLDERS && (_jsx("div", { onClick: (e) => e.stopPropagation(), children: _jsx(FolderMenuOptions, { folder: folder }) }))] }, get(folder, "_id")));
|
|
100
100
|
}) }), _jsx(FilesGridView, { files: files, handleClick: handleClick, selectedFileIds: selectedFileIds, isImagePicker: isImagePicker, selectedPickerFile: selectedPickerFile }), _jsx(LoadMoreItems, { hasNextPage: hasNextPage, isItemsFetching: foldersFetching, fetchNextPage: fetchNextPage }), (!!get(selectedFileIds, "length") ||
|
|
101
|
-
!!get(selectedFolderIds, "length")) && (_jsx(ActionsBar, { fileIds: selectedFileIds, folderIds: selectedFolderIds, onCloseSelection: () => setSelectedItems({ fileIds: [], folderIds: [] })
|
|
101
|
+
!!get(selectedFolderIds, "length")) && (_jsx(ActionsBar, { fileIds: selectedFileIds, folderIds: selectedFolderIds, onCloseSelection: () => setSelectedItems({ fileIds: [], folderIds: [] }), selectedFilesData: filter([...folders, ...files], (item) => includes(selectedFileIds, get(item, "_id")) ||
|
|
102
|
+
includes(selectedFolderIds, get(item, "_id"))) })), showPreviewModal && (_jsx(FileDetails, { open: showPreviewModal, handleClose: () => {
|
|
102
103
|
setState((prevState) => (Object.assign(Object.assign({}, prevState), { showPreviewModal: false, selectedFile: {} })));
|
|
103
104
|
}, file: selectedFile }))] }));
|
|
104
105
|
};
|
|
@@ -197,7 +197,8 @@ const FolderListView = ({ folders, foldersFetching, hasNextPage, fetchNextPage,
|
|
|
197
197
|
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 || "-" }));
|
|
198
198
|
})] }, get(folder, "_id", name)));
|
|
199
199
|
}) })] }, dateLabel))), _jsx(LoadMoreItems, { hasNextPage: hasNextPage, isItemsFetching: foldersFetching, fetchNextPage: fetchNextPage }), (!!get(selectedFileIds, "length") ||
|
|
200
|
-
!!get(selectedFolderIds, "length")) && (_jsx(ActionsBar, { fileIds: selectedFileIds, folderIds: selectedFolderIds, onCloseSelection: () => setSelectedItems({ fileIds: [], folderIds: [] })
|
|
200
|
+
!!get(selectedFolderIds, "length")) && (_jsx(ActionsBar, { fileIds: selectedFileIds, folderIds: selectedFolderIds, onCloseSelection: () => setSelectedItems({ fileIds: [], folderIds: [] }), selectedFilesData: filter(sortedFolders, (item) => includes(selectedFileIds, get(item, "_id")) ||
|
|
201
|
+
includes(selectedFolderIds, get(item, "_id"))) })), showPreviewModal && (_jsx(FileDetails, { open: showPreviewModal, handleClose: () => {
|
|
201
202
|
setState((prevState) => (Object.assign(Object.assign({}, prevState), { showPreviewModal: false, selectedFile: {} })));
|
|
202
203
|
}, file: selectedFile }))] }));
|
|
203
204
|
};
|
|
@@ -59,7 +59,6 @@ const FileDetails = ({ open, handleClose, file, files, fileIds, onCloseSelection
|
|
|
59
59
|
prevFileId.current = currentFileId;
|
|
60
60
|
}, [currentFileId]);
|
|
61
61
|
const currentFile = useMemo(() => {
|
|
62
|
-
console.log("## currentFile calc - file:", file, "initialFile:", initialFile, "fileData:", fileData, "isFetching:", isFetching, "id:", id, "currentIndex:", currentIndex);
|
|
63
62
|
// Priority: fileData (from API) > file prop > files array item > initialFile
|
|
64
63
|
if (fileData) {
|
|
65
64
|
return fileData;
|