From 1470c726fb20a8d5006ebdb8e8fd8b86087a7083 Mon Sep 17 00:00:00 2001 From: Guillaume Paris Date: Wed, 11 Sep 2024 09:47:31 +0200 Subject: [PATCH] [frontend] align style with octi --- .../assets/asset_groups/AssetGroups.tsx | 36 +++++++++---------- .../common/queryable/filter/FilterChip.tsx | 20 +++++++---- .../queryable/filter/FilterChipPopover.tsx | 3 +- .../common/queryable/filter/FilterUtils.tsx | 12 +++---- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/openbas-front/src/admin/components/assets/asset_groups/AssetGroups.tsx b/openbas-front/src/admin/components/assets/asset_groups/AssetGroups.tsx index e4423254a1..41f27b533a 100644 --- a/openbas-front/src/admin/components/assets/asset_groups/AssetGroups.tsx +++ b/openbas-front/src/admin/components/assets/asset_groups/AssetGroups.tsx @@ -119,14 +119,14 @@ const AssetGroups = () => { return ( <> - + -
+
{ searchPaginationInput={searchPaginationInput} setSearchPaginationInput={setSearchPaginationInput} /> - } + } />   @@ -165,7 +165,7 @@ const AssetGroups = () => { onClick={() => setSelectedAssetGroupId(assetGroup.asset_group_id)} > - + { ? assetGroup.asset_group_dynamic_filter?.filters.map((filter, index) => ( <> { - index !== 0 && + index !== 0 && {t(assetGroup.asset_group_dynamic_filter?.mode?.toUpperCase())} } @@ -189,17 +189,17 @@ const AssetGroups = () => { size="small" style={index !== assetGroup.asset_group_dynamic_filter?.filters?.length ? { marginRight: 10 } : {}} key={filter.key} - label={<>{t(filter.key)} {convertOperatorToIcon(t, filter.operator)} {filter.values?.join(', ')}} + label={<>{t(filter.key)} {convertOperatorToIcon(t, filter.operator)}{' '}{filter.values?.join(', ')}} /> )) : ''} {assetGroup.asset_group_assets?.length ? `${assetGroup.asset_group_dynamic_filter?.filters?.length ? t('and') : ''} ${assetGroup.asset_group_assets?.length} ${t('managed assets')}` : ''}
- +
- } + } /> { ))} - {userAdmin && setAssetGroups([result, ...assetGroups])}/>} + {userAdmin && setAssetGroups([result, ...assetGroups])} />} { elevation={1} > {selectedAssetGroupId !== undefined && ( - setSelectedAssetGroupId(undefined)} - onUpdate={(result) => setAssetGroups(assetGroups.map((ag) => (ag.asset_group_id !== result.asset_group_id ? ag : result)))} - onRemoveEndpointFromAssetGroup={(assetId) => setAssetGroups(assetGroups.map((ag) => (ag.asset_group_id !== selectedAssetGroupId ? ag : { - ...ag, - asset_group_assets: ag?.asset_group_assets?.toSpliced(ag?.asset_group_assets?.indexOf(assetId), 1), - })))} - /> + setSelectedAssetGroupId(undefined)} + onUpdate={(result) => setAssetGroups(assetGroups.map((ag) => (ag.asset_group_id !== result.asset_group_id ? ag : result)))} + onRemoveEndpointFromAssetGroup={(assetId) => setAssetGroups(assetGroups.map((ag) => (ag.asset_group_id !== selectedAssetGroupId ? ag : { + ...ag, + asset_group_assets: ag?.asset_group_assets?.toSpliced(ag?.asset_group_assets?.indexOf(assetId), 1), + })))} + /> )} diff --git a/openbas-front/src/components/common/queryable/filter/FilterChip.tsx b/openbas-front/src/components/common/queryable/filter/FilterChip.tsx index a50b54f81c..44f02cafb0 100644 --- a/openbas-front/src/components/common/queryable/filter/FilterChip.tsx +++ b/openbas-front/src/components/common/queryable/filter/FilterChip.tsx @@ -1,7 +1,6 @@ import React, { FunctionComponent, useEffect, useRef, useState } from 'react'; import { Chip, Tooltip } from '@mui/material'; import { makeStyles } from '@mui/styles'; -import classNames from 'classnames'; import { FilterHelpers } from './FilterHelpers'; import FilterChipPopover from './FilterChipPopover'; import type { Filter, PropertySchemaDTO } from '../../../../utils/api-types'; @@ -28,6 +27,10 @@ const useStyles = makeStyles((theme: Theme) => ({ // display: 'flex', // alignItems: 'center', }, + title: { + cursor: 'pointer', + '&:hover': { textDecorationLine: 'underline' }, + }, })); interface Props { @@ -81,10 +84,14 @@ const FilterChip: FunctionComponent = ({ }); }; - const title = (withStyle: boolean) => { + const title = (isTooltip: boolean) => { + if (isTooltip) { + return ({t(filter.key)}{' '}{convertOperatorToIcon(t, filter.operator)} {toValues(options)}); + } return ( - - {t(filter.key)} {convertOperatorToIcon(t, filter.operator)} {toValues(options)} + + {t(filter.key)}{' '} + {convertOperatorToIcon(t, filter.operator)} {toValues(options)} ); }; @@ -92,11 +99,10 @@ const FilterChip: FunctionComponent = ({ return ( <> = ({ const displayOperatorAndFilter = () => { // Specific field if (propertySchema.schema_property_name === 'scenario_recurrence') { - return (); + return (); } const operators = availableOperators(propertySchema); @@ -43,6 +43,7 @@ const FilterChipPopover: FunctionComponent = ({