Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] add graph sample data (#54558) #54763

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions x-pack/plugins/graph/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export const APP_ICON = 'graphApp';

export function createWorkspacePath(id: string) {
return `/app/graph/#/workspace/${id}`;
}
13 changes: 10 additions & 3 deletions x-pack/plugins/graph/server/lib/license_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@
*/

import Boom from 'boom';
import { map } from 'rxjs/operators';
import { Observable, Subscription } from 'rxjs';
import { ILicense } from '../../../licensing/common/types';
import { checkLicense, GraphLicenseInformation } from '../../common/check_license';

export class LicenseState {
private licenseInformation: GraphLicenseInformation = checkLicense(undefined);
private subscription: Subscription | null = null;
private observable: Observable<GraphLicenseInformation> | null = null;

private updateInformation(license: ILicense | undefined) {
this.licenseInformation = checkLicense(license);
private updateInformation(licenseInformation: GraphLicenseInformation) {
this.licenseInformation = licenseInformation;
}

public start(license$: Observable<ILicense>) {
this.subscription = license$.subscribe(this.updateInformation.bind(this));
this.observable = license$.pipe(map(checkLicense));
this.subscription = this.observable.subscribe(this.updateInformation.bind(this));
}

public stop() {
Expand All @@ -30,6 +33,10 @@ export class LicenseState {
public getLicenseInformation() {
return this.licenseInformation;
}

public getLicenseInformation$() {
return this.observable;
}
}

export function verifyApiAccess(licenseState: LicenseState) {
Expand Down
11 changes: 10 additions & 1 deletion x-pack/plugins/graph/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,24 @@ import { LicensingPluginSetup } from '../../licensing/server';
import { LicenseState } from './lib/license_state';
import { registerSearchRoute } from './routes/search';
import { registerExploreRoute } from './routes/explore';
import { HomeServerPluginSetup } from '../../../../src/plugins/home/server';
import { registerSampleData } from './sample_data';

export class GraphPlugin implements Plugin {
private licenseState: LicenseState | null = null;

public async setup(core: CoreSetup, { licensing }: { licensing: LicensingPluginSetup }) {
public async setup(
core: CoreSetup,
{ licensing, home }: { licensing: LicensingPluginSetup; home?: HomeServerPluginSetup }
) {
const licenseState = new LicenseState();
licenseState.start(licensing.license$);
this.licenseState = licenseState;

if (home) {
registerSampleData(home.sampleData, licenseState);
}

const router = core.http.createRouter();
registerSearchRoute({ licenseState, router });
registerExploreRoute({ licenseState, router });
Expand Down
Loading