mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
refactor(docker/stacks): migrate table to react [EE-4705] (#9956)
This commit is contained in:
parent
c3d266931f
commit
c8a1f0fa77
43 changed files with 1127 additions and 492 deletions
|
@ -0,0 +1,65 @@
|
|||
import UpdatesAvailable from '@/assets/ico/icon_updates-available.svg?c';
|
||||
import UpToDate from '@/assets/ico/icon_up-to-date.svg?c';
|
||||
import UpdatesUnknown from '@/assets/ico/icon_updates-unknown.svg?c';
|
||||
import { useEnvironment } from '@/react/portainer/environments/queries';
|
||||
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
|
||||
|
||||
import { Icon } from '@@/Icon';
|
||||
import { Tooltip } from '@@/Tip/Tooltip';
|
||||
import {
|
||||
TableColumnHeaderAngular,
|
||||
TableColumnHeaderAngularProps,
|
||||
} from '@@/datatables/TableHeaderCell';
|
||||
|
||||
export function TableColumnHeaderImageUpToDate({
|
||||
canSort,
|
||||
isSorted,
|
||||
colTitle,
|
||||
isSortedDesc = true,
|
||||
}: TableColumnHeaderAngularProps) {
|
||||
return (
|
||||
<TableColumnHeaderAngular
|
||||
canSort={canSort}
|
||||
isSorted={isSorted}
|
||||
colTitle={colTitle}
|
||||
isSortedDesc={isSortedDesc}
|
||||
>
|
||||
<ImageUpToDateTooltip />
|
||||
</TableColumnHeaderAngular>
|
||||
);
|
||||
}
|
||||
|
||||
export function ImageUpToDateTooltip() {
|
||||
const environmentId = useEnvironmentId();
|
||||
|
||||
const enableImageNotificationQuery = useEnvironment(
|
||||
environmentId,
|
||||
(environment) => environment?.EnableImageNotification
|
||||
);
|
||||
|
||||
if (!enableImageNotificationQuery.data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
position="top"
|
||||
message={
|
||||
<div className="flex flex-col gap-y-2 p-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<Icon icon={UpToDate} />
|
||||
Images are up to date
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Icon icon={UpdatesAvailable} />
|
||||
Updates are available
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Icon icon={UpdatesUnknown} />
|
||||
Updates availability unknown
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { CellContext, ColumnDef } from '@tanstack/react-table';
|
||||
|
||||
import { ownershipIcon } from '@/portainer/filters/filters';
|
||||
import { ResourceControlOwnership } from '@/react/portainer/access-control/types';
|
||||
|
||||
import { Icon } from '@@/Icon';
|
||||
|
||||
export interface IResource {
|
||||
ResourceControl?: {
|
||||
Ownership: ResourceControlOwnership;
|
||||
};
|
||||
}
|
||||
|
||||
export function createOwnershipColumn<D extends IResource>(
|
||||
enableHiding = true
|
||||
): ColumnDef<D, ResourceControlOwnership> {
|
||||
return {
|
||||
accessorFn: (row) =>
|
||||
row.ResourceControl?.Ownership || ResourceControlOwnership.ADMINISTRATORS,
|
||||
header: 'Ownership',
|
||||
id: 'ownership',
|
||||
cell: OwnershipCell,
|
||||
enableHiding,
|
||||
};
|
||||
|
||||
function OwnershipCell({
|
||||
getValue,
|
||||
}: CellContext<D, ResourceControlOwnership>) {
|
||||
const value = getValue();
|
||||
|
||||
return (
|
||||
<span className="flex items-center gap-2">
|
||||
<Icon icon={ownershipIcon(value)} className="space-right" />
|
||||
{value}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue