Skip to content

Commit

Permalink
Merge branch 'master' into IS-51910_share-lens-change-index-pattern-i…
Browse files Browse the repository at this point in the history
…n-discover
  • Loading branch information
elasticmachine authored Dec 19, 2019
2 parents 1112ad5 + e9ac373 commit 1b42770
Show file tree
Hide file tree
Showing 38 changed files with 300 additions and 704 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,6 @@
types="fieldTypes"
>
</discover-field-search>
<div data-test-subj="discoverFieldFilter" class="dscFieldFilter" ng-show="showFilter">
<div class="form-group" >
<label
for="discoverFieldChooserFilterAggregatable"
i18n-id="kbn.discover.fieldChooser.filter.aggregatableLabel"
i18n-default-message="Aggregatable"
></label>
<select
id="discoverFieldChooserFilterAggregatable"
ng-options="opt.value as opt.label for opt in filter.boolOpts"
ng-model="filter.vals.aggregatable"
class="form-control">
</select>
</div>
<div class="form-group" ng-show="showFilter">
<label
for="discoverFieldChooserFilterSearchable"
i18n-id="kbn.discover.fieldChooser.filter.searchableLabel"
i18n-default-message="Searchable"
></label>
<select
id="discoverFieldChooserFilterSearchable"
ng-options="opt.value as opt.label for opt in filter.boolOpts"
ng-model="filter.vals.searchable"
class="form-control">
</select>
</div>
<div class="form-group" ng-show="showFilter">
<label
for="discoverFieldChooserFilterType"
i18n-id="kbn.discover.fieldChooser.filter.typeLabel"
i18n-default-message="Type"
></label>
<select
id="discoverFieldChooserFilterType"
ng-options="field as field for field in fieldTypes"
ng-model="filter.vals.type"
class="form-control">
</select>
</div>
<div class="form-group" ng-show="showFilter">
<label for="discoverFieldChooserHideMissingFields">
<input id="discoverFieldChooserHideMissingFields" type="checkbox" ng-model="filter.vals.missing">
<span
i18n-id="kbn.discover.fieldChooser.filter.hideMissingFieldsLabel"
i18n-default-message="Hide missing fields"
></span>
</label>
</div>
<button
ng-show="showFilter"
ng-click="filter.reset()"
ng-disabled="!filter.active"
class="kuiButton kuiButton--danger kuiButton--fullWidth"
i18n-id="kbn.discover.fieldChooser.filter.resetFiltersButtonLabel"
i18n-default-message="Reset filters"
></button>
</div>
</form>
</div>

Expand Down
5 changes: 2 additions & 3 deletions test/plugin_functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ export default async function({ readConfigFile }) {
...functionalConfig.get('kbnTestServer'),
serverArgs: [
...functionalConfig.get('kbnTestServer.serverArgs'),

// Required to load new platform plugins via `--plugin-path` flag.
'--env.name=development',
...plugins.map(
pluginDir => `--plugin-path=${path.resolve(__dirname, 'plugins', pluginDir)}`
),
// Required to load new platform plugins via `--plugin-path` flag.
'--env.name=development',
],
},
};
Expand Down
15 changes: 9 additions & 6 deletions test/plugin_functional/plugins/core_plugin_b/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import { CorePluginAPluginSetup } from '../../core_plugin_a/public/plugin';

declare global {
interface Window {
corePluginB?: string;
hasAccessToInjectedMetadata?: boolean;
receivedStartServices?: boolean;
env?: PluginInitializerContext['env'];
}
}
Expand All @@ -36,6 +39,12 @@ export class CorePluginBPlugin
window.env = pluginContext.env;
}
public setup(core: CoreSetup, deps: CorePluginBDeps) {
window.corePluginB = `Plugin A said: ${deps.core_plugin_a.getGreeting()}`;
window.hasAccessToInjectedMetadata = 'getInjectedVar' in core.injectedMetadata;
core.getStartServices().then(([coreStart, plugins]) => {
window.receivedStartServices = 'overlays' in coreStart;
});

core.application.register({
id: 'bar',
title: 'Bar',
Expand All @@ -44,12 +53,6 @@ export class CorePluginBPlugin
return renderApp(context, params);
},
});

return {
sayHi() {
return `Plugin A said: ${deps.core_plugin_a.getGreeting()}`;
},
};
}

public start() {}
Expand Down
36 changes: 0 additions & 36 deletions test/plugin_functional/plugins/core_provider_plugin/index.ts

This file was deleted.

17 changes: 0 additions & 17 deletions test/plugin_functional/plugins/core_provider_plugin/package.json

This file was deleted.

14 changes: 0 additions & 14 deletions test/plugin_functional/plugins/core_provider_plugin/tsconfig.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"kibanaVersion": "kibana",
"configPath": ["ui_settings_plugin"],
"server": true,
"ui": false
"ui": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
import { npSetup, npStart } from 'ui/new_platform';
import '../types';
import { UiSettingsPlugin } from './plugin';

window.__coreProvider = {
setup: npSetup,
start: npStart,
testUtils: {
delay: (ms: number) => new Promise(res => setTimeout(res, ms)),
},
};
export const plugin = () => new UiSettingsPlugin();
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
import { LegacyCoreSetup, LegacyCoreStart } from 'kibana/public';

import { CoreSetup, Plugin } from 'kibana/public';

