mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-27 13:49:10 +02:00
feat: adjust columns for a search page refactor (#9709)
- Change "Project ID" to Project name column in search - Remove certain columns that are not present in new design
This commit is contained in:
parent
45a0ddd2a5
commit
28a69afe63
@ -1,4 +1,4 @@
|
|||||||
import { useCallback, useEffect, useMemo, useState, type VFC } from 'react';
|
import { useCallback, useEffect, useMemo, useState, type FC } from 'react';
|
||||||
import { Box, Link, useMediaQuery, useTheme } from '@mui/material';
|
import { Box, Link, useMediaQuery, useTheme } from '@mui/material';
|
||||||
import { Link as RouterLink } from 'react-router-dom';
|
import { Link as RouterLink } from 'react-router-dom';
|
||||||
import { createColumnHelper, useReactTable } from '@tanstack/react-table';
|
import { createColumnHelper, useReactTable } from '@tanstack/react-table';
|
||||||
@ -18,6 +18,7 @@ import { FavoriteIconCell } from 'component/common/Table/cells/FavoriteIconCell/
|
|||||||
import { FavoriteIconHeader } from 'component/common/Table/FavoriteIconHeader/FavoriteIconHeader';
|
import { FavoriteIconHeader } from 'component/common/Table/FavoriteIconHeader/FavoriteIconHeader';
|
||||||
import { useEnvironments } from 'hooks/api/getters/useEnvironments/useEnvironments';
|
import { useEnvironments } from 'hooks/api/getters/useEnvironments/useEnvironments';
|
||||||
import { ExportDialog } from './ExportDialog';
|
import { ExportDialog } from './ExportDialog';
|
||||||
|
import { useUiFlag } from 'hooks/useUiFlag';
|
||||||
import { focusable } from 'themes/themeStyles';
|
import { focusable } from 'themes/themeStyles';
|
||||||
import { FeatureEnvironmentSeenCell } from 'component/common/Table/cells/FeatureSeenCell/FeatureEnvironmentSeenCell';
|
import { FeatureEnvironmentSeenCell } from 'component/common/Table/cells/FeatureSeenCell/FeatureEnvironmentSeenCell';
|
||||||
import useToast from 'hooks/useToast';
|
import useToast from 'hooks/useToast';
|
||||||
@ -29,8 +30,8 @@ import { FeatureToggleListActions } from './FeatureToggleListActions/FeatureTogg
|
|||||||
import useLoading from 'hooks/useLoading';
|
import useLoading from 'hooks/useLoading';
|
||||||
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
import { useGlobalFeatureSearch } from './useGlobalFeatureSearch';
|
import { useGlobalFeatureSearch } from './useGlobalFeatureSearch';
|
||||||
|
import useProjects from 'hooks/api/getters/useProjects/useProjects';
|
||||||
import { LifecycleFilters } from './FeatureToggleFilters/LifecycleFilters';
|
import { LifecycleFilters } from './FeatureToggleFilters/LifecycleFilters';
|
||||||
import { useUiFlag } from 'hooks/useUiFlag';
|
|
||||||
import { ExportFlags } from './ExportFlags';
|
import { ExportFlags } from './ExportFlags';
|
||||||
|
|
||||||
export const featuresPlaceholder = Array(15).fill({
|
export const featuresPlaceholder = Array(15).fill({
|
||||||
@ -43,7 +44,7 @@ export const featuresPlaceholder = Array(15).fill({
|
|||||||
|
|
||||||
const columnHelper = createColumnHelper<FeatureSearchResponseSchema>();
|
const columnHelper = createColumnHelper<FeatureSearchResponseSchema>();
|
||||||
|
|
||||||
export const FeatureToggleListTable: VFC = () => {
|
export const FeatureToggleListTable: FC = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { trackEvent } = usePlausibleTracker();
|
const { trackEvent } = usePlausibleTracker();
|
||||||
const { environments } = useEnvironments();
|
const { environments } = useEnvironments();
|
||||||
@ -69,6 +70,7 @@ export const FeatureToggleListTable: VFC = () => {
|
|||||||
setTableState,
|
setTableState,
|
||||||
filterState,
|
filterState,
|
||||||
} = useGlobalFeatureSearch();
|
} = useGlobalFeatureSearch();
|
||||||
|
const { projects } = useProjects();
|
||||||
const bodyLoadingRef = useLoading(loading);
|
const bodyLoadingRef = useLoading(loading);
|
||||||
const { favorite, unfavorite } = useFavoriteFeaturesApi();
|
const { favorite, unfavorite } = useFavoriteFeaturesApi();
|
||||||
const onFavorite = useCallback(
|
const onFavorite = useCallback(
|
||||||
@ -147,16 +149,24 @@ export const FeatureToggleListTable: VFC = () => {
|
|||||||
width: '50%',
|
width: '50%',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor((row) => row.segments?.join('\n') || '', {
|
...(!flagsReleaseManagementUIEnabled
|
||||||
|
? [
|
||||||
|
columnHelper.accessor(
|
||||||
|
(row) => row.segments?.join('\n') || '',
|
||||||
|
{
|
||||||
header: 'Segments',
|
header: 'Segments',
|
||||||
cell: ({ getValue, row }) => (
|
cell: ({ getValue, row }) => (
|
||||||
<FeatureSegmentCell value={getValue()} row={row} />
|
<FeatureSegmentCell
|
||||||
|
value={getValue()}
|
||||||
|
row={row}
|
||||||
|
/>
|
||||||
),
|
),
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
meta: {
|
meta: {
|
||||||
width: '1%',
|
width: '1%',
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
columnHelper.accessor(
|
columnHelper.accessor(
|
||||||
(row) =>
|
(row) =>
|
||||||
row.tags
|
row.tags
|
||||||
@ -171,6 +181,8 @@ export const FeatureToggleListTable: VFC = () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
]
|
||||||
|
: ([] as never[])),
|
||||||
columnHelper.accessor('createdAt', {
|
columnHelper.accessor('createdAt', {
|
||||||
header: 'Created',
|
header: 'Created',
|
||||||
cell: ({ getValue }) => <DateCell value={getValue()} />,
|
cell: ({ getValue }) => <DateCell value={getValue()} />,
|
||||||
@ -179,24 +191,43 @@ export const FeatureToggleListTable: VFC = () => {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor('project', {
|
columnHelper.accessor('project', {
|
||||||
header: 'Project ID',
|
header: flagsReleaseManagementUIEnabled
|
||||||
cell: ({ getValue }) => (
|
? 'Project'
|
||||||
|
: 'Project ID',
|
||||||
|
cell: ({ getValue }) => {
|
||||||
|
const value = getValue();
|
||||||
|
const project = projects.find(
|
||||||
|
(project) => project.id === value,
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<LinkCell
|
<LinkCell
|
||||||
title={getValue()}
|
title={
|
||||||
|
flagsReleaseManagementUIEnabled
|
||||||
|
? project?.name || value
|
||||||
|
: value
|
||||||
|
}
|
||||||
to={`/projects/${getValue()}`}
|
to={`/projects/${getValue()}`}
|
||||||
/>
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
width: '1%',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
...(!flagsReleaseManagementUIEnabled
|
||||||
|
? [
|
||||||
|
columnHelper.accessor('stale', {
|
||||||
|
header: 'State',
|
||||||
|
cell: ({ getValue }) => (
|
||||||
|
<FeatureStaleCell value={getValue()} />
|
||||||
),
|
),
|
||||||
meta: {
|
meta: {
|
||||||
width: '1%',
|
width: '1%',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor('stale', {
|
]
|
||||||
header: 'State',
|
: ([] as never[])),
|
||||||
cell: ({ getValue }) => <FeatureStaleCell value={getValue()} />,
|
|
||||||
meta: {
|
|
||||||
width: '1%',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
[tableState.favoritesFirst],
|
[tableState.favoritesFirst],
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user