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

Add deprecated message to tile_map and region_map visualizations. #77683

Merged
merged 31 commits into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a3946de
Add deprecation message to coordinate map and region map
nreese Sep 14, 2020
bbf755f
clean up text
nreese Sep 15, 2020
1e672ad
Merge branch 'master' of github.com:elastic/kibana into deprecation_m…
nreese Sep 16, 2020
1b5a900
add default distro link and view in maps link
nreese Sep 16, 2020
7571e3d
move url generation into onClick handler
nreese Sep 16, 2020
7ab105b
create tile map layer descritor
nreese Sep 16, 2020
a18083c
set metrics and color and scaling
nreese Sep 17, 2020
820acb3
lazy load createTileMapLayerDescriptor
nreese Sep 17, 2020
c9fa756
tslint fixes
nreese Sep 17, 2020
45d587b
tslint cleanup for OSS code
nreese Sep 18, 2020
4ba5d75
add region map deprecation message
nreese Sep 18, 2020
1183845
tslint cleanup
nreese Sep 18, 2020
df9bb6a
consolidate logic into LegacyMapDeprecationMessage
nreese Sep 18, 2020
2b081d7
Merge branch 'master' into deprecation_message
elasticmachine Sep 18, 2020
a75891a
fix jest test
nreese Sep 18, 2020
5e6d7cc
fix tile-map and region_map in OSS distro
nreese Sep 20, 2020
7a05652
tslint fixes
nreese Sep 20, 2020
d201e98
assert urlGenerator exists
nreese Sep 20, 2020
381dbd3
Merge branch 'master' into deprecation_message
elasticmachine Sep 21, 2020
bb55c87
update message text
nreese Sep 21, 2020
619751c
Merge branch 'deprecation_message' of github.com:nreese/kibana into d…
nreese Sep 21, 2020
faa2381
Merge branch 'master' into deprecation_message
elasticmachine Sep 23, 2020
8728dca
ensure legacy-ids get correctly evaluated (#37)
thomasneirynck Sep 23, 2020
e7ce0e0
handle 6.x region map saved objects
nreese Sep 23, 2020
d8dcbb4
Merge branch 'master' into deprecation_message
elasticmachine Sep 24, 2020
c7b4611
Merge branch 'master' into deprecation_message
elasticmachine Sep 24, 2020
83d5b45
Merge branch 'master' into deprecation_message
elasticmachine Sep 25, 2020
18af546
merge with master
nreese Sep 28, 2020
030986b
turn off field meta
nreese Sep 28, 2020
a17b91e
fix type
nreese Sep 28, 2020
30f0772
merge with master
nreese Sep 28, 2020
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
3 changes: 2 additions & 1 deletion src/plugins/tile_map/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"expressions",
"mapsLegacy",
"kibanaLegacy",
"data"
"data",
"share"
],
"requiredBundles": [
"kibanaUtils",
Expand Down
114 changes: 114 additions & 0 deletions src/plugins/tile_map/public/get_deprecation_message.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* 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 React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiButton, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { getCoreService, getQueryService, getShareService } from './services';
import { indexPatterns } from '../../data/public';

export function getDeprecationMessage(vis: Vis) {
const mapsTileMapUrlGenerator = getShareService().urlGenerators.getUrlGenerator(
'MAPS_APP_TILE_MAP_URL_GENERATOR'
);

let action;
if (!mapsTileMapUrlGenerator) {
action = (
<FormattedMessage
id="tileMap.vis.defaultDistributionMessage"
defaultMessage="To get Maps, upgrade to the {defaultDistribution} of Elasticsearch and Kibana."
values={{
defaultDistribution: (
<EuiLink
color="accent"
external
href="https://www.elastic.co/downloads/kibana"
target="_blank"
>
default distribution
</EuiLink>
),
}}
/>
);
} else {
action = (
<div>
<EuiButton
onClick={async (e) => {
e.preventDefault();

let geoFieldName: string;
const bucketAggs = vis.data?.aggs.byType('buckets');
if (bucketAggs.length && bucketAggs[0].type.dslName === 'geohash_grid') {
geoFieldName = bucketAggs[0].getField()?.name;
} else {
// attempt to default to first geo point field when geohash is not configured yet
const geoField = vis.data.indexPattern.fields.find((field) => {
return (
!indexPatterns.isNestedField(field) &&
field.aggregatable &&
field.type === 'geo_point'
);
});
if (geoField) {
geoFieldName = geoField.name;
}
}

let metricAgg: string = 'count';
let metricFieldName: string;
const metricAggs = vis.data?.aggs.byType('metrics');
if (metricAggs.length) {
metricAgg = metricAggs[0].type.dslName;
metricFieldName = metricAggs[0].getField()?.name;
}

const query = getQueryService();
const url = await mapsTileMapUrlGenerator.createUrl({
title: vis.title,
mapType: vis.params.mapType,
indexPatternId: vis.data.indexPattern.id,
geoFieldName,
metricAgg,
metricFieldName,
filters: query.filterManager.getFilters(),
query: query.queryString.getQuery(),
timeRange: query.timefilter.timefilter.getTime(),
});
getCoreService().application.navigateToUrl(url);
}}
size="s"
>
<FormattedMessage id="tileMap.vis.viewInMaps" defaultMessage="View in Maps" />
</EuiButton>
</div>
);
}

return (
<FormattedMessage
id="tileMap.vis.deprecationMessage"
defaultMessage="Coordinate map will migrate to Maps in 8.0. With Maps, you can add multiple layers and indices, plot individual documents, symbolize features from data values, and more. {action}"
values={{ action }}
/>
);
}
20 changes: 15 additions & 5 deletions src/plugins/tile_map/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ import { createTileMapFn } from './tile_map_fn';
import { createTileMapTypeDefinition } from './tile_map_type';
import { IServiceSettings, MapsLegacyPluginSetup } from '../../maps_legacy/public';
import { DataPublicPluginStart } from '../../data/public';
import { setFormatService, setQueryService, setKibanaLegacy } from './services';
import {
setCoreService,
setFormatService,
setQueryService,
setKibanaLegacy,
setShareService,
} from './services';
import { KibanaLegacyStart } from '../../kibana_legacy/public';
import { SharePluginSetup, SharePluginStart } from '../../share/public';

export interface TileMapConfigType {
tilemap: any;
Expand All @@ -61,6 +68,7 @@ export interface TileMapPluginSetupDependencies {
export interface TileMapPluginStartDependencies {
data: DataPublicPluginStart;
kibanaLegacy: KibanaLegacyStart;
share: SharePluginStart;
}

export interface TileMapPluginSetup {
Expand Down Expand Up @@ -100,10 +108,12 @@ export class TileMapPlugin implements Plugin<TileMapPluginSetup, TileMapPluginSt
};
}

public start(core: CoreStart, { data, kibanaLegacy }: TileMapPluginStartDependencies) {
setFormatService(data.fieldFormats);
setQueryService(data.query);
setKibanaLegacy(kibanaLegacy);
public start(core: CoreStart, plugins: TileMapPluginStartDependencies) {
setFormatService(plugins.data.fieldFormats);
setQueryService(plugins.data.query);
setKibanaLegacy(plugins.kibanaLegacy);
setShareService(plugins.share);
setCoreService(core);
return {};
}
}
6 changes: 6 additions & 0 deletions src/plugins/tile_map/public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
* under the License.
*/

import { CoreStart } from 'kibana/public';
import { createGetterSetter } from '../../kibana_utils/public';
import { DataPublicPluginStart } from '../../data/public';
import { KibanaLegacyStart } from '../../kibana_legacy/public';
import { SharePluginSetup, SharePluginStart } from '../../share/public';

export const [getCoreService, setCoreService] = createGetterSetter<CoreStart>('Core');

export const [getFormatService, setFormatService] = createGetterSetter<
DataPublicPluginStart['fieldFormats']
Expand All @@ -29,6 +33,8 @@ export const [getQueryService, setQueryService] = createGetterSetter<
DataPublicPluginStart['query']
>('Query');

export const [getShareService, setShareService] = createGetterSetter<SharePluginSetup>('Share');

export const [getKibanaLegacy, setKibanaLegacy] = createGetterSetter<KibanaLegacyStart>(
'KibanaLegacy'
);
3 changes: 3 additions & 0 deletions src/plugins/tile_map/public/tile_map_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ import { createTileMapVisualization } from './tile_map_visualization';
import { TileMapOptions } from './components/tile_map_options';
import { supportsCssFilters } from './css_filters';
import { truncatedColorSchemas } from '../../charts/public';
import { getDeprecationMessage } from './get_deprecation_message';

export function createTileMapTypeDefinition(dependencies) {
const CoordinateMapsVisualization = createTileMapVisualization(dependencies);
const { uiSettings, serviceSettings } = dependencies;

return {
name: 'tile_map',
isDeprecated: true,
getDeprecationMessage,
title: i18n.translate('tileMap.vis.mapTitle', {
defaultMessage: 'Coordinate Map',
}),
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/visualizations/public/vis_types/base_vis_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import _ from 'lodash';
import { ReactElement } from 'react';
import { VisToExpressionAst, VisualizationControllerConstructor } from '../types';
import { TriggerContextMapping } from '../../../ui_actions/public';
import { Adapters } from '../../../inspector/public';
Expand All @@ -43,6 +44,8 @@ export interface BaseVisTypeOptions {
useCustomNoDataScreen?: boolean;
inspectorAdapters?: Adapters | (() => Adapters);
toExpressionAst?: VisToExpressionAst;
isDeprecated?: boolean;
getDeprecationMessage?: (vis: Vis) => ReactElement<any>;
}

export class BaseVisType {
Expand All @@ -68,6 +71,8 @@ export class BaseVisType {
useCustomNoDataScreen: boolean;
inspectorAdapters?: Adapters | (() => Adapters);
toExpressionAst?: VisToExpressionAst;
isDeprecated: boolean;
getDeprecationMessage?: (vis: Vis) => ReactElement<any>;

constructor(opts: BaseVisTypeOptions) {
if (!opts.icon && !opts.image) {
Expand Down Expand Up @@ -105,6 +110,8 @@ export class BaseVisType {
this.useCustomNoDataScreen = opts.useCustomNoDataScreen || false;
this.inspectorAdapters = opts.inspectorAdapters;
this.toExpressionAst = opts.toExpressionAst;
this.isDeprecated = opts.isDeprecated || false;
this.getDeprecationMessage = opts.getDeprecationMessage;
}

public get schemas() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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 React, { ReactElement } from 'react';
import { EuiCallOut } from '@elastic/eui';

export function DeprecatedVisInfo({ message }: ReactElement<any>) {
return (
<EuiCallOut
className="hide-for-sharing"
data-test-subj="deprecatedVisInfo"
size="s"
title={message}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { EuiScreenReaderOnly } from '@elastic/eui';
import { VisualizeTopNav } from './visualize_top_nav';
import { ExperimentalVisInfo } from './experimental_vis_info';
import { DeprecatedVisInfo } from './deprecated_vis_info';
import {
SavedVisInstance,
VisualizeAppState,
Expand Down Expand Up @@ -79,6 +80,9 @@ export const VisualizeEditorCommon = ({
/>
)}
{visInstance?.vis?.type?.isExperimental && <ExperimentalVisInfo />}
{visInstance?.vis?.type?.isDeprecated && visInstance?.vis?.type?.getDeprecationMessage && (
<DeprecatedVisInfo message={visInstance.vis.type.getDeprecationMessage(visInstance?.vis)} />
)}
{visInstance && (
<EuiScreenReaderOnly>
<h1>
Expand Down
Loading