From a1cffdd303d412726be4dd6cb9cb115077c644bc Mon Sep 17 00:00:00 2001
From: Elena Stoeva <59341489+ElenaStoeva@users.noreply.github.com>
Date: Thu, 18 Jan 2024 10:19:31 +0000
Subject: [PATCH] [Advanced Settings] Replace old settings components in
Observability apps (#174712)
Addresses https://github.com/elastic/kibana/issues/172922
## Summary
The `src/plugins/advanced_settings` plugin will soon be removed and
completely replaced by the new settings packages:
`packages/kbn-management/settings`. This PR replaces the usages of the
old Advanced settings component across the Observability apps **APM,
Infrastructure, and Universal Profiling**.
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
---
packages/kbn-optimizer/limits.yml | 2 +-
x-pack/plugins/apm/kibana.jsonc | 1 -
.../app/settings/general_settings/index.tsx | 47 ++++++++----
.../labs/labs_flyout.tsx | 49 +++++++++----
x-pack/plugins/apm/tsconfig.json | 3 +-
x-pack/plugins/infra/kibana.jsonc | 1 -
.../settings/features_configuration_panel.tsx | 62 ++++++++++------
x-pack/plugins/infra/tsconfig.json | 6 +-
.../plugins/observability_shared/kibana.jsonc | 2 +-
.../public/hooks/use_editable_settings.tsx | 72 +++++++++----------
.../observability_shared/tsconfig.json | 6 +-
.../e2e/profiling_views/functions.cy.ts | 6 +-
.../e2e/profiling_views/settings.cy.ts | 6 +-
x-pack/plugins/profiling/kibana.jsonc | 5 +-
.../profiling/public/views/settings/index.tsx | 53 ++++++++------
x-pack/plugins/profiling/tsconfig.json | 6 +-
16 files changed, 201 insertions(+), 126 deletions(-)
diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml
index afd57e44f8455..35714e5e33ad2 100644
--- a/packages/kbn-optimizer/limits.yml
+++ b/packages/kbn-optimizer/limits.yml
@@ -107,7 +107,7 @@ pageLoadAssetSize:
observabilityAIAssistant: 25000
observabilityLogExplorer: 46650
observabilityOnboarding: 19573
- observabilityShared: 52256
+ observabilityShared: 72039
osquery: 107090
painlessLab: 179748
presentationPanel: 55463
diff --git a/x-pack/plugins/apm/kibana.jsonc b/x-pack/plugins/apm/kibana.jsonc
index 858cd142f399c..e563bc9895577 100644
--- a/x-pack/plugins/apm/kibana.jsonc
+++ b/x-pack/plugins/apm/kibana.jsonc
@@ -52,7 +52,6 @@
"profilingDataAccess"
],
"requiredBundles": [
- "advancedSettings",
"fleet",
"kibanaReact",
"kibanaUtils",
diff --git a/x-pack/plugins/apm/public/components/app/settings/general_settings/index.tsx b/x-pack/plugins/apm/public/components/app/settings/general_settings/index.tsx
index c9d3351ce2ebc..797dcc910a390 100644
--- a/x-pack/plugins/apm/public/components/app/settings/general_settings/index.tsx
+++ b/x-pack/plugins/apm/public/components/app/settings/general_settings/index.tsx
@@ -6,7 +6,7 @@
*/
import { EuiSpacer } from '@elastic/eui';
-import { LazyField } from '@kbn/advanced-settings-plugin/public';
+import { withSuspense } from '@kbn/shared-ux-utility';
import { i18n } from '@kbn/i18n';
import {
apmLabsButton,
@@ -28,9 +28,18 @@ import {
useEditableSettings,
useUiTracker,
} from '@kbn/observability-shared-plugin/public';
+import { FieldRowProvider } from '@kbn/management-settings-components-field-row';
+import { ValueValidation } from '@kbn/core-ui-settings-browser/src/types';
import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
import { BottomBarActions } from '../bottom_bar_actions';
+const LazyFieldRow = React.lazy(async () => ({
+ default: (await import('@kbn/management-settings-components-field-row'))
+ .FieldRow,
+}));
+
+const FieldRow = withSuspense(LazyFieldRow);
+
const apmSettingsKeys = [
enableComparisonByDefault,
defaultApmServiceEnvironment,
@@ -50,8 +59,8 @@ export function GeneralSettings() {
const trackApmEvent = useUiTracker({ app: 'apm' });
const { docLinks, notifications } = useApmPluginContext().core;
const {
+ fields,
handleFieldChange,
- settingsEditableConfig,
unsavedChanges,
saveAll,
isSaving,
@@ -61,7 +70,7 @@ export function GeneralSettings() {
async function handleSave() {
try {
const reloadPage = Object.keys(unsavedChanges).some((key) => {
- return settingsEditableConfig[key].requiresPageReload;
+ return fields[key].requiresPageReload;
});
await saveAll();
trackApmEvent({ metric: 'general_settings_save' });
@@ -79,21 +88,33 @@ export function GeneralSettings() {
}
}
+ // We don't validate the user input on these settings
+ const settingsValidationResponse: ValueValidation = {
+ successfulValidation: true,
+ valid: true,
+ };
+
return (
<>
{apmSettingsKeys.map((settingKey) => {
- const editableConfig = settingsEditableConfig[settingKey];
+ const field = fields[settingKey];
return (
-
+
+ notifications.toasts.addDanger(message),
+ validateChange: async () => settingsValidationResponse,
+ }}
+ >
+
+
);
})}
{!isEmpty(unsavedChanges) && (
diff --git a/x-pack/plugins/apm/public/components/routing/app_root/apm_header_action_menu/labs/labs_flyout.tsx b/x-pack/plugins/apm/public/components/routing/app_root/apm_header_action_menu/labs/labs_flyout.tsx
index 6ccac93404869..65164232ef564 100644
--- a/x-pack/plugins/apm/public/components/routing/app_root/apm_header_action_menu/labs/labs_flyout.tsx
+++ b/x-pack/plugins/apm/public/components/routing/app_root/apm_header_action_menu/labs/labs_flyout.tsx
@@ -21,16 +21,25 @@ import {
EuiText,
EuiTitle,
} from '@elastic/eui';
-import { LazyField } from '@kbn/advanced-settings-plugin/public';
+import { withSuspense } from '@kbn/shared-ux-utility';
import { i18n } from '@kbn/i18n';
import React from 'react';
import {
useEditableSettings,
useUiTracker,
} from '@kbn/observability-shared-plugin/public';
+import { FieldRowProvider } from '@kbn/management-settings-components-field-row';
+import { ValueValidation } from '@kbn/core-ui-settings-browser/src/types';
import { useApmPluginContext } from '../../../../../context/apm_plugin/use_apm_plugin_context';
import { useFetcher, isPending } from '../../../../../hooks/use_fetcher';
+const LazyFieldRow = React.lazy(async () => ({
+ default: (await import('@kbn/management-settings-components-field-row'))
+ .FieldRow,
+}));
+
+const FieldRow = withSuspense(LazyFieldRow);
+
interface Props {
onClose: () => void;
}
@@ -46,8 +55,8 @@ export function LabsFlyout({ onClose }: Props) {
const labsItems = data?.labsItems || [];
const {
+ fields,
handleFieldChange,
- settingsEditableConfig,
unsavedChanges,
saveAll,
isSaving,
@@ -57,7 +66,7 @@ export function LabsFlyout({ onClose }: Props) {
async function handleSave() {
try {
const reloadPage = Object.keys(unsavedChanges).some((key) => {
- return settingsEditableConfig[key].requiresPageReload;
+ return fields[key].requiresPageReload;
});
await saveAll();
@@ -86,6 +95,12 @@ export function LabsFlyout({ onClose }: Props) {
const isLoading = isPending(status);
+ // We don't validate the user input on these settings
+ const settingsValidationResponse: ValueValidation = {
+ successfulValidation: true,
+ valid: true,
+ };
+
return (
@@ -138,19 +153,25 @@ export function LabsFlyout({ onClose }: Props) {
) : (
<>
- {labsItems.map((settingKey, i) => {
- const editableConfig = settingsEditableConfig[settingKey];
+ {labsItems.map((settingKey) => {
+ const field = fields[settingKey];
return (
<>
-
+
+ notifications.toasts.addDanger(message),
+ validateChange: async () => settingsValidationResponse,
+ }}
+ >
+
+
>
);
diff --git a/x-pack/plugins/apm/tsconfig.json b/x-pack/plugins/apm/tsconfig.json
index bf49bd5275ae8..4f708fa7fbb8e 100644
--- a/x-pack/plugins/apm/tsconfig.json
+++ b/x-pack/plugins/apm/tsconfig.json
@@ -51,7 +51,6 @@
"@kbn/charts-plugin",
"@kbn/field-formats-plugin",
"@kbn/typed-react-router-config",
- "@kbn/advanced-settings-plugin",
"@kbn/core-http-browser",
"@kbn/server-route-repository",
"@kbn/datemath",
@@ -110,6 +109,8 @@
"@kbn/core-ui-settings-browser",
"@kbn/code-editor",
"@kbn/shared-svg",
+ "@kbn/shared-ux-utility",
+ "@kbn/management-settings-components-field-row",
],
"exclude": ["target/**/*"]
}
diff --git a/x-pack/plugins/infra/kibana.jsonc b/x-pack/plugins/infra/kibana.jsonc
index a5ffd146b618f..fe2086584a033 100644
--- a/x-pack/plugins/infra/kibana.jsonc
+++ b/x-pack/plugins/infra/kibana.jsonc
@@ -46,7 +46,6 @@
"ml",
"embeddable",
"controls",
- "advancedSettings"
]
}
}
diff --git a/x-pack/plugins/infra/public/pages/metrics/settings/features_configuration_panel.tsx b/x-pack/plugins/infra/public/pages/metrics/settings/features_configuration_panel.tsx
index aa69ef543c68f..a8f8569014c7d 100644
--- a/x-pack/plugins/infra/public/pages/metrics/settings/features_configuration_panel.tsx
+++ b/x-pack/plugins/infra/public/pages/metrics/settings/features_configuration_panel.tsx
@@ -15,13 +15,21 @@ import {
enableInfrastructureProfilingIntegration,
} from '@kbn/observability-plugin/common';
import { useEditableSettings } from '@kbn/observability-shared-plugin/public';
-import { LazyField } from '@kbn/advanced-settings-plugin/public';
-import { usePluginConfig } from '../../../containers/plugin_config_context';
+import { withSuspense } from '@kbn/shared-ux-utility';
+import { FieldRowProvider } from '@kbn/management-settings-components-field-row';
+import { ValueValidation } from '@kbn/core-ui-settings-browser/src/types';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
+import { usePluginConfig } from '../../../containers/plugin_config_context';
+
+const LazyFieldRow = React.lazy(async () => ({
+ default: (await import('@kbn/management-settings-components-field-row')).FieldRow,
+}));
+
+const FieldRow = withSuspense(LazyFieldRow);
type Props = Pick<
ReturnType,
- 'handleFieldChange' | 'settingsEditableConfig' | 'unsavedChanges'
+ 'handleFieldChange' | 'fields' | 'unsavedChanges'
> & {
readOnly: boolean;
};
@@ -29,7 +37,7 @@ type Props = Pick<
export function FeaturesConfigurationPanel({
readOnly,
handleFieldChange,
- settingsEditableConfig,
+ fields,
unsavedChanges,
}: Props) {
const {
@@ -37,6 +45,12 @@ export function FeaturesConfigurationPanel({
} = useKibanaContextForPlugin();
const { featureFlags } = usePluginConfig();
+ // We don't validate the user input on these settings
+ const settingsValidationResponse: ValueValidation = {
+ successfulValidation: true,
+ valid: true,
+ };
+
return (
@@ -48,26 +62,28 @@ export function FeaturesConfigurationPanel({
-
- {featureFlags.profilingEnabled && (
- notifications.toasts.addDanger(message),
+ validateChange: async () => settingsValidationResponse,
+ }}
+ >
+
- )}
+ {featureFlags.profilingEnabled && (
+
+ )}
+
);
}
diff --git a/x-pack/plugins/infra/tsconfig.json b/x-pack/plugins/infra/tsconfig.json
index 955a3a18cf2e1..ac5a2b3d15c1a 100644
--- a/x-pack/plugins/infra/tsconfig.json
+++ b/x-pack/plugins/infra/tsconfig.json
@@ -73,14 +73,16 @@
"@kbn/metrics-data-access-plugin",
"@kbn/expressions-plugin",
"@kbn/chart-icons",
- "@kbn/advanced-settings-plugin",
"@kbn/cloud-plugin",
"@kbn/custom-icons",
"@kbn/profiling-utils",
"@kbn/profiling-data-access-plugin",
"@kbn/core-http-request-handler-context-server",
"@kbn/observability-get-padded-alert-time-range-util",
- "@kbn/ebt-tools"
+ "@kbn/ebt-tools",
+ "@kbn/shared-ux-utility",
+ "@kbn/management-settings-components-field-row",
+ "@kbn/core-ui-settings-browser"
],
"exclude": ["target/**/*"]
}
diff --git a/x-pack/plugins/observability_shared/kibana.jsonc b/x-pack/plugins/observability_shared/kibana.jsonc
index 857e198771787..3409c8c11525f 100644
--- a/x-pack/plugins/observability_shared/kibana.jsonc
+++ b/x-pack/plugins/observability_shared/kibana.jsonc
@@ -9,7 +9,7 @@
"configPath": ["xpack", "observability_shared"],
"requiredPlugins": ["cases", "uiActions", "embeddable", "share"],
"optionalPlugins": ["guidedOnboarding"],
- "requiredBundles": ["data", "inspector", "kibanaReact", "kibanaUtils", "advancedSettings"],
+ "requiredBundles": ["data", "inspector", "kibanaReact", "kibanaUtils"],
"extraPublicDirs": ["common"]
}
}
diff --git a/x-pack/plugins/observability_shared/public/hooks/use_editable_settings.tsx b/x-pack/plugins/observability_shared/public/hooks/use_editable_settings.tsx
index 6be1d28554b48..bf9f3ba440562 100644
--- a/x-pack/plugins/observability_shared/public/hooks/use_editable_settings.tsx
+++ b/x-pack/plugins/observability_shared/public/hooks/use_editable_settings.tsx
@@ -5,14 +5,20 @@
* 2.0.
*/
import { useKibana } from '@kbn/kibana-react-plugin/public';
-import { useMemo, useState } from 'react';
-import { FieldState } from '@kbn/advanced-settings-plugin/public';
-import { toEditableConfig } from '@kbn/advanced-settings-plugin/public';
+import React, { useMemo, useState } from 'react';
import { IUiSettingsClient } from '@kbn/core/public';
import { isEmpty } from 'lodash';
+import { getFieldDefinition } from '@kbn/management-settings-field-definition';
+import type {
+ FieldDefinition,
+ OnFieldChangeFn,
+ UiSettingMetadata,
+ UnsavedFieldChange,
+} from '@kbn/management-settings-types';
+import { normalizeSettings } from '@kbn/management-settings-utilities';
import { ObservabilityApp } from '../../typings/common';
-function getEditableConfig({
+function getSettingsFields({
settingsKeys,
uiSettings,
}: {
@@ -23,22 +29,21 @@ function getEditableConfig({
return {};
}
const uiSettingsDefinition = uiSettings.getAll();
- const config: Record> = {};
+ const normalizedSettings = normalizeSettings(uiSettingsDefinition);
+ const fields: Record = {};
settingsKeys.forEach((key) => {
- const settingDef = uiSettingsDefinition?.[key];
- if (settingDef) {
- const editableConfig = toEditableConfig({
- def: settingDef,
- name: key,
- value: settingDef.userValue,
- isCustom: uiSettings.isCustom(key),
- isOverridden: uiSettings.isOverridden(key),
+ const setting: UiSettingMetadata = normalizedSettings[key];
+ if (setting) {
+ const field = getFieldDefinition({
+ id: key,
+ setting,
+ params: { isCustom: uiSettings.isCustom(key), isOverridden: uiSettings.isOverridden(key) },
});
- config[key] = editableConfig;
+ fields[key] = field;
}
});
- return config;
+ return fields;
}
export function useEditableSettings(app: ObservabilityApp, settingsKeys: string[]) {
@@ -48,30 +53,26 @@ export function useEditableSettings(app: ObservabilityApp, settingsKeys: string[
const [isSaving, setIsSaving] = useState(false);
const [forceReloadSettings, setForceReloadSettings] = useState(0);
- const [unsavedChanges, setUnsavedChanges] = useState>({});
+ const [unsavedChanges, setUnsavedChanges] = React.useState>(
+ {}
+ );
- const settingsEditableConfig = useMemo(
+ const fields = useMemo(
() => {
- return getEditableConfig({ settingsKeys, uiSettings: settings?.client });
+ return getSettingsFields({ settingsKeys, uiSettings: settings?.client });
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[settings, settingsKeys, forceReloadSettings]
);
- function handleFieldChange(key: string, fieldState: FieldState) {
- setUnsavedChanges((state) => {
- const newState = { ...state };
- const { value, defVal } = settingsEditableConfig[key];
- const currentValue = value === undefined ? defVal : value;
- if (currentValue === fieldState.value) {
- // Delete property from unsaved object if user changes it to the value that was already saved
- delete newState[key];
- } else {
- newState[key] = fieldState;
- }
- return newState;
- });
- }
+ const handleFieldChange: OnFieldChangeFn = (id, change) => {
+ if (!change) {
+ const { [id]: unsavedChange, ...rest } = unsavedChanges;
+ setUnsavedChanges(rest);
+ return;
+ }
+ setUnsavedChanges((changes) => ({ ...changes, [id]: change }));
+ };
function cleanUnsavedChanges() {
setUnsavedChanges({});
@@ -81,10 +82,9 @@ export function useEditableSettings(app: ObservabilityApp, settingsKeys: string[
if (settings && !isEmpty(unsavedChanges)) {
try {
setIsSaving(true);
- const arr = Object.entries(unsavedChanges).map(([key, fieldState]) =>
- settings.client.set(key, fieldState.value)
+ const arr = Object.entries(unsavedChanges).map(([key, value]) =>
+ settings.client.set(key, value.unsavedValue)
);
-
await Promise.all(arr);
setForceReloadSettings((state) => ++state);
cleanUnsavedChanges();
@@ -95,7 +95,7 @@ export function useEditableSettings(app: ObservabilityApp, settingsKeys: string[
}
return {
- settingsEditableConfig,
+ fields,
unsavedChanges,
handleFieldChange,
saveAll,
diff --git a/x-pack/plugins/observability_shared/tsconfig.json b/x-pack/plugins/observability_shared/tsconfig.json
index bd3e72be99007..7a875f30e8736 100644
--- a/x-pack/plugins/observability_shared/tsconfig.json
+++ b/x-pack/plugins/observability_shared/tsconfig.json
@@ -34,10 +34,12 @@
"@kbn/shared-ux-router",
"@kbn/embeddable-plugin",
"@kbn/profiling-utils",
- "@kbn/advanced-settings-plugin",
"@kbn/utility-types",
"@kbn/share-plugin",
- "@kbn/shared-ux-error-boundary"
+ "@kbn/shared-ux-error-boundary",
+ "@kbn/management-settings-field-definition",
+ "@kbn/management-settings-types",
+ "@kbn/management-settings-utilities"
],
"exclude": ["target/**/*"]
}
diff --git a/x-pack/plugins/profiling/e2e/cypress/e2e/profiling_views/functions.cy.ts b/x-pack/plugins/profiling/e2e/cypress/e2e/profiling_views/functions.cy.ts
index b2f3f743df37e..6daa414df36e7 100644
--- a/x-pack/plugins/profiling/e2e/cypress/e2e/profiling_views/functions.cy.ts
+++ b/x-pack/plugins/profiling/e2e/cypress/e2e/profiling_views/functions.cy.ts
@@ -192,13 +192,13 @@ describe('Functions page', () => {
cy.get(firstRowSelector).eq(5).contains('4.07 lbs / 1.84 kg');
cy.contains('Settings').click();
cy.contains('Advanced Settings');
- cy.get(`[data-test-subj="advancedSetting-editField-${profilingCo2PerKWH}"]`)
+ cy.get(`[data-test-subj="management-settings-editField-${profilingCo2PerKWH}"]`)
.clear()
.type('0.12345');
- cy.get(`[data-test-subj="advancedSetting-editField-${profilingDatacenterPUE}"]`)
+ cy.get(`[data-test-subj="management-settings-editField-${profilingDatacenterPUE}"]`)
.clear()
.type('2.4');
- cy.get(`[data-test-subj="advancedSetting-editField-${profilingPervCPUWattX86}"]`)
+ cy.get(`[data-test-subj="management-settings-editField-${profilingPervCPUWattX86}"]`)
.clear()
.type('20');
cy.contains('Save changes').click();
diff --git a/x-pack/plugins/profiling/e2e/cypress/e2e/profiling_views/settings.cy.ts b/x-pack/plugins/profiling/e2e/cypress/e2e/profiling_views/settings.cy.ts
index 01e5128aeafa1..7b347399de3dd 100644
--- a/x-pack/plugins/profiling/e2e/cypress/e2e/profiling_views/settings.cy.ts
+++ b/x-pack/plugins/profiling/e2e/cypress/e2e/profiling_views/settings.cy.ts
@@ -45,13 +45,13 @@ describe('Settings page', () => {
cy.visitKibana('/app/profiling/settings');
cy.contains('Advanced Settings');
cy.get('[data-test-subj="profilingBottomBarActions"]').should('not.exist');
- cy.get(`[data-test-subj="advancedSetting-editField-${profilingCo2PerKWH}"]`)
+ cy.get(`[data-test-subj="management-settings-editField-${profilingCo2PerKWH}"]`)
.clear()
.type('0.12345');
- cy.get(`[data-test-subj="advancedSetting-editField-${profilingDatacenterPUE}"]`)
+ cy.get(`[data-test-subj="management-settings-editField-${profilingDatacenterPUE}"]`)
.clear()
.type('2.4');
- cy.get(`[data-test-subj="advancedSetting-editField-${profilingPervCPUWattX86}"]`)
+ cy.get(`[data-test-subj="management-settings-editField-${profilingPervCPUWattX86}"]`)
.clear()
.type('20');
cy.get('[data-test-subj="profilingBottomBarActions"]').should('exist');
diff --git a/x-pack/plugins/profiling/kibana.jsonc b/x-pack/plugins/profiling/kibana.jsonc
index 296b4e40bb822..5902c5f63f8fb 100644
--- a/x-pack/plugins/profiling/kibana.jsonc
+++ b/x-pack/plugins/profiling/kibana.jsonc
@@ -8,7 +8,7 @@
"browser": true,
"configPath": ["xpack", "profiling"],
"optionalPlugins": [
- "spaces",
+ "spaces",
"usageCollection",
"security",
"cloud",
@@ -31,8 +31,7 @@
"requiredBundles": [
"kibanaReact",
"kibanaUtils",
- "observabilityAIAssistant",
- "advancedSettings"
+ "observabilityAIAssistant"
]
}
}
diff --git a/x-pack/plugins/profiling/public/views/settings/index.tsx b/x-pack/plugins/profiling/public/views/settings/index.tsx
index d4ac35ff6357b..1d00e9f2410e2 100644
--- a/x-pack/plugins/profiling/public/views/settings/index.tsx
+++ b/x-pack/plugins/profiling/public/views/settings/index.tsx
@@ -15,7 +15,7 @@ import {
EuiText,
EuiTitle,
} from '@elastic/eui';
-import { LazyField } from '@kbn/advanced-settings-plugin/public';
+import { withSuspense } from '@kbn/shared-ux-utility';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import {
@@ -29,10 +29,18 @@ import {
import { useEditableSettings, useUiTracker } from '@kbn/observability-shared-plugin/public';
import { isEmpty } from 'lodash';
import React from 'react';
+import { ValueValidation } from '@kbn/core-ui-settings-browser/src/types';
+import { FieldRowProvider } from '@kbn/management-settings-components-field-row';
import { useProfilingDependencies } from '../../components/contexts/profiling_dependencies/use_profiling_dependencies';
import { ProfilingAppPageTemplate } from '../../components/profiling_app_page_template';
import { BottomBarActions } from './bottom_bar_actions';
+const LazyFieldRow = React.lazy(async () => ({
+ default: (await import('@kbn/management-settings-components-field-row')).FieldRow,
+}));
+
+const FieldRow = withSuspense(LazyFieldRow);
+
const co2Settings = [
profilingCo2PerKWH,
profilingDatacenterPUE,
@@ -49,19 +57,13 @@ export function Settings() {
},
} = useProfilingDependencies();
- const {
- handleFieldChange,
- settingsEditableConfig,
- unsavedChanges,
- saveAll,
- isSaving,
- cleanUnsavedChanges,
- } = useEditableSettings('profiling', [...co2Settings, ...costSettings]);
+ const { fields, handleFieldChange, unsavedChanges, saveAll, isSaving, cleanUnsavedChanges } =
+ useEditableSettings('profiling', [...co2Settings, ...costSettings]);
async function handleSave() {
try {
const reloadPage = Object.keys(unsavedChanges).some((key) => {
- return settingsEditableConfig[key].requiresPageReload;
+ return fields[key].requiresPageReload;
});
await saveAll();
trackProfilingEvent({ metric: 'general_settings_save' });
@@ -79,6 +81,12 @@ export function Settings() {
}
}
+ // We don't validate the user input on these settings
+ const settingsValidationResponse: ValueValidation = {
+ successfulValidation: true,
+ valid: true,
+ };
+
return (
<>
@@ -201,17 +209,22 @@ export function Settings() {
>
) : null}
{item.settings.map((settingKey) => {
- const editableConfig = settingsEditableConfig[settingKey];
+ const field = fields[settingKey];
return (
-
+ notifications.toasts.addDanger(message),
+ validateChange: async () => settingsValidationResponse,
+ }}
+ >
+
+
);
})}
diff --git a/x-pack/plugins/profiling/tsconfig.json b/x-pack/plugins/profiling/tsconfig.json
index 7705c70d0d1b4..78749609e199d 100644
--- a/x-pack/plugins/profiling/tsconfig.json
+++ b/x-pack/plugins/profiling/tsconfig.json
@@ -50,8 +50,10 @@
"@kbn/profiling-data-access-plugin",
"@kbn/embeddable-plugin",
"@kbn/profiling-utils",
- "@kbn/advanced-settings-plugin",
- "@kbn/security-plugin"
+ "@kbn/security-plugin",
+ "@kbn/shared-ux-utility",
+ "@kbn/core-ui-settings-browser",
+ "@kbn/management-settings-components-field-row"
// add references to other TypeScript projects the plugin depends on
// requiredPlugins from ./kibana.json