Skip to content

Commit

Permalink
use constant for geo_point and geo_shape, more TS noise
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Mar 2, 2020
1 parent 6ee0c26 commit 09c1502
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface AppState {
* Number of records to be fetched after the anchor records (older records)
*/
successorCount: number;
query: Query;
query?: Query;
}

interface GlobalState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import './discover_field';
import './discover_field_search_directive';
import './discover_index_pattern_directive';
import fieldChooserTemplate from './field_chooser.html';
import { IndexPatternFieldList } from '../../../../../../../../plugins/data/public';
import {
IndexPatternFieldList,
KBN_FIELD_TYPES,
} from '../../../../../../../../plugins/data/public';
import { getMapsAppUrl, isFieldVisualizable, isMapsAppRegistered } from './lib/visualize_url_utils';

export function createFieldChooserDirective($location, config, $route) {
Expand Down Expand Up @@ -187,12 +190,15 @@ export function createFieldChooserDirective($location, config, $route) {
return '';
}

if ((field.type === 'geo_point' || field.type === 'geo_shape') && isMapsAppRegistered()) {
if (
(field.type === KBN_FIELD_TYPES.GEO_POINT || field.type === KBN_FIELD_TYPES.GEO_SHAPE) &&
isMapsAppRegistered()
) {
return getMapsAppUrl(field, $scope.indexPattern, $scope.state, $scope.columns);
}

let agg = {};
const isGeoPoint = field.type === 'geo_point';
const isGeoPoint = field.type === KBN_FIELD_TYPES.GEO_POINT;
const type = isGeoPoint ? 'tile_map' : 'histogram';
// If we're visualizing a date field, and our index is time based (and thus has a time filter),
// then run a date histogram
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
*/
import uuid from 'uuid/v4';
import rison from 'rison-node';
import { IFieldType, IIndexPattern } from 'src/plugins/data/public';
import {
IFieldType,
IIndexPattern,
KBN_FIELD_TYPES,
} from '../../../../../../../../../plugins/data/public';
import { AppState } from '../../../angular/context_state';
import { getServices } from '../../../../kibana_services';

Expand All @@ -40,7 +44,10 @@ export function isMapsAppRegistered() {
}

export function isFieldVisualizable(field: IFieldType) {
if ((field.type === 'geo_point' || field.type === 'geo_shape') && isMapsAppRegistered()) {
if (
(field.type === KBN_FIELD_TYPES.GEO_POINT || field.type === KBN_FIELD_TYPES.GEO_SHAPE) &&
isMapsAppRegistered()
) {
return true;
}
return field.visualizable;
Expand All @@ -65,7 +72,7 @@ export function getMapsAppUrl(
}

// Copy filters and query in app state
const mapsAppState = {
const mapsAppState: object = {
filters: appState.filters || [],
};
if (appState.query) {
Expand Down

0 comments on commit 09c1502

Please sign in to comment.