Skip to content

Commit

Permalink
[Vega] Maps still experimental (#79114)
Browse files Browse the repository at this point in the history
* [Vega] Maps still experimental

* fix TS issues

* cleanup

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
alexwizp and kibanamachine authored Oct 5, 2020
1 parent 1e9135c commit 4db2203
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/user/dashboard/vega-reference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For additional *Vega* and *Vega-Lite* information, refer to the reference sectio
* Automatic sizing
* Default theme to match {kib}
* Writing {es} queries using the time range and filters from dashboards
* Using the Elastic Map Service in Vega maps
* experimental[] Using the Elastic Map Service in Vega maps
* Additional tooltip styling
* Advanced setting to enable URL loading from any domain
* Limited debugging support using the browser dev tools
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/region_map/public/region_map_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function createRegionMapTypeDefinition(dependencies) {

return {
name: 'region_map',
getDeprecationMessage,
getInfoMessage: getDeprecationMessage,
title: i18n.translate('regionMap.mapVis.regionMapTitle', { defaultMessage: 'Region Map' }),
description: i18n.translate('regionMap.mapVis.regionMapDescription', {
defaultMessage:
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/tile_map/public/tile_map_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function createTileMapTypeDefinition(dependencies) {

return {
name: 'tile_map',
getDeprecationMessage,
getInfoMessage: getDeprecationMessage,
title: i18n.translate('tileMap.vis.mapTitle', {
defaultMessage: 'Coordinate Map',
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { parse } from 'hjson';
import React from 'react';
import { EuiCallOut, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { Vis } from '../../../visualizations/public';

function ExperimentalMapLayerInfo() {
const title = (
<FormattedMessage
id="visTypeVega.mapView.experimentalMapLayerInfo"
defaultMessage="Map layer is experimental and is not subject to the support SLA of official GA features.
For feedback, please create an issue in {githubLink}."
values={{
githubLink: (
<EuiLink
external
href="https://github.com/elastic/kibana/issues/new/choose"
target="_blank"
>
GitHub
</EuiLink>
),
}}
/>
);

return (
<EuiCallOut
className="hide-for-sharing"
data-test-subj="experimentalMapLayerInfo"
size="s"
title={title}
iconType="beaker"
/>
);
}

export const getInfoMessage = (vis: Vis) => {
if (vis.params.spec) {
try {
const spec = parse(vis.params.spec, { legacyRoot: false, keepWsc: true });

if (spec.config?.kibana?.type === 'map') {
return <ExperimentalMapLayerInfo />;
}
} catch (e) {
// spec is invalid
}
}

return null;
};
3 changes: 3 additions & 0 deletions src/plugins/vis_type_vega/public/vega_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ import { getDefaultSpec } from './default_spec';
import { createInspectorAdapters } from './vega_inspector';
import { VIS_EVENT_TO_TRIGGER } from '../../visualizations/public';

import { getInfoMessage } from './components/experimental_map_vis_info';

export const createVegaTypeDefinition = (dependencies: VegaVisualizationDependencies) => {
const requestHandler = createVegaRequestHandler(dependencies);
const visualization = createVegaVisualization(dependencies);

return {
name: 'vega',
title: 'Vega',
getInfoMessage,
description: i18n.translate('visTypeVega.type.vegaDescription', {
defaultMessage: 'Create custom visualizations using Vega and Vega-Lite',
description: 'Vega and Vega-Lite are product names and should not be translated',
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/visualizations/public/vis_types/base_vis_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface CommonBaseVisTypeOptions {
useCustomNoDataScreen?: boolean;
inspectorAdapters?: Adapters | (() => Adapters);
isDeprecated?: boolean;
getDeprecationMessage?: (vis: Vis) => ReactElement<{}>;
getInfoMessage?: (vis: Vis) => ReactElement<{}> | null;
}

interface ExpressionBaseVisTypeOptions<TVisParams> extends CommonBaseVisTypeOptions {
Expand Down Expand Up @@ -84,7 +84,7 @@ export class BaseVisType<TVisParams = VisParams> {
useCustomNoDataScreen: boolean;
inspectorAdapters?: Adapters | (() => Adapters);
toExpressionAst?: VisToExpressionAst<TVisParams>;
getDeprecationMessage?: (vis: Vis) => ReactElement<{}>;
getInfoMessage?: (vis: Vis) => ReactElement<{}> | null;

constructor(opts: BaseVisTypeOptions<TVisParams>) {
if (!opts.icon && !opts.image) {
Expand Down Expand Up @@ -122,7 +122,7 @@ export class BaseVisType<TVisParams = VisParams> {
this.useCustomNoDataScreen = opts.useCustomNoDataScreen || false;
this.inspectorAdapters = opts.inspectorAdapters;
this.toExpressionAst = opts.toExpressionAst;
this.getDeprecationMessage = opts.getDeprecationMessage;
this.getInfoMessage = opts.getInfoMessage;
}

public get schemas() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const VisualizeEditorCommon = ({
/>
)}
{visInstance?.vis?.type?.isExperimental && <ExperimentalVisInfo />}
{visInstance?.vis?.type?.getDeprecationMessage?.(visInstance.vis)}
{visInstance?.vis?.type?.getInfoMessage?.(visInstance.vis)}
{visInstance && (
<EuiScreenReaderOnly>
<h1>
Expand Down

0 comments on commit 4db2203

Please sign in to comment.