diff --git a/app/edge/devices/components/EdgeDevicesDatatable/EdgeDevicesDatatable.tsx b/app/edge/devices/components/EdgeDevicesDatatable/EdgeDevicesDatatable.tsx index 4fbf196ac..01dbd97a6 100644 --- a/app/edge/devices/components/EdgeDevicesDatatable/EdgeDevicesDatatable.tsx +++ b/app/edge/devices/components/EdgeDevicesDatatable/EdgeDevicesDatatable.tsx @@ -206,6 +206,7 @@ export function EdgeDevicesDatatable({ cells={row.cells} diff --git a/app/edge/devices/components/EdgeDevicesDatatable/columns/RowContext.tsx b/app/edge/devices/components/EdgeDevicesDatatable/columns/RowContext.tsx index 9686f523f..bd81f0e89 100644 --- a/app/edge/devices/components/EdgeDevicesDatatable/columns/RowContext.tsx +++ b/app/edge/devices/components/EdgeDevicesDatatable/columns/RowContext.tsx @@ -2,21 +2,24 @@ import { createContext, useContext, useMemo, PropsWithChildren } from 'react'; interface RowContextState { disableTrustOnFirstConnect: boolean; + isOpenAmtEnabled: boolean; } const RowContext = createContext(null); export interface RowProviderProps { disableTrustOnFirstConnect: boolean; + isOpenAmtEnabled: boolean; } export function RowProvider({ disableTrustOnFirstConnect, + isOpenAmtEnabled, children, }: PropsWithChildren) { const state = useMemo( - () => ({ disableTrustOnFirstConnect }), - [disableTrustOnFirstConnect] + () => ({ disableTrustOnFirstConnect, isOpenAmtEnabled }), + [disableTrustOnFirstConnect, isOpenAmtEnabled] ); return {children}; diff --git a/app/edge/devices/components/EdgeDevicesDatatable/columns/name.tsx b/app/edge/devices/components/EdgeDevicesDatatable/columns/name.tsx index 0f028af33..38ed469fa 100644 --- a/app/edge/devices/components/EdgeDevicesDatatable/columns/name.tsx +++ b/app/edge/devices/components/EdgeDevicesDatatable/columns/name.tsx @@ -1,8 +1,9 @@ -import { CellProps, Column, TableInstance } from 'react-table'; +import { CellProps, Column } from 'react-table'; import { Environment } from '@/portainer/environments/types'; import { Link } from '@/portainer/components/Link'; import { ExpandingCell } from '@/portainer/components/datatables/components/ExpandingCell'; +import { useRowContext } from '@/edge/devices/components/EdgeDevicesDatatable/columns/RowContext'; export const name: Column = { Header: 'Name', @@ -15,9 +16,15 @@ export const name: Column = { sortType: 'string', }; -export function NameCell({ value: name, row }: CellProps) { +export function NameCell({ value: name, row }: CellProps) { + const { isOpenAmtEnabled } = useRowContext(); + const showExpandedRow = !!( + isOpenAmtEnabled && + row.original.AMTDeviceGUID && + row.original.AMTDeviceGUID.length > 0 + ); return ( - + ; +import styles from './ExpandingCell.module.css'; + +interface Props = Record> { + row: Row; + showExpandArrow: boolean; } -export function ExpandingCell({ children, row }: PropsWithChildren) { +export function ExpandingCell< + D extends Record = Record +>({ row, showExpandArrow, children }: PropsWithChildren>) { return ( - // eslint-disable-next-line react/jsx-props-no-spreading -
-