From 12ccc35465336ab76cbea4b8e86e637c26d6c04e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 17 May 2022 08:14:50 -0500 Subject: media queries, ability to re-search --- .../src/components/Search/Detail/SearchDetail.js | 5 +- .../components/Search/Detail/SearchDetailHeader.js | 57 ++++++++++++++++------ src/web/src/components/Search/Searches.js | 15 ++++-- 3 files changed, 55 insertions(+), 22 deletions(-) (limited to 'src/web') diff --git a/src/web/src/components/Search/Detail/SearchDetail.js b/src/web/src/components/Search/Detail/SearchDetail.js index 5cadd941..19cc1b84 100644 --- a/src/web/src/components/Search/Detail/SearchDetail.js +++ b/src/web/src/components/Search/Detail/SearchDetail.js @@ -20,7 +20,7 @@ const sortDropdownOptions = [ { key: 'queueLength', text: 'Queue Depth (Least to Most)', value: 'queueLength' } ]; -const SearchDetail = ({ search, onStop, onRemove }) => { +const SearchDetail = ({ search, onCreate, onStop, onRemove }) => { const { id, state, isComplete, fileCount, lockedFileCount, responseCount } = search; const [loading, setLoading] = useState(false); @@ -96,7 +96,8 @@ const SearchDetail = ({ search, onStop, onRemove }) => { <> diff --git a/src/web/src/components/Search/Detail/SearchDetailHeader.js b/src/web/src/components/Search/Detail/SearchDetailHeader.js index 0768d963..7b78d134 100644 --- a/src/web/src/components/Search/Detail/SearchDetailHeader.js +++ b/src/web/src/components/Search/Detail/SearchDetailHeader.js @@ -1,4 +1,5 @@ import React from 'react'; +import { useMediaQuery } from 'react-responsive'; import { Segment, @@ -8,7 +9,10 @@ import { } from 'semantic-ui-react'; import SearchStatusIcon from '../SearchStatusIcon'; -const SearchDetailHeader = ({ search, loading, onStop, onRemove }) => { +const SearchDetailHeader = ({ search, loading, onCreate, onStop, onRemove }) => { + const isSmallScreen = useMediaQuery({ query: '(max-width: 899px)' }); + const isTinyScreen = useMediaQuery({ query: '(max-width: 684px)'}); + const { searchText, isComplete, state } = search; const stopOrRemove = () => { @@ -19,22 +23,43 @@ const SearchDetailHeader = ({ search, loading, onStop, onRemove }) => { } } + const RefreshButton = ({ ...props }) => + + + const StopOrDeleteButton = ({ ...props }) => + + return ( - -
- - {searchText} -
- -
+ <> + +
+ {searchText} +
+ {!isTinyScreen &&
+ + +
} +
+ {isTinyScreen && + + + } + ) }; diff --git a/src/web/src/components/Search/Searches.js b/src/web/src/components/Search/Searches.js index 31e77e08..32496bf9 100644 --- a/src/web/src/components/Search/Searches.js +++ b/src/web/src/components/Search/Searches.js @@ -93,20 +93,26 @@ const Searches = () => { } }, []); - const create = async ({ navigate = false } = {}) => { - const searchText = inputRef.current.inputRef.current.value; + const create = async ({ search, navigate = false } = {}) => { + const searchText = search || inputRef.current.inputRef.current.value; const id = uuidv4(); try { setCreating({ creating: true, createError: false }) await lib.create({ id, searchText }) setCreating({ creating: false, createError: false }) - inputRef.current.inputRef.current.value = ''; + + try { + inputRef.current.inputRef.current.value = ''; + } catch { + // no-op + } if (navigate) { - history.push(`${match.url}/${id}`) + history.push(`/searches/${id}`) } } catch (error) { + console.error(error) setCreating({ creating: false, createError: error.message }) } } @@ -140,6 +146,7 @@ const Searches = () => { return ( -- cgit v1.2.3