@bindu-dashing/dam-solution-v2 5.8.101 → 5.8.103
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.
|
@@ -6,7 +6,7 @@ import { IoArchiveOutline, IoLinkOutline } from "react-icons/io5";
|
|
|
6
6
|
import { concat, find, first, get, join, map } from "lodash";
|
|
7
7
|
import MoveToAnotherFolder from "./files/MoveToAnotherFolder";
|
|
8
8
|
import { useMutation, useQueryClient } from "react-query";
|
|
9
|
-
import { deleteFiles, downloadFiles, restoreFiles, } from "../react-query/services/file-services";
|
|
9
|
+
import { deleteFiles, downloadFiles, restoreFiles, useFile, } from "../react-query/services/file-services";
|
|
10
10
|
import { DeleteConfirmationModal } from "../common/CustomElements";
|
|
11
11
|
import { DeleteOutlined, RedoOutlined } from "@ant-design/icons";
|
|
12
12
|
import { generateFoldersQueryKey, invalidateData, } from "../utilities/constants/queryKeys";
|
|
@@ -72,6 +72,20 @@ const ActionsBar = ({ fileIds, folderIds, onCloseSelection, selectedFilesData =
|
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
74
|
}, [fileIds, folders, selectedFilesData]);
|
|
75
|
+
// Fetch file data from API if selectedFile is null but we have a single fileId
|
|
76
|
+
const singleFileId = useMemo(() => {
|
|
77
|
+
if (selectedFile)
|
|
78
|
+
return ""; // Already have file data
|
|
79
|
+
if (get(fileIds, "length") === 1) {
|
|
80
|
+
return first(fileIds) || "";
|
|
81
|
+
}
|
|
82
|
+
return "";
|
|
83
|
+
}, [selectedFile, fileIds, folderIds]);
|
|
84
|
+
const { data: fetchedFileData } = useFile(api, singleFileId);
|
|
85
|
+
// Use fetched file data if selectedFile is null
|
|
86
|
+
const effectiveFile = useMemo(() => {
|
|
87
|
+
return selectedFile || fetchedFileData || null;
|
|
88
|
+
}, [selectedFile, fetchedFileData]);
|
|
75
89
|
const toggleConfirmPopup = (actionType = "") => {
|
|
76
90
|
setState((prevState) => (Object.assign(Object.assign({}, prevState), { actionType, showConfirmModal: !prevState.showConfirmModal })));
|
|
77
91
|
};
|
|
@@ -137,11 +151,21 @@ const ActionsBar = ({ fileIds, folderIds, onCloseSelection, selectedFilesData =
|
|
|
137
151
|
},
|
|
138
152
|
});
|
|
139
153
|
const onDownloadFiles = () => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
154
|
+
const downloadUrl = get(effectiveFile, "downloadUrl") || get(effectiveFile, "s3Url") || get(effectiveFile, "thumbnailUrl");
|
|
155
|
+
const isSingleFile = get(fileIds, "length") === 1 && get(folderIds, "length") === 0;
|
|
156
|
+
// If single file with downloadUrl available, open directly in new tab
|
|
157
|
+
if (isSingleFile && downloadUrl) {
|
|
158
|
+
window.open(downloadUrl, "_blank");
|
|
159
|
+
onCloseSelection();
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
// For multiple files/folders or when downloadUrl is not available, use API
|
|
163
|
+
downloadFileMutation.mutate({
|
|
164
|
+
fileIds,
|
|
165
|
+
folderIds,
|
|
166
|
+
api,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
145
169
|
};
|
|
146
170
|
const fileLinks = useMemo(() => {
|
|
147
171
|
return map(fileIds, (id) => `${appType == "reactJs"
|
|
@@ -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";
|
|
@@ -44,6 +44,20 @@ function FileMenuOptions({ file, folderIds = [], fileIds = [], folder, onCloseSe
|
|
|
44
44
|
const { folderId, type } = useAppParams();
|
|
45
45
|
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
46
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]);
|
|
47
61
|
const isBulkAction = useMemo(() => !!get(folderIds, "length", 0) || !!get(fileIds, "length", 0), [folderIds, fileIds]);
|
|
48
62
|
const isMultiSelection = useMemo(() => get(folderIds, "length", 0) + get(fileIds, "length", 0) > DEFAULT_PAGE, [folderIds, fileIds]);
|
|
49
63
|
const [state, setState] = useState({
|
|
@@ -194,10 +208,11 @@ function FileMenuOptions({ file, folderIds = [], fileIds = [], folder, onCloseSe
|
|
|
194
208
|
},
|
|
195
209
|
});
|
|
196
210
|
const onDownloadFile = () => {
|
|
197
|
-
//
|
|
211
|
+
// Use effectiveFile which includes fetched data from API
|
|
212
|
+
const fileToUse = effectiveFile;
|
|
198
213
|
// Build fileIds list - use file._id if file exists, otherwise use fileIds prop
|
|
199
|
-
const fileIdsList =
|
|
200
|
-
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");
|
|
201
216
|
const isSingleFile = get(fileIdsList, "length", 0) === 1 && get(folderIds, "length", 0) === 0;
|
|
202
217
|
// If single file with downloadUrl available, open directly in new tab
|
|
203
218
|
if (isSingleFile && downloadUrl) {
|
|
@@ -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;
|