- {objectsList && objectsList.length > 0
- ? objectsList.slice(-1)[0].label
- : ""}
- {rewindEnabled && objectsList.length > 1 && (
+ {splitPaths && splitPaths.length > 0 ? splitPaths[splitPaths.length - 1] : ""}
+ {rewindEnabled && splitPaths.length > 1 && (
(Rewind:{" "}
)
@@ -93,15 +99,10 @@ const BrowserBreadcrumbs = ({
};
const mapStateToProps = ({ objectBrowser }: ObjectBrowserReducer) => ({
- objectsList: get(objectBrowser, "routesList", []),
rewindEnabled: get(objectBrowser, "rewind.rewindEnabled", false),
rewindDate: get(objectBrowser, "rewind.dateToRewind", null),
});
-const mapDispatchToProps = {
- removeRouteLevel,
-};
+const connector = connect(mapStateToProps, null);
-const connector = connect(mapStateToProps, mapDispatchToProps);
-
-export default connector(withStyles(styles)(BrowserBreadcrumbs));
+export default withStyles(styles)(connector(BrowserBreadcrumbs));
diff --git a/portal-ui/src/screens/Console/ObjectBrowser/ObjectBrowser.tsx b/portal-ui/src/screens/Console/ObjectBrowser/ObjectBrowser.tsx
deleted file mode 100644
index a07d9558f..000000000
--- a/portal-ui/src/screens/Console/ObjectBrowser/ObjectBrowser.tsx
+++ /dev/null
@@ -1,90 +0,0 @@
-// This file is part of MinIO Console Server
-// Copyright (c) 2021 MinIO, Inc.
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see .
-
-import React from "react";
-import get from "lodash/get";
-import { createStyles, Theme, withStyles } from "@material-ui/core/styles";
-import { Grid } from "@material-ui/core";
-import BrowseBuckets from "./BrowseBuckets";
-import { containerForHeader } from "../Common/FormComponents/common/styleLibrary";
-import PageHeader from "../Common/PageHeader/PageHeader";
-
-interface IObjectBrowserProps {
- match: any;
- classes: any;
-}
-
-const styles = (theme: Theme) =>
- createStyles({
- watchList: {
- background: "white",
- maxHeight: "400",
- overflow: "auto",
- "& ul": {
- margin: "4",
- padding: "0",
- },
- "& ul li": {
- listStyle: "none",
- margin: "0",
- padding: "0",
- borderBottom: "1px solid #dedede",
- },
- },
- actionsTray: {
- textAlign: "right",
- "& button": {
- marginLeft: 10,
- },
- },
- inputField: {
- background: "#FFFFFF",
- padding: 12,
- borderRadius: 5,
- marginLeft: 10,
- boxShadow: "0px 3px 6px #00000012",
- },
- fieldContainer: {
- background: "#FFFFFF",
- padding: 0,
- borderRadius: 5,
- marginLeft: 10,
- textAlign: "left",
- minWidth: "206",
- boxShadow: "0px 3px 6px #00000012",
- },
- lastElementWPadding: {
- paddingRight: "78",
- },
- ...containerForHeader(theme.spacing(4)),
- });
-
-const ObjectBrowser = ({ match, classes }: IObjectBrowserProps) => {
- const pathIn = get(match, "url", "");
-
- return (
-
-
-
-
- {pathIn === "/object-browser" && }
-
-
-
- );
-};
-
-export default withStyles(styles)(ObjectBrowser);
diff --git a/portal-ui/src/screens/Console/ObjectBrowser/actions.ts b/portal-ui/src/screens/Console/ObjectBrowser/actions.ts
index faf5eb73f..39514caec 100644
--- a/portal-ui/src/screens/Console/ObjectBrowser/actions.ts
+++ b/portal-ui/src/screens/Console/ObjectBrowser/actions.ts
@@ -14,61 +14,10 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-export const OBJECT_BROWSER_ADD_ROUTE = "OBJECT_BROWSER/ADD_ROUTE";
-export const OBJECT_BROWSER_RESET_ROUTES_LIST =
- "OBJECT_BROWSER/RESET_ROUTES_LIST";
-export const OBJECT_BROWSER_REMOVE_ROUTE_LEVEL =
- "OBJECT_BROWSER/REMOVE_ROUTE_LEVEL";
-export const OBJECT_BROWSER_SET_ALL_ROUTES = "OBJECT_BROWSER/SET_ALL_ROUTES";
-export const OBJECT_BROWSER_CREATE_FOLDER = "OBJECT_BROWSER/CREATE_FOLDER";
-export const OBJECT_BROWSER_SET_LAST_AS_FILE =
- "OBJECT_BROWSER/SET_LAST_AS_FILE";
-export const OBJECT_BROWSER_DOWNLOAD_FILE_LOADER =
- "OBJECT_BROWSER/DOWNLOAD_FILE_LOADER";
-export const OBJECT_BROWSER_DOWNLOADED_FILE = "OBJECT_BROWSER/DOWNLOADED_FILE";
export const REWIND_SET_ENABLE = "REWIND/SET_ENABLE";
export const REWIND_RESET_REWIND = "REWIND/RESET_REWIND";
-interface AddRouteAction {
- type: typeof OBJECT_BROWSER_ADD_ROUTE;
- route: string;
- label: string;
- routeType: string;
-}
-
-interface ResetRoutesList {
- type: typeof OBJECT_BROWSER_RESET_ROUTES_LIST;
- reset: boolean;
-}
-
-interface RemoveRouteLevel {
- type: typeof OBJECT_BROWSER_REMOVE_ROUTE_LEVEL;
- toRoute: string;
-}
-
-interface SetAllRoutes {
- type: typeof OBJECT_BROWSER_SET_ALL_ROUTES;
- currentRoute: string;
-}
-
-interface CreateFolder {
- type: typeof OBJECT_BROWSER_CREATE_FOLDER;
- newRoute: string;
-}
-
-interface SetLastAsFile {
- type: typeof OBJECT_BROWSER_SET_LAST_AS_FILE;
-}
-
-interface SetFileDownload {
- type: typeof OBJECT_BROWSER_DOWNLOAD_FILE_LOADER;
- path: string;
-}
-
-interface FileDownloaded {
- type: typeof OBJECT_BROWSER_DOWNLOADED_FILE;
- path: string;
-}
+export const REWIND_FILE_MODE_ENABLED = "BUCKET_BROWSER/FILE_MODE_ENABLED";
interface RewindSetEnabled {
type: typeof REWIND_SET_ENABLE;
@@ -81,74 +30,15 @@ interface RewindReset {
type: typeof REWIND_RESET_REWIND;
}
+interface FileModeEnabled {
+ type: typeof REWIND_FILE_MODE_ENABLED;
+ status: boolean;
+}
+
export type ObjectBrowserActionTypes =
- | AddRouteAction
- | ResetRoutesList
- | RemoveRouteLevel
- | SetAllRoutes
- | CreateFolder
- | SetLastAsFile
- | SetFileDownload
- | FileDownloaded
| RewindSetEnabled
- | RewindReset;
-
-export const addRoute = (route: string, label: string, routeType: string) => {
- return {
- type: OBJECT_BROWSER_ADD_ROUTE,
- route,
- label,
- routeType,
- };
-};
-
-export const resetRoutesList = (reset: boolean) => {
- return {
- type: OBJECT_BROWSER_RESET_ROUTES_LIST,
- reset,
- };
-};
-
-export const removeRouteLevel = (toRoute: string) => {
- return {
- type: OBJECT_BROWSER_REMOVE_ROUTE_LEVEL,
- toRoute,
- };
-};
-
-export const setAllRoutes = (currentRoute: string) => {
- return {
- type: OBJECT_BROWSER_SET_ALL_ROUTES,
- currentRoute,
- };
-};
-
-export const createFolder = (newRoute: string) => {
- return {
- type: OBJECT_BROWSER_CREATE_FOLDER,
- newRoute,
- };
-};
-
-export const setLastAsFile = () => {
- return {
- type: OBJECT_BROWSER_SET_LAST_AS_FILE,
- };
-};
-
-export const fileIsBeingPrepared = (path: string) => {
- return {
- type: OBJECT_BROWSER_DOWNLOAD_FILE_LOADER,
- path,
- };
-};
-
-export const fileDownloadStarted = (path: string) => {
- return {
- type: OBJECT_BROWSER_DOWNLOADED_FILE,
- path,
- };
-};
+ | RewindReset
+ | FileModeEnabled;
export const setRewindEnable = (
state: boolean,
@@ -168,3 +58,10 @@ export const resetRewind = () => {
type: REWIND_RESET_REWIND,
};
};
+
+export const setFileModeEnabled = (status: boolean) => {
+ return {
+ type: REWIND_FILE_MODE_ENABLED,
+ status,
+ };
+};
diff --git a/portal-ui/src/screens/Console/ObjectBrowser/reducers.ts b/portal-ui/src/screens/Console/ObjectBrowser/reducers.ts
index fa5a16399..fe0556898 100644
--- a/portal-ui/src/screens/Console/ObjectBrowser/reducers.ts
+++ b/portal-ui/src/screens/Console/ObjectBrowser/reducers.ts
@@ -13,19 +13,10 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-import history from "../../../history";
-
import {
- OBJECT_BROWSER_ADD_ROUTE,
- OBJECT_BROWSER_CREATE_FOLDER,
- OBJECT_BROWSER_REMOVE_ROUTE_LEVEL,
- OBJECT_BROWSER_RESET_ROUTES_LIST,
- OBJECT_BROWSER_SET_ALL_ROUTES,
- OBJECT_BROWSER_SET_LAST_AS_FILE,
- OBJECT_BROWSER_DOWNLOAD_FILE_LOADER,
- OBJECT_BROWSER_DOWNLOADED_FILE,
REWIND_SET_ENABLE,
REWIND_RESET_REWIND,
+ REWIND_FILE_MODE_ENABLED,
ObjectBrowserActionTypes,
} from "./actions";
@@ -42,8 +33,7 @@ export interface RewindItem {
}
export interface ObjectBrowserState {
- routesList: Route[];
- downloadingFiles: string[];
+ fileMode: boolean;
rewind: RewindItem;
}
@@ -51,10 +41,6 @@ export interface ObjectBrowserReducer {
objectBrowser: ObjectBrowserState;
}
-const initialRoute = [
- { route: "/object-browser", label: "All Buckets", type: "path" },
-];
-
const defaultRewind = {
rewindEnabled: false,
bucketToRewind: "",
@@ -62,8 +48,7 @@ const defaultRewind = {
};
const initialState: ObjectBrowserState = {
- routesList: initialRoute,
- downloadingFiles: [],
+ fileMode: false,
rewind: {
...defaultRewind,
},
@@ -74,107 +59,6 @@ export function objectBrowserReducer(
action: ObjectBrowserActionTypes
): ObjectBrowserState {
switch (action.type) {
- case OBJECT_BROWSER_ADD_ROUTE:
- const newRouteList = [
- ...state.routesList,
- { route: action.route, label: action.label, type: action.routeType },
- ];
- history.push(action.route);
-
- return { ...state, routesList: newRouteList };
- case OBJECT_BROWSER_RESET_ROUTES_LIST:
- return {
- ...state,
- routesList: [...initialRoute],
- };
- case OBJECT_BROWSER_REMOVE_ROUTE_LEVEL:
- const indexOfTopPath =
- state.routesList.findIndex(
- (element) => element.route === action.toRoute
- ) + 1;
- const newRouteLevels = state.routesList.slice(0, indexOfTopPath);
-
- return {
- ...state,
- routesList: newRouteLevels,
- };
- case OBJECT_BROWSER_SET_ALL_ROUTES:
- const splitRoutes = action.currentRoute.split("/");
- const routesArray: Route[] = [];
- let initRoute = initialRoute[0].route;
-
- splitRoutes.forEach((route) => {
- if (route !== "" && route !== "object-browser") {
- initRoute = `${initRoute}/${route}`;
-
- routesArray.push({
- route: initRoute,
- label: route,
- type: "path",
- });
- }
- });
-
- const newSetOfRoutes = [...initialRoute, ...routesArray];
-
- return {
- ...state,
- routesList: newSetOfRoutes,
- };
- case OBJECT_BROWSER_CREATE_FOLDER:
- const newFoldersRoutes = [...state.routesList];
- let lastRoute = state.routesList[state.routesList.length - 1].route;
-
- const splitElements = action.newRoute.split("/");
-
- splitElements.forEach((element) => {
- const folderTrim = element.trim();
- if (folderTrim !== "") {
- lastRoute = `${lastRoute}/${folderTrim}`;
-
- const newItem = { route: lastRoute, label: folderTrim, type: "path" };
- newFoldersRoutes.push(newItem);
- }
- });
-
- history.push(lastRoute);
-
- return {
- ...state,
- routesList: newFoldersRoutes,
- };
- case OBJECT_BROWSER_SET_LAST_AS_FILE:
- const currentList = state.routesList;
- const lastItem = currentList.slice(-1)[0];
-
- if (lastItem.type === "path") {
- lastItem.type = "file";
- }
-
- const newList = [...currentList.slice(0, -1), lastItem];
-
- return {
- ...state,
- routesList: newList,
- };
- case OBJECT_BROWSER_DOWNLOAD_FILE_LOADER:
- const actualFiles = [...state.downloadingFiles];
-
- actualFiles.push(action.path);
-
- return {
- ...state,
- downloadingFiles: [...actualFiles],
- };
- case OBJECT_BROWSER_DOWNLOADED_FILE:
- const downloadingFiles = state.downloadingFiles.filter(
- (item) => item !== action.path
- );
-
- return {
- ...state,
- downloadingFiles: [...downloadingFiles],
- };
case REWIND_SET_ENABLE:
const rewindSetEnabled = {
...state.rewind,
@@ -190,6 +74,8 @@ export function objectBrowserReducer(
dateToRewind: null,
};
return { ...state, rewind: resetItem };
+ case REWIND_FILE_MODE_ENABLED:
+ return { ...state, fileMode: action.status };
default:
return state;
}