From dc5bd06c1d1679ef0b85a72642295e10610d5271 Mon Sep 17 00:00:00 2001 From: mgold1234 Date: Mon, 25 Dec 2023 12:00:38 +0200 Subject: [PATCH] fix linting warnings fix some useEffect changes --- src/App.js | 8 +++----- .../CreateImageWizard/formComponents/AWSSourcesSelect.js | 7 ++++++- .../CreateImageWizard/formComponents/ActivationKeys.js | 2 +- .../formComponents/AzureSourcesSelect.js | 8 +++++++- .../formComponents/FileSystemConfigButtons.js | 4 ++-- .../formComponents/FileSystemConfiguration.js | 6 +++--- .../CreateImageWizard/formComponents/MountPoint.js | 2 +- .../CreateImageWizard/formComponents/Packages.js | 2 +- src/Components/ImagesTable/ClonesTable.tsx | 2 +- 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/App.js b/src/App.js index b7c22f3645..17c0d83684 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import { useChrome } from '@redhat-cloud-services/frontend-components/useChrome'; import NotificationsPortal from '@redhat-cloud-services/frontend-components-notifications/NotificationPortal'; @@ -11,10 +11,8 @@ const App = (props) => { const store = useStore(); const { hideGlobalFilter, updateDocumentTitle } = useChrome(); - useEffect(() => { - updateDocumentTitle('Image Builder | Red Hat Insights'); - hideGlobalFilter(); - }, []); + updateDocumentTitle('Image Builder | Red Hat Insights'); + hideGlobalFilter(); return ( diff --git a/src/Components/CreateImageWizard/formComponents/AWSSourcesSelect.js b/src/Components/CreateImageWizard/formComponents/AWSSourcesSelect.js index 5879e795cf..dd3a99db20 100644 --- a/src/Components/CreateImageWizard/formComponents/AWSSourcesSelect.js +++ b/src/Components/CreateImageWizard/formComponents/AWSSourcesSelect.js @@ -55,7 +55,12 @@ export const AWSSourcesSelect = ({ useEffect(() => { if (isFetchingDetails || !isSuccessDetails) return; change('aws-associated-account-id', sourceDetails?.aws?.account_id); - }, [isFetchingDetails, isSuccessDetails]); + }, [ + isFetchingDetails, + isSuccessDetails, + change, + sourceDetails?.aws?.account_id, + ]); const onFormChange = ({ values }) => { if ( diff --git a/src/Components/CreateImageWizard/formComponents/ActivationKeys.js b/src/Components/CreateImageWizard/formComponents/ActivationKeys.js index 1b798d7bec..b6bb35ac10 100644 --- a/src/Components/CreateImageWizard/formComponents/ActivationKeys.js +++ b/src/Components/CreateImageWizard/formComponents/ActivationKeys.js @@ -91,7 +91,7 @@ const ActivationKeys = ({ label, isRequired, ...props }) => { change('subscription-server-url', 'subscription.rhsm.stage.redhat.com'); change('subscription-base-url', 'https://cdn.stage.redhat.com/'); } - }, []); + }, [isProd, change]); const setActivationKey = (_, selection) => { selectActivationKey(selection); diff --git a/src/Components/CreateImageWizard/formComponents/AzureSourcesSelect.js b/src/Components/CreateImageWizard/formComponents/AzureSourcesSelect.js index b6e8d24cc1..2427856fa9 100644 --- a/src/Components/CreateImageWizard/formComponents/AzureSourcesSelect.js +++ b/src/Components/CreateImageWizard/formComponents/AzureSourcesSelect.js @@ -49,7 +49,13 @@ const AzureSourcesSelect = ({ label, isRequired, className, ...props }) => { if (isFetchingDetails || !isSuccessDetails) return; change('azure-tenant-id', sourceDetails?.azure?.tenant_id); change('azure-subscription-id', sourceDetails?.azure?.subscription_id); - }, [isFetchingDetails, isSuccessDetails]); + }, [ + isFetchingDetails, + isSuccessDetails, + sourceDetails?.azure?.subscription_id, + sourceDetails?.azure?.tenant_id, + change, + ]); const onFormChange = ({ values }) => { if ( diff --git a/src/Components/CreateImageWizard/formComponents/FileSystemConfigButtons.js b/src/Components/CreateImageWizard/formComponents/FileSystemConfigButtons.js index ded6bd37ee..1a76b494bd 100644 --- a/src/Components/CreateImageWizard/formComponents/FileSystemConfigButtons.js +++ b/src/Components/CreateImageWizard/formComponents/FileSystemConfigButtons.js @@ -16,16 +16,16 @@ const FileSystemConfigButtons = ({ handleNext, handlePrev, nextStep }) => { ); const [nextHasBeenClicked, setNextHasBeenClicked] = useState(false); const prefetchArchitectures = imageBuilderApi.usePrefetch('getArchitectures'); + const errors = getState()?.errors?.['file-system-configuration']; useEffect(() => { - const errors = getState()?.errors?.['file-system-configuration']; errors ? setHasErrors(true) : setHasErrors(false); if (!errors) { setNextHasBeenClicked(false); change('file-system-config-show-errors', false); } - }); + }, [errors, change]); const handleClick = () => { if (!hasErrors) { diff --git a/src/Components/CreateImageWizard/formComponents/FileSystemConfiguration.js b/src/Components/CreateImageWizard/formComponents/FileSystemConfiguration.js index d730d7cb7f..4b879f6580 100644 --- a/src/Components/CreateImageWizard/formComponents/FileSystemConfiguration.js +++ b/src/Components/CreateImageWizard/formComponents/FileSystemConfiguration.js @@ -100,7 +100,7 @@ const FileSystemConfiguration = ({ ...props }) => { setItemOrder(newRows.map((row) => row.id)); change('file-system-config-radio', 'manual'); } - }, [customizations, isSuccess]); + }, [customizations, isSuccess, change, hasCustomizations, rows]); useEffect(() => { const fsc = getState()?.values?.['file-system-configuration']; @@ -123,7 +123,7 @@ const FileSystemConfiguration = ({ ...props }) => { }); setRows(newRows); setItemOrder(newOrder); - }, []); + }, [getState]); const showErrors = () => getState()?.values?.['file-system-config-show-errors']; @@ -143,7 +143,7 @@ const FileSystemConfiguration = ({ ...props }) => { } }) ); - }, [rows, itemOrder]); + }, [rows, itemOrder, change, input.name]); const addRow = () => { const id = uuidv4(); diff --git a/src/Components/CreateImageWizard/formComponents/MountPoint.js b/src/Components/CreateImageWizard/formComponents/MountPoint.js index fc33c42f06..40c69ab11f 100644 --- a/src/Components/CreateImageWizard/formComponents/MountPoint.js +++ b/src/Components/CreateImageWizard/formComponents/MountPoint.js @@ -36,7 +36,7 @@ const MountPoint = ({ ...props }) => { return; } } - }, []); + }, [props.mountpoint]); useEffect(() => { let suf = suffix; diff --git a/src/Components/CreateImageWizard/formComponents/Packages.js b/src/Components/CreateImageWizard/formComponents/Packages.js index 91fc72c1ab..92ec397705 100644 --- a/src/Components/CreateImageWizard/formComponents/Packages.js +++ b/src/Components/CreateImageWizard/formComponents/Packages.js @@ -159,7 +159,7 @@ const Packages = ({ getAllPackages, isSuccess }) => { } setChosenPackages(newChosenPackages); } - }, []); + }, [selectedPackages]); useEffect(() => { if (isSuccess) { diff --git a/src/Components/ImagesTable/ClonesTable.tsx b/src/Components/ImagesTable/ClonesTable.tsx index cb6cb41e66..4a6e139cb1 100644 --- a/src/Components/ImagesTable/ClonesTable.tsx +++ b/src/Components/ImagesTable/ClonesTable.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; -import { ClipboardCopy, Skeleton } from '@patternfly/react-core'; +import { ClipboardCopy } from '@patternfly/react-core'; import { Table, Tbody, Td, Th, Thead, Tr } from '@patternfly/react-table'; import { StatusClone, AwsDetailsStatus } from './Status';