Skip to content

Commit

Permalink
[frontend] align style with octi
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumejparis committed Sep 11, 2024
1 parent b8084ac commit 1470c72
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ const AssetGroups = () => {

return (
<>
<Breadcrumbs variant="list" elements={[{ label: t('Assets') }, { label: t('Asset groups'), current: true }]}/>
<Breadcrumbs variant="list" elements={[{ label: t('Assets') }, { label: t('Asset groups'), current: true }]} />
<PaginationComponent
fetch={searchAssetGroups}
searchPaginationInput={searchPaginationInput}
setContent={setAssetGroups}
exportProps={exportProps}
/>
<div className="clearfix"/>
<div className="clearfix" />
<List>
<ListItem
classes={{ root: classes.itemHead }}
Expand All @@ -152,7 +152,7 @@ const AssetGroups = () => {
searchPaginationInput={searchPaginationInput}
setSearchPaginationInput={setSearchPaginationInput}
/>
}
}
/>
<ListItemSecondaryAction> &nbsp; </ListItemSecondaryAction>
</ListItem>
Expand All @@ -165,7 +165,7 @@ const AssetGroups = () => {
onClick={() => setSelectedAssetGroupId(assetGroup.asset_group_id)}
>
<ListItemIcon>
<SelectGroup color="primary"/>
<SelectGroup color="primary" />
</ListItemIcon>
<ListItemText
primary={
Expand All @@ -181,25 +181,25 @@ const AssetGroups = () => {
? assetGroup.asset_group_dynamic_filter?.filters.map((filter, index) => (
<>
{
index !== 0 && <span style={{ marginRight: 10 }}>
index !== 0 && <span style={{ marginRight: 10 }}>
{t(assetGroup.asset_group_dynamic_filter?.mode?.toUpperCase())}
</span>
}
<Chip
size="small"
style={index !== assetGroup.asset_group_dynamic_filter?.filters?.length ? { marginRight: 10 } : {}}
key={filter.key}
label={<><strong>{t(filter.key)}</strong> {convertOperatorToIcon(t, filter.operator)} {filter.values?.join(', ')}</>}
label={<><strong>{t(filter.key)}</strong> {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')}` : ''}
</div>
<div className={classes.bodyItem} style={inlineStyles.asset_group_tags}>
<ItemTags variant="list" tags={assetGroup.asset_group_tags}/>
<ItemTags variant="list" tags={assetGroup.asset_group_tags} />
</div>
</div>
}
}
/>
<ListItemSecondaryAction>
<AssetGroupPopover
Expand All @@ -216,7 +216,7 @@ const AssetGroups = () => {
</ListItem>
))}
</List>
{userAdmin && <AssetGroupCreation onCreate={(result) => setAssetGroups([result, ...assetGroups])}/>}
{userAdmin && <AssetGroupCreation onCreate={(result) => setAssetGroups([result, ...assetGroups])} />}
<MuiDrawer
open={selectedAssetGroupId !== undefined}
keepMounted={false}
Expand All @@ -227,15 +227,15 @@ const AssetGroups = () => {
elevation={1}
>
{selectedAssetGroupId !== undefined && (
<AssetGroupManagement
assetGroupId={selectedAssetGroupId}
handleClose={() => 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),
})))}
/>
<AssetGroupManagement
assetGroupId={selectedAssetGroupId}
handleClose={() => 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),
})))}
/>
)}
</MuiDrawer>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -28,6 +27,10 @@ const useStyles = makeStyles((theme: Theme) => ({
// display: 'flex',
// alignItems: 'center',
},
title: {
cursor: 'pointer',
'&:hover': { textDecorationLine: 'underline' },
},
}));

interface Props {
Expand Down Expand Up @@ -81,22 +84,25 @@ const FilterChip: FunctionComponent<Props> = ({
});
};

const title = (withStyle: boolean) => {
const title = (isTooltip: boolean) => {
if (isTooltip) {
return (<span><strong>{t(filter.key)}</strong>{' '}<span>{convertOperatorToIcon(t, filter.operator)} {toValues(options)}</span></span>);
}
return (
<span className={classNames({ [classes.container]: withStyle })}>
<strong>{t(filter.key)}</strong> {convertOperatorToIcon(t, filter.operator)} {toValues(options)}
<span className={classes.container}>
<strong onClick={handleOpen} className={classes.title}>{t(filter.key)}</strong>{' '}
<span>{convertOperatorToIcon(t, filter.operator)} {toValues(options)}</span>
</span>
);
};

return (
<>
<Tooltip
title={title(false)}
title={title(true)}
>
<Chip
label={title(true)}
onClick={handleOpen}
label={title(false)}
onDelete={handleRemoveFilter}
component="div"
ref={chipRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const FilterChipPopover: FunctionComponent<Props> = ({
const displayOperatorAndFilter = () => {
// Specific field
if (propertySchema.schema_property_name === 'scenario_recurrence') {
return (<ScenarioStatusFilter propertySchema={propertySchema} helpers={helpers}/>);
return (<ScenarioStatusFilter propertySchema={propertySchema} helpers={helpers} />);
}

const operators = availableOperators(propertySchema);
Expand All @@ -43,6 +43,7 @@ const FilterChipPopover: FunctionComponent<Props> = ({
<Select
value={filter.operator ?? operators[0]}
label="Operator"
variant="standard"
fullWidth
onChange={handleChangeOperator}
style={{ marginBottom: 15 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export const isEmptyFilter = (filterGroup: FilterGroup, key: string) => {
export const convertOperatorToIcon = (t: (text: string) => string, operator: Filter['operator']) => {
switch (operator) {
case 'eq':
return <>&nbsp;=</>;
return <>=</>;
case 'not_eq':
return <>&nbsp;&#8800;</>;
return <>&#8800;</>;
case 'not_contains':
return t('not contains');
case 'contains':
Expand All @@ -53,13 +53,13 @@ export const convertOperatorToIcon = (t: (text: string) => string, operator: Fil
case 'not_starts_with':
return t('not starts with');
case 'gt':
return <>&nbsp;&#62;</>;
return <>&#62;</>;
case 'gte':
return <>&nbsp;&#8805;</>;
return <>&#8805;</>;
case 'lt':
return <>&nbsp;&#60;</>;
return <>&#60;</>;
case 'lte':
return <>&nbsp;&#8804;</>;
return <>&#8804;</>;
case 'empty':
return t('is empty');
case 'not_empty':
Expand Down

0 comments on commit 1470c72

Please sign in to comment.