Skip to content

Commit

Permalink
Merge branch 'master' into apm-66867-fix-enable-watcher-error-reports…
Browse files Browse the repository at this point in the history
…-missing-params
  • Loading branch information
elasticmachine authored Jun 8, 2020
2 parents 58d6cab + 07e3c9c commit 807f989
Show file tree
Hide file tree
Showing 31 changed files with 508 additions and 94 deletions.
6 changes: 3 additions & 3 deletions src/core/server/plugins/plugin_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { map } from 'rxjs/operators';
import { map, shareReplay } from 'rxjs/operators';
import { combineLatest } from 'rxjs';
import { CoreContext } from '../core_context';
import { PluginWrapper } from './plugin';
Expand Down Expand Up @@ -107,8 +107,8 @@ export function createPluginInitializerContext(
* @param ConfigClass A class (not an instance of a class) that contains a
* static `schema` that we validate the config at the given `path` against.
*/
create() {
return coreContext.configService.atPath(pluginManifest.configPath);
create<T>() {
return coreContext.configService.atPath<T>(pluginManifest.configPath).pipe(shareReplay(1));
},
createIfExists() {
return coreContext.configService.optionalAtPath(pluginManifest.configPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class KibanaMigrator {
private readonly status$ = new BehaviorSubject<KibanaMigratorStatus>({
status: 'waiting',
});
private readonly activeMappings: IndexMapping;

/**
* Creates an instance of KibanaMigrator.
Expand All @@ -100,6 +101,9 @@ export class KibanaMigrator {
validateDoc: docValidator(savedObjectValidations || {}),
log: this.log,
});
// Building the active mappings (and associated md5sums) is an expensive
// operation so we cache the result
this.activeMappings = buildActiveMappings(this.mappingProperties);
}

/**
Expand Down Expand Up @@ -172,7 +176,7 @@ export class KibanaMigrator {
*
*/
public getActiveMappings(): IndexMapping {
return buildActiveMappings(this.mappingProperties);
return this.activeMappings;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class SavedObjectsRepository {
injectedConstructor: any = SavedObjectsRepository
): ISavedObjectsRepository {
const mappings = migrator.getActiveMappings();
const allTypes = Object.keys(getRootPropertiesObjects(mappings));
const allTypes = typeRegistry.getAllTypes().map((t) => t.name);
const serializer = new SavedObjectsSerializer(typeRegistry);
const visibleTypes = allTypes.filter((type) => !typeRegistry.isHidden(type));

Expand Down
3 changes: 1 addition & 2 deletions src/legacy/server/saved_objects/saved_objects_mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ import {
importSavedObjectsFromStream,
resolveSavedObjectsImportErrors,
} from '../../../core/server/saved_objects';
import { getRootPropertiesObjects } from '../../../core/server/saved_objects/mappings';
import { convertTypesToLegacySchema } from '../../../core/server/saved_objects/utils';

export function savedObjectsMixin(kbnServer, server) {
const migrator = kbnServer.newPlatform.__internals.kibanaMigrator;
const typeRegistry = kbnServer.newPlatform.start.core.savedObjects.getTypeRegistry();
const mappings = migrator.getActiveMappings();
const allTypes = Object.keys(getRootPropertiesObjects(mappings));
const allTypes = typeRegistry.getAllTypes().map((t) => t.name);
const schema = new SavedObjectsSchema(convertTypesToLegacySchema(typeRegistry.getAllTypes()));
const visibleTypes = allTypes.filter((type) => !schema.isHiddenType(type));

Expand Down
3 changes: 2 additions & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"xpack.triggersActionsUI": "plugins/triggers_actions_ui",
"xpack.upgradeAssistant": "plugins/upgrade_assistant",
"xpack.uptime": ["plugins/uptime"],
"xpack.watcher": "plugins/watcher"
"xpack.watcher": "plugins/watcher",
"xpack.observability": "plugins/observability"
},
"translations": [
"plugins/translations/translations/zh-CN.json",
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
core.application.register({
id: 'apm',
title: 'APM',
order: 8100,
order: 8300,
euiIconType: 'apmApp',
appRoute: '/app/apm',
icon: 'plugins/apm/public/icon.svg',
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/infra/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class Plugin
defaultMessage: 'Logs',
}),
euiIconType: 'logsApp',
order: 8000,
order: 8100,
appRoute: '/app/logs',
category: DEFAULT_APP_CATEGORIES.observability,
mount: async (params: AppMountParameters) => {
Expand All @@ -89,7 +89,7 @@ export class Plugin
defaultMessage: 'Metrics',
}),
euiIconType: 'metricsApp',
order: 8001,
order: 8200,
appRoute: '/app/metrics',
category: DEFAULT_APP_CATEGORIES.observability,
mount: async (params: AppMountParameters) => {
Expand Down
29 changes: 29 additions & 0 deletions x-pack/plugins/observability/public/application/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import ReactDOM from 'react-dom';
import { EuiThemeProvider } from '../../../../legacy/common/eui_styled_components';
import { AppMountParameters, CoreStart } from '../../../../../src/core/public';
import { Home } from '../pages/home';
import { PluginContext } from '../context/plugin_context';

export const renderApp = (core: CoreStart, { element }: AppMountParameters) => {
const i18nCore = core.i18n;
const isDarkMode = core.uiSettings.get('theme:darkMode');
ReactDOM.render(
<PluginContext.Provider value={{ core }}>
<EuiThemeProvider darkMode={isDarkMode}>
<i18nCore.Context>
<Home />
</i18nCore.Context>
</EuiThemeProvider>
</PluginContext.Provider>,
element
);
return () => {
ReactDOM.unmountComponentAtNode(element);
};
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions x-pack/plugins/observability/public/context/plugin_context.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { createContext } from 'react';
import { AppMountContext } from 'kibana/public';

export interface PluginContextValue {
core: AppMountContext['core'];
}

export const PluginContext = createContext({} as PluginContextValue);
12 changes: 12 additions & 0 deletions x-pack/plugins/observability/public/hooks/use_plugin_context.tsx
Original file line number Diff line number Diff line change
@@ -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;
* you may not use this file except in compliance with the Elastic License.
*/

import { useContext } from 'react';
import { PluginContext } from '../context/plugin_context';

export function usePluginContext() {
return useContext(PluginContext);
}
205 changes: 205 additions & 0 deletions x-pack/plugins/observability/public/pages/home/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import {
EuiButton,
EuiCard,
EuiFlexGrid,
EuiFlexGroup,
EuiFlexItem,
EuiHorizontalRule,
EuiIcon,
EuiImage,
EuiSpacer,
EuiText,
EuiTitle,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useEffect } from 'react';
import styled from 'styled-components';
import { usePluginContext } from '../../hooks/use_plugin_context';
import { appsSection, tryItOutItemsSection } from './section';

const Container = styled.div`
min-height: calc(100vh - 48px);
background: ${(props) => props.theme.eui.euiColorEmptyShade};
`;

const Title = styled.div`
background-color: ${(props) => props.theme.eui.euiPageBackgroundColor};
border-bottom: ${(props) => props.theme.eui.euiBorderThin};
`;

const Page = styled.div`
width: 100%;
max-width: 1200px;
margin: 0 auto;
overflow: hidden;
}
`;

const EuiCardWithoutPadding = styled(EuiCard)`
padding: 0;
`;

export const Home = () => {
const { core } = usePluginContext();

useEffect(() => {
core.chrome.setBreadcrumbs([
{
text: i18n.translate('xpack.observability.home.breadcrumb.observability', {
defaultMessage: 'Observability',
}),
},
{
text: i18n.translate('xpack.observability.home.breadcrumb.gettingStarted', {
defaultMessage: 'Getting started',
}),
},
]);
}, [core]);

return (
<Container>
<Title>
<Page>
<EuiSpacer size="xxl" />
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiIcon type="logoObservability" size="xxl" />
</EuiFlexItem>
<EuiFlexItem>
<EuiTitle size="m">
<h1>
{i18n.translate('xpack.observability.home.title', {
defaultMessage: 'Observability',
})}
</h1>
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="xxl" />
</Page>
</Title>
<Page>
<EuiSpacer size="xxl" />
<EuiFlexGroup direction="column">
{/* title and description */}
<EuiFlexItem style={{ maxWidth: '50%' }}>
<EuiTitle size="s">
<h2>
{i18n.translate('xpack.observability.home.sectionTitle', {
defaultMessage: 'Observability built on the Elastic Stack',
})}
</h2>
</EuiTitle>
<EuiSpacer size="m" />
<EuiText size="s" color="subdued">
{i18n.translate('xpack.observability.home.sectionsubtitle', {
defaultMessage:
'Bring your logs, metrics, and APM traces together at scale in a single stack so you can monitor and react to events happening anywhere in your environment.',
})}
</EuiText>
</EuiFlexItem>

{/* Apps sections */}
<EuiFlexItem>
<EuiSpacer size="s" />
<EuiFlexGroup>
<EuiFlexItem>
<EuiFlexGrid columns={2}>
{appsSection.map((app) => (
<EuiFlexItem>
<EuiCardWithoutPadding
display="plain"
layout="horizontal"
icon={<EuiIcon size="l" type={app.icon} />}
title={
<EuiTitle size="xs" className="title">
<h3>{app.title}</h3>
</EuiTitle>
}
description={app.description}
/>
</EuiFlexItem>
))}
</EuiFlexGrid>
</EuiFlexItem>
<EuiFlexItem>
<EuiImage
size="xl"
alt="observability overview image"
url={core.http.basePath.prepend(
'/plugins/observability/assets/observability_overview.png'
)}
/>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>

{/* Get started button */}
<EuiFlexItem>
<EuiFlexGroup justifyContent="center" gutterSize="none">
<EuiFlexItem grow={false}>
<EuiButton
fill
iconType="sortRight"
iconSide="right"
href={core.http.basePath.prepend('/app/home#/tutorial_directory/logging')}
>
{i18n.translate('xpack.observability.home.getStatedButton', {
defaultMessage: 'Get started',
})}
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>

<EuiHorizontalRule margin="xl" />

{/* Try it out */}
<EuiFlexItem>
<EuiFlexGroup justifyContent="center">
<EuiFlexItem grow={false}>
<EuiTitle size="s">
<h3>
{i18n.translate('xpack.observability.home.tryItOut', {
defaultMessage: 'Try it out',
})}
</h3>
</EuiTitle>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>

{/* Try it out sections */}
<EuiFlexItem>
<EuiFlexGroup justifyContent="center">
{tryItOutItemsSection.map((item) => (
<EuiFlexItem grow={false} key={item.id} style={{ width: '260px' }}>
<EuiCard
layout="horizontal"
icon={<EuiIcon size="l" type={item.icon} />}
title={
<EuiTitle size="xs" className="title">
<h3>{item.title}</h3>
</EuiTitle>
}
description={item.description}
target={item.target}
href={item.href}
/>
</EuiFlexItem>
))}
</EuiFlexGroup>
<EuiSpacer />
</EuiFlexItem>
</EuiFlexGroup>
</Page>
</Container>
);
};
Loading

0 comments on commit 807f989

Please sign in to comment.