/* eslint-disable @typescript-eslint/no-non-null-assertion */ import { Button, Group } from '@mantine/core'; import { showNotification, updateNotification } from '@mantine/notifications'; import { IconCheck, IconPlayerPlay, IconPlayerStop, IconPlus, IconRefresh, IconRotateClockwise, IconTrash, } from '@tabler/icons'; import axios from 'axios'; import Dockerode from 'dockerode'; import { useTranslation } from 'next-i18next'; import { useState } from 'react'; import { TFunction } from 'react-i18next'; import { v4 as uuidv4 } from 'uuid'; import { openContextModalGeneric } from '../../../../../tools/mantineModalManagerExtensions'; import { AppType } from '../../../../../types/app'; let t: TFunction<'modules/docker', undefined>; function sendDockerCommand( action: string, containerId: string, containerName: string, reload: () => void ) { showNotification({ id: containerId, loading: true, title: `${t(`actions.${action}.start`)} ${containerName}`, message: undefined, autoClose: false, disallowClose: true, }); axios .get(`/api/docker/container/${containerId}?action=${action}`) .then((res) => { updateNotification({ id: containerId, title: containerName, message: `${t(`actions.${action}.end`)} ${containerName}`, icon: , autoClose: 2000, }); }) .catch((err) => { updateNotification({ id: containerId, color: 'red', title: t('errors.unknownError.title'), message: err.response.data.reason, autoClose: 2000, }); }) .finally(() => { reload(); }); } export interface ContainerActionBarProps { selected: Dockerode.ContainerInfo[]; reload: () => void; } export default function ContainerActionBar({ selected, reload }: ContainerActionBarProps) { t = useTranslation('modules/docker').t; const [isLoading, setisLoading] = useState(false); return ( ); }