Skip to content

Commit

Permalink
Nests tutorials service in a tutorials key in the home plugin, change…
Browse files Browse the repository at this point in the history
…s api http routes for legacy platform and NP
  • Loading branch information
TinaHeiligers committed Nov 16, 2019
1 parent 1d79358 commit 8d49809
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 78 deletions.
14 changes: 7 additions & 7 deletions src/legacy/core_plugins/kibana/public/home/load_tutorials.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import _ from 'lodash';
import { getServices } from './kibana_services';
import { i18n } from '@kbn/i18n';

const baseUrl = getServices().addBasePath('/api/kibana/home/tutorials');
const baseUrlNP = getServices().addBasePath('/api/kibana/home/NP_tutorials');
const baseUrl = getServices().addBasePath('/api/kibana/home/tutorials_LP');
const baseUrlNP = getServices().addBasePath('/api/kibana/home/tutorials');
const headers = new Headers();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/json');
Expand All @@ -40,16 +40,16 @@ async function loadTutorials() {
credentials: 'include',
headers: headers,
});
const responseNewPlatform = await fetch(baseUrlNP, {
method: 'get',
credentials: 'include',
headers: headers,
});
if (responseLegacyPlatform.status >= 300) {
throw new Error(i18n.translate('kbn.home.loadTutorials.requestFailedErrorMessage', {
defaultMessage: 'Request failed with status code: {status}', values: { status: responseLegacyPlatform.status } }
));
}
const responseNewPlatform = await fetch(baseUrlNP, {
method: 'get',
credentials: 'include',
headers: headers,
});
if (responseNewPlatform.status >= 300) {
throw new Error(i18n.translate('kbn.home.loadTutorials.requestFailedErrorMessage', {
defaultMessage: 'Request failed with status code: {status}', values: { status: responseNewPlatform.status } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

export function registerTutorials(server) {
server.route({
path: '/api/kibana/home/tutorials',
path: '/api/kibana/home/tutorials_LP',
method: ['GET'],
handler: function (req) {
return server.getTutorials(req);
Expand Down
120 changes: 60 additions & 60 deletions src/legacy/core_plugins/kibana/server/tutorials/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,66 +80,66 @@ import { consulMetricsSpecProvider } from './consul_metrics';
import { cockroachdbMetricsSpecProvider } from './cockroachdb_metrics';

export function registerTutorials(server) {
server.newPlatform.setup.plugins.home.registerTutorial(systemLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(systemMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(apacheLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(apacheMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(elasticsearchLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(iisLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(kafkaLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(logstashLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(nginxLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(nginxMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(mysqlLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(mysqlMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(mongodbMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(osqueryLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(phpfpmMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(postgresqlMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(postgresqlLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(rabbitmqMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(redisLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(redisMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(suricataLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(dockerMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(kubernetesMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(uwsgiMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(netflowSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(traefikLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(systemLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(systemMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(apacheLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(apacheMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(elasticsearchLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(iisLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(kafkaLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(logstashLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(nginxLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(nginxMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(mysqlLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(mysqlMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(mongodbMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(osqueryLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(phpfpmMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(postgresqlMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(postgresqlLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(rabbitmqMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(redisLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(redisMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(suricataLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(dockerMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(kubernetesMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(uwsgiMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(netflowSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(traefikLogsSpecProvider);
server.registerTutorial(apmSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(cephMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(aerospikeMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(couchbaseMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(dropwizardMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(elasticsearchMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(etcdMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(haproxyMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(kafkaMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(kibanaMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(memcachedMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(muninMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(vSphereMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(windowsMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(windowsEventLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(golangMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(logstashMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(prometheusMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(zookeeperMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(uptimeMonitorsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(cloudwatchLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(awsMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(mssqlMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(natsMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(natsLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(zeekLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(corednsMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(corednsLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(auditbeatSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(iptablesLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(ciscoLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(envoyproxyLogsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(couchdbMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(cephMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(aerospikeMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(couchbaseMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(dropwizardMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(elasticsearchMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(etcdMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(haproxyMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(kafkaMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(kibanaMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(memcachedMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(muninMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(vSphereMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(windowsMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(windowsEventLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(golangMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(logstashMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(prometheusMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(zookeeperMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(uptimeMonitorsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(cloudwatchLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(awsMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(mssqlMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(natsMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(natsLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(zeekLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(corednsMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(corednsLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(auditbeatSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(iptablesLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(ciscoLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(envoyproxyLogsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(couchdbMetricsSpecProvider);
server.registerTutorial(emsBoundariesSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(consulMetricsSpecProvider);
server.newPlatform.setup.plugins.home.registerTutorial(cockroachdbMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(consulMetricsSpecProvider);
server.newPlatform.setup.plugins.home.tutorials.registerTutorial(cockroachdbMetricsSpecProvider);
}
6 changes: 4 additions & 2 deletions src/plugins/home/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ describe('HomePlugin', () => {

test('wires up and returns registerTutorial and addScopedTutorialContextFactory', () => {
const setup = new HomePlugin().setup(mockCoreSetup);
expect(setup).toHaveProperty('registerTutorial');
expect(setup).toHaveProperty('addScopedTutorialContextFactory');
expect(setup).toHaveProperty('tutorials');
expect(setup.tutorials).toHaveProperty('registerTutorial');
expect(setup.tutorials).toHaveProperty('addScopedTutorialContextFactory');
});
});

describe('start', () => {
test('is defined', () => {
const start = new HomePlugin().start();
expect(start).toBeDefined();
expect(start).toHaveProperty('tutorials');
});
});
});
14 changes: 9 additions & 5 deletions src/plugins/home/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,28 @@
import { CoreSetup, Plugin } from 'src/core/server';
import { TutorialsRegistry, TutorialsRegistrySetup, TutorialsRegistryStart } from './services';

export class HomePlugin implements Plugin<TutorialsRegistrySetup, TutorialsRegistryStart> {
export class HomePlugin implements Plugin<HomePluginSetup, HomePluginStart> {
private readonly tutorialsRegistry = new TutorialsRegistry();

public setup(core: CoreSetup) {
return {
...this.tutorialsRegistry.setup(core),
tutorials: { ...this.tutorialsRegistry.setup(core) },
};
}

public start() {
return {
...this.tutorialsRegistry.start(),
tutorials: { ...this.tutorialsRegistry.start() },
};
}
}

/** @public */
export type HomePluginSetup = TutorialsRegistrySetup;
export interface HomePluginSetup {
tutorials: TutorialsRegistrySetup;
}

/** @public */
export type HomePluginStart = TutorialsRegistryStart;
export interface HomePluginStart {
tutorials: TutorialsRegistryStart;
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('TutorialsRegistry', () => {
let testProvider: TutorialProvider;
let testScopedTutorialContextFactory: ScopedTutorialContextFactory;

describe('GET /api/kibana/home/NP_tutorials', () => {
describe('GET /api/kibana/home/tutorials', () => {
beforeEach(() => {
mockCoreSetup = coreMock.createSetup();
});
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/home/server/services/tutorials_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class TutorialsRegistry {
public setup(core: CoreSetup) {
const router = core.http.createRouter();
router.get(
{ path: '/api/kibana/home/NP_tutorials', validate: false },
{ path: '/api/kibana/home/tutorials', validate: false },
async (context, req, res) => {
const initialContext = {};
const scopedContext = this.scopedTutorialContextFactories.reduce(
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/spaces/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class Plugin {
}

if (plugins.home) {
plugins.home.addScopedTutorialContextFactory(
plugins.home.tutorials.addScopedTutorialContextFactory(
createSpacesTutorialContextFactory(spacesService)
);
}
Expand Down

0 comments on commit 8d49809

Please sign in to comment.