import { useRouter } from '@uirouter/react'; import * as notifications from '@/portainer/services/notifications'; import { useAuthorizations, Authorized } from '@/portainer/hooks/useUser'; import { Link } from '@/portainer/components/Link'; import { confirmContainerDeletion } from '@/portainer/services/modal.service/prompt'; import { setPortainerAgentTargetHeader } from '@/portainer/services/http-request.helper'; import type { ContainerId, DockerContainer } from '@/docker/containers/types'; import { killContainer, pauseContainer, removeContainer, restartContainer, resumeContainer, startContainer, stopContainer, } from '@/docker/containers/containers.service'; import type { EnvironmentId } from '@/portainer/environments/types'; import { ButtonGroup, Button } from '@/portainer/components/Button'; type ContainerServiceAction = ( endpointId: EnvironmentId, containerId: ContainerId ) => Promise; interface Props { selectedItems: DockerContainer[]; isAddActionVisible: boolean; endpointId: EnvironmentId; } export function ContainersDatatableActions({ selectedItems, isAddActionVisible, endpointId, }: Props) { const selectedItemCount = selectedItems.length; const hasPausedItemsSelected = selectedItems.some( (item) => item.Status === 'paused' ); const hasStoppedItemsSelected = selectedItems.some((item) => ['stopped', 'created'].includes(item.Status) ); const hasRunningItemsSelected = selectedItems.some((item) => ['running', 'healthy', 'unhealthy', 'starting'].includes(item.Status) ); const isAuthorized = useAuthorizations([ 'DockerContainerStart', 'DockerContainerStop', 'DockerContainerKill', 'DockerContainerRestart', 'DockerContainerPause', 'DockerContainerUnpause', 'DockerContainerDelete', 'DockerContainerCreate', ]); const router = useRouter(); if (!isAuthorized) { return null; } return (