1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

feat(kubernetes): support for jobs and cron jobs - r8s-182 (#260)

Co-authored-by: James Carppe <85850129+jamescarppe@users.noreply.github.com>
Co-authored-by: Anthony Lapenna <anthony.lapenna@portainer.io>
Co-authored-by: andres-portainer <91705312+andres-portainer@users.noreply.github.com>
Co-authored-by: Oscar Zhou <100548325+oscarzhou-portainer@users.noreply.github.com>
Co-authored-by: Yajith Dayarathna <yajith.dayarathna@portainer.io>
Co-authored-by: LP B <xAt0mZ@users.noreply.github.com>
Co-authored-by: oscarzhou <oscar.zhou@portainer.io>
Co-authored-by: testA113 <aliharriss1995@gmail.com>
This commit is contained in:
Steven Kang 2025-01-10 13:21:27 +13:00 committed by GitHub
parent 24fdb1f600
commit d32b0f8b7e
51 changed files with 1786 additions and 22 deletions

View file

@ -0,0 +1,30 @@
import { FileText } from 'lucide-react';
import { Link } from '@@/Link';
import { Icon } from '@@/Icon';
import { columnHelper } from './helper';
export const actions = columnHelper.accessor(() => '', {
header: 'Actions',
id: 'actions',
enableSorting: false,
cell: ({ row: { original: job } }) => (
<div className="flex gap-x-2">
<Link
className="flex items-center gap-1"
to="kubernetes.applications.application.logs"
params={{
name: job.PodName,
namespace: job.Namespace,
pod: job.PodName,
container: job.Container?.name,
}}
data-cy={`job-logs-${job.Namespace}-${job.Name}-${job.Container?.name}`}
>
<Icon icon={FileText} />
Logs
</Link>
</div>
),
});

View file

@ -0,0 +1,7 @@
import { columnHelper } from './helper';
export const command = columnHelper.accessor((row) => row.Command, {
header: 'Command',
id: 'command',
cell: ({ getValue }) => getValue(),
});

View file

@ -0,0 +1,7 @@
import { columnHelper } from './helper';
export const duration = columnHelper.accessor((row) => row.Duration, {
header: 'Duration',
id: 'duration',
cell: ({ getValue }) => getValue(),
});

View file

@ -0,0 +1,7 @@
import { columnHelper } from './helper';
export const finished = columnHelper.accessor((row) => row.FinishTime, {
header: 'Finished',
id: 'finished',
cell: ({ getValue }) => getValue(),
});

View file

@ -0,0 +1,5 @@
import { createColumnHelper } from '@tanstack/react-table';
import { Job } from '../types';
export const columnHelper = createColumnHelper<Job>();

View file

@ -0,0 +1,19 @@
import { name } from './name';
import { namespace } from './namespace';
import { started } from './started';
import { finished } from './finished';
import { duration } from './duration';
import { status } from './status';
import { actions } from './actions';
import { command } from './command';
export const columns = [
name,
namespace,
command,
status,
started,
finished,
duration,
actions,
];

View file

@ -0,0 +1,23 @@
import { SystemBadge } from '@@/Badge/SystemBadge';
import { columnHelper } from './helper';
export const name = columnHelper.accessor(
(row) => {
let result = row.Name;
if (row.IsSystem) {
result += ' system';
}
return result;
},
{
header: 'Name',
id: 'name',
cell: ({ row }) => (
<div className="flex gap-2">
{row.original.Name}
{row.original.IsSystem && <SystemBadge />}
</div>
),
}
);

View file

@ -0,0 +1,32 @@
import { Row } from '@tanstack/react-table';
import { filterHOC } from '@@/datatables/Filter';
import { Link } from '@@/Link';
import { Job } from '../types';
import { columnHelper } from './helper';
export const namespace = columnHelper.accessor((row) => row.Namespace, {
header: 'Namespace',
id: 'namespace',
cell: ({ getValue, row }) => (
<Link
to="kubernetes.resourcePools.resourcePool"
params={{
id: getValue(),
}}
title={getValue()}
data-cy={`cronJob-namespace-link-${row.original.Name}`}
>
{getValue()}
</Link>
),
meta: {
filter: filterHOC('Filter by namespace'),
},
enableColumnFilter: true,
filterFn: (row: Row<Job>, _columnId: string, filterValue: string[]) =>
filterValue.length === 0 ||
filterValue.includes(row.original.Namespace ?? ''),
});

View file

@ -0,0 +1,12 @@
import { formatDate } from '@/portainer/filters/filters';
import { columnHelper } from './helper';
export const started = columnHelper.accessor(
(row) => formatDate(row.StartTime),
{
header: 'Started',
id: 'started',
cell: ({ getValue }) => getValue(),
}
);

View file

@ -0,0 +1,13 @@
.status-indicator {
padding: 0 !important;
margin-right: 1ch;
border-radius: 50%;
background-color: var(--red-3);
height: 10px;
width: 10px;
display: inline-block;
}
.status-indicator.ok {
background-color: var(--green-3);
}

View file

@ -0,0 +1,48 @@
import { CellContext } from '@tanstack/react-table';
import { HelpCircle } from 'lucide-react';
import clsx from 'clsx';
import { TooltipWithChildren } from '@@/Tip/TooltipWithChildren';
import { Job } from '../types';
import { columnHelper } from './helper';
import styles from './status.module.css';
export const status = columnHelper.accessor((row) => row.Status, {
header: 'Status',
id: 'status',
cell: Cell,
});
function Cell({ row: { original: item } }: CellContext<Job, string>) {
return (
<>
<span
className={clsx([
styles.statusIndicator,
{
[styles.ok]: item.Status !== 'Failed',
},
])}
/>
{item.Status}
{item.Status === 'Failed' && (
<span className="ml-1">
<TooltipWithChildren
message={
<div>
<span>{item.FailedReason}</span>
</div>
}
position="bottom"
>
<span className="vertical-center text-muted inline-flex whitespace-nowrap text-base">
<HelpCircle className="lucide" aria-hidden="true" />
</span>
</TooltipWithChildren>
</span>
)}
</>
);
}