diff --git a/src/plugins/dashboard/public/dashboard_api/get_dashboard_api.ts b/src/plugins/dashboard/public/dashboard_api/get_dashboard_api.ts index 2e2e6352f829a..f545f5c95ee67 100644 --- a/src/plugins/dashboard/public/dashboard_api/get_dashboard_api.ts +++ b/src/plugins/dashboard/public/dashboard_api/get_dashboard_api.ts @@ -87,18 +87,15 @@ export function getDashboardApi({ controlGroupApi$, panelsManager.api.children$ ); + const settingsManager = initializeSettingsManager(initialState); const unifiedSearchManager = initializeUnifiedSearchManager( initialState, controlGroupApi$, + settingsManager.api.timeRestore$, dataLoadingManager.internalApi.waitForPanelsToLoad$, () => unsavedChangesManager.internalApi.getLastSavedState(), creationOptions ); - const settingsManager = initializeSettingsManager({ - initialState, - setTimeRestore: unifiedSearchManager.internalApi.setTimeRestore, - timeRestore$: unifiedSearchManager.internalApi.timeRestore$, - }); const unsavedChangesManager = initializeUnsavedChangesManager({ creationOptions, controlGroupApi$, diff --git a/src/plugins/dashboard/public/dashboard_api/settings_manager.ts b/src/plugins/dashboard/public/dashboard_api/settings_manager.ts index 0b4903a506a90..9cb93269f4b4b 100644 --- a/src/plugins/dashboard/public/dashboard_api/settings_manager.ts +++ b/src/plugins/dashboard/public/dashboard_api/settings_manager.ts @@ -8,25 +8,12 @@ */ import fastIsEqual from 'fast-deep-equal'; -import { - PublishingSubject, - StateComparators, - initializeTitles, -} from '@kbn/presentation-publishing'; +import { StateComparators, initializeTitles } from '@kbn/presentation-publishing'; import { BehaviorSubject } from 'rxjs'; -import { DashboardState } from './types'; +import { DashboardSettings, DashboardState } from './types'; import { DEFAULT_DASHBOARD_INPUT } from '../dashboard_constants'; -import { DashboardStateFromSettingsFlyout } from '../dashboard_container/types'; -export function initializeSettingsManager({ - initialState, - setTimeRestore, - timeRestore$, -}: { - initialState?: DashboardState; - setTimeRestore: (timeRestore: boolean) => void; - timeRestore$: PublishingSubject; -}) { +export function initializeSettingsManager(initialState?: DashboardState) { const syncColors$ = new BehaviorSubject( initialState?.syncColors ?? DEFAULT_DASHBOARD_INPUT.syncColors ); @@ -50,6 +37,12 @@ export function initializeSettingsManager({ if (!fastIsEqual(tags, tags$.value)) tags$.next(tags); } const titleManager = initializeTitles(initialState ?? {}); + const timeRestore$ = new BehaviorSubject( + initialState?.timeRestore ?? DEFAULT_DASHBOARD_INPUT.timeRestore + ); + function setTimeRestore(timeRestore: boolean) { + if (timeRestore !== timeRestore$.value) timeRestore$.next(timeRestore); + } const useMargins$ = new BehaviorSubject( initialState?.useMargins ?? DEFAULT_DASHBOARD_INPUT.useMargins ); @@ -69,7 +62,7 @@ export function initializeSettingsManager({ }; } - function setSettings(settings: DashboardStateFromSettingsFlyout) { + function setSettings(settings: DashboardSettings) { setSyncColors(settings.syncColors); setSyncCursor(settings.syncCursor); setSyncTooltips(settings.syncTooltips); @@ -100,35 +93,16 @@ export function initializeSettingsManager({ syncColors: [syncColors$, setSyncColors], syncCursor: [syncCursor$, setSyncCursor], syncTooltips: [syncTooltips$, setSyncTooltips], + timeRestore: [timeRestore$, setTimeRestore], useMargins: [useMargins$, setUseMargins], - } as StateComparators< - Pick< - DashboardState, - | 'description' - | 'hidePanelTitles' - | 'syncColors' - | 'syncCursor' - | 'syncTooltips' - | 'title' - | 'useMargins' - > - >, + } as StateComparators>, internalApi: { - getState: (): Pick< - DashboardState, - | 'description' - | 'hidePanelTitles' - | 'syncColors' - | 'syncCursor' - | 'syncTooltips' - | 'tags' - | 'title' - | 'useMargins' - > => { + getState: (): DashboardSettings => { const settings = getSettings(); return { ...settings, title: settings.title ?? '', + timeRestore: settings.timeRestore ?? DEFAULT_DASHBOARD_INPUT.timeRestore, hidePanelTitles: settings.hidePanelTitles ?? DEFAULT_DASHBOARD_INPUT.hidePanelTitles, }; }, diff --git a/src/plugins/dashboard/public/dashboard_api/types.ts b/src/plugins/dashboard/public/dashboard_api/types.ts index 7a1fc5fed7e13..81dce821c0c10 100644 --- a/src/plugins/dashboard/public/dashboard_api/types.ts +++ b/src/plugins/dashboard/public/dashboard_api/types.ts @@ -54,15 +54,12 @@ import { PublishesReload } from '@kbn/presentation-publishing/interfaces/fetch/p import { PublishesSearchSession } from '@kbn/presentation-publishing/interfaces/fetch/publishes_search_session'; import { LocatorPublic } from '@kbn/share-plugin/common'; import { DashboardPanelMap, DashboardPanelState } from '../../common'; -import type { DashboardOptions } from '../../server/content_management'; +import type { DashboardAttributes, DashboardOptions } from '../../server/content_management'; import { LoadDashboardReturn, SaveDashboardReturn, } from '../services/dashboard_content_management_service/types'; -import { - DashboardLocatorParams, - DashboardStateFromSettingsFlyout, -} from '../dashboard_container/types'; +import { DashboardLocatorParams } from '../dashboard_container/types'; export const DASHBOARD_API_TYPE = 'dashboard'; @@ -93,23 +90,19 @@ export interface DashboardCreationOptions { getEmbeddableAppContext?: (dashboardId?: string) => EmbeddableAppContext; } -export interface DashboardState extends DashboardOptions { - // filter context to be passed to children +export type DashboardSettings = DashboardOptions & { + description?: DashboardAttributes['description']; + tags: string[]; + timeRestore: DashboardAttributes['timeRestore']; + title: DashboardAttributes['description']; +}; + +export interface DashboardState extends DashboardSettings { query: Query; filters: Filter[]; - timeRestore: boolean; timeRange?: TimeRange; refreshInterval?: RefreshInterval; - - // dashboard meta info - title: string; - tags: string[]; viewMode: ViewMode; - description?: string; - - // settings from DashboardOptions - - // dashboard contents panels: DashboardPanelMap; /** @@ -152,8 +145,8 @@ export type DashboardApi = CanExpandPanels & fullScreenMode$: PublishingSubject; focusedPanelId$: PublishingSubject; forceRefresh: () => void; - getSettings: () => DashboardStateFromSettingsFlyout; getDashboardPanelFromId: (id: string) => Promise; + getSettings: () => DashboardSettings; hasOverlays$: PublishingSubject; hasUnsavedChanges$: PublishingSubject; highlightPanel: (panelRef: HTMLDivElement) => void; @@ -173,7 +166,7 @@ export type DashboardApi = CanExpandPanels & setPanels: (panels: DashboardPanelMap) => void; setQuery: (query?: Query | undefined) => void; setScrollToPanelId: (id: string | undefined) => void; - setSettings: (settings: DashboardStateFromSettingsFlyout) => void; + setSettings: (settings: DashboardSettings) => void; setTags: (tags: string[]) => void; setTimeRange: (timeRange?: TimeRange | undefined) => void; unifiedSearchFilters$: PublishesUnifiedSearch['filters$']; diff --git a/src/plugins/dashboard/public/dashboard_api/unified_search_manager.ts b/src/plugins/dashboard/public/dashboard_api/unified_search_manager.ts index 1310f0104a5ea..9d39961778a91 100644 --- a/src/plugins/dashboard/public/dashboard_api/unified_search_manager.ts +++ b/src/plugins/dashboard/public/dashboard_api/unified_search_manager.ts @@ -48,6 +48,7 @@ import { DEFAULT_DASHBOARD_INPUT, GLOBAL_STATE_STORAGE_KEY } from '../dashboard_ export function initializeUnifiedSearchManager( initialState: DashboardState, controlGroupApi$: PublishingSubject, + timeRestore$: PublishingSubject, waitForPanelsToLoad$: Observable, getLastSavedState: () => DashboardState | undefined, creationOptions?: DashboardCreationOptions @@ -97,12 +98,6 @@ export function initializeUnifiedSearchManager( timefilterService.setTime(timeRangeOrDefault); } } - const timeRestore$ = new BehaviorSubject( - initialState?.timeRestore ?? DEFAULT_DASHBOARD_INPUT.timeRestore - ); - function setTimeRestore(timeRestore: boolean) { - if (timeRestore !== timeRestore$.value) timeRestore$.next(timeRestore); - } const timeslice$ = new BehaviorSubject<[number, number] | undefined>(undefined); const unifiedSearchFilters$ = new BehaviorSubject(initialState.filters); // setAndSyncUnifiedSearchFilters method not needed since filters synced with 2-way data binding @@ -312,9 +307,8 @@ export function initializeUnifiedSearchManager( return true; }, ], - timeRestore: [timeRestore$, setTimeRestore], } as StateComparators< - Pick + Pick >, internalApi: { controlGroupReload$, @@ -325,7 +319,6 @@ export function initializeUnifiedSearchManager( ...lastSavedState.filters, ]); setQuery(lastSavedState.query); - setTimeRestore(lastSavedState.timeRestore); if (lastSavedState.timeRestore) { setAndSyncRefreshInterval(lastSavedState.refreshInterval); setAndSyncTimeRange(lastSavedState.timeRange); @@ -341,8 +334,6 @@ export function initializeUnifiedSearchManager( timeRange: timeRange$.value, timeRestore: timeRestore$.value ?? DEFAULT_DASHBOARD_INPUT.timeRestore, }), - setTimeRestore, - timeRestore$, }, cleanup: () => { controlGroupSubscriptions.unsubscribe(); diff --git a/src/plugins/dashboard/public/dashboard_container/component/settings/index.ts b/src/plugins/dashboard/public/dashboard_container/component/settings/index.ts index 758ea4bf2fd70..970e67e6b8289 100644 --- a/src/plugins/dashboard/public/dashboard_container/component/settings/index.ts +++ b/src/plugins/dashboard/public/dashboard_container/component/settings/index.ts @@ -7,4 +7,4 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export { DashboardSettings } from './settings_flyout'; +export { DashboardSettingsFlyout } from './settings_flyout'; diff --git a/src/plugins/dashboard/public/dashboard_container/component/settings/settings_flyout.tsx b/src/plugins/dashboard/public/dashboard_container/component/settings/settings_flyout.tsx index 20fd2b93119de..e0de277fc3c06 100644 --- a/src/plugins/dashboard/public/dashboard_container/component/settings/settings_flyout.tsx +++ b/src/plugins/dashboard/public/dashboard_container/component/settings/settings_flyout.tsx @@ -31,7 +31,7 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; -import { DashboardContainerInput } from '../../../../common'; +import { DashboardSettings } from '../../../dashboard_api/types'; import { useDashboardApi } from '../../../dashboard_api/use_dashboard_api'; import { getDashboardContentManagementService } from '../../../services/dashboard_content_management_service'; import { savedObjectsTaggingService } from '../../../services/kibana_services'; @@ -42,7 +42,7 @@ interface DashboardSettingsProps { const DUPLICATE_TITLE_CALLOUT_ID = 'duplicateTitleCallout'; -export const DashboardSettings = ({ onClose }: DashboardSettingsProps) => { +export const DashboardSettingsFlyout = ({ onClose }: DashboardSettingsProps) => { const dashboardApi = useDashboardApi(); const [localSettings, setLocalSettings] = useState(dashboardApi.getSettings()); @@ -81,7 +81,7 @@ export const DashboardSettings = ({ onClose }: DashboardSettingsProps) => { } }; - const updateDashboardSetting = useCallback((newSettings: Partial) => { + const updateDashboardSetting = useCallback((newSettings: Partial) => { setLocalSettings((prevSettings) => { return { ...prevSettings, diff --git a/src/plugins/dashboard/public/dashboard_container/embeddable/api/open_settings_flyout.tsx b/src/plugins/dashboard/public/dashboard_container/embeddable/api/open_settings_flyout.tsx index 0f78bcc96a975..582d19af620f9 100644 --- a/src/plugins/dashboard/public/dashboard_container/embeddable/api/open_settings_flyout.tsx +++ b/src/plugins/dashboard/public/dashboard_container/embeddable/api/open_settings_flyout.tsx @@ -14,14 +14,14 @@ import { toMountPoint } from '@kbn/react-kibana-mount'; import { DashboardApi } from '../../../dashboard_api/types'; import { DashboardContext } from '../../../dashboard_api/use_dashboard_api'; import { coreServices } from '../../../services/kibana_services'; -import { DashboardSettings } from '../../component/settings/settings_flyout'; +import { DashboardSettingsFlyout } from '../../component/settings/settings_flyout'; export function openSettingsFlyout(dashboardApi: DashboardApi) { dashboardApi.openOverlay( coreServices.overlays.openFlyout( toMountPoint( - { dashboardApi.clearOverlays(); }} diff --git a/src/plugins/dashboard/public/dashboard_container/types.ts b/src/plugins/dashboard/public/dashboard_container/types.ts index eac2a782f11c2..631d9f66499c7 100644 --- a/src/plugins/dashboard/public/dashboard_container/types.ts +++ b/src/plugins/dashboard/public/dashboard_container/types.ts @@ -12,7 +12,7 @@ import { SerializableRecord } from '@kbn/utility-types'; import { ControlGroupRuntimeState } from '@kbn/controls-plugin/public'; import type { DashboardContainerInput } from '../../common'; -import type { DashboardOptions, DashboardPanel } from '../../server/content_management'; +import type { DashboardPanel } from '../../server/content_management'; export interface UnsavedPanelState { [key: string]: object | undefined; @@ -23,13 +23,6 @@ export type RedirectToProps = | { destination: 'dashboard'; id?: string; useReplace?: boolean; editMode?: boolean } | { destination: 'listing'; filter?: string; useReplace?: boolean }; -export type DashboardStateFromSaveModal = Pick< - DashboardContainerInput, - 'title' | 'description' | 'tags' | 'timeRestore' ->; - -export type DashboardStateFromSettingsFlyout = DashboardStateFromSaveModal & DashboardOptions; - export type DashboardLoadType = | 'sessionFirstLoad' | 'dashboardFirstLoad' @@ -41,8 +34,6 @@ export interface DashboardRenderPerformanceStats { panelsRenderStartTime: number; } -export type DashboardContainerInputWithoutId = Omit; - export interface DashboardContainerOutput extends ContainerOutput { usedDataViewIds?: string[]; } diff --git a/x-pack/platform/plugins/shared/integration_assistant/common/api/analyze_logs/analyze_logs_route.schema.yaml b/x-pack/platform/plugins/shared/integration_assistant/common/api/analyze_logs/analyze_logs_route.schema.yaml index 298abbc1201ea..2be69571865e8 100644 --- a/x-pack/platform/plugins/shared/integration_assistant/common/api/analyze_logs/analyze_logs_route.schema.yaml +++ b/x-pack/platform/plugins/shared/integration_assistant/common/api/analyze_logs/analyze_logs_route.schema.yaml @@ -3,7 +3,7 @@ info: title: Auto Import Analyze Logs API endpoint version: "1" paths: - /api/integration_assistant/analyzelogs: + /internal/automatic_import/analyzelogs: post: summary: Analyzes log samples and processes them. operationId: AnalyzeLogs diff --git a/x-pack/platform/plugins/shared/integration_assistant/common/api/build_integration/build_integration.schema.yaml b/x-pack/platform/plugins/shared/integration_assistant/common/api/build_integration/build_integration.schema.yaml index 7a5a994cff4df..cc210c53f1e70 100644 --- a/x-pack/platform/plugins/shared/integration_assistant/common/api/build_integration/build_integration.schema.yaml +++ b/x-pack/platform/plugins/shared/integration_assistant/common/api/build_integration/build_integration.schema.yaml @@ -3,7 +3,7 @@ info: title: Integration Assistatnt Build Integrarion API endpoint version: "1" paths: - /api/integration_assistant/build: + /internal/automatic_import/build: post: summary: Builds Integration with the given input samples operationId: BuildIntegration diff --git a/x-pack/platform/plugins/shared/integration_assistant/common/api/categorization/categorization_route.schema.yaml b/x-pack/platform/plugins/shared/integration_assistant/common/api/categorization/categorization_route.schema.yaml index 4a8a28abf3a7e..694eb80e852c4 100644 --- a/x-pack/platform/plugins/shared/integration_assistant/common/api/categorization/categorization_route.schema.yaml +++ b/x-pack/platform/plugins/shared/integration_assistant/common/api/categorization/categorization_route.schema.yaml @@ -3,7 +3,7 @@ info: title: Integration Assistatnt Categorization API endpoint version: "1" paths: - /api/integration_assistant/categorization: + /internal/automatic_import/categorization: post: summary: Builds Categorization processors based on the samples operationId: Categorization diff --git a/x-pack/platform/plugins/shared/integration_assistant/common/api/cel/cel_input_route.schema.yaml b/x-pack/platform/plugins/shared/integration_assistant/common/api/cel/cel_input_route.schema.yaml index 18187959fe461..dc33d9ac69e3e 100644 --- a/x-pack/platform/plugins/shared/integration_assistant/common/api/cel/cel_input_route.schema.yaml +++ b/x-pack/platform/plugins/shared/integration_assistant/common/api/cel/cel_input_route.schema.yaml @@ -3,7 +3,7 @@ info: title: Automatic Import CEL Input API endpoint version: "1" paths: - /api/integration_assistant/cel: + /internal/automatic_import/cel: post: summary: Builds CEL input configuration operationId: CelInput diff --git a/x-pack/platform/plugins/shared/integration_assistant/common/api/check_pipeline/check_pipeline.schema.yaml b/x-pack/platform/plugins/shared/integration_assistant/common/api/check_pipeline/check_pipeline.schema.yaml index b7f20616007ea..e592565c52b63 100644 --- a/x-pack/platform/plugins/shared/integration_assistant/common/api/check_pipeline/check_pipeline.schema.yaml +++ b/x-pack/platform/plugins/shared/integration_assistant/common/api/check_pipeline/check_pipeline.schema.yaml @@ -3,7 +3,7 @@ info: title: Integration Assistatnt Check Pipeline API endpoint version: "1" paths: - /api/integration_assistant/pipeline: + /internal/automatic_import/pipeline: post: summary: Checks if the pipeline is valid for the given samples operationId: CheckPipeline diff --git a/x-pack/platform/plugins/shared/integration_assistant/common/api/ecs/ecs_route.schema.yaml b/x-pack/platform/plugins/shared/integration_assistant/common/api/ecs/ecs_route.schema.yaml index 6bc125a74f52a..2534823b1d171 100644 --- a/x-pack/platform/plugins/shared/integration_assistant/common/api/ecs/ecs_route.schema.yaml +++ b/x-pack/platform/plugins/shared/integration_assistant/common/api/ecs/ecs_route.schema.yaml @@ -3,7 +3,7 @@ info: title: Integration Assistatnt ECS Mapping API endpoint version: "1" paths: - /api/integration_assistant/ecs: + /internal/automatic_import/ecs: post: summary: Builds ECS Mapping based on the input samples operationId: EcsMapping diff --git a/x-pack/platform/plugins/shared/integration_assistant/common/api/related/related_route.schema.yaml b/x-pack/platform/plugins/shared/integration_assistant/common/api/related/related_route.schema.yaml index 9ca2f6ab7bae0..2d53b07d4f846 100644 --- a/x-pack/platform/plugins/shared/integration_assistant/common/api/related/related_route.schema.yaml +++ b/x-pack/platform/plugins/shared/integration_assistant/common/api/related/related_route.schema.yaml @@ -3,7 +3,7 @@ info: title: Integration Assistatnt Related API endpoint version: "1" paths: - /api/integration_assistant/related: + /internal/automatic_import/related: post: summary: Builds related.* fields for integration with the given input samples operationId: Related diff --git a/x-pack/platform/plugins/shared/integration_assistant/common/constants.ts b/x-pack/platform/plugins/shared/integration_assistant/common/constants.ts index 3026101ebf54d..2e5975a1d4074 100644 --- a/x-pack/platform/plugins/shared/integration_assistant/common/constants.ts +++ b/x-pack/platform/plugins/shared/integration_assistant/common/constants.ts @@ -14,7 +14,7 @@ export const PLUGIN_ID = 'integrationAssistant'; export const INTEGRATION_ASSISTANT_APP_ROUTE = '/app/integration_assistant'; // Server API Routes -export const INTEGRATION_ASSISTANT_BASE_PATH = '/api/integration_assistant'; +export const INTEGRATION_ASSISTANT_BASE_PATH = '/internal/automatic_import'; export const ECS_GRAPH_PATH = `${INTEGRATION_ASSISTANT_BASE_PATH}/ecs`; export const CATEGORIZATION_GRAPH_PATH = `${INTEGRATION_ASSISTANT_BASE_PATH}/categorization`; diff --git a/x-pack/plugins/fleet/cypress/e2e/integrations_automatic_import.cy.ts b/x-pack/plugins/fleet/cypress/e2e/integrations_automatic_import.cy.ts index e2454cb1dcf77..74050d9244e0b 100644 --- a/x-pack/plugins/fleet/cypress/e2e/integrations_automatic_import.cy.ts +++ b/x-pack/plugins/fleet/cypress/e2e/integrations_automatic_import.cy.ts @@ -45,19 +45,19 @@ describe('Add Integration - Automatic Import', () => { deleteConnectors(); createBedrockConnector(); // Mock API Responses - cy.intercept('POST', '/api/integration_assistant/ecs', { + cy.intercept('POST', '/internal/automatic_import/ecs', { statusCode: 200, body: { results: ecsResultsForJson, }, }); - cy.intercept('POST', '/api/integration_assistant/categorization', { + cy.intercept('POST', '/internal/automatic_import/categorization', { statusCode: 200, body: { results: categorizationResultsForJson, }, }); - cy.intercept('POST', '/api/integration_assistant/related', { + cy.intercept('POST', '/internal/automatic_import/related', { statusCode: 200, body: { results: relatedResultsForJson,