From 780cf7240b1c725b277a0f141b902db191cc8120 Mon Sep 17 00:00:00 2001 From: Alex <33497058+bexsoft@users.noreply.github.com> Date: Mon, 31 Jan 2022 20:46:57 -0700 Subject: [PATCH] Changed position of search box for list objects module (#1497) - Changed the searchbox component to be a controlled component - Added reducer to control searchbox in objects list - Adjusted styles to search box component & placeholders - Fixed navigation of folders Signed-off-by: Benjamin Perez Co-authored-by: Benjamin Perez --- .../src/screens/Console/Account/Account.tsx | 1 + .../Buckets/BucketDetails/BrowserHandler.tsx | 33 ++++++++++++- .../Buckets/ListBuckets/ListBuckets.tsx | 1 + .../Objects/ListObjects/ListObjects.tsx | 48 ++++++++++--------- .../Objects/ObjectDetails/ObjectDetails.tsx | 1 + .../CommentBoxWrapper/CommentBoxWrapper.tsx | 4 +- .../FormComponents/common/styleLibrary.ts | 6 ++- .../Console/Common/PageHeader/PageHeader.tsx | 41 ++++++++++++---- .../src/screens/Console/Common/SearchBox.tsx | 19 ++++++++ .../ListTiersConfiguration.tsx | 1 + .../src/screens/Console/Groups/Groups.tsx | 1 + .../screens/Console/Groups/GroupsDetails.tsx | 1 + .../screens/Console/Groups/UsersSelectors.tsx | 1 + .../Console/Logs/ErrorLogs/ErrorLogs.tsx | 2 +- .../ListNotificationEndpoints.tsx | 1 + .../screens/Console/ObjectBrowser/actions.ts | 15 +++++- .../screens/Console/ObjectBrowser/reducers.ts | 8 ++++ .../screens/Console/Policies/ListPolicies.tsx | 1 + .../Console/Policies/PolicySelectors.tsx | 1 + .../Tenants/ListTenants/ListTenants.tsx | 1 + .../screens/Console/Users/GroupsSelectors.tsx | 1 + .../src/screens/Console/Users/ListUsers.tsx | 1 + 22 files changed, 150 insertions(+), 39 deletions(-) diff --git a/portal-ui/src/screens/Console/Account/Account.tsx b/portal-ui/src/screens/Console/Account/Account.tsx index 202d57951..b8f149d7c 100644 --- a/portal-ui/src/screens/Console/Account/Account.tsx +++ b/portal-ui/src/screens/Console/Account/Account.tsx @@ -197,6 +197,7 @@ const Account = ({ classes, displayErrorMessage }: IServiceAccountsProps) => { placeholder={"Search Service Accounts"} onChange={setFilter} overrideClass={classes.searchField} + value={filter} /> @@ -62,7 +69,8 @@ const BrowserHandler = ({ history, classes, setFileModeEnabled, - bucketInfo, + searchObjects, + setSearchObjects, }: IBrowserHandlerProps) => { const bucketName = match.params["bucketName"]; const internalPaths = get(match.params, "subpaths", ""); @@ -105,6 +113,25 @@ const BrowserHandler = ({ } + middleComponent={ + + {!fileMode && ( + + { + setSearchObjects(value); + }} + value={searchObjects} + /> + + )} + + } /> {fileMode ? : } @@ -115,11 +142,13 @@ const mapStateToProps = ({ objectBrowser, buckets }: AppState) => ({ fileMode: get(objectBrowser, "fileMode", false), bucketToRewind: get(objectBrowser, "rewind.bucketToRewind", ""), bucketInfo: buckets.bucketDetails.bucketInfo, + searchObjects: objectBrowser.searchObjects, }); const mapDispatchToProps = { setFileModeEnabled, setErrorSnackMessage, + setSearchObjects, }; const connector = connect(mapStateToProps, mapDispatchToProps); diff --git a/portal-ui/src/screens/Console/Buckets/ListBuckets/ListBuckets.tsx b/portal-ui/src/screens/Console/Buckets/ListBuckets/ListBuckets.tsx index a3f4428c4..0a216a045 100644 --- a/portal-ui/src/screens/Console/Buckets/ListBuckets/ListBuckets.tsx +++ b/portal-ui/src/screens/Console/Buckets/ListBuckets/ListBuckets.tsx @@ -217,6 +217,7 @@ const ListBuckets = ({ onChange={setFilterBuckets} placeholder="Search Buckets" overrideClass={classes.searchField} + value={filterBuckets} /> { const [records, setRecords] = useState([]); @@ -261,7 +265,6 @@ const ListObjects = ({ const [loadingRewind, setLoadingRewind] = useState(false); const [deleteMultipleOpen, setDeleteMultipleOpen] = useState(false); const [createFolderOpen, setCreateFolderOpen] = useState(false); - const [filterObjects, setFilterObjects] = useState(""); const [loadingStartTime, setLoadingStartTime] = useState(0); const [loadingMessage, setLoadingMessage] = useState(defLoading); @@ -434,7 +437,9 @@ const ListObjects = ({ useEffect(() => { setLoading(true); - }, [internalPaths]); + setDetailsOpen(false); + setSearchObjects(""); + }, [internalPaths, setSearchObjects]); useEffect(() => { if (loading) { @@ -685,6 +690,14 @@ const ListObjects = ({ }; const openPath = (idElement: string) => { + if(idElement.endsWith("/")) { + const newPath = `/buckets/${bucketName}/browse${ + idElement ? `/${encodeFileName(idElement)}` : `` + }`; + history.push(newPath); + return; + } + setDetailsOpen(true); setSelectedInternalPaths( `${idElement ? `${encodeFileName(idElement)}` : ``}` @@ -923,11 +936,11 @@ const ListObjects = ({ ]; const filteredRecords = records.filter((b: BucketObject) => { - if (filterObjects === "") { + if (searchObjects === "") { return true; } else { const objectName = b.name.toLowerCase(); - if (objectName.indexOf(filterObjects.toLowerCase()) >= 0) { + if (objectName.indexOf(searchObjects.toLowerCase()) >= 0) { return true; } else { return false; @@ -1181,19 +1194,6 @@ const ListObjects = ({ } /> - - - - -
@@ -1321,11 +1321,11 @@ const ListObjects = ({ }} > {selectedInternalPaths !== null && ( - - )} + + )} @@ -1343,6 +1343,7 @@ const mapStateToProps = ({ objectBrowser, buckets }: AppState) => ({ bucketToRewind: get(objectBrowser, "rewind.bucketToRewind", ""), loadingBucket: buckets.bucketDetails.loadingBucket, bucketInfo: buckets.bucketDetails.bucketInfo, + searchObjects: objectBrowser.searchObjects, }); const mapDispatchToProps = { @@ -1356,6 +1357,7 @@ const mapDispatchToProps = { updateProgress, completeObject, openList, + setSearchObjects, }; const connector = connect(mapStateToProps, mapDispatchToProps); diff --git a/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ObjectDetails/ObjectDetails.tsx b/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ObjectDetails/ObjectDetails.tsx index ef4f6fa8f..36e5be753 100644 --- a/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ObjectDetails/ObjectDetails.tsx +++ b/portal-ui/src/screens/Console/Buckets/ListBuckets/Objects/ObjectDetails/ObjectDetails.tsx @@ -748,6 +748,7 @@ const ObjectDetails = ({ )} diff --git a/portal-ui/src/screens/Console/Common/FormComponents/CommentBoxWrapper/CommentBoxWrapper.tsx b/portal-ui/src/screens/Console/Common/FormComponents/CommentBoxWrapper/CommentBoxWrapper.tsx index 3669276f4..a4cc861a8 100644 --- a/portal-ui/src/screens/Console/Common/FormComponents/CommentBoxWrapper/CommentBoxWrapper.tsx +++ b/portal-ui/src/screens/Console/Common/FormComponents/CommentBoxWrapper/CommentBoxWrapper.tsx @@ -13,6 +13,7 @@ // // 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 { Grid, InputLabel, TextField, Tooltip } from "@mui/material"; import { Theme } from "@mui/material/styles"; @@ -72,8 +73,9 @@ const styles = (theme: Theme) => fontSize: 13, fontWeight: 600, "&:placeholder": { - color: "#393939", + color: "#858585", opacity: 1, + fontWeight: 400, }, }, }, diff --git a/portal-ui/src/screens/Console/Common/FormComponents/common/styleLibrary.ts b/portal-ui/src/screens/Console/Common/FormComponents/common/styleLibrary.ts index 830caed75..f5e43f690 100644 --- a/portal-ui/src/screens/Console/Common/FormComponents/common/styleLibrary.ts +++ b/portal-ui/src/screens/Console/Common/FormComponents/common/styleLibrary.ts @@ -280,8 +280,9 @@ export const searchField = { fontWeight: 700, color: "#000", "&::placeholder": { - color: "#a6a5a5", + color: "#858585", opacity: 1, + fontWeight: 400, }, }, "&:hover": { @@ -898,8 +899,9 @@ export const inputFieldStyles = { fontSize: 13, fontWeight: 600, "&:placeholder": { - color: "#393939", + color: "#858585", opacity: 1, + fontWeight: 400, }, }, error: { diff --git a/portal-ui/src/screens/Console/Common/PageHeader/PageHeader.tsx b/portal-ui/src/screens/Console/Common/PageHeader/PageHeader.tsx index 9793908de..6bfd53c6b 100644 --- a/portal-ui/src/screens/Console/Common/PageHeader/PageHeader.tsx +++ b/portal-ui/src/screens/Console/Common/PageHeader/PageHeader.tsx @@ -1,7 +1,22 @@ +// This file is part of MinIO Console Server +// Copyright (c) 2022 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 { Theme } from "@mui/material/styles"; import { connect } from "react-redux"; -import { Box } from "@mui/material"; import Grid from "@mui/material/Grid"; import createStyles from "@mui/styles/createStyles"; import withStyles from "@mui/styles/withStyles"; @@ -22,12 +37,12 @@ interface IPageHeader { actions?: any; managerObjects?: IFileItem[]; toggleList: typeof toggleList; + middleComponent?: React.ReactNode; } const styles = (theme: Theme) => createStyles({ headerContainer: { - // position: "absolute", width: "100%", minHeight: 79, display: "flex", @@ -57,6 +72,11 @@ const styles = (theme: Theme) => width: 120, }, }, + middleComponent: { + display: "flex", + justifyContent: "center", + alignItems: "center", + } }); const PageHeader = ({ @@ -67,6 +87,7 @@ const PageHeader = ({ operatorMode, managerObjects, toggleList, + middleComponent, }: IPageHeader) => { return ( - - -   - - - + {!sidebarOpen && (
{operatorMode ? : } @@ -90,7 +108,12 @@ const PageHeader = ({ {label} - + {middleComponent && ( + + {middleComponent} + + )} + {actions && actions} {managerObjects && managerObjects.length > 0 && ( . + import React from "react"; import InputAdornment from "@mui/material/InputAdornment"; import SearchIcon from "../../../icons/SearchIcon"; @@ -17,6 +33,7 @@ const styles = (theme: Theme) => type SearchBoxProps = { placeholder?: string; + value: string; classes: any; onChange: (value: string) => void; adornmentPosition?: "start" | "end"; @@ -29,6 +46,7 @@ const SearchBox = ({ onChange, adornmentPosition = "end", overrideClass, + value, }: SearchBoxProps) => { const inputProps = { disableUnderline: true, @@ -52,6 +70,7 @@ const SearchBox = ({ onChange(e.target.value); }} variant="standard" + value={value} /> ); }; diff --git a/portal-ui/src/screens/Console/Configurations/TiersConfiguration/ListTiersConfiguration.tsx b/portal-ui/src/screens/Console/Configurations/TiersConfiguration/ListTiersConfiguration.tsx index 2285c6072..2052cf216 100644 --- a/portal-ui/src/screens/Console/Configurations/TiersConfiguration/ListTiersConfiguration.tsx +++ b/portal-ui/src/screens/Console/Configurations/TiersConfiguration/ListTiersConfiguration.tsx @@ -245,6 +245,7 @@ const ListTiersConfiguration = ({ placeholder="Filter" onChange={setFilter} overrideClass={classes.searchField} + value={filter} />
{ placeholder={"Search Groups"} onChange={setFilter} overrideClass={classes.searchField} + value={filter} /> diff --git a/portal-ui/src/screens/Console/Groups/GroupsDetails.tsx b/portal-ui/src/screens/Console/Groups/GroupsDetails.tsx index 156ae88b5..78c366801 100644 --- a/portal-ui/src/screens/Console/Groups/GroupsDetails.tsx +++ b/portal-ui/src/screens/Console/Groups/GroupsDetails.tsx @@ -191,6 +191,7 @@ const GroupsDetails = ({ classes }: IGroupDetailsProps) => { setMemberFilter(searchText); }} overrideClass={classes.searchField} + value={memberFilter} />
diff --git a/portal-ui/src/screens/Console/Logs/ErrorLogs/ErrorLogs.tsx b/portal-ui/src/screens/Console/Logs/ErrorLogs/ErrorLogs.tsx index fd3d0bdf1..332e73e45 100644 --- a/portal-ui/src/screens/Console/Logs/ErrorLogs/ErrorLogs.tsx +++ b/portal-ui/src/screens/Console/Logs/ErrorLogs/ErrorLogs.tsx @@ -331,7 +331,7 @@ const ErrorLogs = ({ - +
diff --git a/portal-ui/src/screens/Console/NotificationEndpoints/ListNotificationEndpoints.tsx b/portal-ui/src/screens/Console/NotificationEndpoints/ListNotificationEndpoints.tsx index 8b8e09718..411edc6fb 100644 --- a/portal-ui/src/screens/Console/NotificationEndpoints/ListNotificationEndpoints.tsx +++ b/portal-ui/src/screens/Console/NotificationEndpoints/ListNotificationEndpoints.tsx @@ -147,6 +147,7 @@ const ListNotificationEndpoints = ({ placeholder="Search target" onChange={setFilter} overrideClass={classes.searchField} + value={filter} />
{ type: OBJECT_MANAGER_CLOSE_LIST, }; }; + +export const setSearchObjects = (searchString: string) => { + return { + type: OBJECT_MANAGER_SET_SEARCH_OBJECT, + searchString, + } +}; diff --git a/portal-ui/src/screens/Console/ObjectBrowser/reducers.ts b/portal-ui/src/screens/Console/ObjectBrowser/reducers.ts index af20656ad..cc40ecdca 100644 --- a/portal-ui/src/screens/Console/ObjectBrowser/reducers.ts +++ b/portal-ui/src/screens/Console/ObjectBrowser/reducers.ts @@ -26,6 +26,7 @@ import { OBJECT_MANAGER_TOGGLE_LIST, OBJECT_MANAGER_CLOSE_LIST, OBJECT_MANAGER_OPEN_LIST, + OBJECT_MANAGER_SET_SEARCH_OBJECT, } from "./actions"; export interface Route { @@ -44,6 +45,7 @@ export interface ObjectBrowserState { fileMode: boolean; rewind: RewindItem; objectManager: ObjectManager; + searchObjects: string; } export interface ObjectBrowserReducer { @@ -80,6 +82,7 @@ const initialState: ObjectBrowserState = { objectsToManage: [], managerOpen: false, }, + searchObjects: "", }; export function objectBrowserReducer( @@ -212,6 +215,11 @@ export function objectBrowserReducer( managerOpen: false, }, }; + case OBJECT_MANAGER_SET_SEARCH_OBJECT: + return { + ...state, + searchObjects: action.searchString, + }; default: return state; } diff --git a/portal-ui/src/screens/Console/Policies/ListPolicies.tsx b/portal-ui/src/screens/Console/Policies/ListPolicies.tsx index 5b90fe454..85ad11b76 100644 --- a/portal-ui/src/screens/Console/Policies/ListPolicies.tsx +++ b/portal-ui/src/screens/Console/Policies/ListPolicies.tsx @@ -202,6 +202,7 @@ const ListPolicies = ({ classes, setErrorSnackMessage }: IPoliciesProps) => { onChange={setFilterPolicies} placeholder="Search Policies" overrideClass={classes.searchField} + value={filterPolicies} /> { setFilter(value); }} + value={filter} />
diff --git a/portal-ui/src/screens/Console/Tenants/ListTenants/ListTenants.tsx b/portal-ui/src/screens/Console/Tenants/ListTenants/ListTenants.tsx index 9d5a245db..799314a5b 100644 --- a/portal-ui/src/screens/Console/Tenants/ListTenants/ListTenants.tsx +++ b/portal-ui/src/screens/Console/Tenants/ListTenants/ListTenants.tsx @@ -204,6 +204,7 @@ const ListTenants = ({ classes, setErrorSnackMessage }: ITenantsList) => { setFilterTenants(val); }} overrideClass={classes.searchField} + value={filterTenants} />
diff --git a/portal-ui/src/screens/Console/Users/ListUsers.tsx b/portal-ui/src/screens/Console/Users/ListUsers.tsx index 01023dfbb..850ed5e58 100644 --- a/portal-ui/src/screens/Console/Users/ListUsers.tsx +++ b/portal-ui/src/screens/Console/Users/ListUsers.tsx @@ -244,6 +244,7 @@ const ListUsers = ({ classes, setErrorSnackMessage, history }: IUsersProps) => { placeholder={"Search Users"} onChange={setFilter} overrideClass={classes.searchField} + value={filter} />