diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-05-02 19:40:46 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-05-02 19:40:46 -0500 |
| commit | b8a125f51888c307f187779f19841ab2cfbd954b (patch) | |
| tree | fd181302b9c0715baf20aaa34ab366397f7e053b /src/web | |
| parent | 21a87f6f9cb86842dce3145da1014c154f66267a (diff) | |
| download | slskd-b8a125f51888c307f187779f19841ab2cfbd954b.tar.gz | |
cleanup
Diffstat (limited to 'src/web')
| -rw-r--r-- | src/web/src/components/Search/List/SearchActionIcon.js | 27 | ||||
| -rw-r--r-- | src/web/src/components/Search/List/SearchList.js | 8 | ||||
| -rw-r--r-- | src/web/src/components/Search/List/SearchListRow.js | 42 | ||||
| -rw-r--r-- | src/web/src/components/Search/List/SearchStatusIcon.js (renamed from src/web/src/components/Search/SearchIcon.js) | 4 | ||||
| -rw-r--r-- | src/web/src/components/Search/Searches.js | 4 |
5 files changed, 46 insertions, 39 deletions
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 (<Icon name='spinner' loading {...props}/>) + } + + if (search.state.includes('Completed')) { + return (<Icon + name="trash alternate" + color='red' + onClick={() => onRemove()} + style={{ cursor: 'pointer' }} + />) + } + + return (<Icon + name="stop circle" + color="red" + onClick={() => 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 = () => { <Segment basic style={{opacity: .5}} textAlign='center'>No searches to display</Segment> } > - <Table selectable> + <Table> <Table.Header> <Table.Row> <Table.HeaderCell className="search-list-action"><Icon name="info circle"/></Table.HeaderCell> 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 (<Icon name='spinner' loading/>) - } - - if (search.state.includes('Completed')) { - return (<Icon - name="trash alternate" - color='red' - onClick={() => invoke(() => onRemove(search))} - />) - } - - return (<Icon - name="stop circle" - color="red" - onClick={() => invoke(() => onStop(search))} - />) - } - return ( <Table.Row disabled={working} style={{ cursor: working ? 'wait' : undefined }} > - <Table.Cell><SearchIcon state={search.state}/></Table.Cell> + <Table.Cell> + <SearchStatusIcon + state={search.state} + /> + </Table.Cell> <Table.Cell><a href={`searches/${search.id}`}>{search.searchText}</a></Table.Cell> <Table.Cell>{search.fileCount}</Table.Cell> <Table.Cell><Icon name="lock" color="yellow" size="small"/>{search.lockedFileCount}</Table.Cell> <Table.Cell>{search.responseCount}</Table.Cell> <Table.Cell>{search.endedAt ? new Date(search.endedAt).toLocaleTimeString() : '-'}</Table.Cell> - <Table.Cell style={{ cursor: 'pointer' }}> - <ActionIcon/> + <Table.Cell> + <SearchActionIcon + search={search} + loading={working} + onRemove={() => invoke(() => onRemove(search))} + onStop={() => invoke(() => onStop(search))} + style={{ cursor: 'pointer' }} + /> </Table.Cell> </Table.Row> ) diff --git a/src/web/src/components/Search/SearchIcon.js b/src/web/src/components/Search/List/SearchStatusIcon.js index 05704643..c5de5d72 100644 --- a/src/web/src/components/Search/SearchIcon.js +++ b/src/web/src/components/Search/List/SearchStatusIcon.js @@ -29,7 +29,7 @@ const getIcon = ({ state, ...props }) => { } } -const SearchIcon = ({ state, ...props }) => +const SearchStatusIcon = ({ state, ...props }) => <Popup content={state} trigger={getIcon({ state, ...props })}/> -export default SearchIcon;
\ No newline at end of file +export default SearchStatusIcon;
\ 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 }); |
