Skip to content

Commit

Permalink
visualize embeddable to visualizations plugin (#54840)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar authored Jan 15, 2020
1 parent 63ad7a9 commit 297aa7b
Show file tree
Hide file tree
Showing 36 changed files with 200 additions and 191 deletions.
5 changes: 1 addition & 4 deletions src/legacy/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ export default function(kibana) {

uiExports: {
hacks: ['plugins/kibana/discover', 'plugins/kibana/dev_tools', 'plugins/kibana/visualize'],
savedObjectTypes: [
'plugins/kibana/visualize/saved_visualizations/saved_visualization_register',
'plugins/kibana/dashboard/saved_dashboard/saved_dashboard_register',
],
savedObjectTypes: ['plugins/kibana/dashboard/saved_dashboard/saved_dashboard_register'],
app: {
id: 'kibana',
title: 'Kibana',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ export { ensureDefaultIndexPattern } from 'ui/legacy_compat';
export { unhashUrl } from '../../../../../plugins/kibana_utils/public';
export { IInjector } from 'ui/chrome';
export { SavedObjectLoader } from 'ui/saved_objects';
export { VISUALIZE_EMBEDDABLE_TYPE } from '../visualize_embeddable';
export { VISUALIZE_EMBEDDABLE_TYPE } from '../../../visualizations/public/embeddable';
export { registerTimefilterWithGlobalStateFactory } from 'ui/timefilter/setup_router';
export { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url';
1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana/public/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

// Visualize styles
@import './visualize/index';
@import './visualize_embeddable/index';
// Has to come after visualize because of some
// bad cascading in the Editor layout
@import 'src/legacy/ui/public/vis/index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,5 @@ export { VisType } from 'ui/vis';
export { wrapInI18nContext } from 'ui/i18n';

export { DashboardConstants } from '../dashboard/np_ready/dashboard_constants';
export { VisSavedObject } from '../visualize_embeddable/visualize_embeddable';
export { VISUALIZE_EMBEDDABLE_TYPE } from '../visualize_embeddable';
export { VisualizeEmbeddableFactory } from '../visualize_embeddable/visualize_embeddable_factory';
export { VisSavedObject } from '../../../visualizations/public/embeddable/visualize_embeddable';
export { VISUALIZE_EMBEDDABLE_TYPE } from '../../../visualizations/public/embeddable';
34 changes: 24 additions & 10 deletions src/legacy/core_plugins/kibana/public/visualize/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import {
SavedObjectsClientContract,
} from 'kibana/public';

// @ts-ignore
import { uiModules } from 'ui/modules';

import { Storage } from '../../../../../plugins/kibana_utils/public';
import { DataPublicPluginStart } from '../../../../../plugins/data/public';
import { IEmbeddableStart } from '../../../../../plugins/embeddable/public';
Expand All @@ -40,14 +43,11 @@ import {
FeatureCatalogueCategory,
HomePublicPluginSetup,
} from '../../../../../plugins/home/public';
import {
defaultEditor,
VisEditorTypesRegistryProvider,
VisualizeEmbeddableFactory,
VISUALIZE_EMBEDDABLE_TYPE,
} from './legacy_imports';
import { defaultEditor, VisEditorTypesRegistryProvider } from './legacy_imports';
import { UsageCollectionSetup } from '../../../../../plugins/usage_collection/public';
import { createSavedVisLoader } from './saved_visualizations/saved_visualizations';
// @ts-ignore
import { savedObjectManagementRegistry } from '../management/saved_object_registry';

export interface LegacyAngularInjectedDependencies {
legacyChrome: any;
Expand Down Expand Up @@ -113,6 +113,7 @@ export class VisualizePlugin implements Plugin {
indexPatterns: data.indexPatterns,
chrome: contextCore.chrome,
overlays: contextCore.overlays,
visualizations,
});
const deps: VisualizeKibanaServices = {
...angularDependencies,
Expand Down Expand Up @@ -159,19 +160,32 @@ export class VisualizePlugin implements Plugin {
}

public start(
{ savedObjects: { client: savedObjectsClient } }: CoreStart,
core: CoreStart,
{ embeddables, navigation, data, share, visualizations }: VisualizePluginStartDependencies
) {
this.startDependencies = {
data,
embeddables,
navigation,
savedObjectsClient,
savedObjectsClient: core.savedObjects.client,
share,
visualizations,
};

const embeddableFactory = new VisualizeEmbeddableFactory(visualizations.types);
embeddables.registerEmbeddableFactory(VISUALIZE_EMBEDDABLE_TYPE, embeddableFactory);
const savedVisualizations = createSavedVisLoader({
savedObjectsClient: core.savedObjects.client,
indexPatterns: data.indexPatterns,
chrome: core.chrome,
overlays: core.overlays,
visualizations,
});

// TODO: remove once savedobjectregistry is refactored
savedObjectManagementRegistry.register({
service: 'savedVisualizations',
title: 'visualizations',
});

uiModules.get('app/visualize').service('savedVisualizations', () => savedVisualizations);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { IIndexPattern } from '../../../../../../plugins/data/public';
import { VisSavedObject } from '../legacy_imports';

import { createSavedSearchesService } from '../../discover';
import { VisualizeConstants } from '..';
import { VisualizeConstants } from '../np_ready/visualize_constants';

async function _afterEsResp(savedVis: VisSavedObject, services: any) {
await _getLinkedSavedSearch(savedVis, services);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { extractReferences, injectReferences } from './saved_visualization_references';
import { VisSavedObject } from '../../visualize_embeddable/visualize_embeddable';
import { VisSavedObject } from '../../../../visualizations/public/embeddable/visualize_embeddable';

describe('extractReferences', () => {
test('extracts nothing if savedSearchId is empty', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import { SavedObjectAttributes, SavedObjectReference } from 'kibana/server';
import { VisSavedObject } from '../../visualize_embeddable/visualize_embeddable';
import { VisSavedObject } from '../../../../visualizations/public/embeddable/visualize_embeddable';

export function extractReferences({
attributes,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
import { SavedObjectLoader } from 'ui/saved_objects';
import { SavedObjectKibanaServices } from 'ui/saved_objects/types';

import { start as visualizations } from '../../../../visualizations/public/np_ready/public/legacy';
// @ts-ignore
import { findListItems } from './find_list_items';
import { createSavedVisClass } from './_saved_vis';
import { createVisualizeEditUrl } from '..';
import { createVisualizeEditUrl } from '../np_ready/visualize_constants';
import { VisualizationsStart } from '../../../../visualizations/public/np_ready/public';

export function createSavedVisLoader(services: SavedObjectKibanaServices) {
const { savedObjectsClient } = services;
interface SavedObjectKibanaServicesWithVisualizations extends SavedObjectKibanaServices {
visualizations: VisualizationsStart;
}

export function createSavedVisLoader(services: SavedObjectKibanaServicesWithVisualizations) {
const { savedObjectsClient, visualizations } = services;

class SavedObjectLoaderVisualize extends SavedObjectLoader {
mapHitSource = (source: Record<string, any>, id: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/visualizations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const visualizations: LegacyPluginInitializer = kibana =>
publicDir: resolve(__dirname, 'public'),
require: [],
uiExports: {
interpreter: ['plugins/visualizations/expressions/boot'],
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export function DisabledLabVisualization({ title }: { title: string }) {
/>
<div className="kuiVerticalRhythm">
<FormattedMessage
id="kbn.visualize.disabledLabVisualizationTitle"
id="visualizations.disabledLabVisualizationTitle"
defaultMessage="{title} is a lab visualization."
values={{ title: <em className="visDisabledLabVisualization__title">{title}</em> }}
/>
</div>
<div className="kuiVerticalRhythm">
<FormattedMessage
id="kbn.visualize.disabledLabVisualizationMessage"
id="visualizations.disabledLabVisualizationMessage"
defaultMessage="Please turn on lab-mode in the advanced settings to see lab visualizations."
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
* under the License.
*/

import { npStart } from 'ui/new_platform';

import { VisSavedObject } from './visualize_embeddable';
import { indexPatterns, IIndexPattern } from '../../../../../plugins/data/public';
import { getUISettings, getSavedObjects } from '../np_ready/public/services';

export async function getIndexPattern(
savedVis: VisSavedObject
Expand All @@ -29,8 +28,8 @@ export async function getIndexPattern(
return savedVis.vis.indexPattern;
}

const savedObjectsClient = npStart.core.savedObjects.client;
const defaultIndex = npStart.core.uiSettings.get('defaultIndex');
const savedObjectsClient = getSavedObjects().client;
const defaultIndex = getUISettings().get('defaultIndex');

if (savedVis.vis.params.index_pattern) {
const indexPatternObjects = await savedObjectsClient.find({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {
APPLY_FILTER_TRIGGER,
} from '../../../../../plugins/embeddable/public';
import { dispatchRenderComplete } from '../../../../../plugins/kibana_utils/public';
import { SavedSearch } from '../discover/np_ready/types';
import { SavedSearch } from '../../../kibana/public/discover/np_ready/types';

const getKeys = <T extends {}>(o: T): Array<keyof T> => Object.keys(o) as Array<keyof T>;

Expand Down
Loading

0 comments on commit 297aa7b

Please sign in to comment.