Skip to content

Commit

Permalink
Merge branch 'feature-ingest-fix-api-key-id-escaping' of github.com:n…
Browse files Browse the repository at this point in the history
…chaulet/kibana into feature-ingest-fix-api-key-id-escaping
  • Loading branch information
nchaulet committed Mar 30, 2020
2 parents 999820e + c7af9c1 commit c121664
Show file tree
Hide file tree
Showing 49 changed files with 2,537 additions and 344 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ describe('filter manager utilities', () => {
expect(compareFilters([f1], [f2], COMPARE_ALL_OPTIONS)).toBeTruthy();
});

test('should compare alias with alias true', () => {
const f1 = {
$state: { store: FilterStateStore.GLOBAL_STATE },
...buildQueryFilter({ _type: { match: { query: 'apache', type: 'phrase' } } }, 'index', ''),
};
const f2 = {
$state: { store: FilterStateStore.GLOBAL_STATE },
...buildQueryFilter({ _type: { match: { query: 'apache', type: 'phrase' } } }, 'index', ''),
};

f2.meta.alias = 'wassup';
f2.meta.alias = 'dog';

expect(compareFilters([f1], [f2], { alias: true })).toBeFalsy();
});

test('should compare alias with COMPARE_ALL_OPTIONS', () => {
const f1 = {
$state: { store: FilterStateStore.GLOBAL_STATE },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const mapFilter = (

if (comparators.negate) cleaned.negate = filter.meta && Boolean(filter.meta.negate);
if (comparators.disabled) cleaned.disabled = filter.meta && Boolean(filter.meta.disabled);
if (comparators.disabled) cleaned.alias = filter.meta?.alias;
if (comparators.alias) cleaned.alias = filter.meta?.alias;

return cleaned;
};
Expand Down
1 change: 0 additions & 1 deletion test/plugin_functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default async function({ readConfigFile }) {

return {
testFiles: [
require.resolve('./test_suites/app_plugins'),
require.resolve('./test_suites/custom_visualizations'),
require.resolve('./test_suites/panel_actions'),
require.resolve('./test_suites/embeddable_explorer'),
Expand Down
9 changes: 9 additions & 0 deletions test/plugin_functional/plugins/kbn_top_nav/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": "kbn_top_nav",
"version": "0.0.1",
"kibanaVersion": "kibana",
"configPath": ["kbn_top_nav"],
"server": false,
"ui": true,
"requiredPlugins": ["navigation"]
}
18 changes: 18 additions & 0 deletions test/plugin_functional/plugins/kbn_top_nav/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "kbn_top_nav",
"version": "1.0.0",
"main": "target/test/plugin_functional/plugins/kbn_top_nav",
"kibana": {
"version": "kibana",
"templateVersion": "1.0.0"
},
"license": "Apache-2.0",
"scripts": {
"kbn": "node ../../../../scripts/kbn.js",
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"typescript": "3.7.2"
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
*/

import React from 'react';
import './initialize';
import { npStart } from 'ui/new_platform';
import { render, unmountComponentAtNode } from 'react-dom';
import { AppMountParameters } from 'kibana/public';
import { AppPluginDependencies } from './types';

export const AppWithTopNav = () => {
const { TopNavMenu } = npStart.plugins.navigation.ui;
export const renderApp = (
depsStart: AppPluginDependencies,
{ appBasePath, element }: AppMountParameters
) => {
const { TopNavMenu } = depsStart.navigation.ui;
const config = [
{
id: 'new',
Expand All @@ -32,10 +36,12 @@ export const AppWithTopNav = () => {
testId: 'demoNewButton',
},
];

return (
render(
<TopNavMenu appName="demo-app" config={config}>
Hey
</TopNavMenu>
</TopNavMenu>,
element
);

return () => unmountComponentAtNode(element);
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
import 'ui/autoload/all';

import chrome from 'ui/chrome';
import { PluginInitializer } from 'kibana/public';
import { TopNavTestPlugin, TopNavTestPluginSetup, TopNavTestPluginStart } from './plugin';

chrome.setRootTemplate('<div data-test-subj="pluginContent">Super simple app plugin</div>');
export const plugin: PluginInitializer<TopNavTestPluginSetup, TopNavTestPluginStart> = () =>
new TopNavTestPlugin();
65 changes: 65 additions & 0 deletions test/plugin_functional/plugins/kbn_top_nav/public/plugin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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 { CoreSetup, Plugin, AppMountParameters } from 'kibana/public';
import { NavigationPublicPluginSetup } from '../../../../../src/plugins/navigation/public';
import { AppPluginDependencies } from './types';

export class TopNavTestPlugin implements Plugin<TopNavTestPluginSetup, TopNavTestPluginStart> {
public setup(core: CoreSetup, { navigation }: { navigation: NavigationPublicPluginSetup }) {
const customExtension = {
id: 'registered-prop',
label: 'Registered Button',
description: 'Registered Demo',
run() {},
testId: 'demoRegisteredNewButton',
};

navigation.registerMenuItem(customExtension);

const customDiscoverExtension = {
id: 'registered-discover-prop',
label: 'Registered Discover Button',
description: 'Registered Discover Demo',
run() {},
testId: 'demoDiscoverRegisteredNewButton',
appName: 'discover',
};

navigation.registerMenuItem(customDiscoverExtension);

core.application.register({
id: 'topNavMenu',
title: 'Top nav menu example',
async mount(params: AppMountParameters) {
const { renderApp } = await import('./application');
const services = await core.getStartServices();
return renderApp(services[1] as AppPluginDependencies, params);
},
});

return {};
}

public start() {}
public stop() {}
}

export type TopNavTestPluginSetup = ReturnType<TopNavTestPlugin['setup']>;
export type TopNavTestPluginStart = ReturnType<TopNavTestPlugin['start']>;
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

export default function({ loadTestFile }) {
describe('app plugins', () => {
loadTestFile(require.resolve('./app_navigation'));
});
import { NavigationPublicPluginStart } from '../../../../../src/plugins/navigation/public';

export interface AppPluginDependencies {
navigation: NavigationPublicPluginStart;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "kbn_tp_custom_visualizations",
"version": "0.0.1",
"kibanaVersion": "kibana",
"requiredPlugins": [
"visualizations"
],
"server": false,
"ui": true
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "kbn_tp_custom_visualizations",
"version": "1.0.0",
"main": "target/test/plugin_functional/plugins/kbn_tp_custom_visualizations",
"kibana": {
"version": "kibana",
"templateVersion": "1.0.0"
Expand All @@ -9,5 +10,13 @@
"dependencies": {
"@elastic/eui": "21.0.1",
"react": "^16.12.0"
},
"scripts": {
"kbn": "node ../../../../scripts/kbn.js",
"build": "rm -rf './target' && tsc"
},
"devDependencies": {
"@kbn/plugin-helpers": "9.0.2",
"typescript": "3.7.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
* under the License.
*/

export default function(kibana) {
return new kibana.Plugin({
uiExports: {
hacks: ['plugins/kbn_tp_custom_visualizations/self_changing_vis/self_changing_vis'],
},
});
}
import { PluginInitializer } from 'kibana/public';
import {
CustomVisualizationsPublicPlugin,
CustomVisualizationsSetup,
CustomVisualizationsStart,
} from './plugin';

export { CustomVisualizationsPublicPlugin as Plugin };

export const plugin: PluginInitializer<CustomVisualizationsSetup, CustomVisualizationsStart> = () =>
new CustomVisualizationsPublicPlugin();
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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 { CoreSetup, Plugin } from 'kibana/public';
import { VisualizationsSetup } from '../../../../../src/plugins/visualizations/public';
import { SelfChangingEditor } from './self_changing_vis/self_changing_editor';
import { SelfChangingComponent } from './self_changing_vis/self_changing_components';

export interface SetupDependencies {
visualizations: VisualizationsSetup;
}

export class CustomVisualizationsPublicPlugin
implements Plugin<CustomVisualizationsSetup, CustomVisualizationsStart> {
public setup(core: CoreSetup, setupDeps: SetupDependencies) {
setupDeps.visualizations.createReactVisualization({
name: 'self_changing_vis',
title: 'Self Changing Vis',
icon: 'controlsHorizontal',
description:
'This visualization is able to change its own settings, that you could also set in the editor.',
visConfig: {
component: SelfChangingComponent,
defaults: {
counter: 0,
},
},
editorConfig: {
optionTabs: [
{
name: 'options',
title: 'Options',
editor: SelfChangingEditor,
},
],
},
requestHandler: 'none',
});
}

public start() {}
public stop() {}
}

export type CustomVisualizationsSetup = ReturnType<CustomVisualizationsPublicPlugin['setup']>;
export type CustomVisualizationsStart = ReturnType<CustomVisualizationsPublicPlugin['start']>;

This file was deleted.

Loading

0 comments on commit c121664

Please sign in to comment.