1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-04 13:25:26 +02:00

fix(edge): only show expand row for Edge Devices with AMT activated [EE-2489] (#6519)

This commit is contained in:
Marcelo Rydel 2022-02-14 11:44:55 -03:00 committed by GitHub
parent 37ca62eb06
commit 2bffba7371
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 16 deletions

View file

@ -206,6 +206,7 @@ export function EdgeDevicesDatatable({
<RowProvider
key={key}
disableTrustOnFirstConnect={disableTrustOnFirstConnect}
isOpenAmtEnabled={isOpenAmtEnabled}
>
<TableRow<Environment>
cells={row.cells}

View file

@ -2,21 +2,24 @@ import { createContext, useContext, useMemo, PropsWithChildren } from 'react';
interface RowContextState {
disableTrustOnFirstConnect: boolean;
isOpenAmtEnabled: boolean;
}
const RowContext = createContext<RowContextState | null>(null);
export interface RowProviderProps {
disableTrustOnFirstConnect: boolean;
isOpenAmtEnabled: boolean;
}
export function RowProvider({
disableTrustOnFirstConnect,
isOpenAmtEnabled,
children,
}: PropsWithChildren<RowProviderProps>) {
const state = useMemo(
() => ({ disableTrustOnFirstConnect }),
[disableTrustOnFirstConnect]
() => ({ disableTrustOnFirstConnect, isOpenAmtEnabled }),
[disableTrustOnFirstConnect, isOpenAmtEnabled]
);
return <RowContext.Provider value={state}>{children}</RowContext.Provider>;

View file

@ -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<Environment> = {
Header: 'Name',
@ -15,9 +16,15 @@ export const name: Column<Environment> = {
sortType: 'string',
};
export function NameCell({ value: name, row }: CellProps<TableInstance>) {
export function NameCell({ value: name, row }: CellProps<Environment>) {
const { isOpenAmtEnabled } = useRowContext();
const showExpandedRow = !!(
isOpenAmtEnabled &&
row.original.AMTDeviceGUID &&
row.original.AMTDeviceGUID.length > 0
);
return (
<ExpandingCell row={row}>
<ExpandingCell row={row} showExpandArrow={showExpandedRow}>
<Link
to="portainer.endpoints.endpoint"
params={{ id: row.original.Id }}