diff --git a/client/src/Pages/Settings/index.tsx b/client/src/Pages/Settings/index.tsx index 564cb3bda..e7172638e 100644 --- a/client/src/Pages/Settings/index.tsx +++ b/client/src/Pages/Settings/index.tsx @@ -347,14 +347,16 @@ export const SettingsPage = () => { const onError = (errors: unknown) => { logger.debug("Form validation errors", errors); - // The save bar lists errors by field name, so reveal the tab owning the - // first one rather than naming a field the user cannot see. - const firstField = Object.keys(errors ?? {})[0]; - if (firstField) { - const target = tabForField(firstField); - if (visibleTabs.some((tab) => tab.key === target)) { - handleTabChange(target); - } + }; + + // The save bar lists errors by field name, and the offending field may sit on + // a tab that is not open. Submitting cannot reveal it -- the button is + // disabled while the form is invalid -- so each listed field switches to its + // own tab instead. + const revealField = (field: string) => { + const target = tabForField(field); + if (visibleTabs.some((tab) => tab.key === target)) { + handleTabChange(target); } }; @@ -398,272 +400,229 @@ export const SettingsPage = () => { )} {/* general tab */} - - } - /> - {/* URL Settings */} - - } - /> - {/* About */} - - - {t("common.appName")} {__APP_VERSION__} - - - {t("pages.settings.form.about.developedBy")} - - - https://github.com/bluewave-labs/checkmate - - - } - /> - - - {/* monitoring tab */} - + )} {/* email tab */} - + )} + + {/* integrations tab */} + {activeTab === "integrations" && ( + + {isAdmin && ( + 0 ? ( + + + {globalProxyEnabled && ( + + )} + + ) : ( + + ) + } + /> + )} + {isAdmin && ( + + {(isApiKeySet === false || apiKeyHasBeenReset === true) && ( + + )} + + {isApiKeySet === true && apiKeyHasBeenReset === false && ( + + + {t("pages.settings.form.pagespeed.option.apiKey.labelSet")} + - - - ) : ( - - )} - - {/* TLS Servername (Optional) */} - )} - /> - - {/* Connection Host (Optional) */} - - - {/* Boolean Switches */} - - {emailSwitches.map(({ name, label }) => ( - - ))} - - - {/* Test Email Button */} - - - - - } - /> - )} - - - {/* integrations tab */} - + + } + /> + )} + + )} {/* data tab */} - - } - /> - )} - {/* Clear All Stats */} - {isAdmin && ( - setIsStatsDialogOpen(true)} - > - {t("common.buttons.clear")} - - } - /> - )} - - {/* Remove All Monitors - Admin Only */} - {isAdmin && ( - + + + + + } + /> + )} + {/* Clear All Stats */} + {isAdmin && ( + setIsDemoMonitorsDialogOpen(true)} + onClick={() => setIsStatsDialogOpen(true)} > - {t("common.buttons.removeMonitors")} + {t("common.buttons.clear")} - - } - /> - )} - + } + /> + )} + + {/* Remove All Monitors - Admin Only */} + {isAdmin && ( + + + + } + /> + )} + + )} {/* Clear Stats Confirmation Dialog */} { return (
  • - {field}: {message} + revealField(field)} + > + {field} + + : {message}
  • );