Skip to content

Commit

Permalink
src: Prefetch list of targets on hover of Create blueprint button
Browse files Browse the repository at this point in the history
This prefetches list of possible targets based on distribution for `onMouseEnter` event of Create blueprint button.
  • Loading branch information
regexowl authored and mgold1234 committed Oct 1, 2024
1 parent 2f5d5cf commit cec56c7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Components/sharedComponents/ImageBuilderHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import {
CREATING_IMAGES_WITH_IB_SERVICE_URL,
OSBUILD_SERVICE_ARCHITECTURE_URL,
} from '../../constants';
import { useAppSelector } from '../../store/hooks';
import { imageBuilderApi } from '../../store/imageBuilderApi';
import { selectDistribution } from '../../store/wizardSlice';
import { resolveRelPath } from '../../Utilities/path';
import './ImageBuilderHeader.scss';
import { useFlagWithEphemDefault } from '../../Utilities/useGetEnvironment';
Expand Down Expand Up @@ -94,6 +97,10 @@ export const ImageBuilderHeader = ({
inWizard,
}: ImageBuilderHeaderPropTypes) => {
const navigate = useNavigate();

const distribution = useAppSelector(selectDistribution);
const prefetchTargets = imageBuilderApi.usePrefetch('getArchitectures');

const importExportFlag = useFlagWithEphemDefault(
'image-builder.import.enabled'
);
Expand Down Expand Up @@ -130,6 +137,11 @@ export const ImageBuilderHeader = ({
data-testid="blueprints-create-button"
onClick={() => navigate(resolveRelPath('imagewizard'))}
isDisabled={!isOnBlueprintsTab}
onMouseEnter={() =>
prefetchTargets({
distribution: distribution,
})
}
>
Create blueprint
</Button>
Expand Down

0 comments on commit cec56c7

Please sign in to comment.