From b8a125f51888c307f187779f19841ab2cfbd954b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 2 May 2022 19:40:46 -0500 Subject: cleanup --- .../src/components/Search/List/SearchActionIcon.js | 27 ++++++++++++++ src/web/src/components/Search/List/SearchList.js | 8 +---- .../src/components/Search/List/SearchListRow.js | 42 +++++++++------------- .../src/components/Search/List/SearchStatusIcon.js | 35 ++++++++++++++++++ src/web/src/components/Search/SearchIcon.js | 35 ------------------ src/web/src/components/Search/Searches.js | 4 --- 6 files changed, 79 insertions(+), 72 deletions(-) create mode 100644 src/web/src/components/Search/List/SearchActionIcon.js create mode 100644 src/web/src/components/Search/List/SearchStatusIcon.js delete mode 100644 src/web/src/components/Search/SearchIcon.js (limited to 'src/web') diff --git a/src/web/src/components/Search/List/SearchActionIcon.js b/src/web/src/components/Search/List/SearchActionIcon.js new file mode 100644 index 00000000..98455241 --- /dev/null +++ b/src/web/src/components/Search/List/SearchActionIcon.js @@ -0,0 +1,27 @@ +import React from 'react'; + +import { Icon } from 'semantic-ui-react'; + +const SearchActionIcon = ({ search, loading, onRemove, onStop,...props }) => { + if (loading) { + return () + } + + if (search.state.includes('Completed')) { + return ( onRemove()} + style={{ cursor: 'pointer' }} + />) + } + + return ( onStop()} + style={{ cursor: 'pointer' }} + />) +}; + +export default SearchActionIcon; \ No newline at end of file diff --git a/src/web/src/components/Search/List/SearchList.js b/src/web/src/components/Search/List/SearchList.js index 1bbeedb9..71f55307 100644 --- a/src/web/src/components/Search/List/SearchList.js +++ b/src/web/src/components/Search/List/SearchList.js @@ -1,4 +1,3 @@ -import { isEmpty } from 'lodash'; import React, { useState, useEffect, useRef, useMemo } from 'react'; import { v4 as uuidv4 } from 'uuid'; @@ -19,7 +18,6 @@ import { Header, List } from 'semantic-ui-react'; -import SearchIcon from '../SearchIcon'; const SearchList = () => { const [{ connected, connecting, connectError} , setConnected] = useState({ connected: false, connecting: true, connectError: false }); @@ -99,10 +97,6 @@ const SearchList = () => { } } - const get = async () => { - - } - const remove = async (search) => { console.log('remove', searches) try { @@ -142,7 +136,7 @@ const SearchList = () => { No searches to display } > - +
diff --git a/src/web/src/components/Search/List/SearchListRow.js b/src/web/src/components/Search/List/SearchListRow.js index 860bf465..24d24082 100644 --- a/src/web/src/components/Search/List/SearchListRow.js +++ b/src/web/src/components/Search/List/SearchListRow.js @@ -1,14 +1,14 @@ import React, { useState } from 'react'; -import SearchIcon from '../SearchIcon'; +import SearchStatusIcon from './SearchStatusIcon'; +import SearchActionIcon from './SearchActionIcon'; import { Table, Icon, - Checkbox } from 'semantic-ui-react'; -const SearchListRow = ({ search, index, onRemove, onStop }) => { +const SearchListRow = ({ search, onRemove, onStop }) => { const [working, setWorking] = useState(false); const invoke = async (func) => { @@ -17,39 +17,29 @@ const SearchListRow = ({ search, index, onRemove, onStop }) => { setWorking(false); } - const ActionIcon = () => { - if (working) { - return () - } - - if (search.state.includes('Completed')) { - return ( invoke(() => onRemove(search))} - />) - } - - return ( invoke(() => onStop(search))} - />) - } - return ( - + + + {search.searchText} {search.fileCount} {search.lockedFileCount} {search.responseCount} {search.endedAt ? new Date(search.endedAt).toLocaleTimeString() : '-'} - - + + invoke(() => onRemove(search))} + onStop={() => invoke(() => onStop(search))} + style={{ cursor: 'pointer' }} + /> ) diff --git a/src/web/src/components/Search/List/SearchStatusIcon.js b/src/web/src/components/Search/List/SearchStatusIcon.js new file mode 100644 index 00000000..c5de5d72 --- /dev/null +++ b/src/web/src/components/Search/List/SearchStatusIcon.js @@ -0,0 +1,35 @@ +import React from 'react'; + +import { Icon, Popup } from 'semantic-ui-react'; + +// as of 4.5.2, states are: +// transient: +// None, Requested, InProgress +// terminal: +// good: Completed, [TimedOut | ResponseLimitReached | FileLimitReached] +// bad: Completed, [Errored | Cancelled] + +const getIcon = ({ state, ...props }) => { + switch (state) { + case 'None': + case 'Requested': + return + case 'InProgress': + return + case 'Completed, TimedOut': + case 'Completed, ResponseLimitReached': + case 'Completed, FileLimitReached': + return + case 'Completed, Cancelled': + return + case 'Completed, Errored': + return + default: + return + } +} + +const SearchStatusIcon = ({ state, ...props }) => + + +export default SearchStatusIcon; \ No newline at end of file diff --git a/src/web/src/components/Search/SearchIcon.js b/src/web/src/components/Search/SearchIcon.js deleted file mode 100644 index 05704643..00000000 --- a/src/web/src/components/Search/SearchIcon.js +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react'; - -import { Icon, Popup } from 'semantic-ui-react'; - -// as of 4.5.2, states are: -// transient: -// None, Requested, InProgress -// terminal: -// good: Completed, [TimedOut | ResponseLimitReached | FileLimitReached] -// bad: Completed, [Errored | Cancelled] - -const getIcon = ({ state, ...props }) => { - switch (state) { - case 'None': - case 'Requested': - return - case 'InProgress': - return - case 'Completed, TimedOut': - case 'Completed, ResponseLimitReached': - case 'Completed, FileLimitReached': - return - case 'Completed, Cancelled': - return - case 'Completed, Errored': - return - default: - return - } -} - -const SearchIcon = ({ state, ...props }) => - - -export default SearchIcon; \ No newline at end of file diff --git a/src/web/src/components/Search/Searches.js b/src/web/src/components/Search/Searches.js index ca541cee..f8dff702 100644 --- a/src/web/src/components/Search/Searches.js +++ b/src/web/src/components/Search/Searches.js @@ -12,11 +12,7 @@ import './Search.css'; import { Input, Segment, - Card, - Table, - Icon } from 'semantic-ui-react'; -import SearchIcon from './SearchIcon'; const Searches = () => { const [{ loading, loadError }, setLoading] = useState({ loading: true, loadError: false }); -- cgit v1.2.3