1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-03 01:18:43 +02:00

feat: feature table tags (#5659)

- tags on project overview
- refactor of tags cell
This commit is contained in:
Tymoteusz Czech 2023-12-15 16:22:19 +01:00 committed by GitHub
parent d429f51cbd
commit 50ff36cbce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 8 deletions

View File

@ -1,5 +1,5 @@
import { VFC } from 'react'; import { VFC } from 'react';
import { FeatureSchema } from 'openapi'; import { FeatureSchema, TagSchema } from 'openapi';
import { styled, Typography } from '@mui/material'; import { styled, Typography } from '@mui/material';
import { TextCell } from '../TextCell/TextCell'; import { TextCell } from '../TextCell/TextCell';
import { Highlighter } from 'component/common/Highlighter/Highlighter'; import { Highlighter } from 'component/common/Highlighter/Highlighter';
@ -14,21 +14,25 @@ interface IFeatureTagCellProps {
row: { row: {
original: FeatureSchema; original: FeatureSchema;
}; };
value: string;
} }
export const FeatureTagCell: VFC<IFeatureTagCellProps> = ({ row, value }) => { export const FeatureTagCell: VFC<IFeatureTagCellProps> = ({ row }) => {
const { searchQuery } = useSearchHighlightContext(); const { searchQuery } = useSearchHighlightContext();
if (!row.original.tags || row.original.tags.length === 0) if (!row.original.tags || row.original.tags.length === 0)
return <TextCell />; return <TextCell />;
const value =
row.original.tags
?.map(({ type, value }) => `${type}:${value}`)
.join('\n') || '';
return ( return (
<TextCell> <TextCell>
<TooltipLink <TooltipLink
highlighted={ highlighted={
searchQuery.length > 0 && searchQuery.length > 0 &&
value.toLowerCase().includes(searchQuery.toLowerCase()) value?.toLowerCase().includes(searchQuery.toLowerCase())
} }
tooltip={ tooltip={
<> <>

View File

@ -197,9 +197,7 @@ const FeatureToggleListTableComponent: VFC = () => {
.join('\n') || '', .join('\n') || '',
{ {
header: 'Tags', header: 'Tags',
cell: ({ getValue, row }) => ( cell: FeatureTagCell,
<FeatureTagCell value={getValue()} row={row} />
),
enableSorting: false, enableSorting: false,
}, },
), ),

View File

@ -49,6 +49,7 @@ import { useDefaultColumnVisibility } from './hooks/useDefaultColumnVisibility';
import { Placeholder } from './TablePlaceholder/TablePlaceholder'; import { Placeholder } from './TablePlaceholder/TablePlaceholder';
import { useRowActions } from './hooks/useRowActions'; import { useRowActions } from './hooks/useRowActions';
import { useUiFlag } from 'hooks/useUiFlag'; import { useUiFlag } from 'hooks/useUiFlag';
import { FeatureTagCell } from 'component/common/Table/cells/FeatureTagCell/FeatureTagCell';
interface IPaginatedProjectFeatureTogglesProps { interface IPaginatedProjectFeatureTogglesProps {
environments: IProject['environments']; environments: IProject['environments'];
@ -208,6 +209,14 @@ export const PaginatedProjectFeatureToggles = ({
width: '50%', width: '50%',
}, },
}), }),
columnHelper.accessor('tags', {
id: 'tags',
header: 'Tags',
cell: FeatureTagCell,
meta: {
width: '1%',
},
}),
columnHelper.accessor('createdAt', { columnHelper.accessor('createdAt', {
id: 'createdAt', id: 'createdAt',
header: 'Created', header: 'Created',
@ -396,6 +405,11 @@ export const PaginatedProjectFeatureToggles = ({
isVisible: columnVisibility.name, isVisible: columnVisibility.name,
isStatic: true, isStatic: true,
}, },
{
header: 'Tags',
id: 'tags',
isVisible: columnVisibility.tags,
},
{ {
header: 'Created', header: 'Created',
id: 'createdAt', id: 'createdAt',

View File

@ -57,6 +57,7 @@ export const useDefaultColumnVisibility = (allColumnIds: string[]) => {
'lastSeenAt', 'lastSeenAt',
'createdAt', 'createdAt',
'type', 'type',
...showEnvironments(3), 'tags',
...showEnvironments(2),
]); ]);
}; };