mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
* hide ui monitor management features behind feature flag * adjust tests * adjust content * adjust rtl_helpers Co-authored-by: Dominique Clarke <doclarke71@gmail.com>
This commit is contained in:
parent
b9888d24d3
commit
a086bd8fc1
18 changed files with 295 additions and 109 deletions
|
@ -9,9 +9,25 @@ import { PluginConfigDescriptor } from 'kibana/server';
|
||||||
import { schema, TypeOf } from '@kbn/config-schema';
|
import { schema, TypeOf } from '@kbn/config-schema';
|
||||||
|
|
||||||
export const config: PluginConfigDescriptor = {
|
export const config: PluginConfigDescriptor = {
|
||||||
|
exposeToBrowser: {
|
||||||
|
ui: true,
|
||||||
|
},
|
||||||
schema: schema.maybe(
|
schema: schema.maybe(
|
||||||
schema.object({
|
schema.object({
|
||||||
index: schema.maybe(schema.string()),
|
index: schema.maybe(schema.string()),
|
||||||
|
ui: schema.maybe(
|
||||||
|
schema.object({
|
||||||
|
unsafe: schema.maybe(
|
||||||
|
schema.object({
|
||||||
|
monitorManagement: schema.maybe(
|
||||||
|
schema.object({
|
||||||
|
enabled: schema.boolean(),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
})
|
||||||
|
),
|
||||||
unsafe: schema.maybe(
|
unsafe: schema.maybe(
|
||||||
schema.object({
|
schema.object({
|
||||||
service: schema.maybe(
|
service: schema.maybe(
|
||||||
|
@ -30,3 +46,6 @@ export const config: PluginConfigDescriptor = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UptimeConfig = TypeOf<typeof config.schema>;
|
export type UptimeConfig = TypeOf<typeof config.schema>;
|
||||||
|
export interface UptimeUiConfig {
|
||||||
|
ui?: TypeOf<typeof config.schema>['ui'];
|
||||||
|
}
|
|
@ -7,6 +7,10 @@
|
||||||
|
|
||||||
export const MONITOR_ROUTE = '/monitor/:monitorId?';
|
export const MONITOR_ROUTE = '/monitor/:monitorId?';
|
||||||
|
|
||||||
|
export const MONITOR_ADD_ROUTE = '/add-monitor';
|
||||||
|
|
||||||
|
export const MONITOR_EDIT_ROUTE = '/edit-monitor/:monitorId';
|
||||||
|
|
||||||
export const OVERVIEW_ROUTE = '/';
|
export const OVERVIEW_ROUTE = '/';
|
||||||
|
|
||||||
export const SETTINGS_ROUTE = '/settings';
|
export const SETTINGS_ROUTE = '/settings';
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { from } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { i18n } from '@kbn/i18n';
|
import { i18n } from '@kbn/i18n';
|
||||||
import { DEFAULT_APP_CATEGORIES } from '../../../../../src/core/public';
|
import { DEFAULT_APP_CATEGORIES } from '../../../../../src/core/public';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
FeatureCatalogueCategory,
|
FeatureCatalogueCategory,
|
||||||
HomePublicPluginSetup,
|
HomePublicPluginSetup,
|
||||||
|
@ -43,6 +44,7 @@ import {
|
||||||
} from '../components/fleet_package';
|
} from '../components/fleet_package';
|
||||||
import { LazySyntheticsCustomAssetsExtension } from '../components/fleet_package/lazy_synthetics_custom_assets_extension';
|
import { LazySyntheticsCustomAssetsExtension } from '../components/fleet_package/lazy_synthetics_custom_assets_extension';
|
||||||
import { Start as InspectorPluginStart } from '../../../../../src/plugins/inspector/public';
|
import { Start as InspectorPluginStart } from '../../../../../src/plugins/inspector/public';
|
||||||
|
import { UptimeUiConfig } from '../../common/config';
|
||||||
|
|
||||||
export interface ClientPluginsSetup {
|
export interface ClientPluginsSetup {
|
||||||
data: DataPublicPluginSetup;
|
data: DataPublicPluginSetup;
|
||||||
|
@ -73,9 +75,10 @@ export type ClientStart = void;
|
||||||
export class UptimePlugin
|
export class UptimePlugin
|
||||||
implements Plugin<ClientSetup, ClientStart, ClientPluginsSetup, ClientPluginsStart>
|
implements Plugin<ClientSetup, ClientStart, ClientPluginsSetup, ClientPluginsStart>
|
||||||
{
|
{
|
||||||
constructor(_context: PluginInitializerContext) {}
|
constructor(private readonly initContext: PluginInitializerContext) {}
|
||||||
|
|
||||||
public setup(core: CoreSetup<ClientPluginsStart, unknown>, plugins: ClientPluginsSetup): void {
|
public setup(core: CoreSetup<ClientPluginsStart, unknown>, plugins: ClientPluginsSetup): void {
|
||||||
|
const config = this.initContext.config.get<UptimeUiConfig>();
|
||||||
if (plugins.home) {
|
if (plugins.home) {
|
||||||
plugins.home.featureCatalogue.register({
|
plugins.home.featureCatalogue.register({
|
||||||
id: PLUGIN.ID,
|
id: PLUGIN.ID,
|
||||||
|
@ -203,7 +206,7 @@ export class UptimePlugin
|
||||||
const [coreStart, corePlugins] = await core.getStartServices();
|
const [coreStart, corePlugins] = await core.getStartServices();
|
||||||
|
|
||||||
const { renderApp } = await import('./render_app');
|
const { renderApp } = await import('./render_app');
|
||||||
return renderApp(coreStart, plugins, corePlugins, params);
|
return renderApp(coreStart, plugins, corePlugins, params, config);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,14 @@ import {
|
||||||
} from '../../common/constants';
|
} from '../../common/constants';
|
||||||
import { UptimeApp, UptimeAppProps } from './uptime_app';
|
import { UptimeApp, UptimeAppProps } from './uptime_app';
|
||||||
import { ClientPluginsSetup, ClientPluginsStart } from './plugin';
|
import { ClientPluginsSetup, ClientPluginsStart } from './plugin';
|
||||||
|
import { UptimeUiConfig } from '../../common/config';
|
||||||
|
|
||||||
export function renderApp(
|
export function renderApp(
|
||||||
core: CoreStart,
|
core: CoreStart,
|
||||||
plugins: ClientPluginsSetup,
|
plugins: ClientPluginsSetup,
|
||||||
startPlugins: ClientPluginsStart,
|
startPlugins: ClientPluginsStart,
|
||||||
appMountParameters: AppMountParameters
|
appMountParameters: AppMountParameters,
|
||||||
|
config: UptimeUiConfig
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
application: { capabilities },
|
application: { capabilities },
|
||||||
|
@ -70,6 +72,7 @@ export function renderApp(
|
||||||
setBadge,
|
setBadge,
|
||||||
appMountParameters,
|
appMountParameters,
|
||||||
setBreadcrumbs: core.chrome.setBreadcrumbs,
|
setBreadcrumbs: core.chrome.setBreadcrumbs,
|
||||||
|
config,
|
||||||
};
|
};
|
||||||
|
|
||||||
ReactDOM.render(<UptimeApp {...props} />, appMountParameters.element);
|
ReactDOM.render(<UptimeApp {...props} />, appMountParameters.element);
|
||||||
|
|
|
@ -34,6 +34,7 @@ import { EuiThemeProvider } from '../../../../../src/plugins/kibana_react/common
|
||||||
import { Storage } from '../../../../../src/plugins/kibana_utils/public';
|
import { Storage } from '../../../../../src/plugins/kibana_utils/public';
|
||||||
import { UptimeIndexPatternContextProvider } from '../contexts/uptime_index_pattern_context';
|
import { UptimeIndexPatternContextProvider } from '../contexts/uptime_index_pattern_context';
|
||||||
import { InspectorContextProvider } from '../../../observability/public';
|
import { InspectorContextProvider } from '../../../observability/public';
|
||||||
|
import { UptimeUiConfig } from '../../common/config';
|
||||||
|
|
||||||
export interface UptimeAppColors {
|
export interface UptimeAppColors {
|
||||||
danger: string;
|
danger: string;
|
||||||
|
@ -62,6 +63,7 @@ export interface UptimeAppProps {
|
||||||
commonlyUsedRanges: CommonlyUsedRange[];
|
commonlyUsedRanges: CommonlyUsedRange[];
|
||||||
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
|
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
|
||||||
appMountParameters: AppMountParameters;
|
appMountParameters: AppMountParameters;
|
||||||
|
config: UptimeUiConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Application = (props: UptimeAppProps) => {
|
const Application = (props: UptimeAppProps) => {
|
||||||
|
@ -76,6 +78,7 @@ const Application = (props: UptimeAppProps) => {
|
||||||
setBadge,
|
setBadge,
|
||||||
startPlugins,
|
startPlugins,
|
||||||
appMountParameters,
|
appMountParameters,
|
||||||
|
config,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -130,7 +133,7 @@ const Application = (props: UptimeAppProps) => {
|
||||||
>
|
>
|
||||||
<InspectorContextProvider>
|
<InspectorContextProvider>
|
||||||
<UptimeAlertsFlyoutWrapper />
|
<UptimeAlertsFlyoutWrapper />
|
||||||
<PageRouter />
|
<PageRouter config={config} />
|
||||||
<ActionMenu appMountParameters={appMountParameters} />
|
<ActionMenu appMountParameters={appMountParameters} />
|
||||||
</InspectorContextProvider>
|
</InspectorContextProvider>
|
||||||
</RedirectAppLinks>
|
</RedirectAppLinks>
|
||||||
|
|
|
@ -40,6 +40,7 @@ describe('ML Flyout component', () => {
|
||||||
isApmAvailable: true,
|
isApmAvailable: true,
|
||||||
isInfraAvailable: true,
|
isInfraAvailable: true,
|
||||||
isLogsAvailable: true,
|
isLogsAvailable: true,
|
||||||
|
config: {},
|
||||||
};
|
};
|
||||||
const { findByText, findAllByText } = render(
|
const { findByText, findAllByText } = render(
|
||||||
<UptimeSettingsContext.Provider value={value}>
|
<UptimeSettingsContext.Provider value={value}>
|
||||||
|
@ -66,6 +67,7 @@ describe('ML Flyout component', () => {
|
||||||
isApmAvailable: true,
|
isApmAvailable: true,
|
||||||
isInfraAvailable: true,
|
isInfraAvailable: true,
|
||||||
isLogsAvailable: true,
|
isLogsAvailable: true,
|
||||||
|
config: {},
|
||||||
};
|
};
|
||||||
const { queryByText } = render(
|
const { queryByText } = render(
|
||||||
<UptimeSettingsContext.Provider value={value}>
|
<UptimeSettingsContext.Provider value={value}>
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { UptimeAppProps } from '../apps/uptime_app';
|
||||||
import { CLIENT_DEFAULTS, CONTEXT_DEFAULTS } from '../../common/constants';
|
import { CLIENT_DEFAULTS, CONTEXT_DEFAULTS } from '../../common/constants';
|
||||||
import { CommonlyUsedRange } from '../components/common/uptime_date_picker';
|
import { CommonlyUsedRange } from '../components/common/uptime_date_picker';
|
||||||
import { useGetUrlParams } from '../hooks';
|
import { useGetUrlParams } from '../hooks';
|
||||||
|
import { UptimeUiConfig } from '../../common/config';
|
||||||
|
|
||||||
export interface UptimeSettingsContextValues {
|
export interface UptimeSettingsContextValues {
|
||||||
basePath: string;
|
basePath: string;
|
||||||
|
@ -18,6 +19,7 @@ export interface UptimeSettingsContextValues {
|
||||||
isApmAvailable: boolean;
|
isApmAvailable: boolean;
|
||||||
isInfraAvailable: boolean;
|
isInfraAvailable: boolean;
|
||||||
isLogsAvailable: boolean;
|
isLogsAvailable: boolean;
|
||||||
|
config: UptimeUiConfig;
|
||||||
commonlyUsedRanges?: CommonlyUsedRange[];
|
commonlyUsedRanges?: CommonlyUsedRange[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,11 +38,19 @@ const defaultContext: UptimeSettingsContextValues = {
|
||||||
isApmAvailable: true,
|
isApmAvailable: true,
|
||||||
isInfraAvailable: true,
|
isInfraAvailable: true,
|
||||||
isLogsAvailable: true,
|
isLogsAvailable: true,
|
||||||
|
config: {},
|
||||||
};
|
};
|
||||||
export const UptimeSettingsContext = createContext(defaultContext);
|
export const UptimeSettingsContext = createContext(defaultContext);
|
||||||
|
|
||||||
export const UptimeSettingsContextProvider: React.FC<UptimeAppProps> = ({ children, ...props }) => {
|
export const UptimeSettingsContextProvider: React.FC<UptimeAppProps> = ({ children, ...props }) => {
|
||||||
const { basePath, isApmAvailable, isInfraAvailable, isLogsAvailable, commonlyUsedRanges } = props;
|
const {
|
||||||
|
basePath,
|
||||||
|
isApmAvailable,
|
||||||
|
isInfraAvailable,
|
||||||
|
isLogsAvailable,
|
||||||
|
commonlyUsedRanges,
|
||||||
|
config,
|
||||||
|
} = props;
|
||||||
|
|
||||||
const { dateRangeStart, dateRangeEnd } = useGetUrlParams();
|
const { dateRangeStart, dateRangeEnd } = useGetUrlParams();
|
||||||
|
|
||||||
|
@ -51,6 +61,7 @@ export const UptimeSettingsContextProvider: React.FC<UptimeAppProps> = ({ childr
|
||||||
isInfraAvailable,
|
isInfraAvailable,
|
||||||
isLogsAvailable,
|
isLogsAvailable,
|
||||||
commonlyUsedRanges,
|
commonlyUsedRanges,
|
||||||
|
config,
|
||||||
dateRangeStart: dateRangeStart ?? DATE_RANGE_START,
|
dateRangeStart: dateRangeStart ?? DATE_RANGE_START,
|
||||||
dateRangeEnd: dateRangeEnd ?? DATE_RANGE_END,
|
dateRangeEnd: dateRangeEnd ?? DATE_RANGE_END,
|
||||||
};
|
};
|
||||||
|
@ -62,6 +73,7 @@ export const UptimeSettingsContextProvider: React.FC<UptimeAppProps> = ({ childr
|
||||||
dateRangeStart,
|
dateRangeStart,
|
||||||
dateRangeEnd,
|
dateRangeEnd,
|
||||||
commonlyUsedRanges,
|
commonlyUsedRanges,
|
||||||
|
config,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return <UptimeSettingsContext.Provider value={value} children={children} />;
|
return <UptimeSettingsContext.Provider value={value} children={children} />;
|
||||||
|
|
|
@ -14,6 +14,8 @@ export enum UptimePage {
|
||||||
Overview = 'Overview',
|
Overview = 'Overview',
|
||||||
MappingError = 'MappingError',
|
MappingError = 'MappingError',
|
||||||
Monitor = 'Monitor',
|
Monitor = 'Monitor',
|
||||||
|
MonitorAdd = 'AddMonitor',
|
||||||
|
MonitorEdit = 'EditMonitor',
|
||||||
Settings = 'Settings',
|
Settings = 'Settings',
|
||||||
Certificates = 'Certificates',
|
Certificates = 'Certificates',
|
||||||
StepDetail = 'StepDetail',
|
StepDetail = 'StepDetail',
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { Router } from 'react-router-dom';
|
||||||
import { createMemoryHistory, History } from 'history';
|
import { createMemoryHistory, History } from 'history';
|
||||||
import { CoreStart } from 'kibana/public';
|
import { CoreStart } from 'kibana/public';
|
||||||
import { I18nProvider } from '@kbn/i18n-react';
|
import { I18nProvider } from '@kbn/i18n-react';
|
||||||
|
import { EuiPageTemplate } from '@elastic/eui';
|
||||||
import { coreMock } from 'src/core/public/mocks';
|
import { coreMock } from 'src/core/public/mocks';
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
import { configure } from '@testing-library/dom';
|
import { configure } from '@testing-library/dom';
|
||||||
|
@ -113,6 +114,12 @@ const mockCore: () => Partial<CoreStart> = () => {
|
||||||
triggersActionsUi: triggersActionsUiMock.createStart(),
|
triggersActionsUi: triggersActionsUiMock.createStart(),
|
||||||
storage: createMockStore(),
|
storage: createMockStore(),
|
||||||
data: dataPluginMock.createStartContract(),
|
data: dataPluginMock.createStartContract(),
|
||||||
|
observability: {
|
||||||
|
navigation: {
|
||||||
|
// @ts-ignore
|
||||||
|
PageTemplate: EuiPageTemplate,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return core;
|
return core;
|
||||||
|
|
12
x-pack/plugins/uptime/public/pages/add_monitor.tsx
Normal file
12
x-pack/plugins/uptime/public/pages/add_monitor.tsx
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
/*
|
||||||
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||||
|
* 2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
export const AddMonitorPage: React.FC = () => {
|
||||||
|
return null;
|
||||||
|
};
|
12
x-pack/plugins/uptime/public/pages/edit_monitor.tsx
Normal file
12
x-pack/plugins/uptime/public/pages/edit_monitor.tsx
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
/*
|
||||||
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||||
|
* 2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
export const EditMonitorPage: React.FC = () => {
|
||||||
|
return null;
|
||||||
|
};
|
|
@ -10,3 +10,5 @@ export { MonitorPage } from './monitor';
|
||||||
export { StepDetailPage } from './synthetics/step_detail_page';
|
export { StepDetailPage } from './synthetics/step_detail_page';
|
||||||
export { SettingsPage } from './settings';
|
export { SettingsPage } from './settings';
|
||||||
export { NotFoundPage } from './not_found';
|
export { NotFoundPage } from './not_found';
|
||||||
|
export { AddMonitorPage } from './add_monitor';
|
||||||
|
export { EditMonitorPage } from './edit_monitor';
|
||||||
|
|
47
x-pack/plugins/uptime/public/routes.test.tsx
Normal file
47
x-pack/plugins/uptime/public/routes.test.tsx
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||||
|
* or more contributor license agreements. Licensed under the Elastic License
|
||||||
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||||
|
* 2.0.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// app.test.js
|
||||||
|
import { screen } from '@testing-library/react';
|
||||||
|
import { render } from './lib/helper/rtl_helpers';
|
||||||
|
import { createMemoryHistory } from 'history';
|
||||||
|
import React from 'react';
|
||||||
|
import * as telemetry from './hooks/use_telemetry';
|
||||||
|
import { MONITOR_ADD_ROUTE, MONITOR_EDIT_ROUTE } from '../common/constants';
|
||||||
|
|
||||||
|
import '@testing-library/jest-dom';
|
||||||
|
|
||||||
|
import { PageRouter } from './routes';
|
||||||
|
|
||||||
|
describe('PageRouter', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.spyOn(telemetry, 'useUptimeTelemetry').mockImplementation(() => {});
|
||||||
|
});
|
||||||
|
it.each([MONITOR_ADD_ROUTE, MONITOR_EDIT_ROUTE])(
|
||||||
|
'hides ui monitor management pages when feature flag is not enabled',
|
||||||
|
(page) => {
|
||||||
|
const history = createMemoryHistory();
|
||||||
|
history.push(page);
|
||||||
|
render(<PageRouter config={{}} />, { history });
|
||||||
|
|
||||||
|
expect(screen.getByText(/Page not found/i)).toBeInTheDocument();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[MONITOR_ADD_ROUTE, 'Add Monitor'],
|
||||||
|
[MONITOR_EDIT_ROUTE, 'Edit Monitor'],
|
||||||
|
])('hides ui monitor management pages when feature flag is not enabled', (page, heading) => {
|
||||||
|
const history = createMemoryHistory();
|
||||||
|
history.push(page);
|
||||||
|
render(<PageRouter config={{ ui: { unsafe: { monitorManagement: { enabled: true } } } }} />, {
|
||||||
|
history,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(screen.getByText(heading)).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
|
@ -13,12 +13,22 @@ import {
|
||||||
CERTIFICATES_ROUTE,
|
CERTIFICATES_ROUTE,
|
||||||
MAPPING_ERROR_ROUTE,
|
MAPPING_ERROR_ROUTE,
|
||||||
MONITOR_ROUTE,
|
MONITOR_ROUTE,
|
||||||
|
MONITOR_ADD_ROUTE,
|
||||||
|
MONITOR_EDIT_ROUTE,
|
||||||
OVERVIEW_ROUTE,
|
OVERVIEW_ROUTE,
|
||||||
SETTINGS_ROUTE,
|
SETTINGS_ROUTE,
|
||||||
STEP_DETAIL_ROUTE,
|
STEP_DETAIL_ROUTE,
|
||||||
SYNTHETIC_CHECK_STEPS_ROUTE,
|
SYNTHETIC_CHECK_STEPS_ROUTE,
|
||||||
} from '../common/constants';
|
} from '../common/constants';
|
||||||
import { MappingErrorPage, MonitorPage, StepDetailPage, NotFoundPage, SettingsPage } from './pages';
|
import {
|
||||||
|
MappingErrorPage,
|
||||||
|
MonitorPage,
|
||||||
|
AddMonitorPage,
|
||||||
|
EditMonitorPage,
|
||||||
|
StepDetailPage,
|
||||||
|
NotFoundPage,
|
||||||
|
SettingsPage,
|
||||||
|
} from './pages';
|
||||||
import { CertificatesPage } from './pages/certificates';
|
import { CertificatesPage } from './pages/certificates';
|
||||||
import { UptimePage, useUptimeTelemetry } from './hooks';
|
import { UptimePage, useUptimeTelemetry } from './hooks';
|
||||||
import { OverviewPageComponent } from './pages/overview';
|
import { OverviewPageComponent } from './pages/overview';
|
||||||
|
@ -41,6 +51,11 @@ import {
|
||||||
import { UptimePageTemplateComponent } from './apps/uptime_page_template';
|
import { UptimePageTemplateComponent } from './apps/uptime_page_template';
|
||||||
import { apiService } from './state/api/utils';
|
import { apiService } from './state/api/utils';
|
||||||
import { useInspectorContext } from '../../observability/public';
|
import { useInspectorContext } from '../../observability/public';
|
||||||
|
import { UptimeConfig } from '../common/config';
|
||||||
|
|
||||||
|
interface PageRouterProps {
|
||||||
|
config: UptimeConfig;
|
||||||
|
}
|
||||||
|
|
||||||
interface RouteProps {
|
interface RouteProps {
|
||||||
path: string;
|
path: string;
|
||||||
|
@ -63,109 +78,151 @@ export const MONITORING_OVERVIEW_LABEL = i18n.translate('xpack.uptime.overview.h
|
||||||
defaultMessage: 'Monitors',
|
defaultMessage: 'Monitors',
|
||||||
});
|
});
|
||||||
|
|
||||||
const Routes: RouteProps[] = [
|
const getRoutes = (config: UptimeConfig): RouteProps[] => {
|
||||||
{
|
return [
|
||||||
title: i18n.translate('xpack.uptime.monitorRoute.title', {
|
{
|
||||||
defaultMessage: 'Monitor | {baseTitle}',
|
title: i18n.translate('xpack.uptime.monitorRoute.title', {
|
||||||
values: { baseTitle },
|
defaultMessage: 'Monitor | {baseTitle}',
|
||||||
}),
|
values: { baseTitle },
|
||||||
path: MONITOR_ROUTE,
|
}),
|
||||||
component: MonitorPage,
|
path: MONITOR_ROUTE,
|
||||||
dataTestSubj: 'uptimeMonitorPage',
|
component: MonitorPage,
|
||||||
telemetryId: UptimePage.Monitor,
|
dataTestSubj: 'uptimeMonitorPage',
|
||||||
pageHeader: {
|
telemetryId: UptimePage.Monitor,
|
||||||
children: <MonitorPageTitleContent />,
|
pageHeader: {
|
||||||
pageTitle: <MonitorPageTitle />,
|
children: <MonitorPageTitleContent />,
|
||||||
rightSideItems: [<UptimeDatePicker />],
|
pageTitle: <MonitorPageTitle />,
|
||||||
|
rightSideItems: [<UptimeDatePicker />],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
title: i18n.translate('xpack.uptime.settingsRoute.title', {
|
||||||
title: i18n.translate('xpack.uptime.settingsRoute.title', {
|
defaultMessage: `Settings | {baseTitle}`,
|
||||||
defaultMessage: `Settings | {baseTitle}`,
|
values: { baseTitle },
|
||||||
values: { baseTitle },
|
}),
|
||||||
}),
|
path: SETTINGS_ROUTE,
|
||||||
path: SETTINGS_ROUTE,
|
component: SettingsPage,
|
||||||
component: SettingsPage,
|
dataTestSubj: 'uptimeSettingsPage',
|
||||||
dataTestSubj: 'uptimeSettingsPage',
|
telemetryId: UptimePage.Settings,
|
||||||
telemetryId: UptimePage.Settings,
|
pageHeader: {
|
||||||
pageHeader: {
|
pageTitle: (
|
||||||
pageTitle: (
|
<FormattedMessage id="xpack.uptime.settings.heading" defaultMessage="Uptime settings" />
|
||||||
<FormattedMessage id="xpack.uptime.settings.heading" defaultMessage="Uptime settings" />
|
),
|
||||||
),
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
title: i18n.translate('xpack.uptime.certificatesRoute.title', {
|
||||||
title: i18n.translate('xpack.uptime.certificatesRoute.title', {
|
defaultMessage: `Certificates | {baseTitle}`,
|
||||||
defaultMessage: `Certificates | {baseTitle}`,
|
values: { baseTitle },
|
||||||
values: { baseTitle },
|
}),
|
||||||
}),
|
path: CERTIFICATES_ROUTE,
|
||||||
path: CERTIFICATES_ROUTE,
|
component: CertificatesPage,
|
||||||
component: CertificatesPage,
|
dataTestSubj: 'uptimeCertificatesPage',
|
||||||
dataTestSubj: 'uptimeCertificatesPage',
|
telemetryId: UptimePage.Certificates,
|
||||||
telemetryId: UptimePage.Certificates,
|
pageHeader: {
|
||||||
pageHeader: {
|
pageTitle: <CertificateTitle />,
|
||||||
pageTitle: <CertificateTitle />,
|
rightSideItems: [<CertRefreshBtn />],
|
||||||
rightSideItems: [<CertRefreshBtn />],
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
title: i18n.translate('xpack.uptime.stepDetailRoute.title', {
|
||||||
title: i18n.translate('xpack.uptime.stepDetailRoute.title', {
|
defaultMessage: 'Synthetics detail | {baseTitle}',
|
||||||
defaultMessage: 'Synthetics detail | {baseTitle}',
|
values: { baseTitle },
|
||||||
values: { baseTitle },
|
}),
|
||||||
}),
|
path: STEP_DETAIL_ROUTE,
|
||||||
path: STEP_DETAIL_ROUTE,
|
component: StepDetailPage,
|
||||||
component: StepDetailPage,
|
dataTestSubj: 'uptimeStepDetailPage',
|
||||||
dataTestSubj: 'uptimeStepDetailPage',
|
telemetryId: UptimePage.StepDetail,
|
||||||
telemetryId: UptimePage.StepDetail,
|
pageHeader: {
|
||||||
pageHeader: {
|
children: <StepDetailPageChildren />,
|
||||||
children: <StepDetailPageChildren />,
|
pageTitle: <StepDetailPageHeader />,
|
||||||
pageTitle: <StepDetailPageHeader />,
|
rightSideItems: [<StepDetailPageRightSideItem />],
|
||||||
rightSideItems: [<StepDetailPageRightSideItem />],
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
title: baseTitle,
|
||||||
title: baseTitle,
|
path: SYNTHETIC_CHECK_STEPS_ROUTE,
|
||||||
path: SYNTHETIC_CHECK_STEPS_ROUTE,
|
component: SyntheticsCheckSteps,
|
||||||
component: SyntheticsCheckSteps,
|
dataTestSubj: 'uptimeSyntheticCheckStepsPage',
|
||||||
dataTestSubj: 'uptimeSyntheticCheckStepsPage',
|
telemetryId: UptimePage.SyntheticCheckStepsPage,
|
||||||
telemetryId: UptimePage.SyntheticCheckStepsPage,
|
pageHeader: {
|
||||||
pageHeader: {
|
pageTitle: <SyntheticsCheckStepsPageHeader />,
|
||||||
pageTitle: <SyntheticsCheckStepsPageHeader />,
|
rightSideItems: [<SyntheticsCheckStepsPageRightSideItem />],
|
||||||
rightSideItems: [<SyntheticsCheckStepsPageRightSideItem />],
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
title: baseTitle,
|
||||||
title: baseTitle,
|
path: OVERVIEW_ROUTE,
|
||||||
path: OVERVIEW_ROUTE,
|
component: OverviewPageComponent,
|
||||||
component: OverviewPageComponent,
|
dataTestSubj: 'uptimeOverviewPage',
|
||||||
dataTestSubj: 'uptimeOverviewPage',
|
telemetryId: UptimePage.Overview,
|
||||||
telemetryId: UptimePage.Overview,
|
pageHeader: {
|
||||||
pageHeader: {
|
pageTitle: MONITORING_OVERVIEW_LABEL,
|
||||||
pageTitle: MONITORING_OVERVIEW_LABEL,
|
rightSideItems: [<UptimeDatePicker />],
|
||||||
rightSideItems: [<UptimeDatePicker />],
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
title: i18n.translate('xpack.uptime.mappingErrorRoute.title', {
|
||||||
title: i18n.translate('xpack.uptime.mappingErrorRoute.title', {
|
defaultMessage: 'Synthetics | mapping error',
|
||||||
defaultMessage: 'Synthetics | mapping error',
|
}),
|
||||||
}),
|
path: MAPPING_ERROR_ROUTE,
|
||||||
path: MAPPING_ERROR_ROUTE,
|
component: MappingErrorPage,
|
||||||
component: MappingErrorPage,
|
dataTestSubj: 'uptimeMappingErrorPage',
|
||||||
dataTestSubj: 'uptimeMappingErrorPage',
|
telemetryId: UptimePage.MappingError,
|
||||||
telemetryId: UptimePage.MappingError,
|
pageHeader: {
|
||||||
pageHeader: {
|
pageTitle: (
|
||||||
pageTitle: (
|
<div>
|
||||||
<div>
|
<FormattedMessage
|
||||||
<FormattedMessage
|
id="xpack.uptime.mappingErrorRoute.pageHeader.title"
|
||||||
id="xpack.uptime.mappingErrorRoute.pageHeader.title"
|
defaultMessage="Mapping error"
|
||||||
defaultMessage="Mapping error"
|
/>
|
||||||
/>
|
</div>
|
||||||
</div>
|
),
|
||||||
),
|
rightSideItems: [],
|
||||||
rightSideItems: [],
|
},
|
||||||
},
|
},
|
||||||
},
|
...(config.ui?.unsafe?.monitorManagement?.enabled
|
||||||
];
|
? [
|
||||||
|
{
|
||||||
|
title: i18n.translate('xpack.uptime.addMonitorRoute.title', {
|
||||||
|
defaultMessage: 'Add Monitor | {baseTitle}',
|
||||||
|
values: { baseTitle },
|
||||||
|
}),
|
||||||
|
path: MONITOR_ADD_ROUTE,
|
||||||
|
component: AddMonitorPage,
|
||||||
|
dataTestSubj: 'uptimeMonitorAddPage',
|
||||||
|
telemetryId: UptimePage.MonitorAdd,
|
||||||
|
pageHeader: {
|
||||||
|
pageTitle: (
|
||||||
|
<FormattedMessage
|
||||||
|
id="xpack.uptime.addMonitor.pageHeader.title"
|
||||||
|
defaultMessage="Add Monitor"
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: i18n.translate('xpack.uptime.editMonitorRoute.title', {
|
||||||
|
defaultMessage: 'Edit Monitor | {baseTitle}',
|
||||||
|
values: { baseTitle },
|
||||||
|
}),
|
||||||
|
path: MONITOR_EDIT_ROUTE,
|
||||||
|
component: EditMonitorPage,
|
||||||
|
dataTestSubj: 'uptimeMonitorEditPage',
|
||||||
|
telemetryId: UptimePage.MonitorEdit,
|
||||||
|
pageHeader: {
|
||||||
|
pageTitle: (
|
||||||
|
<FormattedMessage
|
||||||
|
id="xpack.uptime.editMonitor.pageHeader.title"
|
||||||
|
defaultMessage="Edit Monitor"
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
const RouteInit: React.FC<Pick<RouteProps, 'path' | 'title' | 'telemetryId'>> = ({
|
const RouteInit: React.FC<Pick<RouteProps, 'path' | 'title' | 'telemetryId'>> = ({
|
||||||
path,
|
path,
|
||||||
|
@ -179,14 +236,15 @@ const RouteInit: React.FC<Pick<RouteProps, 'path' | 'title' | 'telemetryId'>> =
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PageRouter: FC = () => {
|
export const PageRouter: FC<PageRouterProps> = ({ config = {} }) => {
|
||||||
|
const routes = getRoutes(config);
|
||||||
const { addInspectorRequest } = useInspectorContext();
|
const { addInspectorRequest } = useInspectorContext();
|
||||||
|
|
||||||
apiService.addInspectorRequest = addInspectorRequest;
|
apiService.addInspectorRequest = addInspectorRequest;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Switch>
|
<Switch>
|
||||||
{Routes.map(
|
{routes.map(
|
||||||
({ title, path, component: RouteComponent, dataTestSubj, telemetryId, pageHeader }) => (
|
({ title, path, component: RouteComponent, dataTestSubj, telemetryId, pageHeader }) => (
|
||||||
<Route path={path} key={telemetryId} exact={true}>
|
<Route path={path} key={telemetryId} exact={true}>
|
||||||
<div className={APP_WRAPPER_CLASS} data-test-subj={dataTestSubj}>
|
<div className={APP_WRAPPER_CLASS} data-test-subj={dataTestSubj}>
|
||||||
|
|
|
@ -11,4 +11,4 @@ import { Plugin } from './plugin';
|
||||||
export const plugin = (initializerContext: PluginInitializerContext) =>
|
export const plugin = (initializerContext: PluginInitializerContext) =>
|
||||||
new Plugin(initializerContext);
|
new Plugin(initializerContext);
|
||||||
|
|
||||||
export { config } from './config';
|
export { config } from '../common/config';
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { MlPluginSetup as MlSetup } from '../../../../../ml/server';
|
||||||
import { RuleRegistryPluginSetupContract } from '../../../../../rule_registry/server';
|
import { RuleRegistryPluginSetupContract } from '../../../../../rule_registry/server';
|
||||||
import { UptimeESClient } from '../../lib';
|
import { UptimeESClient } from '../../lib';
|
||||||
import type { UptimeRouter } from '../../../types';
|
import type { UptimeRouter } from '../../../types';
|
||||||
import { UptimeConfig } from '../../../config';
|
import { UptimeConfig } from '../../../../common/config';
|
||||||
|
|
||||||
export type UMElasticsearchQueryFn<P, R = any> = (
|
export type UMElasticsearchQueryFn<P, R = any> = (
|
||||||
params: {
|
params: {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
import { DYNAMIC_SETTINGS_DEFAULTS } from '../../../common/constants';
|
import { DYNAMIC_SETTINGS_DEFAULTS } from '../../../common/constants';
|
||||||
import { DynamicSettings } from '../../../common/runtime_types';
|
import { DynamicSettings } from '../../../common/runtime_types';
|
||||||
import { UMSavedObjectsQueryFn } from '../adapters';
|
import { UMSavedObjectsQueryFn } from '../adapters';
|
||||||
import { UptimeConfig } from '../../config';
|
import { UptimeConfig } from '../../../common/config';
|
||||||
import { settingsObjectId, umDynamicSettings } from './uptime_settings';
|
import { settingsObjectId, umDynamicSettings } from './uptime_settings';
|
||||||
import { syntheticsMonitor } from './synthetics_monitor';
|
import { syntheticsMonitor } from './synthetics_monitor';
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import { KibanaTelemetryAdapter, UptimeCorePlugins } from './lib/adapters';
|
||||||
import { registerUptimeSavedObjects, savedObjectsAdapter } from './lib/saved_objects/saved_objects';
|
import { registerUptimeSavedObjects, savedObjectsAdapter } from './lib/saved_objects/saved_objects';
|
||||||
import { mappingFromFieldMap } from '../../rule_registry/common/mapping_from_field_map';
|
import { mappingFromFieldMap } from '../../rule_registry/common/mapping_from_field_map';
|
||||||
import { Dataset } from '../../rule_registry/server';
|
import { Dataset } from '../../rule_registry/server';
|
||||||
import { UptimeConfig } from './config';
|
import { UptimeConfig } from '../common/config';
|
||||||
|
|
||||||
export type UptimeRuleRegistry = ReturnType<Plugin['setup']>['ruleRegistry'];
|
export type UptimeRuleRegistry = ReturnType<Plugin['setup']>['ruleRegistry'];
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ export class Plugin implements PluginType {
|
||||||
private initContext: PluginInitializerContext;
|
private initContext: PluginInitializerContext;
|
||||||
private logger?: Logger;
|
private logger?: Logger;
|
||||||
|
|
||||||
constructor(_initializerContext: PluginInitializerContext) {
|
constructor(_initializerContext: PluginInitializerContext<UptimeConfig>) {
|
||||||
this.initContext = _initializerContext;
|
this.initContext = _initializerContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue