import { FileText, Info, BarChart2, Terminal, Paperclip } from 'lucide-react'; import { useCurrentStateAndParams } from '@uirouter/react'; import { ContainerId } from '@/react/docker/containers/types'; import { useAuthorizations } from '@/react/hooks/useUser'; import { Icon } from '@@/Icon'; import { Button, ButtonGroup } from '@@/buttons'; import { Link } from '@@/Link'; import { STACK_CONTAINER_STATE_NAME, buildStackContainerLinkParams, isStackContainerState, } from '../containerBreadcrumbs'; interface Props { containerId: ContainerId; } export function ActionLinksRow({ containerId }: Props) { const { state, params } = useCurrentStateAndParams(); // When the container was opened from a stack, keep the sub-tab links inside // the stack tree (docker.stacks.stack.container.*) so the stack params are // preserved and the breadcrumb keeps the stack trail. Otherwise use the // global container states. const fromStack = isStackContainerState(state?.name); const baseState = fromStack ? STACK_CONTAINER_STATE_NAME : 'docker.containers.container'; const linkParams = fromStack ? buildStackContainerLinkParams(params, containerId) : { id: containerId }; const { authorized: canLogs } = useAuthorizations(['DockerContainerLogs']); const { authorized: canInspect } = useAuthorizations([ 'DockerContainerInspect', ]); const { authorized: canStats } = useAuthorizations(['DockerContainerStats']); const { authorized: canExec } = useAuthorizations(['DockerExecStart']); const { authorized: canAttach } = useAuthorizations([ 'DockerContainerAttach', ]); const hasAnyAuthorization = canLogs || canInspect || canStats || canExec || canAttach; if (!hasAnyAuthorization) { return null; } return (