Reload versions list after clicking on Reload button (#1717)

This commit is contained in:
Alex
2022-03-15 09:45:28 -07:00
committed by GitHub
parent 78983ce76f
commit b0119a55df
4 changed files with 46 additions and 8 deletions

View File

@@ -60,6 +60,7 @@ import {
completeObject,
openList,
resetRewind,
setLoadingVersions,
setNewObject,
setSearchObjects,
setShowDeletedObjects,
@@ -225,6 +226,7 @@ interface IListObjectsProps {
setSearchObjects: typeof setSearchObjects;
setVersionsModeEnabled: typeof setVersionsModeEnabled;
setShowDeletedObjects: typeof setShowDeletedObjects;
setLoadingVersions: typeof setLoadingVersions;
}
function useInterval(callback: any, delay: number) {
@@ -276,6 +278,7 @@ const ListObjects = ({
setVersionsModeEnabled,
showDeleted,
setShowDeletedObjects,
setLoadingVersions,
}: IListObjectsProps) => {
const [records, setRecords] = useState<BucketObject[]>([]);
const [loading, setLoading] = useState<boolean>(true);
@@ -738,6 +741,7 @@ const ListObjects = ({
}
setDetailsOpen(true);
setLoadingVersions(true);
setSelectedInternalPaths(
`${idElement ? `${encodeFileName(idElement)}` : ``}`
);
@@ -1244,7 +1248,11 @@ const ListObjects = ({
color="primary"
variant={"outlined"}
onClick={() => {
setLoading(true);
if (versionsMode) {
setLoadingVersions(true);
} else {
setLoading(true);
}
}}
disabled={
!hasPermission(bucketName, [IAM_SCOPES.S3_LIST_BUCKET]) ||
@@ -1421,6 +1429,7 @@ const mapDispatchToProps = {
setSearchObjects,
setVersionsModeEnabled,
setShowDeletedObjects,
setLoadingVersions,
};
const connector = connect(mapStateToProps, mapDispatchToProps);

View File

@@ -47,6 +47,7 @@ import ScreenTitle from "../../../../Common/ScreenTitle/ScreenTitle";
import RestoreFileVersion from "./RestoreFileVersion";
import {
completeObject,
setLoadingVersions,
setNewObject,
setSelectedVersion,
updateProgress,
@@ -110,12 +111,14 @@ interface IVersionsNavigatorProps {
internalPaths: string;
bucketName: string;
searchVersions: string;
loadingVersions: boolean;
setErrorSnackMessage: typeof setErrorSnackMessage;
setSnackBarMessage: typeof setSnackBarMessage;
setNewObject: typeof setNewObject;
updateProgress: typeof updateProgress;
completeObject: typeof completeObject;
setSelectedVersion: typeof setSelectedVersion;
setLoadingVersions: typeof setLoadingVersions;
}
const emptyFile: IFileInfo = {
@@ -137,12 +140,13 @@ const VersionsNavigator = ({
setNewObject,
updateProgress,
searchVersions,
loadingVersions,
completeObject,
internalPaths,
bucketName,
setSelectedVersion,
setLoadingVersions,
}: IVersionsNavigatorProps) => {
const [loadObjectData, setLoadObjectData] = useState<boolean>(true);
const [shareFileModalOpen, setShareFileModalOpen] = useState<boolean>(false);
const [actualInfo, setActualInfo] = useState<IFileInfo | null>(null);
const [objectToShare, setObjectToShare] = useState<IFileInfo | null>(null);
@@ -159,7 +163,7 @@ const VersionsNavigator = ({
}
useEffect(() => {
if (loadObjectData && internalPaths !== "") {
if (loadingVersions && internalPaths !== "") {
api
.invoke(
"GET",
@@ -179,15 +183,16 @@ const VersionsNavigator = ({
setVersions([]);
}
setLoadObjectData(false);
setLoadingVersions(false);
})
.catch((error: ErrorResponseHandler) => {
setErrorSnackMessage(error);
setLoadObjectData(false);
setLoadingVersions(false);
});
}
}, [
loadObjectData,
setLoadingVersions,
loadingVersions,
bucketName,
internalPaths,
setErrorSnackMessage,
@@ -268,7 +273,7 @@ const VersionsNavigator = ({
setRestoreVersion("");
if (reloadObjectData) {
setLoadObjectData(true);
setLoadingVersions(true);
}
};
@@ -455,6 +460,7 @@ const VersionsNavigator = ({
const mapStateToProps = ({ system, objectBrowser }: AppState) => ({
distributedSetup: get(system, "distributedSetup", false),
searchVersions: objectBrowser.searchVersions,
loadingVersions: objectBrowser.loadingVersions,
});
const mapDispatchToProps = {
@@ -464,6 +470,7 @@ const mapDispatchToProps = {
updateProgress,
completeObject,
setSelectedVersion,
setLoadingVersions,
};
const connector = connect(mapStateToProps, mapDispatchToProps);

View File

@@ -39,6 +39,7 @@ export const BUCKET_BROWSER_VERSIONS_SET_SEARCH =
export const BUCKET_BROWSER_SET_SELECTED_VERSION =
"BUCKET_BROWSER/SET_SELECTED_VERSION";
export const BUCKET_BROWSER_SHOW_DELETED = "BUCKET_BROWSER/SHOW_DELETED";
export const BUCKET_BROWSER_LOAD_VERSIONS = "BUCKET_BROWSER/LOAD_VERSIONS";
interface RewindSetEnabled {
type: typeof REWIND_SET_ENABLE;
@@ -114,6 +115,11 @@ interface SetShowDeletedObjects {
status: boolean;
}
interface SetLoadingVersions {
type: typeof BUCKET_BROWSER_LOAD_VERSIONS;
status: boolean;
}
export type ObjectBrowserActionTypes =
| RewindSetEnabled
| RewindReset
@@ -129,7 +135,8 @@ export type ObjectBrowserActionTypes =
| SetSearchObjects
| SetSearchVersions
| SetSelectedversion
| SetShowDeletedObjects;
| SetShowDeletedObjects
| SetLoadingVersions;
export const setRewindEnable = (
state: boolean,
@@ -241,3 +248,10 @@ export const setShowDeletedObjects = (status: boolean) => {
status,
};
};
export const setLoadingVersions = (status: boolean) => {
return {
type: BUCKET_BROWSER_LOAD_VERSIONS,
status,
};
};

View File

@@ -30,6 +30,7 @@ import {
BUCKET_BROWSER_VERSIONS_SET_SEARCH,
BUCKET_BROWSER_SET_SELECTED_VERSION,
BUCKET_BROWSER_SHOW_DELETED,
BUCKET_BROWSER_LOAD_VERSIONS,
} from "./actions";
export interface Route {
@@ -48,6 +49,7 @@ export interface ObjectBrowserState {
rewind: RewindItem;
objectManager: ObjectManager;
searchObjects: string;
loadingVersions: boolean;
versionsMode: boolean;
versionedFile: string;
searchVersions: string;
@@ -82,6 +84,7 @@ const defaultRewind = {
const initialState: ObjectBrowserState = {
versionsMode: false,
loadingVersions: true,
rewind: {
...defaultRewind,
},
@@ -253,6 +256,11 @@ export function objectBrowserReducer(
...state,
showDeleted: action.status,
};
case BUCKET_BROWSER_LOAD_VERSIONS:
return {
...state,
loadingVersions: action.status,
};
default:
return state;
}