From d281b8796dcb73805a18606b99f803b85f051d16 Mon Sep 17 00:00:00 2001 From: Maksym Yadlovskyi Date: Fri, 18 Nov 2022 13:44:35 +0000 Subject: [PATCH] Add new sort icon to CollectorsList --- src/web/collectors/CollectorsList.jsx | 56 +++++++++++---------------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/src/web/collectors/CollectorsList.jsx b/src/web/collectors/CollectorsList.jsx index 673a0347..d2c1249b 100644 --- a/src/web/collectors/CollectorsList.jsx +++ b/src/web/collectors/CollectorsList.jsx @@ -21,7 +21,7 @@ import { defaultCompare as naturalSort } from 'logic/DefaultCompare'; import styled from 'styled-components'; import { Alert, Button, Col, Row, Table } from 'components/bootstrap'; -import { Icon, Spinner } from 'components/common'; +import { Spinner, SortIcon } from 'components/common'; import CollectorsStore from './CollectorsStore'; import CollectorsActions from './CollectorsActions'; @@ -33,17 +33,8 @@ const StyledTable = styled(Table)` margin-bottom: 0px; `; -const StyledIcon = styled(Icon)(({ $isAlwaysVisible }) => ` +const StyledSortIcon = styled(SortIcon)` margin-left: 5px; - visibility: ${$isAlwaysVisible ? 'visible' : 'hidden'} -`); - -const SortableTh = styled.th` - cursor: pointer; - - &:hover ${StyledIcon} { - visibility: visible; - } `; const CollectorList = createReactClass({ @@ -90,11 +81,10 @@ const CollectorList = createReactClass({ return (this.state.sortDesc ? naturalSort(field2, field1) : naturalSort(field1, field2)); }, - _getSortingIcon(field) { + _getSortingIcon(field, onChange) { const { sortBy, sortDesc } = this.state; - const name = (sortBy === field ? (sortDesc ? 'sort-amount-up' : 'sort-amount-down') : 'sort'); - - return ; + const activeDirection = (sortBy === field ? (sortDesc ? 'desc' : 'asc') : null); + return }, _formatCollectorList(collectors) { @@ -103,30 +93,30 @@ const CollectorList = createReactClass({ - + Name - {this._getSortingIcon('node_id')} - - + {this._getSortingIcon('node_id', this.sortByNodeId)} + + Status - {this._getSortingIcon('collector_status')} - - + {this._getSortingIcon('collector_status', this.sortByCollectorStatus)} + + Operating System - {this._getSortingIcon('operating_system')} - - + {this._getSortingIcon('operating_system', this.sortByOperatingSystem)} + + Last Seen - {this._getSortingIcon('last_seen')} - - + {this._getSortingIcon('last_seen', this.sortByLastSeen)} + + Collector Id - {this._getSortingIcon('id')} - - + {this._getSortingIcon('id', this.sortById)} + + Collector Version - {this._getSortingIcon('collector_version')} - + {this._getSortingIcon('collector_version', this.sortByCollectorVersion)} +