Skip to content

Commit

Permalink
Fix actions on a del marker in object list view (#3134)
Browse files Browse the repository at this point in the history
  • Loading branch information
prakashsvmx authored Nov 24, 2023
1 parent e4d5f96 commit 924c38f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions portal-ui/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
coverage
.nyc_output
2 changes: 1 addition & 1 deletion portal-ui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ find-deadcode:
./check-deadcode.sh

prettify:
yarn prettier --write . --loglevel warn
yarn prettier --write . --log-level warn

pretty: prettify
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ const ListObjects = () => {
(state: AppState) => state.objectBrowser.anonymousAccessOpen,
);

const records = useSelector(
(state: AppState) => state.objectBrowser?.records || [],
);

const loadingBucket = useSelector(selBucketDetailsLoading);
const bucketInfo = useSelector(selBucketDetailsInfo);

Expand Down Expand Up @@ -291,6 +295,20 @@ const ListObjects = () => {
(state: AppState) => state.objectBrowser.selectedObjects,
);

const checkForDelMarker = (): boolean => {
let isObjDelMarker = false;
if (selectedObjects.length === 1) {
let matchingRec = records.find((obj) => {
return obj.name === `${selectedObjects[0]}` && obj.delete_flag;
});

isObjDelMarker = !!matchingRec;
}
return isObjDelMarker;
};

const isSelObjectDelMarker = checkForDelMarker();

const fetchMetadata = useCallback(() => {
const objectName = selectedObjects[0];

Expand All @@ -317,10 +335,10 @@ const ListObjects = () => {
}, [bucketName, selectedObjects, isMetaDataLoaded]);

useEffect(() => {
if (bucketName && selectedObjects.length === 1) {
if (bucketName && !isSelObjectDelMarker) {
fetchMetadata();
}
}, [bucketName, selectedObjects, fetchMetadata]);
}, [bucketName, selectedObjects, fetchMetadata, isSelObjectDelMarker]);

useEffect(() => {
if (rewindEnabled) {
Expand Down Expand Up @@ -834,7 +852,7 @@ const ListObjects = () => {
dispatch(downloadSelected(bucketName));
},
label: "Download",
disabled: !canDownload || selectedObjects?.length === 0,
disabled: !canDownload || isSelObjectDelMarker,
icon: <DownloadIcon />,
tooltip: canDownload
? downloadToolTip
Expand All @@ -848,7 +866,8 @@ const ListObjects = () => {
dispatch(openShare());
},
label: "Share",
disabled: selectedObjects.length !== 1 || !canShareFile,
disabled:
selectedObjects.length !== 1 || !canShareFile || isSelObjectDelMarker,
icon: <ShareIcon />,
tooltip: canShareFile ? "Share Selected File" : "Sharing unavailable",
},
Expand All @@ -857,7 +876,8 @@ const ListObjects = () => {
dispatch(openPreview());
},
label: "Preview",
disabled: selectedObjects.length !== 1 || !canPreviewFile,
disabled:
selectedObjects.length !== 1 || !canPreviewFile || isSelObjectDelMarker,
icon: <PreviewIcon />,
tooltip: canPreviewFile ? "Preview Selected File" : "Preview unavailable",
},
Expand Down

0 comments on commit 924c38f

Please sign in to comment.