mirror of https://github.com/portainer/portainer
fix(edge/updates): allow group search [EE-6179] (#10408)
parent
5a73605df2
commit
57c45838d5
@ -1,27 +1,18 @@
|
||||
import _ from 'lodash';
|
||||
import { CellContext } from '@tanstack/react-table';
|
||||
|
||||
import { EdgeGroup } from '@/react/edge/edge-groups/types';
|
||||
import { useEdgeGroups } from '@/react/edge/edge-groups/queries/useEdgeGroups';
|
||||
|
||||
import { EdgeUpdateListItemResponse } from '../../queries/list';
|
||||
import { DecoratedItem } from '../types';
|
||||
|
||||
import { columnHelper } from './helper';
|
||||
|
||||
export const groups = columnHelper.accessor('edgeGroupIds', {
|
||||
header: 'Groups',
|
||||
export const groups = columnHelper.accessor('edgeGroupNames', {
|
||||
header: 'Edge Groups',
|
||||
cell: GroupsCell,
|
||||
});
|
||||
|
||||
export function GroupsCell({
|
||||
getValue,
|
||||
}: CellContext<EdgeUpdateListItemResponse, Array<EdgeGroup['Id']>>) {
|
||||
const groupsIds = getValue();
|
||||
const groupsQuery = useEdgeGroups();
|
||||
|
||||
const groups = _.compact(
|
||||
groupsIds.map((id) => groupsQuery.data?.find((g) => g.Id === id))
|
||||
);
|
||||
}: CellContext<DecoratedItem, Array<string>>) {
|
||||
const groups = getValue();
|
||||
|
||||
return groups.map((g) => g.Name).join(', ');
|
||||
return groups.join(', ');
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createColumnHelper } from '@tanstack/react-table';
|
||||
|
||||
import { EdgeUpdateListItemResponse } from '../../queries/list';
|
||||
import { DecoratedItem } from '../types';
|
||||
|
||||
export const columnHelper = createColumnHelper<EdgeUpdateListItemResponse>();
|
||||
export const columnHelper = createColumnHelper<DecoratedItem>();
|
||||
|
@ -0,0 +1,5 @@
|
||||
import { EdgeUpdateListItemResponse } from '../queries/list';
|
||||
|
||||
export type DecoratedItem = EdgeUpdateListItemResponse & {
|
||||
edgeGroupNames: string[];
|
||||
};
|
Loading…
Reference in new issue