Skip to content

Commit b774718

Browse files
Merge branch 'master' into ML-54441-calculate-mml-test
2 parents 01da7df + b9a0f95 commit b774718

21 files changed

Lines changed: 313 additions & 52 deletions

File tree

src/legacy/core_plugins/kibana/public/home/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ let copiedLegacyCatalogue = false;
7373
},
7474
});
7575
instance.start(npStart.core, {
76-
data: npStart.plugins.data,
76+
...npStart.plugins,
7777
});
7878
})();

src/legacy/core_plugins/kibana/public/home/kibana_services.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
UiSettingsState,
3030
} from 'kibana/public';
3131
import { UiStatsMetricType } from '@kbn/analytics';
32-
import { FeatureCatalogueEntry } from '../../../../../plugins/home/public';
32+
import { Environment, FeatureCatalogueEntry } from '../../../../../plugins/home/public';
3333

3434
export interface HomeKibanaServices {
3535
indexPatternService: any;
@@ -61,6 +61,7 @@ export interface HomeKibanaServices {
6161
shouldShowTelemetryOptIn: boolean;
6262
docLinks: DocLinksStart;
6363
addBasePath: (url: string) => string;
64+
environment: Environment;
6465
}
6566

6667
let services: HomeKibanaServices | null = null;

src/legacy/core_plugins/kibana/public/home/np_ready/components/home_app.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,19 @@ import { HashRouter as Router, Switch, Route, Redirect } from 'react-router-dom'
2828
import { getTutorial } from '../load_tutorials';
2929
import { replaceTemplateStrings } from './tutorial/replace_template_strings';
3030
import { getServices } from '../../kibana_services';
31-
// TODO This is going to be refactored soon
32-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
33-
import { npSetup } from 'ui/new_platform';
3431
export function HomeApp({ directories }) {
3532
const {
3633
getInjected,
3734
savedObjectsClient,
3835
getBasePath,
3936
addBasePath,
37+
environment,
4038
telemetryOptInProvider: { setOptInNoticeSeen, getOptIn },
4139
} = getServices();
42-
const { cloud } = npSetup.plugins;
43-
const isCloudEnabled = !!(cloud && cloud.isCloudEnabled);
40+
const isCloudEnabled = environment.cloud;
41+
const mlEnabled = environment.ml;
42+
const apmUiEnabled = environment.apmUi;
4443

45-
const apmUiEnabled = getInjected('apmUiEnabled', true);
46-
const mlEnabled = getInjected('mlEnabled', false);
4744
const defaultAppId = getInjected('kbnDefaultAppId', 'discover');
4845

4946
const renderTutorialDirectory = props => {

src/legacy/core_plugins/kibana/public/home/plugin.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ import { UiStatsMetricType } from '@kbn/analytics';
2323
import { DataPublicPluginStart } from 'src/plugins/data/public';
2424
import { setServices } from './kibana_services';
2525
import { KibanaLegacySetup } from '../../../../../plugins/kibana_legacy/public';
26-
import { FeatureCatalogueEntry } from '../../../../../plugins/home/public';
26+
import {
27+
Environment,
28+
FeatureCatalogueEntry,
29+
HomePublicPluginStart,
30+
} from '../../../../../plugins/home/public';
2731

2832
export interface LegacyAngularInjectedDependencies {
2933
telemetryOptInProvider: any;
@@ -32,6 +36,7 @@ export interface LegacyAngularInjectedDependencies {
3236

3337
export interface HomePluginStartDependencies {
3438
data: DataPublicPluginStart;
39+
home: HomePublicPluginStart;
3540
}
3641

3742
export interface HomePluginSetupDependencies {
@@ -60,6 +65,7 @@ export interface HomePluginSetupDependencies {
6065
export class HomePlugin implements Plugin {
6166
private dataStart: DataPublicPluginStart | null = null;
6267
private savedObjectsClient: any = null;
68+
private environment: Environment | null = null;
6369

6470
setup(
6571
core: CoreSetup,
@@ -86,6 +92,7 @@ export class HomePlugin implements Plugin {
8692
addBasePath: core.http.basePath.prepend,
8793
getBasePath: core.http.basePath.get,
8894
indexPatternService: this.dataStart!.indexPatterns,
95+
environment: this.environment!,
8996
...angularDependencies,
9097
});
9198
const { renderApp } = await import('./np_ready/application');
@@ -94,8 +101,8 @@ export class HomePlugin implements Plugin {
94101
});
95102
}
96103

97-
start(core: CoreStart, { data }: HomePluginStartDependencies) {
98-
// TODO is this really the right way? I though the app context would give us those
104+
start(core: CoreStart, { data, home }: HomePluginStartDependencies) {
105+
this.environment = home.environment.get();
99106
this.dataStart = data;
100107
this.savedObjectsClient = core.savedObjects.client;
101108
}

src/legacy/core_plugins/kibana/public/visualize_embeddable/visualize_embeddable_factory.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import 'uiExports/docViews';
2323
import 'uiExports/embeddableActions';
2424
import 'uiExports/fieldFormatEditors';
2525
import 'uiExports/fieldFormats';
26-
import 'uiExports/home';
2726
import 'uiExports/indexManagement';
2827
import 'uiExports/inspectorViews';
2928
import 'uiExports/savedObjectTypes';

src/legacy/ui/public/new_platform/new_platform.karma_mock.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ export const npSetup = {
131131
featureCatalogue: {
132132
register: sinon.fake(),
133133
},
134+
environment: {
135+
update: sinon.fake(),
136+
},
134137
},
135138
},
136139
};

src/plugins/home/public/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export {
2323
HomePublicPluginSetup,
2424
HomePublicPluginStart,
2525
} from './plugin';
26-
export { FeatureCatalogueEntry, FeatureCatalogueCategory } from './services';
26+
export { FeatureCatalogueEntry, FeatureCatalogueCategory, Environment } from './services';
2727
import { HomePublicPlugin } from './plugin';
2828

2929
export const plugin = () => new HomePublicPlugin();

src/plugins/home/public/plugin.test.mocks.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
*/
1919

2020
import { featureCatalogueRegistryMock } from './services/feature_catalogue/feature_catalogue_registry.mock';
21+
import { environmentServiceMock } from './services/environment/environment.mock';
2122

2223
export const registryMock = featureCatalogueRegistryMock.create();
24+
export const environmentMock = environmentServiceMock.create();
2325
jest.doMock('./services', () => ({
2426
FeatureCatalogueRegistry: jest.fn(() => registryMock),
27+
EnvironmentService: jest.fn(() => environmentMock),
2528
}));

src/plugins/home/public/plugin.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
* under the License.
1818
*/
1919

20-
import { registryMock } from './plugin.test.mocks';
20+
import { registryMock, environmentMock } from './plugin.test.mocks';
2121
import { HomePublicPlugin } from './plugin';
2222

2323
describe('HomePublicPlugin', () => {
2424
beforeEach(() => {
2525
registryMock.setup.mockClear();
2626
registryMock.start.mockClear();
27+
environmentMock.setup.mockClear();
28+
environmentMock.start.mockClear();
2729
});
2830

2931
describe('setup', () => {
@@ -32,6 +34,12 @@ describe('HomePublicPlugin', () => {
3234
expect(setup).toHaveProperty('featureCatalogue');
3335
expect(setup.featureCatalogue).toHaveProperty('register');
3436
});
37+
38+
test('wires up and returns environment service', async () => {
39+
const setup = await new HomePublicPlugin().setup();
40+
expect(setup).toHaveProperty('environment');
41+
expect(setup.environment).toHaveProperty('update');
42+
});
3543
});
3644

3745
describe('start', () => {
@@ -45,5 +53,15 @@ describe('HomePublicPlugin', () => {
4553
});
4654
expect(start.featureCatalogue.get).toBeDefined();
4755
});
56+
57+
test('wires up and returns environment service', async () => {
58+
const service = new HomePublicPlugin();
59+
await service.setup();
60+
const start = await service.start({
61+
application: { capabilities: { catalogue: {} } },
62+
} as any);
63+
expect(environmentMock.start).toHaveBeenCalled();
64+
expect(start.environment.get).toBeDefined();
65+
});
4866
});
4967
});

src/plugins/home/public/plugin.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,22 @@
1919

2020
import { CoreStart, Plugin } from 'src/core/public';
2121
import {
22+
EnvironmentService,
23+
EnvironmentServiceSetup,
24+
EnvironmentServiceStart,
2225
FeatureCatalogueRegistry,
2326
FeatureCatalogueRegistrySetup,
2427
FeatureCatalogueRegistryStart,
2528
} from './services';
2629

2730
export class HomePublicPlugin implements Plugin<HomePublicPluginSetup, HomePublicPluginStart> {
2831
private readonly featuresCatalogueRegistry = new FeatureCatalogueRegistry();
32+
private readonly environmentService = new EnvironmentService();
2933

3034
public async setup() {
3135
return {
3236
featureCatalogue: { ...this.featuresCatalogueRegistry.setup() },
37+
environment: { ...this.environmentService.setup() },
3338
};
3439
}
3540

@@ -40,6 +45,7 @@ export class HomePublicPlugin implements Plugin<HomePublicPluginSetup, HomePubli
4045
capabilities: core.application.capabilities,
4146
}),
4247
},
48+
environment: { ...this.environmentService.start() },
4349
};
4450
}
4551
}
@@ -50,12 +56,25 @@ export type FeatureCatalogueSetup = FeatureCatalogueRegistrySetup;
5056
/** @public */
5157
export type FeatureCatalogueStart = FeatureCatalogueRegistryStart;
5258

59+
/** @public */
60+
export type EnvironmentSetup = EnvironmentServiceSetup;
61+
62+
/** @public */
63+
export type EnvironmentStart = EnvironmentServiceStart;
64+
5365
/** @public */
5466
export interface HomePublicPluginSetup {
5567
featureCatalogue: FeatureCatalogueSetup;
68+
/**
69+
* The environment service is only available for a transition period and will
70+
* be replaced by display specific extension points.
71+
* @deprecated
72+
*/
73+
environment: EnvironmentSetup;
5674
}
5775

5876
/** @public */
5977
export interface HomePublicPluginStart {
6078
featureCatalogue: FeatureCatalogueStart;
79+
environment: EnvironmentStart;
6180
}

0 commit comments

Comments
 (0)