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

refactor(settings): migrate hidden containers panel to react [EE-5507] (#9119)

This commit is contained in:
Chaim Lev-Ari 2023-07-10 03:39:11 +07:00 committed by GitHub
parent eefb4c4287
commit 8b11e1678e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 230 additions and 139 deletions

View file

@ -2,10 +2,11 @@ import clsx from 'clsx';
import { ReactNode } from 'react';
interface Props {
children?: ReactNode;
children: ReactNode;
label: string;
colClassName?: string;
className?: string;
columns?: Array<ReactNode>;
}
export function DetailsRow({
@ -13,17 +14,21 @@ export function DetailsRow({
children,
colClassName,
className,
columns,
}: Props) {
return (
<tr className={className}>
<td className={clsx(colClassName, 'min-w-[150px] !break-normal')}>
{label}
</td>
{!!children && (
<td className={colClassName} data-cy={`detailsTable-${label}Value`}>
{children}
<td className={colClassName} data-cy={`detailsTable-${label}Value`}>
{children}
</td>
{columns?.map((column, index) => (
<td key={index} className={colClassName}>
{column}
</td>
)}
))}
</tr>
);
}

View file

@ -1,17 +1,22 @@
import { PropsWithChildren } from 'react';
import clsx from 'clsx';
import { Children, PropsWithChildren } from 'react';
type Props = {
headers?: string[];
dataCy?: string;
className?: string;
emptyMessage?: string;
};
export function DetailsTable({
headers = [],
dataCy,
className,
emptyMessage,
children,
}: PropsWithChildren<Props>) {
return (
<table className="table" data-cy={dataCy}>
<table className={clsx('table', className)} data-cy={dataCy}>
{headers.length > 0 && (
<thead>
<tr>
@ -21,7 +26,17 @@ export function DetailsTable({
</tr>
</thead>
)}
{children && <tbody>{children}</tbody>}
<tbody>
{Children.count(children) > 0 ? (
children
) : (
<tr>
<td colSpan={headers.length} className="text-muted text-center">
{emptyMessage}
</td>
</tr>
)}
</tbody>
</table>
);
}