[Vega] Maps still experimental (#79114)

* [Vega] Maps still experimental

* fix TS issues

* cleanup

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Alexey Antonov 2020-10-05 12:29:51 +03:00 committed by GitHub
parent 1e9135c0e5
commit 4db22034d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 81 additions and 7 deletions

View file

@ -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

View file

@ -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:

View file

@ -33,7 +33,7 @@ export function createTileMapTypeDefinition(dependencies) {
return {
name: 'tile_map',
getDeprecationMessage,
getInfoMessage: getDeprecationMessage,
title: i18n.translate('tileMap.vis.mapTitle', {
defaultMessage: 'Coordinate Map',
}),

View file

@ -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;
};

View file

@ -29,6 +29,8 @@ 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);
@ -36,6 +38,7 @@ export const createVegaTypeDefinition = (dependencies: VegaVisualizationDependen
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',

View file

@ -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 {
@ -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) {
@ -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() {

View file

@ -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>