ImagesTable: extract toolbar to separate component
This extracts the toolbar, that was getting bit too big to a separate component. It also adjusts the title to correspond to the filter of the images. If there is a Blueprint selected, it changes the title to '<BlueprintName> images'
This commit is contained in:
parent
61c25e8331
commit
947c20875c
3 changed files with 136 additions and 62 deletions
|
|
@ -2,25 +2,22 @@ import React from 'react';
|
|||
|
||||
import { Button } from '@patternfly/react-core';
|
||||
|
||||
import { selectSelectedBlueprintId } from '../../store/BlueprintSlice';
|
||||
import { useAppSelector } from '../../store/hooks';
|
||||
import { useComposeBlueprintMutation } from '../../store/imageBuilderApi';
|
||||
|
||||
interface BuildImagesButtonProps {
|
||||
selectedBlueprint?: string | undefined;
|
||||
}
|
||||
|
||||
export const BuildImagesButton: React.FunctionComponent<
|
||||
BuildImagesButtonProps
|
||||
> = ({ selectedBlueprint }: BuildImagesButtonProps) => {
|
||||
export const BuildImagesButton = () => {
|
||||
const selectedBlueprintId = useAppSelector(selectSelectedBlueprintId);
|
||||
const [buildBlueprint, { isLoading: imageBuildLoading }] =
|
||||
useComposeBlueprintMutation();
|
||||
const onBuildHandler = async () => {
|
||||
selectedBlueprint && (await buildBlueprint({ id: selectedBlueprint }));
|
||||
selectedBlueprintId && (await buildBlueprint({ id: selectedBlueprintId }));
|
||||
};
|
||||
return (
|
||||
<Button
|
||||
ouiaId="build-images-button"
|
||||
onClick={onBuildHandler}
|
||||
isDisabled={!selectedBlueprint}
|
||||
isDisabled={!selectedBlueprintId}
|
||||
isLoading={imageBuildLoading}
|
||||
>
|
||||
Build images
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue