diff --git a/frontend/components/AddHostsModal/PlatformWrapper/PlatformWrapper.tsx b/frontend/components/AddHostsModal/PlatformWrapper/PlatformWrapper.tsx index cbfce304b0..876dc04e52 100644 --- a/frontend/components/AddHostsModal/PlatformWrapper/PlatformWrapper.tsx +++ b/frontend/components/AddHostsModal/PlatformWrapper/PlatformWrapper.tsx @@ -7,8 +7,6 @@ import { NotificationContext } from "context/notification"; import { AppContext } from "context/app"; // @ts-ignore import { stringToClipboard } from "utilities/copy_text"; -import { ITeam } from "interfaces/team"; -import { IEnrollSecret } from "interfaces/enroll_secret"; import configAPI from "services/entities/config"; @@ -67,8 +65,8 @@ const PlatformWrapper = ({ const { config, isPreviewMode } = useContext(AppContext); const { renderFlash } = useContext(NotificationContext); const [copyMessage, setCopyMessage] = useState>({}); - const [includeFleetDesktop, setIncludeFleetDesktop] = useState(true); - const [showPlainOsquery, setShowPlainOsquery] = useState(false); + const [includeFleetDesktop, setIncludeFleetDesktop] = useState(true); + const [showPlainOsquery, setShowPlainOsquery] = useState(false); const { data: certificate, diff --git a/frontend/components/App/App.tsx b/frontend/components/App/App.tsx index a55b376d55..0c9f745d9d 100644 --- a/frontend/components/App/App.tsx +++ b/frontend/components/App/App.tsx @@ -48,7 +48,7 @@ const App = ({ children, location }: IAppProps): JSX.Element => { setSandboxExpiry, } = useContext(AppContext); - const [isLoading, setIsLoading] = useState(false); + const [isLoading, setIsLoading] = useState(false); const fetchConfig = async () => { try { diff --git a/frontend/components/Avatar/Avatar.tsx b/frontend/components/Avatar/Avatar.tsx index e8835ba5f9..46cfe98cf6 100644 --- a/frontend/components/Avatar/Avatar.tsx +++ b/frontend/components/Avatar/Avatar.tsx @@ -16,8 +16,8 @@ export interface IAvatarInterface { const baseClass = "avatar"; const Avatar = ({ className, size, user }: IAvatarInterface): JSX.Element => { - const [isLoading, setIsLoading] = useState(true); - const [isError, setIsError] = useState(); + const [isLoading, setIsLoading] = useState(true); + const [isError, setIsError] = useState(false); const onLoad = useCallback(() => { setIsLoading(false); diff --git a/frontend/components/DeleteSecretModal/DeleteSecretModal.tsx b/frontend/components/DeleteSecretModal/DeleteSecretModal.tsx index 8ade21920a..61bb4140df 100644 --- a/frontend/components/DeleteSecretModal/DeleteSecretModal.tsx +++ b/frontend/components/DeleteSecretModal/DeleteSecretModal.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from "react"; +import React from "react"; import Modal from "components/Modal"; import Button from "components/buttons/Button"; import { ITeam } from "interfaces/team"; diff --git a/frontend/components/EnrollSecretTable/EnrollSecretRow/EnrollSecretRow.tsx b/frontend/components/EnrollSecretTable/EnrollSecretRow/EnrollSecretRow.tsx index 857ac0123f..70ac87926d 100644 --- a/frontend/components/EnrollSecretTable/EnrollSecretRow/EnrollSecretRow.tsx +++ b/frontend/components/EnrollSecretTable/EnrollSecretRow/EnrollSecretRow.tsx @@ -28,8 +28,8 @@ const EnrollSecretRow = ({ toggleDeleteSecretModal, setSelectedSecret, }: IEnrollSecretRowProps): JSX.Element | null => { - const [showSecret, setShowSecret] = useState(false); - const [copyMessage, setCopyMessage] = useState(""); + const [showSecret, setShowSecret] = useState(false); + const [copyMessage, setCopyMessage] = useState(""); const onCopySecret = (evt: React.MouseEvent) => { evt.preventDefault(); diff --git a/frontend/components/LiveQuery/SelectTargets.tsx b/frontend/components/LiveQuery/SelectTargets.tsx index 9868e873dd..d3ef139cd5 100644 --- a/frontend/components/LiveQuery/SelectTargets.tsx +++ b/frontend/components/LiveQuery/SelectTargets.tsx @@ -138,9 +138,9 @@ const SelectTargets = ({ const [labels, setLabels] = useState(null); const [inputTabIndex, setInputTabIndex] = useState(null); - const [searchText, setSearchText] = useState(""); - const [debouncedSearchText, setDebouncedSearchText] = useState(""); - const [isDebouncing, setIsDebouncing] = useState(false); + const [searchText, setSearchText] = useState(""); + const [debouncedSearchText, setDebouncedSearchText] = useState(""); + const [isDebouncing, setIsDebouncing] = useState(false); const debounceSearch = useDebouncedCallback( (search: string) => { diff --git a/frontend/components/SecretEditorModal/SecretEditorModal.tsx b/frontend/components/SecretEditorModal/SecretEditorModal.tsx index 624730cd18..add769c3ca 100644 --- a/frontend/components/SecretEditorModal/SecretEditorModal.tsx +++ b/frontend/components/SecretEditorModal/SecretEditorModal.tsx @@ -38,7 +38,7 @@ const SecretEditorModal = ({ selectedSecret, isUpdatingSecret, }: ISecretEditorModalProps): JSX.Element => { - const [enrollSecretString, setEnrollSecretString] = useState( + const [enrollSecretString, setEnrollSecretString] = useState( selectedSecret ? selectedSecret.secret : randomSecretGenerator() ); const [errors, setErrors] = useState<{ [key: string]: string }>({}); diff --git a/frontend/components/SecretField/SecretField.tsx b/frontend/components/SecretField/SecretField.tsx index 338589745b..bce339705e 100644 --- a/frontend/components/SecretField/SecretField.tsx +++ b/frontend/components/SecretField/SecretField.tsx @@ -15,8 +15,8 @@ interface ISecretFieldProps { secret: string | null; } const SecretField = ({ secret }: ISecretFieldProps): JSX.Element | null => { - const [showSecret, setShowSecret] = useState(false); - const [copyMessage, setCopyMessage] = useState(""); + const [showSecret, setShowSecret] = useState(false); + const [copyMessage, setCopyMessage] = useState(""); const onCopySecret = (evt: React.MouseEvent) => { evt.preventDefault(); diff --git a/frontend/components/TableContainer/TableContainer.tsx b/frontend/components/TableContainer/TableContainer.tsx index 9284cab99c..032cd73252 100644 --- a/frontend/components/TableContainer/TableContainer.tsx +++ b/frontend/components/TableContainer/TableContainer.tsx @@ -143,7 +143,7 @@ const TableContainer = ({ const [sortDirection, setSortDirection] = useState( defaultSortDirection || "" ); - const [pageIndex, setPageIndex] = useState(DEFAULT_PAGE_INDEX); + const [pageIndex, setPageIndex] = useState(DEFAULT_PAGE_INDEX); const [clientFilterCount, setClientFilterCount] = useState(); const prevPageIndex = useRef(0); diff --git a/frontend/components/forms/packs/EditPackForm/EditPackForm.tsx b/frontend/components/forms/packs/EditPackForm/EditPackForm.tsx index 9b26e9629f..6da6fe0ede 100644 --- a/frontend/components/forms/packs/EditPackForm/EditPackForm.tsx +++ b/frontend/components/forms/packs/EditPackForm/EditPackForm.tsx @@ -55,10 +55,8 @@ const EditPackForm = ({ isUpdatingPack, }: IEditPackForm): JSX.Element => { const [errors, setErrors] = useState<{ [key: string]: string }>({}); - const [packName, setPackName] = useState(formData.name); - const [packDescription, setPackDescription] = useState( - formData.description - ); + const [packName, setPackName] = useState(formData.name); + const [packDescription, setPackDescription] = useState(formData.description); const [packFormTargets, setPackFormTargets] = useState( formData.targets ); diff --git a/frontend/components/forms/packs/PackForm/PackForm.tsx b/frontend/components/forms/packs/PackForm/PackForm.tsx index 20fc8bf26a..bc789edb6e 100644 --- a/frontend/components/forms/packs/PackForm/PackForm.tsx +++ b/frontend/components/forms/packs/PackForm/PackForm.tsx @@ -37,8 +37,8 @@ const EditPackForm = ({ isUpdatingPack, }: IPackForm): JSX.Element => { const [errors, setErrors] = useState<{ [key: string]: string }>({}); - const [packName, setPackName] = useState(""); - const [packDescription, setPackDescription] = useState(""); + const [packName, setPackName] = useState(""); + const [packDescription, setPackDescription] = useState(""); const [packFormTargets, setPackFormTargets] = useState([]); const onChangePackName = (value: string) => { diff --git a/frontend/components/queries/PackQueriesTable/PackQueriesTable.tsx b/frontend/components/queries/PackQueriesTable/PackQueriesTable.tsx index 3fc1361bd5..8fdda48077 100644 --- a/frontend/components/queries/PackQueriesTable/PackQueriesTable.tsx +++ b/frontend/components/queries/PackQueriesTable/PackQueriesTable.tsx @@ -29,7 +29,7 @@ const PackQueriesTable = ({ scheduledQueries, isLoadingPackQueries, }: IPackQueriesTableProps): JSX.Element => { - const [querySearchText, setQuerySearchText] = useState(""); + const [querySearchText, setQuerySearchText] = useState(""); // NOTE: this is called once on the initial rendering. The initial render of // the TableContainer child component will call this handler. diff --git a/frontend/docs/patterns.md b/frontend/docs/patterns.md index dc4905134b..3937f8d9a5 100644 --- a/frontend/docs/patterns.md +++ b/frontend/docs/patterns.md @@ -45,7 +45,7 @@ All Javascript and React files use Typescript, meaning the extensions are `.ts` - Local states ```typescript -const [item, setItem] = useState(""); +const [item, setItem] = useState(""); ``` - Fetch function signatures (i.e. `react-query`) @@ -112,7 +112,7 @@ of React. Hooks are only allowed in functional components, which are created lik import React, { useState, useEffect } from "React"; const PageOrComponent = (props) => { - const [item, setItem] = useState(""); + const [item, setItem] = useState(""); // runs only on first mount (replaces componentDidMount) useEffect(() => { diff --git a/frontend/hooks/usePlaformSelector.tsx b/frontend/hooks/usePlaformSelector.tsx index ebf20b9ad1..b7a10cccd2 100644 --- a/frontend/hooks/usePlaformSelector.tsx +++ b/frontend/hooks/usePlaformSelector.tsx @@ -16,9 +16,9 @@ const usePlatformSelector = ( platformContext: IPlatformString | null | undefined, baseClass = "" ): IPlatformSelector => { - const [checkDarwin, setCheckDarwin] = useState(false); - const [checkWindows, setCheckWindows] = useState(false); - const [checkLinux, setCheckLinux] = useState(false); + const [checkDarwin, setCheckDarwin] = useState(false); + const [checkWindows, setCheckWindows] = useState(false); + const [checkLinux, setCheckLinux] = useState(false); const checksByPlatform: Record = { darwin: checkDarwin, diff --git a/frontend/layouts/CoreLayout/CoreLayout.tsx b/frontend/layouts/CoreLayout/CoreLayout.tsx index cc7a9089b1..c0e92ab8e3 100644 --- a/frontend/layouts/CoreLayout/CoreLayout.tsx +++ b/frontend/layouts/CoreLayout/CoreLayout.tsx @@ -37,10 +37,9 @@ const CoreLayout = ({ children, router }: ICoreLayoutProps) => { const { config, currentUser, isPremiumTier } = useContext(AppContext); const { notification, hideFlash } = useContext(NotificationContext); const { setResetSelectedRows } = useContext(TableContext); - const [ - showExpirationFlashMessage, - setShowExpirationFlashMessage, - ] = useState(false); + const [showExpirationFlashMessage, setShowExpirationFlashMessage] = useState( + false + ); // on success of an action, the table will reset its checkboxes. // setTimeout is to help with race conditions as table reloads diff --git a/frontend/pages/ForgotPasswordPage/ForgotPasswordPage.tsx b/frontend/pages/ForgotPasswordPage/ForgotPasswordPage.tsx index 607f60bd54..766d50472c 100644 --- a/frontend/pages/ForgotPasswordPage/ForgotPasswordPage.tsx +++ b/frontend/pages/ForgotPasswordPage/ForgotPasswordPage.tsx @@ -13,9 +13,9 @@ import Spinner from "components/Spinner"; import ExternalURLIcon from "../../../assets/images/icon-external-url-12x12@2x.png"; const ForgotPasswordPage = () => { - const [email, setEmail] = useState(""); + const [email, setEmail] = useState(""); const [errors, setErrors] = useState<{ [key: string]: string }>({}); - const [isLoading, setIsLoading] = useState(false); + const [isLoading, setIsLoading] = useState(false); const baseClass = "forgot-password"; diff --git a/frontend/pages/Homepage/Homepage.tsx b/frontend/pages/Homepage/Homepage.tsx index 95fd7623e9..3d68fe41e1 100644 --- a/frontend/pages/Homepage/Homepage.tsx +++ b/frontend/pages/Homepage/Homepage.tsx @@ -52,24 +52,20 @@ const Homepage = (): JSX.Element => { setCurrentTeam, } = useContext(AppContext); - const [selectedPlatform, setSelectedPlatform] = useState(""); + const [selectedPlatform, setSelectedPlatform] = useState(""); const [labels, setLabels] = useState(); - const [macCount, setMacCount] = useState(0); - const [windowsCount, setWindowsCount] = useState(0); - const [linuxCount, setLinuxCount] = useState(0); - const [onlineCount, setOnlineCount] = useState(0); - const [offlineCount, setOfflineCount] = useState(0); - const [showActivityFeedTitle, setShowActivityFeedTitle] = useState( - false - ); - const [showSoftwareUI, setShowSoftwareUI] = useState(false); - const [showMunkiUI, setShowMunkiUI] = useState(false); - const [showMDMUI, setShowMDMUI] = useState(false); - const [showAddHostsModal, setShowAddHostsModal] = useState(false); - const [showOperatingSystemsUI, setShowOperatingSystemsUI] = useState( - false - ); - const [showHostsUI, setShowHostsUI] = useState(false); // Hides UI on first load only + const [macCount, setMacCount] = useState(0); + const [windowsCount, setWindowsCount] = useState(0); + const [linuxCount, setLinuxCount] = useState(0); + const [onlineCount, setOnlineCount] = useState(0); + const [offlineCount, setOfflineCount] = useState(0); + const [showActivityFeedTitle, setShowActivityFeedTitle] = useState(false); + const [showSoftwareUI, setShowSoftwareUI] = useState(false); + const [showMunkiUI, setShowMunkiUI] = useState(false); + const [showMDMUI, setShowMDMUI] = useState(false); + const [showAddHostsModal, setShowAddHostsModal] = useState(false); + const [showOperatingSystemsUI, setShowOperatingSystemsUI] = useState(false); + const [showHostsUI, setShowHostsUI] = useState(false); // Hides UI on first load only const canEnrollHosts = isGlobalAdmin || isGlobalMaintainer || isTeamAdmin || isTeamMaintainer; @@ -124,24 +120,20 @@ const Homepage = (): JSX.Element => { } ); - const { - isLoading: isGlobalSecretsLoading, - data: globalSecrets, - refetch: refetchGlobalSecrets, - } = useQuery( - ["global secrets"], - () => enrollSecretsAPI.getGlobalEnrollSecrets(), - { - enabled: !!canEnrollGlobalHosts, - select: (data: IEnrollSecretsResponse) => data.secrets, - } - ); + const { isLoading: isGlobalSecretsLoading, data: globalSecrets } = useQuery< + IEnrollSecretsResponse, + Error, + IEnrollSecret[] + >(["global secrets"], () => enrollSecretsAPI.getGlobalEnrollSecrets(), { + enabled: !!canEnrollGlobalHosts, + select: (data: IEnrollSecretsResponse) => data.secrets, + }); - const { - isLoading: isTeamSecretsLoading, - data: teamSecrets, - refetch: refetchTeamSecrets, - } = useQuery( + const { data: teamSecrets } = useQuery< + IEnrollSecretsResponse, + Error, + IEnrollSecret[] + >( ["team secrets", currentTeam], () => { if (currentTeam) { diff --git a/frontend/pages/Homepage/cards/ActivityFeed/ActivityFeed.tsx b/frontend/pages/Homepage/cards/ActivityFeed/ActivityFeed.tsx index f073e326b6..effc106c4d 100644 --- a/frontend/pages/Homepage/cards/ActivityFeed/ActivityFeed.tsx +++ b/frontend/pages/Homepage/cards/ActivityFeed/ActivityFeed.tsx @@ -74,8 +74,8 @@ const TAGGED_TEMPLATES = { const ActivityFeed = ({ setShowActivityFeedTitle, }: IActvityCardProps): JSX.Element => { - const [pageIndex, setPageIndex] = useState(0); - const [showMore, setShowMore] = useState(true); + const [pageIndex, setPageIndex] = useState(0); + const [showMore, setShowMore] = useState(true); const { data: activities, diff --git a/frontend/pages/Homepage/cards/MDM/MDM.tsx b/frontend/pages/Homepage/cards/MDM/MDM.tsx index e814482a06..65091ee8c0 100644 --- a/frontend/pages/Homepage/cards/MDM/MDM.tsx +++ b/frontend/pages/Homepage/cards/MDM/MDM.tsx @@ -67,7 +67,7 @@ const MDM = ({ setShowMDMUI, setTitleDetail, }: IMDMCardProps): JSX.Element => { - const [navTabIndex, setNavTabIndex] = useState(0); + const [navTabIndex, setNavTabIndex] = useState(0); const [formattedMDMData, setFormattedMDMData] = useState< IDataTableMDMFormat[] >([]); diff --git a/frontend/pages/Homepage/cards/Software/Software.tsx b/frontend/pages/Homepage/cards/Software/Software.tsx index 03043e8d94..4fad8c0df3 100644 --- a/frontend/pages/Homepage/cards/Software/Software.tsx +++ b/frontend/pages/Homepage/cards/Software/Software.tsx @@ -35,9 +35,9 @@ const Software = ({ setActionURL, setTitleDetail, }: ISoftwareCardProps): JSX.Element => { - const [navTabIndex, setNavTabIndex] = useState(0); - const [pageIndex, setPageIndex] = useState(0); - const [isSoftwareEnabled, setIsSoftwareEnabled] = useState(); + const [navTabIndex, setNavTabIndex] = useState(0); + const [pageIndex, setPageIndex] = useState(0); + const [isSoftwareEnabled, setIsSoftwareEnabled] = useState(false); const { availableTeams, currentTeam, isOnGlobalTeam } = useContext( AppContext diff --git a/frontend/pages/Homepage/cards/WelcomeHost/WelcomeHost.tsx b/frontend/pages/Homepage/cards/WelcomeHost/WelcomeHost.tsx index 67f74600b0..d38656b0f7 100644 --- a/frontend/pages/Homepage/cards/WelcomeHost/WelcomeHost.tsx +++ b/frontend/pages/Homepage/cards/WelcomeHost/WelcomeHost.tsx @@ -41,12 +41,11 @@ const WelcomeHost = ({ const { renderFlash } = useContext(NotificationContext); const [refetchStartTime, setRefetchStartTime] = useState(null); const [currentPolicyShown, setCurrentPolicyShown] = useState(); - const [showPolicyModal, setShowPolicyModal] = useState(false); - const [isPoliciesEmpty, setIsPoliciesEmpty] = useState(false); - const [ - showRefetchLoadingSpinner, - setShowRefetchLoadingSpinner, - ] = useState(false); + const [showPolicyModal, setShowPolicyModal] = useState(false); + const [isPoliciesEmpty, setIsPoliciesEmpty] = useState(false); + const [showRefetchLoadingSpinner, setShowRefetchLoadingSpinner] = useState( + false + ); const { isLoading: isLoadingHost, diff --git a/frontend/pages/LoginPage/LoginPage.tsx b/frontend/pages/LoginPage/LoginPage.tsx index 9abe194f50..17f862a918 100644 --- a/frontend/pages/LoginPage/LoginPage.tsx +++ b/frontend/pages/LoginPage/LoginPage.tsx @@ -55,7 +55,7 @@ const LoginPage = ({ router, location }: ILoginPageProps) => { } = useContext(AppContext); const { renderFlash } = useContext(NotificationContext); const { redirectLocation } = useContext(RoutingContext); - const [loginVisible, setLoginVisible] = useState(true); + const [loginVisible, setLoginVisible] = useState(true); const [ssoSettings, setSSOSettings] = useState(); const [pageStatus, setPageStatus] = useState( new URLSearchParams(location.search).get("status") diff --git a/frontend/pages/LoginPage/LoginPreviewPage.tsx b/frontend/pages/LoginPage/LoginPreviewPage.tsx index d70d98360a..6d2d9ad10c 100644 --- a/frontend/pages/LoginPage/LoginPreviewPage.tsx +++ b/frontend/pages/LoginPage/LoginPreviewPage.tsx @@ -26,7 +26,7 @@ const LoginPreviewPage = ({ router }: ILoginPreviewPageProps): JSX.Element => { setCurrentUser, setCurrentTeam, } = useContext(AppContext); - const [loginVisible, setLoginVisible] = useState(true); + const [loginVisible, setLoginVisible] = useState(true); const onSubmit = async (formData: ILoginData) => { const { HOME } = paths; diff --git a/frontend/pages/UserSettingsPage/UserSettingsPage.tsx b/frontend/pages/UserSettingsPage/UserSettingsPage.tsx index 8287516d1e..934b7a66ad 100644 --- a/frontend/pages/UserSettingsPage/UserSettingsPage.tsx +++ b/frontend/pages/UserSettingsPage/UserSettingsPage.tsx @@ -38,14 +38,14 @@ interface IUserSettingsPageProps { const UserSettingsPage = ({ router, }: IUserSettingsPageProps): JSX.Element | null => { - const { config, currentUser, isSandboxMode } = useContext(AppContext); + const { config, currentUser } = useContext(AppContext); const { renderFlash } = useContext(NotificationContext); - const [pendingEmail, setPendingEmail] = useState(""); - const [showEmailModal, setShowEmailModal] = useState(false); - const [showPasswordModal, setShowPasswordModal] = useState(false); + const [pendingEmail, setPendingEmail] = useState(""); + const [showEmailModal, setShowEmailModal] = useState(false); + const [showPasswordModal, setShowPasswordModal] = useState(false); const [updatedUser, setUpdatedUser] = useState>({}); - const [showApiTokenModal, setShowApiTokenModal] = useState(false); + const [showApiTokenModal, setShowApiTokenModal] = useState(false); const [errors, setErrors] = useState<{ [key: string]: string }>({}); const [userErrors, setUserErrors] = useState<{ [key: string]: string }>({}); diff --git a/frontend/pages/admin/AppSettingsPage/cards/HostStatusWebhook/HostStatusWebhook.tsx b/frontend/pages/admin/AppSettingsPage/cards/HostStatusWebhook/HostStatusWebhook.tsx index 978f2dda2b..0e5925e2da 100644 --- a/frontend/pages/admin/AppSettingsPage/cards/HostStatusWebhook/HostStatusWebhook.tsx +++ b/frontend/pages/admin/AppSettingsPage/cards/HostStatusWebhook/HostStatusWebhook.tsx @@ -27,7 +27,7 @@ const HostStatusWebhook = ({ const [ showHostStatusWebhookPreviewModal, setShowHostStatusWebhookPreviewModal, - ] = useState(false); + ] = useState(false); const [formData, setFormData] = useState({ enableHostStatusWebhook: appConfig.webhook_settings.host_status_webhook diff --git a/frontend/pages/admin/AppSettingsPage/cards/Statistics/Statistics.tsx b/frontend/pages/admin/AppSettingsPage/cards/Statistics/Statistics.tsx index 3da9ad716b..7f761f742b 100644 --- a/frontend/pages/admin/AppSettingsPage/cards/Statistics/Statistics.tsx +++ b/frontend/pages/admin/AppSettingsPage/cards/Statistics/Statistics.tsx @@ -19,10 +19,9 @@ const Statistics = ({ handleSubmit, isUpdatingSettings, }: IAppConfigFormProps): JSX.Element => { - const [ - showUsageStatsPreviewModal, - setShowUsageStatsPreviewModal, - ] = useState(false); + const [showUsageStatsPreviewModal, setShowUsageStatsPreviewModal] = useState( + false + ); const [formData, setFormData] = useState({ enableUsageStatistics: appConfig.server_settings.enable_analytics, }); diff --git a/frontend/pages/admin/AppSettingsPage/components/OrgSettingsForm/OrgSettingsForm.tsx b/frontend/pages/admin/AppSettingsPage/components/OrgSettingsForm/OrgSettingsForm.tsx index cd4e4ee916..eb9927070d 100644 --- a/frontend/pages/admin/AppSettingsPage/components/OrgSettingsForm/OrgSettingsForm.tsx +++ b/frontend/pages/admin/AppSettingsPage/components/OrgSettingsForm/OrgSettingsForm.tsx @@ -35,8 +35,8 @@ const OrgSettingsForm = ({ const handlePageError = useErrorHandler(); - const [activeSection, setActiveSection] = useState("info"); - const [isUpdatingSettings, setIsUpdatingSettings] = useState(false); + const [activeSection, setActiveSection] = useState("info"); + const [isUpdatingSettings, setIsUpdatingSettings] = useState(false); const { data: appConfig, isLoading, refetch: refetchConfig } = useQuery< IConfig, diff --git a/frontend/pages/admin/IntegrationsPage/IntegrationsPage.tsx b/frontend/pages/admin/IntegrationsPage/IntegrationsPage.tsx index 3dfceafdfc..32f5643336 100644 --- a/frontend/pages/admin/IntegrationsPage/IntegrationsPage.tsx +++ b/frontend/pages/admin/IntegrationsPage/IntegrationsPage.tsx @@ -54,9 +54,7 @@ const IntegrationsPage = (): JSX.Element => { integrationEditing, setIntegrationEditing, ] = useState(); - const [isUpdatingIntegration, setIsUpdatingIntegration] = useState( - false - ); + const [isUpdatingIntegration, setIsUpdatingIntegration] = useState(false); const [jiraIntegrations, setJiraIntegrations] = useState< IJiraIntegration[] >(); @@ -66,7 +64,7 @@ const IntegrationsPage = (): JSX.Element => { const [backendValidators, setBackendValidators] = useState<{ [key: string]: string; }>({}); - const [testingConnection, setTestingConnection] = useState(false); + const [testingConnection, setTestingConnection] = useState(false); const { data: integrations, diff --git a/frontend/pages/admin/IntegrationsPage/components/CreateIntegrationModal/CreateIntegrationModal.tsx b/frontend/pages/admin/IntegrationsPage/components/CreateIntegrationModal/CreateIntegrationModal.tsx index 2eecd8a06d..d0908deb6c 100644 --- a/frontend/pages/admin/IntegrationsPage/components/CreateIntegrationModal/CreateIntegrationModal.tsx +++ b/frontend/pages/admin/IntegrationsPage/components/CreateIntegrationModal/CreateIntegrationModal.tsx @@ -37,7 +37,7 @@ const CreateIntegrationModal = ({ const [errors, setErrors] = useState<{ [key: string]: string }>( backendValidators ); - const [destination, setDestination] = useState("jira"); + const [destination, setDestination] = useState("jira"); const onDestinationChange = (value: string) => { setDestination(value); diff --git a/frontend/pages/admin/IntegrationsPage/components/IntegrationForm/IntegrationForm.tsx b/frontend/pages/admin/IntegrationsPage/components/IntegrationForm/IntegrationForm.tsx index de9e41ba61..899a533874 100644 --- a/frontend/pages/admin/IntegrationsPage/components/IntegrationForm/IntegrationForm.tsx +++ b/frontend/pages/admin/IntegrationsPage/components/IntegrationForm/IntegrationForm.tsx @@ -64,7 +64,7 @@ const IntegrationForm = ({ enableSoftwareVulnerabilities: integrationEnableSoftwareVulnerabilities || false, }); - const [integrationDestination, setIntegrationDestination] = useState( + const [integrationDestination, setIntegrationDestination] = useState( integrationEditingType || destination || "jira" ); const [urlError, setUrlError] = useState(null); diff --git a/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/MembersPage/MembersPage.tsx b/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/MembersPage/MembersPage.tsx index 32e931c97c..64529f9c2d 100644 --- a/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/MembersPage/MembersPage.tsx +++ b/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/MembersPage/MembersPage.tsx @@ -58,18 +58,13 @@ const MembersPage = ({ const smtpConfigured = config?.smtp_settings.configured || false; const canUseSso = config?.sso_settings.enable_sso || false; - const [showAddMemberModal, setShowAddMemberModal] = useState(false); - const [showRemoveMemberModal, setShowRemoveMemberModal] = useState( - false - ); - const [showEditUserModal, setShowEditUserModal] = useState(false); - const [showCreateUserModal, setShowCreateUserModal] = useState( - false - ); - const [isLoading, setIsLoading] = useState(false); - const [isUpdatingMembers, setIsUpdatingMembers] = useState(false); + const [showAddMemberModal, setShowAddMemberModal] = useState(false); + const [showRemoveMemberModal, setShowRemoveMemberModal] = useState(false); + const [showEditUserModal, setShowEditUserModal] = useState(false); + const [showCreateUserModal, setShowCreateUserModal] = useState(false); + const [isUpdatingMembers, setIsUpdatingMembers] = useState(false); const [userEditing, setUserEditing] = useState(); - const [searchString, setSearchString] = useState(""); + const [searchString, setSearchString] = useState(""); const [createUserErrors, setCreateUserErrors] = useState( DEFAULT_CREATE_USER_ERRORS ); diff --git a/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/TeamDetailsWrapper.tsx b/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/TeamDetailsWrapper.tsx index d981de7e76..a655e535b2 100644 --- a/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/TeamDetailsWrapper.tsx +++ b/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/TeamDetailsWrapper.tsx @@ -127,8 +127,8 @@ const TeamDetailsWrapper = ({ const [backendValidators, setBackendValidators] = useState<{ [key: string]: string; }>({}); - const [isUpdatingTeams, setIsUpdatingTeams] = useState(false); - const [isUpdatingSecret, setIsUpdatingSecret] = useState(false); + const [isUpdatingTeams, setIsUpdatingTeams] = useState(false); + const [isUpdatingSecret, setIsUpdatingSecret] = useState(false); const { refetch: refetchMe } = useQuery(["me"], () => usersAPI.me(), { enabled: false, onSuccess: ({ user, available_teams }: IGetMeResponse) => { diff --git a/frontend/pages/admin/TeamManagementPage/TeamManagementPage.tsx b/frontend/pages/admin/TeamManagementPage/TeamManagementPage.tsx index 237b4cd126..3a13bada56 100644 --- a/frontend/pages/admin/TeamManagementPage/TeamManagementPage.tsx +++ b/frontend/pages/admin/TeamManagementPage/TeamManagementPage.tsx @@ -25,12 +25,12 @@ const noTeamsClass = "no-teams"; const TeamManagementPage = (): JSX.Element => { const { renderFlash } = useContext(NotificationContext); - const [isUpdatingTeams, setIsUpdatingTeams] = useState(false); + const [isUpdatingTeams, setIsUpdatingTeams] = useState(false); const [showCreateTeamModal, setShowCreateTeamModal] = useState(false); const [showDeleteTeamModal, setShowDeleteTeamModal] = useState(false); const [showEditTeamModal, setShowEditTeamModal] = useState(false); const [teamEditing, setTeamEditing] = useState(); - const [searchString, setSearchString] = useState(""); + const [searchString, setSearchString] = useState(""); const [backendValidators, setBackendValidators] = useState<{ [key: string]: string; }>({}); diff --git a/frontend/pages/admin/UserManagementPage/components/CreateUserModal/CreateUserModal.tsx b/frontend/pages/admin/UserManagementPage/components/CreateUserModal/CreateUserModal.tsx index c917ee31bb..95e9c5d90d 100644 --- a/frontend/pages/admin/UserManagementPage/components/CreateUserModal/CreateUserModal.tsx +++ b/frontend/pages/admin/UserManagementPage/components/CreateUserModal/CreateUserModal.tsx @@ -3,7 +3,6 @@ import React from "react"; import { ITeam } from "interfaces/team"; import { IUserFormErrors } from "interfaces/user"; import Modal from "components/Modal"; -import Spinner from "components/Spinner"; import UserForm from "../UserForm"; import { IFormData } from "../UserForm/UserForm"; diff --git a/frontend/pages/admin/UserManagementPage/components/EditUserModal/EditUserModal.tsx b/frontend/pages/admin/UserManagementPage/components/EditUserModal/EditUserModal.tsx index 0d04785381..80966f4010 100644 --- a/frontend/pages/admin/UserManagementPage/components/EditUserModal/EditUserModal.tsx +++ b/frontend/pages/admin/UserManagementPage/components/EditUserModal/EditUserModal.tsx @@ -3,7 +3,6 @@ import React from "react"; import { ITeam } from "interfaces/team"; import { IUserFormErrors } from "interfaces/user"; import Modal from "components/Modal"; -import Spinner from "components/Spinner"; import UserForm from "../UserForm"; import { IFormData } from "../UserForm/UserForm"; diff --git a/frontend/pages/admin/UserManagementPage/components/SelectRoleForm/SelectRoleForm.tsx b/frontend/pages/admin/UserManagementPage/components/SelectRoleForm/SelectRoleForm.tsx index 166481daa9..cd80702f27 100644 --- a/frontend/pages/admin/UserManagementPage/components/SelectRoleForm/SelectRoleForm.tsx +++ b/frontend/pages/admin/UserManagementPage/components/SelectRoleForm/SelectRoleForm.tsx @@ -62,7 +62,7 @@ const SelectRoleForm = ({ onFormChange, label, }: ISelectRoleFormProps): JSX.Element => { - const [selectedRole, setSelectedRole] = useState( + const [selectedRole, setSelectedRole] = useState( defaultTeamRole.toLowerCase() ); diff --git a/frontend/pages/admin/UserManagementPage/components/UserForm/UserForm.tsx b/frontend/pages/admin/UserManagementPage/components/UserForm/UserForm.tsx index f57750fa85..a0b2f6d9ee 100644 --- a/frontend/pages/admin/UserManagementPage/components/UserForm/UserForm.tsx +++ b/frontend/pages/admin/UserManagementPage/components/UserForm/UserForm.tsx @@ -125,9 +125,7 @@ const UserForm = ({ currentUserId, }); - const [isGlobalUser, setIsGlobalUser] = useState( - !!defaultGlobalRole - ); + const [isGlobalUser, setIsGlobalUser] = useState(!!defaultGlobalRole); useEffect(() => { setErrors(createOrEditUserErrors); diff --git a/frontend/pages/admin/UserManagementPage/components/UsersTable/UsersTable.tsx b/frontend/pages/admin/UserManagementPage/components/UsersTable/UsersTable.tsx index 22df1a4c53..c294b0fc4a 100644 --- a/frontend/pages/admin/UserManagementPage/components/UsersTable/UsersTable.tsx +++ b/frontend/pages/admin/UserManagementPage/components/UsersTable/UsersTable.tsx @@ -38,20 +38,12 @@ const UsersTable = ({ router }: IUsersTableProps): JSX.Element => { const { renderFlash } = useContext(NotificationContext); // STATES - const [showCreateUserModal, setShowCreateUserModal] = useState( - false - ); - const [showEditUserModal, setShowEditUserModal] = useState(false); - const [showDeleteUserModal, setShowDeleteUserModal] = useState( - false - ); - const [showResetPasswordModal, setShowResetPasswordModal] = useState( - false - ); - const [showResetSessionsModal, setShowResetSessionsModal] = useState( - false - ); - const [isUpdatingUsers, setIsUpdatingUsers] = useState(false); + const [showCreateUserModal, setShowCreateUserModal] = useState(false); + const [showEditUserModal, setShowEditUserModal] = useState(false); + const [showDeleteUserModal, setShowDeleteUserModal] = useState(false); + const [showResetPasswordModal, setShowResetPasswordModal] = useState(false); + const [showResetSessionsModal, setShowResetSessionsModal] = useState(false); + const [isUpdatingUsers, setIsUpdatingUsers] = useState(false); const [userEditing, setUserEditing] = useState(null); const [createUserErrors, setCreateUserErrors] = useState( DEFAULT_CREATE_USER_ERRORS @@ -59,7 +51,7 @@ const UsersTable = ({ router }: IUsersTableProps): JSX.Element => { const [editUserErrors, setEditUserErrors] = useState( DEFAULT_CREATE_USER_ERRORS ); - const [querySearchText, setQuerySearchText] = useState(""); + const [querySearchText, setQuerySearchText] = useState(""); // API CALLS const { diff --git a/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx b/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx index 079dafc640..239c2a0d70 100644 --- a/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx +++ b/frontend/pages/hosts/ManageHostsPage/ManageHostsPage.tsx @@ -203,47 +203,31 @@ const ManageHostsPage = ({ // ========= states const [selectedLabel, setSelectedLabel] = useState(); const [selectedSecret, setSelectedSecret] = useState(); - const [ - showNoEnrollSecretBanner, - setShowNoEnrollSecretBanner, - ] = useState(true); - const [showDeleteSecretModal, setShowDeleteSecretModal] = useState( - false - ); - const [showSecretEditorModal, setShowSecretEditorModal] = useState( - false - ); - const [showEnrollSecretModal, setShowEnrollSecretModal] = useState( - false - ); - const [showDeleteLabelModal, setShowDeleteLabelModal] = useState( - false - ); - const [showEditColumnsModal, setShowEditColumnsModal] = useState( - false - ); - const [showAddHostsModal, setShowAddHostsModal] = useState(false); - const [showTransferHostModal, setShowTransferHostModal] = useState( - false - ); - const [showDeleteHostModal, setShowDeleteHostModal] = useState( - false + const [showNoEnrollSecretBanner, setShowNoEnrollSecretBanner] = useState( + true ); + const [showDeleteSecretModal, setShowDeleteSecretModal] = useState(false); + const [showSecretEditorModal, setShowSecretEditorModal] = useState(false); + const [showEnrollSecretModal, setShowEnrollSecretModal] = useState(false); + const [showDeleteLabelModal, setShowDeleteLabelModal] = useState(false); + const [showEditColumnsModal, setShowEditColumnsModal] = useState(false); + const [showAddHostsModal, setShowAddHostsModal] = useState(false); + const [showTransferHostModal, setShowTransferHostModal] = useState(false); + const [showDeleteHostModal, setShowDeleteHostModal] = useState(false); const [hiddenColumns, setHiddenColumns] = useState( storedHiddenColumns || defaultHiddenColumns ); const [selectedHostIds, setSelectedHostIds] = useState([]); - const [ - isAllMatchingHostsSelected, - setIsAllMatchingHostsSelected, - ] = useState(false); - const [searchQuery, setSearchQuery] = useState(initialQuery); + const [isAllMatchingHostsSelected, setIsAllMatchingHostsSelected] = useState( + false + ); + const [searchQuery, setSearchQuery] = useState(initialQuery); const [hosts, setHosts] = useState(); - const [isHostsLoading, setIsHostsLoading] = useState(false); - const [hasHostErrors, setHasHostErrors] = useState(false); + const [isHostsLoading, setIsHostsLoading] = useState(false); + const [hasHostErrors, setHasHostErrors] = useState(false); const [filteredHostCount, setFilteredHostCount] = useState(); - const [isHostCountLoading, setIsHostCountLoading] = useState(false); - const [hasHostCountErrors, setHasHostCountErrors] = useState(false); + const [isHostCountLoading, setIsHostCountLoading] = useState(false); + const [hasHostCountErrors, setHasHostCountErrors] = useState(false); const [sortBy, setSortBy] = useState(initialSortBy); const [policy, setPolicy] = useState(); const [softwareDetails, setSoftwareDetails] = useState( @@ -261,10 +245,10 @@ const ManageHostsPage = ({ const [labelValidator, setLabelValidator] = useState<{ [key: string]: string; }>(DEFAULT_CREATE_LABEL_ERRORS); - const [resetPageIndex, setResetPageIndex] = useState(false); - const [isUpdatingLabel, setIsUpdatingLabel] = useState(false); - const [isUpdatingSecret, setIsUpdatingSecret] = useState(false); - const [isUpdatingHosts, setIsUpdatingHosts] = useState(false); + const [resetPageIndex, setResetPageIndex] = useState(false); + const [isUpdatingLabel, setIsUpdatingLabel] = useState(false); + const [isUpdatingSecret, setIsUpdatingSecret] = useState(false); + const [isUpdatingHosts, setIsUpdatingHosts] = useState(false); // ======== end states diff --git a/frontend/pages/hosts/ManageHostsPage/components/LabelForm/LabelForm.tsx b/frontend/pages/hosts/ManageHostsPage/components/LabelForm/LabelForm.tsx index 3662eadffe..39ba5e0aa9 100644 --- a/frontend/pages/hosts/ManageHostsPage/components/LabelForm/LabelForm.tsx +++ b/frontend/pages/hosts/ManageHostsPage/components/LabelForm/LabelForm.tsx @@ -63,17 +63,15 @@ const LabelForm = ({ backendValidators, isUpdatingLabel, }: ILabelFormProps): JSX.Element => { - const [name, setName] = useState(selectedLabel?.name || ""); - const [nameError, setNameError] = useState(""); - const [description, setDescription] = useState( + const [name, setName] = useState(selectedLabel?.name || ""); + const [nameError, setNameError] = useState(""); + const [description, setDescription] = useState( selectedLabel?.description || "" ); - const [descriptionError, setDescriptionError] = useState(""); - const [query, setQuery] = useState(selectedLabel?.query || ""); - const [queryError, setQueryError] = useState(""); - const [platform, setPlatform] = useState( - selectedLabel?.platform || "" - ); + const [descriptionError, setDescriptionError] = useState(""); + const [query, setQuery] = useState(selectedLabel?.query || ""); + const [queryError, setQueryError] = useState(""); + const [platform, setPlatform] = useState(selectedLabel?.platform || ""); const debounceSQL = useDebouncedCallback((queryString: string) => { let valid = true; diff --git a/frontend/pages/hosts/ManageHostsPage/helpers.ts b/frontend/pages/hosts/ManageHostsPage/helpers.ts index 8479e8c433..20e9ae083c 100644 --- a/frontend/pages/hosts/ManageHostsPage/helpers.ts +++ b/frontend/pages/hosts/ManageHostsPage/helpers.ts @@ -1,4 +1,3 @@ -import { ILabel } from "interfaces/label"; import { isEmpty, reduce, trim, union } from "lodash"; import { buildQueryStringFromParams } from "utilities/url"; diff --git a/frontend/pages/hosts/details/DeviceUserPage/DeviceUserPage.tsx b/frontend/pages/hosts/details/DeviceUserPage/DeviceUserPage.tsx index 9a0e96f660..9f266ec6d0 100644 --- a/frontend/pages/hosts/details/DeviceUserPage/DeviceUserPage.tsx +++ b/frontend/pages/hosts/details/DeviceUserPage/DeviceUserPage.tsx @@ -51,19 +51,17 @@ const DeviceUserPage = ({ const deviceAuthToken = device_auth_token; const { renderFlash } = useContext(NotificationContext); - const [isPremiumTier, setIsPremiumTier] = useState(false); - const [showInfoModal, setShowInfoModal] = useState(false); + const [isPremiumTier, setIsPremiumTier] = useState(false); + const [showInfoModal, setShowInfoModal] = useState(false); const [refetchStartTime, setRefetchStartTime] = useState(null); - const [showRefetchSpinner, setShowRefetchSpinner] = useState(false); + const [showRefetchSpinner, setShowRefetchSpinner] = useState(false); const [hostSoftware, setHostSoftware] = useState([]); const [host, setHost] = useState(); - const [orgLogoURL, setOrgLogoURL] = useState(""); + const [orgLogoURL, setOrgLogoURL] = useState(""); const [selectedPolicy, setSelectedPolicy] = useState( null ); - const [showPolicyDetailsModal, setShowPolicyDetailsModal] = useState( - false - ); + const [showPolicyDetailsModal, setShowPolicyDetailsModal] = useState(false); const { data: deviceMapping, refetch: refetchDeviceMapping } = useQuery( ["deviceMapping", deviceAuthToken], diff --git a/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx b/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx index 714fc98f58..b72952ea8e 100644 --- a/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx +++ b/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx @@ -126,29 +126,23 @@ const HostDetailsPage = ({ return false; }; - const [showDeleteHostModal, setShowDeleteHostModal] = useState( - false - ); - const [showTransferHostModal, setShowTransferHostModal] = useState( - false - ); - const [showQueryHostModal, setShowQueryHostModal] = useState(false); - const [showPolicyDetailsModal, setPolicyDetailsModal] = useState( - false - ); - const [showOSPolicyModal, setShowOSPolicyModal] = useState(false); + const [showDeleteHostModal, setShowDeleteHostModal] = useState(false); + const [showTransferHostModal, setShowTransferHostModal] = useState(false); + const [showQueryHostModal, setShowQueryHostModal] = useState(false); + const [showPolicyDetailsModal, setPolicyDetailsModal] = useState(false); + const [showOSPolicyModal, setShowOSPolicyModal] = useState(false); const [selectedPolicy, setSelectedPolicy] = useState( null ); - const [isUpdatingHost, setIsUpdatingHost] = useState(false); + const [isUpdatingHost, setIsUpdatingHost] = useState(false); const [refetchStartTime, setRefetchStartTime] = useState(null); - const [showRefetchSpinner, setShowRefetchSpinner] = useState(false); + const [showRefetchSpinner, setShowRefetchSpinner] = useState(false); const [packsState, setPacksState] = useState(); const [scheduleState, setScheduleState] = useState(); const [hostSoftware, setHostSoftware] = useState([]); const [usersState, setUsersState] = useState<{ username: string }[]>([]); - const [usersSearchString, setUsersSearchString] = useState(""); + const [usersSearchString, setUsersSearchString] = useState(""); const { data: fleetQueries, error: fleetQueriesError } = useQuery< IFleetQueriesResponse, diff --git a/frontend/pages/hosts/details/HostDetailsPage/modals/OSPolicyModal/OSPolicyModal.tsx b/frontend/pages/hosts/details/HostDetailsPage/modals/OSPolicyModal/OSPolicyModal.tsx index 49a8f02016..072c0974fc 100644 --- a/frontend/pages/hosts/details/HostDetailsPage/modals/OSPolicyModal/OSPolicyModal.tsx +++ b/frontend/pages/hosts/details/HostDetailsPage/modals/OSPolicyModal/OSPolicyModal.tsx @@ -30,7 +30,7 @@ const RenderOSPolicyModal = ({ osPolicy, osPolicyLabel, }: IRenderOSPolicyModal): JSX.Element => { - const [copyMessage, setCopyMessage] = useState(""); + const [copyMessage, setCopyMessage] = useState(""); const renderOsPolicyLabel = () => { const onCopyOsPolicy = (evt: React.MouseEvent) => { diff --git a/frontend/pages/packs/EditPackPage/EditPackPage.tsx b/frontend/pages/packs/EditPackPage/EditPackPage.tsx index 8d07ffadf7..29201478b7 100644 --- a/frontend/pages/packs/EditPackPage/EditPackPage.tsx +++ b/frontend/pages/packs/EditPackPage/EditPackPage.tsx @@ -89,20 +89,18 @@ const EditPacksPage = ({ } ); - const [targetsCount, setTargetsCount] = useState(0); - const [ - showPackQueryEditorModal, - setShowPackQueryEditorModal, - ] = useState(false); - const [ - showRemovePackQueryModal, - setShowRemovePackQueryModal, - ] = useState(false); + const [targetsCount, setTargetsCount] = useState(0); + const [showPackQueryEditorModal, setShowPackQueryEditorModal] = useState( + false + ); + const [showRemovePackQueryModal, setShowRemovePackQueryModal] = useState( + false + ); const [selectedPackQuery, setSelectedPackQuery] = useState(); const [selectedPackQueryIds, setSelectedPackQueryIds] = useState< number[] | never[] >([]); - const [isUpdatingPack, setIsUpdatingPack] = useState(false); + const [isUpdatingPack, setIsUpdatingPack] = useState(false); const packTargets = storedPack ? [ diff --git a/frontend/pages/packs/EditPackPage/components/PackQueryEditorModal/PackQueryEditorModal.tsx b/frontend/pages/packs/EditPackPage/components/PackQueryEditorModal/PackQueryEditorModal.tsx index 9995b6cee5..947721804f 100644 --- a/frontend/pages/packs/EditPackPage/components/PackQueryEditorModal/PackQueryEditorModal.tsx +++ b/frontend/pages/packs/EditPackPage/components/PackQueryEditorModal/PackQueryEditorModal.tsx @@ -69,28 +69,27 @@ const PackQueryEditorModal = ({ const [selectedQuery, setSelectedQuery] = useState< IScheduledQuery | INoQueryOption >(); - const [selectedFrequency, setSelectedFrequency] = useState( + const [selectedFrequency, setSelectedFrequency] = useState( editQuery?.interval.toString() || "" ); - const [errorFrequency, setErrorFrequency] = useState(""); - const [ - selectedPlatformOptions, - setSelectedPlatformOptions, - ] = useState(editQuery?.platform || ""); - const [selectedLoggingType, setSelectedLoggingType] = useState( + const [errorFrequency, setErrorFrequency] = useState(""); + const [selectedPlatformOptions, setSelectedPlatformOptions] = useState( + editQuery?.platform || "" + ); + const [selectedLoggingType, setSelectedLoggingType] = useState( editQuery ? generateLoggingType(editQuery) : "snapshot" ); - const [selectedSnapshot, setSelectedSnapshot] = useState( + const [selectedSnapshot, setSelectedSnapshot] = useState( selectedLoggingType === "snapshot" ); - const [selectedRemoved, setSelectedRemoved] = useState( + const [selectedRemoved, setSelectedRemoved] = useState( selectedLoggingType === "differential" ); const [ selectedMinOsqueryVersionOptions, setSelectedMinOsqueryVersionOptions, - ] = useState(editQuery?.version || ""); - const [selectedShard, setSelectedShard] = useState( + ] = useState(editQuery?.version || ""); + const [selectedShard, setSelectedShard] = useState( editQuery?.shard ? editQuery?.shard.toString() : "" ); diff --git a/frontend/pages/packs/EditPackPage/components/RemovePackQueryModal/RemovePackQueryModal.tsx b/frontend/pages/packs/EditPackPage/components/RemovePackQueryModal/RemovePackQueryModal.tsx index b90e90e064..de37d81e04 100644 --- a/frontend/pages/packs/EditPackPage/components/RemovePackQueryModal/RemovePackQueryModal.tsx +++ b/frontend/pages/packs/EditPackPage/components/RemovePackQueryModal/RemovePackQueryModal.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from "react"; +import React from "react"; import Modal from "components/Modal"; import Button from "components/buttons/Button"; diff --git a/frontend/pages/packs/ManagePacksPage/ManagePacksPage.tsx b/frontend/pages/packs/ManagePacksPage/ManagePacksPage.tsx index d66005e220..5758421057 100644 --- a/frontend/pages/packs/ManagePacksPage/ManagePacksPage.tsx +++ b/frontend/pages/packs/ManagePacksPage/ManagePacksPage.tsx @@ -61,10 +61,8 @@ const ManagePacksPage = ({ router }: IManagePacksPageProps): JSX.Element => { const onCreatePackClick = () => router.push(PATHS.NEW_PACK); const [selectedPackIds, setSelectedPackIds] = useState([]); - const [showDeletePackModal, setShowDeletePackModal] = useState( - false - ); - const [isUpdatingPack, setIsUpdatingPack] = useState(false); + const [showDeletePackModal, setShowDeletePackModal] = useState(false); + const [isUpdatingPack, setIsUpdatingPack] = useState(false); const { data: packs, diff --git a/frontend/pages/packs/ManagePacksPage/components/DeletePackModal/DeletePackModal.tsx b/frontend/pages/packs/ManagePacksPage/components/DeletePackModal/DeletePackModal.tsx index f65fffe9f5..7a9cb5cabe 100644 --- a/frontend/pages/packs/ManagePacksPage/components/DeletePackModal/DeletePackModal.tsx +++ b/frontend/pages/packs/ManagePacksPage/components/DeletePackModal/DeletePackModal.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from "react"; +import React from "react"; import Modal from "components/Modal"; import Button from "components/buttons/Button"; diff --git a/frontend/pages/packs/ManagePacksPage/components/PacksTable/PacksTable.tsx b/frontend/pages/packs/ManagePacksPage/components/PacksTable/PacksTable.tsx index 4081eddeeb..2510700094 100644 --- a/frontend/pages/packs/ManagePacksPage/components/PacksTable/PacksTable.tsx +++ b/frontend/pages/packs/ManagePacksPage/components/PacksTable/PacksTable.tsx @@ -32,7 +32,7 @@ const PacksTable = ({ const [filteredPacks, setFilteredPacks] = useState( packs ); - const [searchString, setSearchString] = useState(""); + const [searchString, setSearchString] = useState(""); useEffect(() => { setFilteredPacks(packs); diff --git a/frontend/pages/packs/PackComposerPage/PackComposerPage.tsx b/frontend/pages/packs/PackComposerPage/PackComposerPage.tsx index 6c53f2d77a..07e8312355 100644 --- a/frontend/pages/packs/PackComposerPage/PackComposerPage.tsx +++ b/frontend/pages/packs/PackComposerPage/PackComposerPage.tsx @@ -28,8 +28,8 @@ const PackComposerPage = ({ router }: IPackComposerPageProps): JSX.Element => { const { isPremiumTier } = useContext(AppContext); const { renderFlash } = useContext(NotificationContext); - const [selectedTargetsCount, setSelectedTargetsCount] = useState(0); - const [isUpdatingPack, setIsUpdatingPack] = useState(false); + const [selectedTargetsCount, setSelectedTargetsCount] = useState(0); + const [isUpdatingPack, setIsUpdatingPack] = useState(false); const onFetchTargets = ( query: IQuery, diff --git a/frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx b/frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx index ad3fd57c3b..9e98c66db5 100644 --- a/frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx +++ b/frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx @@ -75,10 +75,8 @@ const ManagePolicyPage = ({ } = useContext(PolicyContext); const { setResetSelectedRows } = useContext(TableContext); - const [isUpdatingAutomations, setIsUpdatingAutomations] = useState( - false - ); - const [isUpdatingPolicies, setIsUpdatingPolicies] = useState(false); + const [isUpdatingAutomations, setIsUpdatingAutomations] = useState(false); + const [isUpdatingPolicies, setIsUpdatingPolicies] = useState(false); const [selectedPolicyIds, setSelectedPolicyIds] = useState([]); const [showManageAutomationsModal, setShowManageAutomationsModal] = useState( false diff --git a/frontend/pages/policies/ManagePoliciesPage/components/DeletePolicyModal/DeletePolicyModal.tsx b/frontend/pages/policies/ManagePoliciesPage/components/DeletePolicyModal/DeletePolicyModal.tsx index bc6f8c568e..1600519a8d 100644 --- a/frontend/pages/policies/ManagePoliciesPage/components/DeletePolicyModal/DeletePolicyModal.tsx +++ b/frontend/pages/policies/ManagePoliciesPage/components/DeletePolicyModal/DeletePolicyModal.tsx @@ -2,7 +2,6 @@ import React from "react"; import Modal from "components/Modal"; import Button from "components/buttons/Button"; -import Spinner from "components/Spinner"; const baseClass = "delete-policy-modal"; diff --git a/frontend/pages/policies/ManagePoliciesPage/components/ManageAutomationsModal/ManageAutomationsModal.tsx b/frontend/pages/policies/ManagePoliciesPage/components/ManageAutomationsModal/ManageAutomationsModal.tsx index 1ca83e23c2..afbe67f353 100644 --- a/frontend/pages/policies/ManagePoliciesPage/components/ManageAutomationsModal/ManageAutomationsModal.tsx +++ b/frontend/pages/policies/ManagePoliciesPage/components/ManageAutomationsModal/ManageAutomationsModal.tsx @@ -19,7 +19,6 @@ import Dropdown from "components/forms/fields/Dropdown"; import InputField from "components/forms/fields/InputField"; import Radio from "components/forms/fields/Radio"; -import Spinner from "components/Spinner"; import PreviewPayloadModal from "../PreviewPayloadModal"; import PreviewTicketModal from "../PreviewTicketModal"; @@ -112,10 +111,7 @@ const ManageAutomationsModal = ({ automationsConfig.integrations ); - const [ - isPolicyAutomationsEnabled, - setIsPolicyAutomationsEnabled, - ] = useState( + const [isPolicyAutomationsEnabled, setIsPolicyAutomationsEnabled] = useState( !!webhook.enable_failing_policies_webhook || !!serverEnabledIntegration ); @@ -123,7 +119,7 @@ const ManageAutomationsModal = ({ !isPolicyAutomationsEnabled || webhook.enable_failing_policies_webhook ); - const [destinationUrl, setDestinationUrl] = useState( + const [destinationUrl, setDestinationUrl] = useState( webhook.destination_url || "" ); diff --git a/frontend/pages/policies/PolicyPage/PolicyPage.tsx b/frontend/pages/policies/PolicyPage/PolicyPage.tsx index 939cc034b9..07fccec84c 100644 --- a/frontend/pages/policies/PolicyPage/PolicyPage.tsx +++ b/frontend/pages/policies/PolicyPage/PolicyPage.tsx @@ -91,18 +91,17 @@ const PolicyPage = ({ } } - const [step, setStep] = useState(QUERIES_PAGE_STEPS[1]); + const [step, setStep] = useState(QUERIES_PAGE_STEPS[1]); const [selectedTargets, setSelectedTargets] = useState([]); const [targetedHosts, setTargetedHosts] = useState([]); const [targetedLabels, setTargetedLabels] = useState([]); const [targetedTeams, setTargetedTeams] = useState([]); - const [targetsTotalCount, setTargetsTotalCount] = useState(0); - const [isLiveQueryRunnable, setIsLiveQueryRunnable] = useState(true); - const [isSidebarOpen, setIsSidebarOpen] = useState(true); - const [ - showOpenSchemaActionText, - setShowOpenSchemaActionText, - ] = useState(false); + const [targetsTotalCount, setTargetsTotalCount] = useState(0); + const [isLiveQueryRunnable, setIsLiveQueryRunnable] = useState(true); + const [isSidebarOpen, setIsSidebarOpen] = useState(true); + const [showOpenSchemaActionText, setShowOpenSchemaActionText] = useState( + false + ); const { isLoading: isStoredPolicyLoading, diff --git a/frontend/pages/policies/PolicyPage/components/NewPolicyModal/NewPolicyModal.tsx b/frontend/pages/policies/PolicyPage/components/NewPolicyModal/NewPolicyModal.tsx index ea565eb57a..ccf3d68f46 100644 --- a/frontend/pages/policies/PolicyPage/components/NewPolicyModal/NewPolicyModal.tsx +++ b/frontend/pages/policies/PolicyPage/components/NewPolicyModal/NewPolicyModal.tsx @@ -12,7 +12,6 @@ import InputField from "components/forms/fields/InputField"; import Button from "components/buttons/Button"; import Modal from "components/Modal"; import ReactTooltip from "react-tooltip"; -import Spinner from "components/Spinner"; export interface INewPolicyModalProps { baseClass: string; @@ -51,13 +50,9 @@ const NewPolicyModal = ({ setLastEditedQueryPlatform, } = useContext(PolicyContext); - const [name, setName] = useState(lastEditedQueryName); - const [description, setDescription] = useState( - lastEditedQueryDescription - ); - const [resolution, setResolution] = useState( - lastEditedQueryResolution - ); + const [name, setName] = useState(lastEditedQueryName); + const [description, setDescription] = useState(lastEditedQueryDescription); + const [resolution, setResolution] = useState(lastEditedQueryResolution); const [errors, setErrors] = useState<{ [key: string]: string }>( backendValidators ); diff --git a/frontend/pages/policies/PolicyPage/components/PolicyForm/PolicyForm.tsx b/frontend/pages/policies/PolicyPage/components/PolicyForm/PolicyForm.tsx index 5e58be4313..c254d33d04 100644 --- a/frontend/pages/policies/PolicyPage/components/PolicyForm/PolicyForm.tsx +++ b/frontend/pages/policies/PolicyPage/components/PolicyForm/PolicyForm.tsx @@ -73,18 +73,11 @@ const PolicyForm = ({ backendValidators, }: IPolicyFormProps): JSX.Element => { const [errors, setErrors] = useState<{ [key: string]: any }>({}); // string | null | undefined or boolean | undefined - const [isNewPolicyModalOpen, setIsNewPolicyModalOpen] = useState( - false - ); - const [showQueryEditor, setShowQueryEditor] = useState(false); - const [isEditingName, setIsEditingName] = useState(false); - const [isEditingDescription, setIsEditingDescription] = useState( - false - ); - const [isEditingResolution, setIsEditingResolution] = useState( - false - ); - const [isPolicySaving, setIsPolicySaving] = useState(false); + const [isNewPolicyModalOpen, setIsNewPolicyModalOpen] = useState(false); + const [showQueryEditor, setShowQueryEditor] = useState(false); + const [isEditingName, setIsEditingName] = useState(false); + const [isEditingDescription, setIsEditingDescription] = useState(false); + const [isEditingResolution, setIsEditingResolution] = useState(false); // Note: The PolicyContext values should always be used for any mutable policy data such as query name // The storedPolicy prop should only be used to access immutable metadata such as author id diff --git a/frontend/pages/policies/PolicyPage/components/QueryResults/QueryResults.tsx b/frontend/pages/policies/PolicyPage/components/QueryResults/QueryResults.tsx index 5e50a09fd3..89d67f8a00 100644 --- a/frontend/pages/policies/PolicyPage/components/QueryResults/QueryResults.tsx +++ b/frontend/pages/policies/PolicyPage/components/QueryResults/QueryResults.tsx @@ -56,7 +56,7 @@ const QueryResults = ({ const totalRowsCount = get(campaign, ["hosts_count", "successful"], 0); - const [pageTitle, setPageTitle] = useState(PAGE_TITLES.RUNNING); + const [pageTitle, setPageTitle] = useState(PAGE_TITLES.RUNNING); const [navTabIndex, setNavTabIndex] = useState(0); const [ targetsRespondedPercent, diff --git a/frontend/pages/policies/PolicyPage/screens/QueryEditor.tsx b/frontend/pages/policies/PolicyPage/screens/QueryEditor.tsx index db28457083..c8d4e99459 100644 --- a/frontend/pages/policies/PolicyPage/screens/QueryEditor.tsx +++ b/frontend/pages/policies/PolicyPage/screens/QueryEditor.tsx @@ -67,7 +67,7 @@ const QueryEditor = ({ } }, []); - const [isUpdatingPolicy, setIsUpdatingPolicy] = useState(false); + const [isUpdatingPolicy, setIsUpdatingPolicy] = useState(false); const [backendValidators, setBackendValidators] = useState<{ [key: string]: string; }>({}); diff --git a/frontend/pages/policies/PolicyPage/screens/RunQuery.tsx b/frontend/pages/policies/PolicyPage/screens/RunQuery.tsx index 70d08f2463..08abf3070b 100644 --- a/frontend/pages/policies/PolicyPage/screens/RunQuery.tsx +++ b/frontend/pages/policies/PolicyPage/screens/RunQuery.tsx @@ -33,7 +33,7 @@ const RunQuery = ({ }: IRunQueryProps): JSX.Element => { const { renderFlash } = useContext(NotificationContext); - const [isQueryFinished, setIsQueryFinished] = useState(false); + const [isQueryFinished, setIsQueryFinished] = useState(false); const [campaignState, setCampaignState] = useState( DEFAULT_CAMPAIGN_STATE ); diff --git a/frontend/pages/queries/ManageQueriesPage/ManageQueriesPage.tsx b/frontend/pages/queries/ManageQueriesPage/ManageQueriesPage.tsx index a156f5ef2a..fe983a0159 100644 --- a/frontend/pages/queries/ManageQueriesPage/ManageQueriesPage.tsx +++ b/frontend/pages/queries/ManageQueriesPage/ManageQueriesPage.tsx @@ -93,14 +93,10 @@ const ManageQueriesPage = ({ const [queriesList, setQueriesList] = useState( null ); - const [selectedDropdownFilter, setSelectedDropdownFilter] = useState( - "all" - ); + const [selectedDropdownFilter, setSelectedDropdownFilter] = useState("all"); const [selectedQueryIds, setSelectedQueryIds] = useState([]); - const [showDeleteQueryModal, setShowDeleteQueryModal] = useState( - false - ); - const [isUpdatingQueries, setIsUpdatingQueries] = useState(false); + const [showDeleteQueryModal, setShowDeleteQueryModal] = useState(false); + const [isUpdatingQueries, setIsUpdatingQueries] = useState(false); const { data: fleetQueries, diff --git a/frontend/pages/queries/ManageQueriesPage/components/DeleteQueryModal/DeleteQueryModal.tsx b/frontend/pages/queries/ManageQueriesPage/components/DeleteQueryModal/DeleteQueryModal.tsx index e2a2525e6c..46a24cb172 100644 --- a/frontend/pages/queries/ManageQueriesPage/components/DeleteQueryModal/DeleteQueryModal.tsx +++ b/frontend/pages/queries/ManageQueriesPage/components/DeleteQueryModal/DeleteQueryModal.tsx @@ -2,7 +2,6 @@ import React from "react"; import Modal from "components/Modal"; import Button from "components/buttons/Button"; -import Spinner from "components/Spinner"; const baseClass = "delete-query-modal"; diff --git a/frontend/pages/queries/ManageQueriesPage/components/QueriesTable/QueriesTable.tsx b/frontend/pages/queries/ManageQueriesPage/components/QueriesTable/QueriesTable.tsx index 363d9451b0..d7da9fc15a 100644 --- a/frontend/pages/queries/ManageQueriesPage/components/QueriesTable/QueriesTable.tsx +++ b/frontend/pages/queries/ManageQueriesPage/components/QueriesTable/QueriesTable.tsx @@ -37,7 +37,7 @@ const QueriesTable = ({ isOnlyObserver, }: IQueriesTableProps): JSX.Element | null => { const { currentUser } = useContext(AppContext); - const [searchString, setSearchString] = useState(""); + const [searchString, setSearchString] = useState(""); const handleSearchChange = ({ searchQuery }: ITableQueryData) => { setSearchString(searchQuery); diff --git a/frontend/pages/queries/QueryPage/QueryPage.tsx b/frontend/pages/queries/QueryPage/QueryPage.tsx index 10d5a6162d..79e771bd24 100644 --- a/frontend/pages/queries/QueryPage/QueryPage.tsx +++ b/frontend/pages/queries/QueryPage/QueryPage.tsx @@ -65,21 +65,18 @@ const QueryPage = ({ setLastEditedQueryObserverCanRun, } = useContext(QueryContext); - const [queryParamHostsAdded, setQueryParamHostsAdded] = useState( - false - ); - const [step, setStep] = useState(QUERIES_PAGE_STEPS[1]); + const [queryParamHostsAdded, setQueryParamHostsAdded] = useState(false); + const [step, setStep] = useState(QUERIES_PAGE_STEPS[1]); const [selectedTargets, setSelectedTargets] = useState([]); const [targetedHosts, setTargetedHosts] = useState([]); const [targetedLabels, setTargetedLabels] = useState([]); const [targetedTeams, setTargetedTeams] = useState([]); - const [targetsTotalCount, setTargetsTotalCount] = useState(0); - const [isLiveQueryRunnable, setIsLiveQueryRunnable] = useState(true); - const [isSidebarOpen, setIsSidebarOpen] = useState(true); - const [ - showOpenSchemaActionText, - setShowOpenSchemaActionText, - ] = useState(false); + const [targetsTotalCount, setTargetsTotalCount] = useState(0); + const [isLiveQueryRunnable, setIsLiveQueryRunnable] = useState(true); + const [isSidebarOpen, setIsSidebarOpen] = useState(true); + const [showOpenSchemaActionText, setShowOpenSchemaActionText] = useState( + false + ); // disabled on page load so we can control the number of renders // else it will re-populate the context on occasion diff --git a/frontend/pages/queries/QueryPage/components/NewQueryModal/NewQueryModal.tsx b/frontend/pages/queries/QueryPage/components/NewQueryModal/NewQueryModal.tsx index b9349a2e1d..c66c82e25b 100644 --- a/frontend/pages/queries/QueryPage/components/NewQueryModal/NewQueryModal.tsx +++ b/frontend/pages/queries/QueryPage/components/NewQueryModal/NewQueryModal.tsx @@ -9,7 +9,6 @@ import Checkbox from "components/forms/fields/Checkbox"; import InputField from "components/forms/fields/InputField"; import Button from "components/buttons/Button"; import Modal from "components/Modal"; -import Spinner from "components/Spinner"; export interface INewQueryModalProps { baseClass: string; @@ -39,9 +38,9 @@ const NewQueryModal = ({ setIsSaveModalOpen, backendValidators, }: INewQueryModalProps): JSX.Element => { - const [name, setName] = useState(""); - const [description, setDescription] = useState(""); - const [observerCanRun, setObserverCanRun] = useState(false); + const [name, setName] = useState(""); + const [description, setDescription] = useState(""); + const [observerCanRun, setObserverCanRun] = useState(false); const [errors, setErrors] = useState<{ [key: string]: string }>( backendValidators ); diff --git a/frontend/pages/queries/QueryPage/components/QueryForm/QueryForm.tsx b/frontend/pages/queries/QueryPage/components/QueryForm/QueryForm.tsx index 118f627a83..f02d3e9905 100644 --- a/frontend/pages/queries/QueryPage/components/QueryForm/QueryForm.tsx +++ b/frontend/pages/queries/QueryPage/components/QueryForm/QueryForm.tsx @@ -78,13 +78,11 @@ const QueryForm = ({ }: IQueryFormProps): JSX.Element => { const isEditMode = !!queryIdForEdit; const [errors, setErrors] = useState<{ [key: string]: any }>({}); // string | null | undefined or boolean | undefined - const [isSaveModalOpen, setIsSaveModalOpen] = useState(false); - const [showQueryEditor, setShowQueryEditor] = useState(false); - const [isEditingName, setIsEditingName] = useState(false); - const [isEditingDescription, setIsEditingDescription] = useState( - false - ); - const [isSaveAsNewLoading, setIsSaveAsNewLoading] = useState(false); + const [isSaveModalOpen, setIsSaveModalOpen] = useState(false); + const [showQueryEditor, setShowQueryEditor] = useState(false); + const [isEditingName, setIsEditingName] = useState(false); + const [isEditingDescription, setIsEditingDescription] = useState(false); + const [isSaveAsNewLoading, setIsSaveAsNewLoading] = useState(false); // Note: The QueryContext values should always be used for any mutable query data such as query name // The storedQuery prop should only be used to access immutable metadata such as author id diff --git a/frontend/pages/queries/QueryPage/components/QueryResults/QueryResults.tsx b/frontend/pages/queries/QueryPage/components/QueryResults/QueryResults.tsx index 87eb0674fe..91e81ef83e 100644 --- a/frontend/pages/queries/QueryPage/components/QueryResults/QueryResults.tsx +++ b/frontend/pages/queries/QueryPage/components/QueryResults/QueryResults.tsx @@ -83,9 +83,9 @@ const QueryResults = ({ ? Math.round((hostsCount.total / targetsTotalCount) * 100) : 0; - const [pageTitle, setPageTitle] = useState(PAGE_TITLES.RUNNING); + const [pageTitle, setPageTitle] = useState(PAGE_TITLES.RUNNING); const [navTabIndex, setNavTabIndex] = useState(0); - const [showQueryModal, setShowQueryModal] = useState(false); + const [showQueryModal, setShowQueryModal] = useState(false); const [filteredResults, setFilteredResults] = useState([]); const [filteredErrors, setFilteredErrors] = useState([]); diff --git a/frontend/pages/queries/QueryPage/screens/QueryEditor.tsx b/frontend/pages/queries/QueryPage/screens/QueryEditor.tsx index 44e568550b..352553ddbe 100644 --- a/frontend/pages/queries/QueryPage/screens/QueryEditor.tsx +++ b/frontend/pages/queries/QueryPage/screens/QueryEditor.tsx @@ -61,8 +61,8 @@ const QueryEditor = ({ lastEditedQueryObserverCanRun, } = useContext(QueryContext); - const [isQuerySaving, setIsQuerySaving] = useState(false); - const [isQueryUpdating, setIsQueryUpdating] = useState(false); + const [isQuerySaving, setIsQuerySaving] = useState(false); + const [isQueryUpdating, setIsQueryUpdating] = useState(false); useEffect(() => { if (storedQueryError) { diff --git a/frontend/pages/queries/QueryPage/screens/RunQuery.tsx b/frontend/pages/queries/QueryPage/screens/RunQuery.tsx index 38ff23a03b..34e19d39ec 100644 --- a/frontend/pages/queries/QueryPage/screens/RunQuery.tsx +++ b/frontend/pages/queries/QueryPage/screens/RunQuery.tsx @@ -37,7 +37,7 @@ const RunQuery = ({ const { lastEditedQueryBody } = useContext(QueryContext); const { renderFlash } = useContext(NotificationContext); - const [isQueryFinished, setIsQueryFinished] = useState(false); + const [isQueryFinished, setIsQueryFinished] = useState(false); const [campaignState, setCampaignState] = useState( DEFAULT_CAMPAIGN_STATE ); diff --git a/frontend/pages/schedule/ManageSchedulePage/ManageSchedulePage.tsx b/frontend/pages/schedule/ManageSchedulePage/ManageSchedulePage.tsx index dec0826724..b5d9d17b4f 100644 --- a/frontend/pages/schedule/ManageSchedulePage/ManageSchedulePage.tsx +++ b/frontend/pages/schedule/ManageSchedulePage/ManageSchedulePage.tsx @@ -295,13 +295,10 @@ const ManageSchedulePage = ({ const selectedTeamData = teams?.find((team: ITeam) => selectedTeam === team.id) || undefined; - const [ - isUpdatingScheduledQuery, - setIsUpdatingScheduledQuery, - ] = useState(false); - const [showInheritedQueries, setShowInheritedQueries] = useState( + const [isUpdatingScheduledQuery, setIsUpdatingScheduledQuery] = useState( false ); + const [showInheritedQueries, setShowInheritedQueries] = useState(false); const [showScheduleEditorModal, setShowScheduleEditorModal] = useState(false); const [showShowQueryModal, setShowShowQueryModal] = useState(false); const [showPreviewDataModal, setShowPreviewDataModal] = useState(false); diff --git a/frontend/pages/schedule/ManageSchedulePage/components/RemoveScheduledQueryModal/RemoveScheduledQueryModal.tsx b/frontend/pages/schedule/ManageSchedulePage/components/RemoveScheduledQueryModal/RemoveScheduledQueryModal.tsx index 711f9b58eb..fa08aeb3a3 100644 --- a/frontend/pages/schedule/ManageSchedulePage/components/RemoveScheduledQueryModal/RemoveScheduledQueryModal.tsx +++ b/frontend/pages/schedule/ManageSchedulePage/components/RemoveScheduledQueryModal/RemoveScheduledQueryModal.tsx @@ -1,8 +1,7 @@ -import React, { useEffect } from "react"; +import React from "react"; import Modal from "components/Modal"; import Button from "components/buttons/Button"; -import Spinner from "components/Spinner"; const baseClass = "remove-scheduled-query-modal"; diff --git a/frontend/pages/schedule/ManageSchedulePage/components/ScheduleEditorModal/ScheduleEditorModal.tsx b/frontend/pages/schedule/ManageSchedulePage/components/ScheduleEditorModal/ScheduleEditorModal.tsx index 5d3e1d186d..d676f82f0d 100644 --- a/frontend/pages/schedule/ManageSchedulePage/components/ScheduleEditorModal/ScheduleEditorModal.tsx +++ b/frontend/pages/schedule/ManageSchedulePage/components/ScheduleEditorModal/ScheduleEditorModal.tsx @@ -1,6 +1,6 @@ /* This component is used for creating and editing both global and team scheduled queries */ -import React, { useState, useCallback, useContext, useEffect } from "react"; +import React, { useState, useCallback, useContext } from "react"; import { pull } from "lodash"; import { AppContext } from "context/app"; @@ -15,7 +15,6 @@ import InfoBanner from "components/InfoBanner/InfoBanner"; import Dropdown from "components/forms/fields/Dropdown"; // @ts-ignore import InputField from "components/forms/fields/InputField"; -import Spinner from "components/Spinner"; import { FREQUENCY_DROPDOWN_OPTIONS, PLATFORM_DROPDOWN_OPTIONS, @@ -100,27 +99,24 @@ const ScheduleEditorModal = ({ const loggingConfig = config?.logging.result.plugin || "unknown"; - const [showAdvancedOptions, setShowAdvancedOptions] = useState( - false - ); + const [showAdvancedOptions, setShowAdvancedOptions] = useState(false); const [selectedQuery, setSelectedQuery] = useState< IEditScheduledQuery | INoQueryOption >(); - const [selectedFrequency, setSelectedFrequency] = useState( + const [selectedFrequency, setSelectedFrequency] = useState( editQuery ? editQuery.interval : 86400 ); - const [ - selectedPlatformOptions, - setSelectedPlatformOptions, - ] = useState(editQuery?.platform || ""); - const [selectedLoggingType, setSelectedLoggingType] = useState( + const [selectedPlatformOptions, setSelectedPlatformOptions] = useState( + editQuery?.platform || "" + ); + const [selectedLoggingType, setSelectedLoggingType] = useState( editQuery ? generateLoggingType(editQuery) : "snapshot" ); const [ selectedMinOsqueryVersionOptions, setSelectedMinOsqueryVersionOptions, - ] = useState(editQuery?.version || ""); - const [selectedShard, setSelectedShard] = useState( + ] = useState(editQuery?.version || ""); + const [selectedShard, setSelectedShard] = useState( editQuery?.shard ? editQuery?.shard.toString() : "" ); diff --git a/frontend/pages/software/ManageSoftwarePage/ManageSoftwarePage.tsx b/frontend/pages/software/ManageSoftwarePage/ManageSoftwarePage.tsx index 8ce27d6f84..b997e1ed49 100644 --- a/frontend/pages/software/ManageSoftwarePage/ManageSoftwarePage.tsx +++ b/frontend/pages/software/ManageSoftwarePage/ManageSoftwarePage.tsx @@ -99,11 +99,11 @@ const ManageSoftwarePage = ({ const DEFAULT_SORT_HEADER = isPremiumTier ? "vulnerabilities" : "hosts_count"; - const [isSoftwareEnabled, setIsSoftwareEnabled] = useState(); + const [isSoftwareEnabled, setIsSoftwareEnabled] = useState(false); const [ isVulnerabilityAutomationsEnabled, setIsVulnerabilityAutomationsEnabled, - ] = useState(); + ] = useState(false); const [ recentVulnerabilityMaxAge, setRecentVulnerabilityMaxAge, diff --git a/frontend/pages/software/ManageSoftwarePage/components/ManageAutomationsModal/ManageAutomationsModal.tsx b/frontend/pages/software/ManageSoftwarePage/components/ManageAutomationsModal/ManageAutomationsModal.tsx index 8a014aaf12..0f73578896 100644 --- a/frontend/pages/software/ManageSoftwarePage/components/ManageAutomationsModal/ManageAutomationsModal.tsx +++ b/frontend/pages/software/ManageSoftwarePage/components/ManageAutomationsModal/ManageAutomationsModal.tsx @@ -73,15 +73,14 @@ const ManageAutomationsModal = ({ currentDestinationUrl, recentVulnerabilityMaxAge, }: IManageAutomationsModalProps): JSX.Element => { - const [destinationUrl, setDestinationUrl] = useState( + const [destinationUrl, setDestinationUrl] = useState( currentDestinationUrl || "" ); const [errors, setErrors] = useState<{ [key: string]: string }>({}); - const [ - softwareAutomationsEnabled, - setSoftwareAutomationsEnabled, - ] = useState(softwareVulnerabilityAutomationEnabled || false); - const [integrationEnabled, setIntegrationEnabled] = useState( + const [softwareAutomationsEnabled, setSoftwareAutomationsEnabled] = useState( + softwareVulnerabilityAutomationEnabled || false + ); + const [integrationEnabled, setIntegrationEnabled] = useState( !softwareVulnerabilityWebhookEnabled ); const [jiraIntegrationsIndexed, setJiraIntegrationsIndexed] = useState<