import React, { useState } from 'react'; import { Button, Popover, Text, TextContent, Flex, FlexItem, Dropdown, DropdownList, MenuToggle, MenuToggleElement, DropdownItem, } from '@patternfly/react-core'; import { ExternalLinkAltIcon, HelpIcon } from '@patternfly/react-icons'; // eslint-disable-next-line rulesdir/disallow-fec-relative-imports import { OpenSourceBadge, PageHeader, PageHeaderTitle, } from '@redhat-cloud-services/frontend-components'; import { Link } from 'react-router-dom'; import { useComposeBlueprintMutation, useDeleteBlueprintMutation, } from '../../store/imageBuilderApi'; import { resolveRelPath } from '../../Utilities/path'; import './ImageBuilderHeader.scss'; import { DeleteBlueprintModal } from '../Blueprints/DeleteBlueprintModal'; type ImageBuilderHeaderPropTypes = { experimentalFlag?: string | true | undefined; selectedBlueprint?: string | undefined; }; export const ImageBuilderHeader = ({ experimentalFlag, selectedBlueprint, }: ImageBuilderHeaderPropTypes) => { const [buildBlueprint, { isLoading: imageBuildLoading }] = useComposeBlueprintMutation(); const onBuildHandler = async () => { selectedBlueprint && (await buildBlueprint({ id: selectedBlueprint })); }; const [isOpen, setIsOpen] = useState(false); const onSelect = () => { setIsOpen(!isOpen); }; const [showDeleteModal, setShowDeleteModal] = React.useState(false); const [deleteBlueprint] = useDeleteBlueprintMutation({ fixedCacheKey: 'delete-blueprint', }); const handleDelete = async () => { if (selectedBlueprint) { setShowDeleteModal(false); await deleteBlueprint({ id: selectedBlueprint }); } }; const onDeleteClose = () => { setShowDeleteModal(false); }; return ( <> {/*@ts-ignore*/} Image builder is a tool for creating deployment-ready customized system images: installation disks, virtual machines, cloud vendor-specific images, and others. By using image builder, you can make these images faster than manual procedures because it eliminates the specific configurations required for each output type. } > {experimentalFlag && ( <> Create setIsOpen(isOpen)} shouldFocusToggleOnSelect toggle={(toggleRef: React.Ref) => ( setIsOpen(!isOpen)} variant="secondary" aria-label="blueprint menu toggle" isDisabled={selectedBlueprint === undefined} > Blueprint actions )} > Edit details setShowDeleteModal(true)}> Delete blueprint {' '} )} ); };