@bindu-dashing/dam-solution-v2 5.8.99 → 5.8.101

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.
@@ -1,6 +1,8 @@
1
- declare const ActionsBar: ({ fileIds, folderIds, onCloseSelection, }: {
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
  };
@@ -194,8 +194,11 @@ function FileMenuOptions({ file, folderIds = [], fileIds = [], folder, onCloseSe
194
194
  },
195
195
  });
196
196
  const onDownloadFile = () => {
197
- const downloadUrl = get(file, "thumbnailUrl") || get(file, "downloadUrl");
198
- const isSingleFile = file && get(fileIds, "length", 0) <= 1;
197
+ // Debug logging
198
+ // Build fileIds list - use file._id if file exists, otherwise use fileIds prop
199
+ const fileIdsList = file && get(file, "_id") ? [get(file, "_id")] : fileIds;
200
+ const downloadUrl = get(file, "downloadUrl") || get(file, "s3Url") || get(file, "thumbnailUrl");
201
+ const isSingleFile = get(fileIdsList, "length", 0) === 1 && get(folderIds, "length", 0) === 0;
199
202
  // If single file with downloadUrl available, open directly in new tab
200
203
  if (isSingleFile && downloadUrl) {
201
204
  window.open(downloadUrl, "_blank");
@@ -203,7 +206,7 @@ function FileMenuOptions({ file, folderIds = [], fileIds = [], folder, onCloseSe
203
206
  else {
204
207
  // For multiple files/folders or when downloadUrl is not available, use API
205
208
  downloadFileMutation.mutate({
206
- fileIds: file ? [get(file, "_id")] : fileIds,
209
+ fileIds: fileIdsList,
207
210
  folderIds: folderIds,
208
211
  api,
209
212
  });
@@ -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: [] }) })), showPreviewModal && (_jsx(FileDetails, { open: showPreviewModal, handleClose: () => {
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: [] }) })), showPreviewModal && (_jsx(FileDetails, { open: showPreviewModal, handleClose: () => {
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
  };
@@ -15,10 +15,12 @@ const FileDetailsHeader = ({ handleClose, file, onCloseSelection, }) => {
15
15
  const damConfig = useDamConfig();
16
16
  const { isAdmin } = damConfig;
17
17
  const { id, type } = useAppParams();
18
- return (_jsxs("div", { className: "md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor md-lib-py-3 md-lib-px-5 md-lib-border-b md-lib-border-borderColor dark:md-lib-border-darkBorderColor 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: [!id && type !== DriveModes.FILE && (_jsx(IoIosCloseIcon, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-cursor-pointer", size: 24, onClick: handleClose })), !!file && (_jsx("h4", { className: "md-lib-font-semibold md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-text-base md-lib-truncate md-lib-max-w-[calc(100vw-180px)]", title: get(file, "name", "N/A"), children: get(file, "name", "N/A") }))] }), !!file && (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-4", children: [_jsx(FileMenuOptions, { file: file, onCloseSelection: onCloseSelection, fileModal: true }), _jsx(Button, { size: "large", className: "md-lib-bg-secondaryColor dark:md-lib-bg-darkSecondaryColor hover:md-lib-bg-secondaryHoverColor dark:hover:md-lib-bg-darkSecondaryColor md-lib-border-none", onClick: () => {
19
- const url = get(file, "downloadUrl");
20
- if (!url)
18
+ return (_jsxs("div", { className: "md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor md-lib-py-3 md-lib-px-5 md-lib-border-b md-lib-border-borderColor dark:md-lib-border-darkBorderColor 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: [!id && type !== DriveModes.FILE && (_jsx(IoIosCloseIcon, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-cursor-pointer", size: 24, onClick: handleClose })), !!file && (_jsx("h4", { className: "md-lib-font-semibold md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-text-base md-lib-truncate md-lib-max-w-[calc(100vw-180px)]", title: get(file, "name", "N/A"), children: get(file, "name", "N/A") }))] }), !!file && (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-4", children: [_jsx(FileMenuOptions, { file: file, fileIds: get(file, "_id") ? [get(file, "_id")] : [], onCloseSelection: onCloseSelection, fileModal: true }), _jsx(Button, { size: "large", className: "md-lib-bg-secondaryColor dark:md-lib-bg-darkSecondaryColor hover:md-lib-bg-secondaryHoverColor dark:hover:md-lib-bg-darkSecondaryColor md-lib-border-none", onClick: () => {
19
+ const url = get(file, "downloadUrl") || get(file, "s3Url") || get(file, "thumbnailUrl");
20
+ if (!url) {
21
21
  showNotification(INVALID_URL, NotificationStatus.ERROR);
22
+ return;
23
+ }
22
24
  window.open(url, "_blank");
23
25
  }, children: _jsx(BsDownloadIcon, { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor", size: 24 }) })] }))] }));
24
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.99",
3
+ "version": "5.8.101",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",