From 61f9c94f5a5de828cf95bcfa6e19a042ad52e166 Mon Sep 17 00:00:00 2001 From: Tristan Chuine Date: Tue, 12 Dec 2023 08:36:06 +0100 Subject: [PATCH] Remove now unused search component Move code to GridStudy --- .../element-search-dialog.js | 10 +- src/components/TopBar/TopBar.js | 92 +++---------------- 2 files changed, 19 insertions(+), 83 deletions(-) diff --git a/src/components/ElementSearchDialog/element-search-dialog.js b/src/components/ElementSearchDialog/element-search-dialog.js index 2bce31f4..b7636748 100644 --- a/src/components/ElementSearchDialog/element-search-dialog.js +++ b/src/components/ElementSearchDialog/element-search-dialog.js @@ -6,9 +6,9 @@ */ import React, { useCallback, useEffect, useState } from 'react'; -import { Dialog, DialogContent, TextField, Autocomplete } from '@mui/material'; +import { Autocomplete, Dialog, DialogContent, TextField } from '@mui/material'; import PropTypes from 'prop-types'; -import SearchIcon from '@mui/icons-material/Search'; +import { Search, SearchOff } from '@mui/icons-material'; import { useIntl } from 'react-intl'; const ElementSearchDialog = (props) => { @@ -134,7 +134,11 @@ const ElementSearchDialog = (props) => { ...params.InputProps, startAdornment: ( - + {searchTermDisabled ? ( + + ) : ( + + )} {params.InputProps.startAdornment} ), diff --git a/src/components/TopBar/TopBar.js b/src/components/TopBar/TopBar.js index 97560d94..ce2a4a8e 100644 --- a/src/components/TopBar/TopBar.js +++ b/src/components/TopBar/TopBar.js @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import React, { useEffect, useRef, useState, useMemo } from 'react'; +import React, { useMemo, useRef, useState } from 'react'; import { FormattedMessage } from 'react-intl'; import { @@ -13,6 +13,7 @@ import { Box, Button, ClickAwayListener, + IconButton, ListItemIcon, ListItemText, Menu, @@ -32,11 +33,10 @@ import { Brightness3 as Brightness3Icon, Computer as ComputerIcon, ExitToApp as ExitToAppIcon, - FullscreenExit as FullscreenExitIcon, Fullscreen as FullscreenIcon, + FullscreenExit as FullscreenExitIcon, HelpOutline as HelpOutlineIcon, Person as PersonIcon, - Search as SearchIcon, Settings as SettingsIcon, WbSunny as WbSunnyIcon, } from '@mui/icons-material'; @@ -46,7 +46,6 @@ import { styled } from '@mui/system'; import PropTypes from 'prop-types'; import FullScreen, { fullScreenSupported } from 'react-request-fullscreen'; -import ElementSearchDialog from '../ElementSearchDialog'; import GridLogo from './GridLogo'; import AboutDialog from './AboutDialog'; @@ -56,9 +55,8 @@ const styles = { display: 'flex', overflow: 'hidden', }, - menuIcon: { - width: 24, - height: 24, + menuContainer: { + marginLeft: 1, }, link: { textDecoration: 'none', @@ -174,28 +172,14 @@ const TopBar = ({ theme, onEquipmentLabellingClick, equipmentLabelling, - withElementsSearch, - searchDisabled, - searchingLabel, - onSearchTermChange, - onSelectionChange, - elementsFound, - renderElement, onLanguageClick, language, - searchTermDisabled, - searchTermDisableReason, }) => { const [anchorElSettingsMenu, setAnchorElSettingsMenu] = React.useState(null); const [anchorElAppsMenu, setAnchorElAppsMenu] = React.useState(null); const fullScreenRef = useRef(null); const [isFullScreen, setIsFullScreen] = useState(false); - const [isDialogSearchOpen, setDialogSearchOpen] = useState(false); - - const handleClickElementSearch = () => { - setDialogSearchOpen(true); - }; const handleToggleSettingsMenu = (event) => { setAnchorElSettingsMenu(event.currentTarget); @@ -267,23 +251,6 @@ const TopBar = ({ } }; - useEffect(() => { - if (user && withElementsSearch && !searchDisabled) { - const openSearch = (e) => { - if ( - e.ctrlKey && - e.shiftKey && - (e.key === 'F' || e.key === 'f') - ) { - e.preventDefault(); - setDialogSearchOpen(true); - } - }; - document.addEventListener('keydown', openSearch); - return () => document.removeEventListener('keydown', openSearch); - } - }, [user, withElementsSearch, searchDisabled]); - const logo_clickable = useMemo( () => ( {logo_clickable} {children} - {user && withElementsSearch && ( - - setDialogSearchOpen(false)} - searchingLabel={searchingLabel} - onSearchTermChange={onSearchTermChange} - onSelectionChange={(element) => { - setDialogSearchOpen(false); - onSelectionChange(element); - }} - elementsFound={elementsFound} - renderElement={renderElement} - searchTermDisabled={searchTermDisabled} - searchTermDisableReason={searchTermDisableReason} - /> -
- -
-
- )} {user && ( -
- + ))} -
+ )} {user && ( -
+ {/* Button width abbreviation and arrow icon */}
+ )}