Skip to content

Commit

Permalink
Merge branch 'master' into saved-objects/scoped-client-with-extra-types
Browse files Browse the repository at this point in the history
* master:
  [ML] fix url assertion (elastic#66850)
  Skip failing lens test(s). elastic#66779
  [SOM] Preserve saved object references when saving the object (elastic#66584)
  Use ES API from start contract (elastic#66157)
  Reorganize Management apps into Ingest, Data, Alerts and Insights, Security, Kibana, and Stack groups (elastic#65796)
  [Uptime] Fix flaky navigation to certs page in tests (elastic#66806)
  [Maps] Do not check count for blended layers when layer is not visible (elastic#66460)
  [SIEM] Fixes glob patterns from directory changes recently for GraphQL
  chore(NA): bump static-fs to 1.0.2 (elastic#66775)
  [Maps] Handle cross cluster index _settings resp (elastic#66797)
  [SIEM][Lists] Adds 90% of the REST API and client API for exception lists and exception items
  allow any type for customResponseHeaders config (elastic#66689)
  [APM] Disable map layout animation (elastic#66763)
  [ML] Add linking to dataframe from job management tab (elastic#65778)
  • Loading branch information
gmmorris committed May 18, 2020
2 parents 278b375 + a997d1f commit 5ac7e88
Show file tree
Hide file tree
Showing 272 changed files with 5,258 additions and 1,280 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
"@elastic/eslint-plugin-eui": "0.0.2",
"@elastic/github-checks-reporter": "0.0.20b3",
"@elastic/makelogs": "^5.0.1",
"@elastic/static-fs": "1.0.1",
"@elastic/static-fs": "1.0.2",
"@kbn/dev-utils": "1.0.0",
"@kbn/es": "1.0.0",
"@kbn/eslint-import-resolver-kibana": "2.0.0",
Expand Down
1 change: 1 addition & 0 deletions src/core/server/http/cookie_session_storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ configService.atPath.mockReturnValue(
disableProtection: true,
whitelist: [],
},
customResponseHeaders: {},
} as any)
);

Expand Down
47 changes: 46 additions & 1 deletion src/core/server/http/http_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/

import uuid from 'uuid';
import { config } from '.';
import { config, HttpConfig } from './http_config';
import { CspConfig } from '../csp';

const validHostnames = ['www.example.com', '8.8.8.8', '::1', 'localhost'];
const invalidHostname = 'asdf$%^';
Expand Down Expand Up @@ -107,6 +108,23 @@ test('throws if xsrf.whitelist element does not start with a slash', () => {
);
});

test('accepts any type of objects for custom headers', () => {
const httpSchema = config.schema;
const obj = {
customResponseHeaders: {
string: 'string',
bool: true,
number: 12,
array: [1, 2, 3],
nested: {
foo: 1,
bar: 'dolly',
},
},
};
expect(() => httpSchema.validate(obj)).not.toThrow();
});

describe('with TLS', () => {
test('throws if TLS is enabled but `redirectHttpFromPort` is equal to `port`', () => {
const httpSchema = config.schema;
Expand Down Expand Up @@ -173,3 +191,30 @@ describe('with compression', () => {
expect(() => httpSchema.validate(obj)).toThrowErrorMatchingSnapshot();
});
});

describe('HttpConfig', () => {
it('converts customResponseHeaders to strings or arrays of strings', () => {
const httpSchema = config.schema;
const rawConfig = httpSchema.validate({
customResponseHeaders: {
string: 'string',
bool: true,
number: 12,
array: [1, 2, 3],
nested: {
foo: 1,
bar: 'dolly',
},
},
});
const httpConfig = new HttpConfig(rawConfig, CspConfig.DEFAULT);

expect(httpConfig.customResponseHeaders).toEqual({
string: 'string',
bool: 'true',
number: '12',
array: ['1', '2', '3'],
nested: '{"foo":1,"bar":"dolly"}',
});
});
});
18 changes: 15 additions & 3 deletions src/core/server/http/http_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const config = {
),
schema.boolean({ defaultValue: false })
),
customResponseHeaders: schema.recordOf(schema.string(), schema.string(), {
customResponseHeaders: schema.recordOf(schema.string(), schema.any(), {
defaultValue: {},
}),
host: schema.string({
Expand Down Expand Up @@ -136,7 +136,7 @@ export class HttpConfig {
public socketTimeout: number;
public port: number;
public cors: boolean | { origin: string[] };
public customResponseHeaders: Record<string, string>;
public customResponseHeaders: Record<string, string | string[]>;
public maxPayload: ByteSizeValue;
public basePath?: string;
public rewriteBasePath: boolean;
Expand All @@ -153,7 +153,15 @@ export class HttpConfig {
this.host = rawHttpConfig.host;
this.port = rawHttpConfig.port;
this.cors = rawHttpConfig.cors;
this.customResponseHeaders = rawHttpConfig.customResponseHeaders;
this.customResponseHeaders = Object.entries(rawHttpConfig.customResponseHeaders ?? {}).reduce(
(headers, [key, value]) => {
return {
...headers,
[key]: Array.isArray(value) ? value.map(e => convertHeader(e)) : convertHeader(value),
};
},
{}
);
this.maxPayload = rawHttpConfig.maxPayload;
this.name = rawHttpConfig.name;
this.basePath = rawHttpConfig.basePath;
Expand All @@ -166,3 +174,7 @@ export class HttpConfig {
this.xsrf = rawHttpConfig.xsrf;
}
}

const convertHeader = (entry: any): string => {
return typeof entry === 'object' ? JSON.stringify(entry) : String(entry);
};
1 change: 1 addition & 0 deletions src/core/server/http/test_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ configService.atPath.mockReturnValue(
disableProtection: true,
whitelist: [],
},
customResponseHeaders: {},
} as any)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { management } from 'ui/management';
import { ManagementSectionId } from '../../../../../../../plugins/management/public';
import './create_index_pattern_wizard';
import './edit_index_pattern';
import uiRoutes from 'ui/routes';
Expand Down Expand Up @@ -163,7 +164,7 @@ uiModules
};
});

management.getSection('kibana').register('index_patterns', {
management.getSection(ManagementSectionId.Kibana).register('index_patterns', {
display: i18n.translate('kbn.management.indexPattern.sectionsHeader', {
defaultMessage: 'Index Patterns',
}),
Expand Down
9 changes: 3 additions & 6 deletions src/plugins/advanced_settings/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import { i18n } from '@kbn/i18n';
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { ManagementApp } from '../../management/public';
import { ManagementApp, ManagementSectionId } from '../../management/public';
import { ComponentRegistry } from './component_registry';
import { AdvancedSettingsSetup, AdvancedSettingsStart, AdvancedSettingsPluginSetup } from './types';

Expand All @@ -32,15 +32,12 @@ export class AdvancedSettingsPlugin
implements Plugin<AdvancedSettingsSetup, AdvancedSettingsStart, AdvancedSettingsPluginSetup> {
private managementApp?: ManagementApp;
public setup(core: CoreSetup, { management }: AdvancedSettingsPluginSetup) {
const kibanaSection = management.sections.getSection('kibana');
if (!kibanaSection) {
throw new Error('`kibana` management section not found.');
}
const kibanaSection = management.sections.getSection(ManagementSectionId.Kibana);

this.managementApp = kibanaSection.registerApp({
id: 'settings',
title,
order: 20,
order: 3,
async mount(params) {
const { mountManagementSection } = await import(
'./management_app/mount_management_section'
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/data/public/search/long_query_notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ export function LongQueryNotification(props: Props) {
<EuiButton
size="s"
onClick={async () => {
await props.application.navigateToApp(
'kibana#/management/elasticsearch/license_management'
);
await props.application.navigateToApp('kibana#/management/stack/license_management');
}}
>
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.mgtSideBarNav {
width: 192px;
width: 210px;
}

@include euiBreakpoint('xs','s') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import {
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import React from 'react';
import React, { ReactElement } from 'react';
import { LegacySection, LegacyApp } from '../../types';
import { ManagementApp } from '../../management_app';
import { ManagementSection } from '../../management_section';

interface NavApp {
id: string;
name: string;
name: ReactElement | string;
[key: string]: unknown;
order: number; // only needed while merging platform and legacy
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/management/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export {
ManagementSetup,
ManagementStart,
RegisterManagementApp,
ManagementSectionId,
RegisterManagementAppArgs,
ManagementAppMountParams,
} from './types';
Expand Down
31 changes: 7 additions & 24 deletions src/plugins/management/public/legacy/sections_register.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
* under the License.
*/

import { LegacyManagementSection } from './section';
import { i18n } from '@kbn/i18n';
import { LegacyManagementSection } from './section';
import { managementSections } from '../management_sections';

export class LegacyManagementAdapter {
main = undefined;
Expand All @@ -33,29 +34,11 @@ export class LegacyManagementAdapter {
capabilities
);

this.main.register('data', {
display: i18n.translate('management.connectDataDisplayName', {
defaultMessage: 'Connect Data',
}),
order: 0,
});

this.main.register('elasticsearch', {
display: 'Elasticsearch',
order: 20,
icon: 'logoElasticsearch',
});

this.main.register('kibana', {
display: 'Kibana',
order: 30,
icon: 'logoKibana',
});

this.main.register('logstash', {
display: 'Logstash',
order: 30,
icon: 'logoLogstash',
managementSections.forEach(({ id, title }, idx) => {
this.main.register(id, {
display: title,
order: idx,
});
});

return this.main;
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/management/public/management_section.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { ManagementSection } from './management_section';
import { ManagementSectionId } from './types';
// @ts-ignore
import { LegacyManagementSection } from './legacy';
import { coreMock } from '../../../core/public/mocks';
Expand All @@ -27,7 +28,7 @@ function createSection(registerLegacyApp: () => void) {
const getLegacySection = () => legacySection;
const getManagementSections: () => ManagementSection[] = () => [];

const testSectionConfig = { id: 'test-section', title: 'Test Section' };
const testSectionConfig = { id: ManagementSectionId.Data, title: 'Test Section' };
return new ManagementSection(
testSectionConfig,
getManagementSections,
Expand Down
8 changes: 5 additions & 3 deletions src/plugins/management/public/management_section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@
* under the License.
*/

import { CreateSection, RegisterManagementAppArgs } from './types';
import { ReactElement } from 'react';

import { CreateSection, RegisterManagementAppArgs, ManagementSectionId } from './types';
import { KibanaLegacySetup } from '../../kibana_legacy/public';
import { StartServicesAccessor } from '../../../core/public';
// @ts-ignore
import { LegacyManagementSection } from './legacy';
import { ManagementApp } from './management_app';

export class ManagementSection {
public readonly id: string = '';
public readonly title: string = '';
public readonly id: ManagementSectionId;
public readonly title: string | ReactElement = '';
public readonly apps: ManagementApp[] = [];
public readonly order: number;
public readonly euiIconType?: string;
Expand Down
77 changes: 77 additions & 0 deletions src/plugins/management/public/management_sections.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiToolTip, EuiIcon } from '@elastic/eui';

import { ManagementSectionId } from './types';

interface Props {
text: string;
tip: string;
}

const ManagementSectionTitle = ({ text, tip }: Props) => (
<EuiToolTip content={tip} position="right">
<EuiFlexGroup alignItems="center" gutterSize="s" responsive={false}>
<EuiFlexItem grow={false}>{text}</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiIcon type="questionInCircle" />
</EuiFlexItem>
</EuiFlexGroup>
</EuiToolTip>
);

export const managementSections = [
{
id: ManagementSectionId.Ingest,
title: (
<ManagementSectionTitle
text="Ingest"
tip="Manage how to transform data and load it into the cluster."
/>
),
},
{
id: ManagementSectionId.Data,
title: <ManagementSectionTitle text="Data" tip="Manage your cluster data and backups" />,
},
{
id: ManagementSectionId.InsightsAndAlerting,
title: (
<ManagementSectionTitle
text="Alerts and Insights"
tip="Manage how to detect changes in your data"
/>
),
},
{
id: ManagementSectionId.Security,
title: <ManagementSectionTitle text="Security" tip="Control access to features and data" />,
},
{
id: ManagementSectionId.Kibana,
title: <ManagementSectionTitle text="Kibana" tip="Customize Kibana and manage saved objects" />,
},
{
id: ManagementSectionId.Stack,
title: <ManagementSectionTitle text="Stack" tip="Manage your license and upgrade the Stack" />,
},
];
Loading

0 comments on commit 5ac7e88

Please sign in to comment.