Skip to content

Commit

Permalink
Move vis registration to NP
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Apr 17, 2020
1 parent 75fa8b3 commit 2c537ce
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 51 deletions.
1 change: 0 additions & 1 deletion x-pack/legacy/plugins/maps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export function maps(kibana) {
},
mappings,
migrations,
hacks: ['plugins/maps/register_vis_type_alias'],
},
config(Joi) {
return Joi.object({
Expand Down
49 changes: 0 additions & 49 deletions x-pack/legacy/plugins/maps/public/register_vis_type_alias.js

This file was deleted.

3 changes: 2 additions & 1 deletion x-pack/plugins/maps/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"data",
"fileUpload",
"uiActions",
"navigation"
"navigation",
"visualizations"
],
"ui": true
}
46 changes: 46 additions & 0 deletions x-pack/plugins/maps/public/maps_vis_type_alias.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.
*/

import { i18n } from '@kbn/i18n';
import { APP_ID, APP_ICON, MAP_BASE_URL } from '../../../legacy/plugins/maps/common/constants';
import {
getInjectedVarFunc,
getVisualizations,
} from './kibana_services';

export function getMapsVisTypeAlias() {
const showMapVisualizationTypes = getInjectedVarFunc()('showMapVisualizationTypes', false);
if (!showMapVisualizationTypes) {
getVisualizations().hideTypes(['region_map', 'tile_map']);
}

const description = i18n.translate('xpack.maps.visTypeAlias.description', {
defaultMessage: 'Create and style maps with multiple layers and indices.',
});

const legacyMapVisualizationWarning = i18n.translate(
'xpack.maps.visTypeAlias.legacyMapVizWarning',
{
defaultMessage: `Use the Maps app instead of Coordinate Map and Region Map.
The Maps app offers more functionality and is easier to use.`,
}
);

return ({
aliasUrl: MAP_BASE_URL,
name: APP_ID,
title: i18n.translate('xpack.maps.visTypeAlias.title', {
defaultMessage: 'Maps',
}),
description: showMapVisualizationTypes
? `${description} ${legacyMapVisualizationWarning}`
: description,
icon: APP_ICON,
stage: 'production',
});

}

2 changes: 2 additions & 0 deletions x-pack/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
// @ts-ignore
} from './kibana_services';
import { featureCatalogueEntry } from './feature_catalogue_entry';
import { getMapsVisTypeAlias } from './maps_vis_type_alias';

export interface MapsPluginSetupDependencies {
inspector: InspectorSetupContract;
Expand Down Expand Up @@ -97,6 +98,7 @@ export class MapsPlugin

plugins.inspector.registerView(MapView);
plugins.home.featureCatalogue.register(featureCatalogueEntry);
plugins.visualizations.registerAlias(getMapsVisTypeAlias());
}

public start(core: CoreStart, plugins: any) {
Expand Down

0 comments on commit 2c537ce

Please sign in to comment.