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

visualize embeddable to visualizations plugin #54840

Merged
merged 9 commits into from
Jan 15, 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
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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You seem to now be missing the import of this index file from inside the legacy folder. So the styles won't be compiled.

// 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({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kertal Changes how this works in this PR and it looks like it will make this logic unnecessary: #54155

@ppisljar Can you wait with your PR till that one is merged? This PR introduces managementRegistry and uiModules in this file which I would like to avoid because Matthias' PR will get rid of it anyway.

Copy link
Member Author

@ppisljar ppisljar Jan 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems that PR is reviewed and just waiting for 7.6 branch ?
i am fine with it merging first, this will probably anyway take another day to review

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it happens the other way around (and this is ready first) i also don't think it should be a problem, either @kertal removes the uiModules and managementRegistry from this file, or i can do it in followup

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, please leave a TODO comment to document it somewhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better than a comment would be to pass in uiModules and managementRegistry as a __LEGACY plugin dependency, just to follow the convention of shimmed plugins.

Copy link
Member

@kertal kertal Jan 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved #54155 to 7.7, it's no problem to wait until this is merged in

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