1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-13 11:17:26 +02:00

Merge branch 'main' into feat/last_seen_archive

This commit is contained in:
andreas-unleash 2023-08-21 15:38:35 +03:00
commit 50849a9d38
No known key found for this signature in database
GPG Key ID: DB82A1577B38F66B

View File

@ -1,5 +1,8 @@
import { useMemo } from 'react';
import { IFeatureToggleListItem } from 'interfaces/featureToggle';
import {
IEnvironments,
IFeatureToggleListItem,
} from 'interfaces/featureToggle';
import { TablePlaceholder, VirtualizedTable } from 'component/common/Table';
import { PageContent } from 'component/common/PageContent/PageContent';
import { SearchHighlightProvider } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
@ -24,6 +27,8 @@ import { ReportStatusCell } from './ReportStatusCell/ReportStatusCell';
import { formatStatus, ReportingStatus } from './ReportStatusCell/formatStatus';
import { formatExpiredAt } from './ReportExpiredCell/formatExpiredAt';
import { useConditionallyHiddenColumns } from 'hooks/useConditionallyHiddenColumns';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { FeatureEnvironmentSeenCell } from 'component/common/Table/cells/FeatureSeenCell/FeatureEnvironmentSeenCell';
interface IReportTableProps {
projectId: string;
@ -37,6 +42,7 @@ export interface IReportTableRow {
stale?: boolean;
status: ReportingStatus;
lastSeenAt?: string;
environments?: IEnvironments[];
createdAt: string;
expiredAt?: string;
}
@ -46,6 +52,10 @@ export const ReportTable = ({ projectId, features }: IReportTableProps) => {
const isExtraSmallScreen = useMediaQuery(theme.breakpoints.down('sm'));
const isSmallScreen = useMediaQuery(theme.breakpoints.down('md'));
const isMediumScreen = useMediaQuery(theme.breakpoints.down('lg'));
const { uiConfig } = useUiConfig();
const showEnvironmentLastSeen = Boolean(
uiConfig.flags.lastSeenByEnvironment
);
const data: IReportTableRow[] = useMemo<IReportTableRow[]>(
() =>
@ -54,6 +64,7 @@ export const ReportTable = ({ projectId, features }: IReportTableProps) => {
name: report.name,
type: report.type,
stale: report.stale,
environments: report.environments,
status: formatStatus(report),
lastSeenAt: report.lastSeenAt,
createdAt: report.createdAt,
@ -70,6 +81,71 @@ export const ReportTable = ({ projectId, features }: IReportTableProps) => {
[]
);
const COLUMNS = useMemo(
() => [
{
Header: 'Seen',
accessor: 'lastSeenAt',
Cell: ({ value, row: { original: feature } }: any) => {
return showEnvironmentLastSeen ? (
<FeatureEnvironmentSeenCell feature={feature} />
) : (
<FeatureSeenCell value={value} />
);
},
align: 'center',
maxWidth: 80,
},
{
Header: 'Type',
accessor: 'type',
align: 'center',
Cell: FeatureTypeCell,
disableGlobalFilter: true,
maxWidth: 85,
},
{
Header: 'Name',
accessor: 'name',
sortType: 'alphanumeric',
Cell: FeatureNameCell,
minWidth: 120,
},
{
Header: 'Created',
accessor: 'createdAt',
sortType: 'date',
Cell: DateCell,
disableGlobalFilter: true,
maxWidth: 150,
},
{
Header: 'Expired',
accessor: 'expiredAt',
Cell: ReportExpiredCell,
disableGlobalFilter: true,
maxWidth: 150,
},
{
Header: 'Status',
id: 'status',
accessor: 'status',
Cell: ReportStatusCell,
disableGlobalFilter: true,
width: 180,
},
{
Header: 'State',
accessor: 'stale',
sortType: 'boolean',
Cell: FeatureStaleCell,
disableGlobalFilter: true,
maxWidth: 120,
},
],
[showEnvironmentLastSeen]
);
const {
headerGroups,
rows,
@ -162,61 +238,3 @@ export const ReportTable = ({ projectId, features }: IReportTableProps) => {
</PageContent>
);
};
const COLUMNS = [
{
Header: 'Seen',
accessor: 'lastSeenAt',
sortType: 'date',
align: 'center',
Cell: FeatureSeenCell,
disableGlobalFilter: true,
maxWidth: 85,
},
{
Header: 'Type',
accessor: 'type',
align: 'center',
Cell: FeatureTypeCell,
disableGlobalFilter: true,
maxWidth: 85,
},
{
Header: 'Name',
accessor: 'name',
sortType: 'alphanumeric',
Cell: FeatureNameCell,
minWidth: 120,
},
{
Header: 'Created',
accessor: 'createdAt',
sortType: 'date',
Cell: DateCell,
disableGlobalFilter: true,
maxWidth: 150,
},
{
Header: 'Expired',
accessor: 'expiredAt',
Cell: ReportExpiredCell,
disableGlobalFilter: true,
maxWidth: 150,
},
{
Header: 'Status',
id: 'status',
accessor: 'status',
Cell: ReportStatusCell,
disableGlobalFilter: true,
width: 180,
},
{
Header: 'State',
accessor: 'stale',
sortType: 'boolean',
Cell: FeatureStaleCell,
disableGlobalFilter: true,
maxWidth: 120,
},
];