From 82d27a463cdad31c7dcedec1c4afcf7a907c08db Mon Sep 17 00:00:00 2001 From: barreiro Date: Tue, 31 Dec 2024 07:25:36 +0000 Subject: [PATCH] Remove usage of deprecated Dropdown component --- horreum-web/src/About.tsx | 53 ++++++++-------- .../src/components/HttpActionUrlSelector.tsx | 52 ++++------------ .../src/domain/runs/JsonPathSearchToolbar.tsx | 62 +++++++------------ 3 files changed, 59 insertions(+), 108 deletions(-) diff --git a/horreum-web/src/About.tsx b/horreum-web/src/About.tsx index d92570cad..70631ffb1 100644 --- a/horreum-web/src/About.tsx +++ b/horreum-web/src/About.tsx @@ -1,20 +1,19 @@ -import { useState, useEffect } from "react" +import {useState, useEffect, Ref} from "react" import { - Bullseye, - Button, + Bullseye, + Button, DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm, - MenuToggle, - Modal, - Spinner + Dropdown, + DropdownItem, + DropdownList, + MenuToggle, + MenuToggleElement, + Modal, + Spinner } from '@patternfly/react-core'; -import { - Dropdown, - DropdownItem, - DropdownToggle -} from '@patternfly/react-core/deprecated'; import { QuestionCircleIcon } from "@patternfly/react-icons" import MoonIcon from '@patternfly/react-icons/dist/esm/icons/moon-icon'; @@ -60,18 +59,20 @@ export default function About() { { isDarkTheme ? : } setDropdownOpen(false)} - toggle={ - setDropdownOpen(val)} id="toggle-icon-only"> - - - } isOpen={isDropdownOpen} - isPlain - dropdownItems={[ + onSelect={() => setDropdownOpen(false)} + popperProps={{preventOverflow: true, position: "end"}} + toggle={(toggleRef: Ref) => ( + setDropdownOpen(!isDropdownOpen)}> + + + )} + > + { @@ -80,12 +81,12 @@ export default function About() { }} > Project documentation - , + setModalOpen(true)}> Version info - , - ]} - /> + + + value.startsWith(p.prefix)) const extraCheckResult = extraCheck ? extraCheck(value) : true - - const [dropdownOpen, setDropdownOpen] = useState(false) - - const ref = useRef() - return ( - {!isReadOnly && ( - { - if (event && event.currentTarget) { - if (setValid) { - setValid(true) - } - setValue(event.currentTarget.innerText) - } - setDropdownOpen(false) - if (ref.current) { - ref.current.focus() - } - }} - toggle={ - setDropdownOpen(val)} isDisabled={isDisabled}> - Pick URL prefix - - } - isOpen={dropdownOpen} - dropdownItems={prefixes.map((p, i) => ( - - {p.prefix} - - ))} + {!isReadOnly && + ({value: p.prefix, content: p.prefix, selected: false}))} + onSelect={(_, item) => setValue(item as string)} /> - )} + } ([]) function runPathQuery(type?: string, query?: string) { @@ -118,36 +118,16 @@ export default function JsonPathSearchToolbar(props: ToolbarProps) { - ) => { - if (e) { - setPathType(e.currentTarget.id) - onQueryUpdate(e.currentTarget.id, pathQuery) - } - setPathTypeOpen(false) - }} - toggle={ - { - setPathTypeOpen(e) - }} - > - {pathType} - - } - dropdownItems={[ - - jsonb_path_query_first - , - - jsonb_path_query_array - , - - js - - ]} - > + + ({value: t, content: t, selected: pathType === t}) + )} + selected={pathType} + onSelect={(_, item) => setPathType(item as string)} + toggleWidth="225px" + /> + - {pathType == "js" ? ( + {pathType == JS_QUERY_LOCAL ? ( <>

Variant js executes the search expression inside your browser using{" "}