diff --git a/apps/nextjs/src/app/[locale]/manage/tools/docker/docker-table.tsx b/apps/nextjs/src/app/[locale]/manage/tools/docker/docker-table.tsx index caea75a79..e5ca818de 100644 --- a/apps/nextjs/src/app/[locale]/manage/tools/docker/docker-table.tsx +++ b/apps/nextjs/src/app/[locale]/manage/tools/docker/docker-table.tsx @@ -2,7 +2,7 @@ import type { MantineColor } from "@mantine/core"; import { Avatar, Badge, Box, Button, Group, Text } from "@mantine/core"; -import { IconPlayerPlay, IconPlayerStop, IconRotateClockwise, IconTrash } from "@tabler/icons-react"; +import { IconPlayerPlay, IconPlayerStop, IconRefresh, IconRotateClockwise, IconTrash } from "@tabler/icons-react"; import type { MRT_ColumnDef } from "mantine-react-table"; import { MantineReactTable } from "mantine-react-table"; @@ -46,10 +46,12 @@ const createColumns = ( accessorKey: "image", header: t("docker.field.containerImage.label"), maxSize: 200, - Cell({ renderedCellValue }) { + Cell({ renderedCellValue, cell }) { return ( - {renderedCellValue} + + {renderedCellValue} + ); }, @@ -93,6 +95,35 @@ export function DockerTable(initialData: RouterOutputs["docker"]["getContainers" }, initialState: { density: "xs", showGlobalFilter: true }, + renderTopToolbarCustomActions: () => { + const utils = clientApi.useUtils(); + const { mutate, isPending } = clientApi.docker.invalidate.useMutation({ + async onSuccess() { + await utils.docker.getContainers.invalidate(); + showSuccessNotification({ + title: tDocker("action.refresh.notification.success.title"), + message: tDocker("action.refresh.notification.success.message"), + }); + }, + onError() { + showErrorNotification({ + title: tDocker("action.refresh.notification.error.title"), + message: tDocker("action.refresh.notification.error.message"), + }); + }, + }); + + return ( + + ); + }, renderToolbarAlertBannerContent: ({ groupedAlert, table }) => { return ( diff --git a/packages/api/src/router/docker/docker-router.ts b/packages/api/src/router/docker/docker-router.ts index 876ab683d..127573173 100644 --- a/packages/api/src/router/docker/docker-router.ts +++ b/packages/api/src/router/docker/docker-router.ts @@ -59,6 +59,10 @@ export const dockerRouter = createTRPCRouter({ timestamp, }; }), + invalidate: permissionRequiredProcedure.requiresPermission("admin").mutation(async () => { + await dockerCache.invalidateAsync(); + return; + }), startAll: permissionRequiredProcedure .requiresPermission("admin") .input(z.object({ ids: z.array(z.string()) })) diff --git a/packages/translation/src/lang/en.ts b/packages/translation/src/lang/en.ts index 836674744..00aa2f60d 100644 --- a/packages/translation/src/lang/en.ts +++ b/packages/translation/src/lang/en.ts @@ -1656,6 +1656,19 @@ export default { }, }, }, + refresh: { + label: "Refresh", + notification: { + success: { + title: "Containers refreshed", + message: "You are now viewing the most recent data", + }, + error: { + title: "Containers not refreshed", + message: "Something went wrong while refreshing the containers", + }, + }, + }, }, }, permission: {