declare global {
interface Window {
__coreProvider: {
setup: {
core: LegacyCoreSetup;
plugins: Record<string, any>;
};
start: {
core: LegacyCoreStart;
plugins: Record<string, any>;
};
testUtils: {
delay: (ms: number) => Promise<void>;
};
};
uiSettingsPlugin?: Record<string, any>;
uiSettingsPluginValue?: string;
}
}

export class UiSettingsPlugin implements Plugin {
public setup(core: CoreSetup) {
window.uiSettingsPlugin = core.uiSettings.getAll().ui_settings_plugin;
window.uiSettingsPluginValue = core.uiSettings.get('ui_settings_plugin');
}

public start() {}
public stop() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"skipLibCheck": true
},
"include": [
"index.ts",
"public/**/*.ts",
"public/**/*.tsx",
"server/**/*.ts",
"../../../../typings/**/*",
],
Expand Down
45 changes: 21 additions & 24 deletions test/plugin_functional/test_suites/core_plugins/ui_plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import expect from '@kbn/expect';
import { PluginFunctionalProviderContext } from '../../services';
import '../../../../test/plugin_functional/plugins/core_provider_plugin/types';

// eslint-disable-next-line import/no-default-export
export default function({ getService, getPageObjects }: PluginFunctionalProviderContext) {
Expand All @@ -32,35 +31,22 @@ export default function({ getService, getPageObjects }: PluginFunctionalProvider
await PageObjects.common.navigateToApp('settings');
});

it('should run the new platform plugins', async () => {
expect(
await browser.execute(() => {
return window.__coreProvider.setup.plugins.core_plugin_b.sayHi();
})
).to.be('Plugin A said: Hello from Plugin A!');
it('should attach string to window.corePluginB', async () => {
const corePluginB = await browser.execute('return window.corePluginB');
expect(corePluginB).to.equal(`Plugin A said: Hello from Plugin A!`);
});
});

describe('should have access to the core services', function describeIndexTests() {
describe('have injectedMetadata service provided', function describeIndexTests() {
before(async () => {
await PageObjects.common.navigateToApp('settings');
});

it('to injectedMetadata service', async () => {
expect(
await browser.execute(() => {
return window.__coreProvider.setup.core.injectedMetadata.getKibanaBuildNumber();
})
).to.be.a('number');
await PageObjects.common.navigateToApp('bar');
});

it('to start services via coreSetup.getStartServices', async () => {
expect(
await browser.executeAsync(async cb => {
const [coreStart] = await window.__coreProvider.setup.core.getStartServices();
cb(Boolean(coreStart.overlays));
})
).to.be(true);
it('should attach boolean to window.hasAccessToInjectedMetadata', async () => {
const hasAccessToInjectedMetadata = await browser.execute(
'return window.hasAccessToInjectedMetadata'
);
expect(hasAccessToInjectedMetadata).to.equal(true);
});
});

Expand All @@ -75,5 +61,16 @@ export default function({ getService, getPageObjects }: PluginFunctionalProvider
expect(envData.packageInfo.version).to.be.a('string');
});
});

describe('have access to start services via coreSetup.getStartServices', function describeIndexTests() {
before(async () => {
await PageObjects.common.navigateToApp('bar');
});

it('should attach boolean to window.receivedStartServices', async () => {
const receivedStartServices = await browser.execute('return window.receivedStartServices');
expect(receivedStartServices).to.equal(true);
});
});
});
}
20 changes: 2 additions & 18 deletions test/plugin_functional/test_suites/core_plugins/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
import expect from '@kbn/expect';
import { PluginFunctionalProviderContext } from '../../services';
import '../../plugins/core_provider_plugin/types';

// eslint-disable-next-line import/no-default-export
export default function({ getService, getPageObjects }: PluginFunctionalProviderContext) {
Expand All @@ -32,30 +31,15 @@ export default function({ getService, getPageObjects }: PluginFunctionalProvider
});

it('client plugins have access to registered settings', async () => {
const settings = await browser.execute(() => {
return window.__coreProvider.setup.core.uiSettings.getAll().ui_settings_plugin;
});

const settings = await browser.execute('return window.uiSettingsPlugin');
expect(settings).to.eql({
category: ['any'],
description: 'just for testing',
name: 'from_ui_settings_plugin',
value: '2',
});

const settingsValue = await browser.execute(() => {
return window.__coreProvider.setup.core.uiSettings.get('ui_settings_plugin');
});

const settingsValue = await browser.execute('return window.uiSettingsPluginValue');
expect(settingsValue).to.be('2');

const settingsValueViaObservables = await browser.executeAsync(async (callback: Function) => {
window.__coreProvider.setup.core.uiSettings
.get$('ui_settings_plugin')
.subscribe(v => callback(v));
});

expect(settingsValueViaObservables).to.be('2');
});

it('server plugins have access to registered settings', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiEmptyPrompt } from '@elastic/eui';
import { EuiFlexGroup, EuiFlexItem, EuiLoadingSpinner } from '@elastic/eui';

export function LoadingStatePrompt() {
return (
<EuiEmptyPrompt
title={
<div>
{i18n.translate('xpack.apm.loading.prompt', {
defaultMessage: 'Loading...'
})}
</div>
}
titleSize="s"
/>
<EuiFlexGroup justifyContent="spaceAround">
<EuiFlexItem grow={false}>
<EuiLoadingSpinner size="l" />
</EuiFlexItem>
</EuiFlexGroup>
);
}
Loading

0 comments on commit 1b42770

Please sign in to comment.