-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Maps] convert tooltip classes to typescript #59589
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e3056bc
getting started
nreese 772e97a
fix ts lint errors
nreese a1bfa25
TS es_tooltip_property
nreese e9eddb4
merge with master
nreese 49ad1ac
convert ESAggTooltipProperty to TS
nreese 468994d
final clean up
nreese 2467231
ts lint cleanup
nreese a555ea0
Merge branch 'master' into ts_tooltips
elasticmachine 302f62c
Merge branch 'master' into ts_tooltips
elasticmachine 4ae08a7
review feedback
nreese 5293241
remove unused import
nreese 49d155f
Merge branch 'master' into ts_tooltips
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* 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 { IESTermSource } from '../sources/es_term_source'; | ||
|
||
export interface IJoin { | ||
getRightJoinSource(): IESTermSource; | ||
} |
12 changes: 12 additions & 0 deletions
12
x-pack/legacy/plugins/maps/public/layers/sources/es_term_source.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* 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 { IField } from '../fields/field'; | ||
import { IESAggSource } from './es_agg_source'; | ||
|
||
export interface IESTermSource extends IESAggSource { | ||
getTermField(): IField; | ||
} |
12 changes: 12 additions & 0 deletions
12
x-pack/legacy/plugins/maps/public/layers/tooltips/es_agg_tooltip_property.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* 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 { ESTooltipProperty } from './es_tooltip_property'; | ||
|
||
export class ESAggTooltipProperty extends ESTooltipProperty { | ||
isFilterable(): boolean { | ||
return false; | ||
} | ||
} |
40 changes: 0 additions & 40 deletions
40
x-pack/legacy/plugins/maps/public/layers/tooltips/es_aggmetric_tooltip_property.js
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
x-pack/legacy/plugins/maps/public/layers/tooltips/es_tooltip_property.js
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
x-pack/legacy/plugins/maps/public/layers/tooltips/es_tooltip_property.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* 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 _ from 'lodash'; | ||
import { ITooltipProperty } from './tooltip_property'; | ||
import { IField } from '../fields/field'; | ||
import { esFilters, IFieldType, IndexPattern } from '../../../../../../../src/plugins/data/public'; | ||
import { PhraseFilter } from '../../../../../../../src/plugins/data/public'; | ||
|
||
export class ESTooltipProperty implements ITooltipProperty { | ||
private readonly _tooltipProperty: ITooltipProperty; | ||
private readonly _indexPattern: IndexPattern; | ||
private readonly _field: IField; | ||
|
||
constructor(tooltipProperty: ITooltipProperty, indexPattern: IndexPattern, field: IField) { | ||
this._tooltipProperty = tooltipProperty; | ||
this._indexPattern = indexPattern; | ||
this._field = field; | ||
} | ||
|
||
getPropertyKey(): string { | ||
return this._tooltipProperty.getPropertyKey(); | ||
} | ||
|
||
getPropertyName(): string { | ||
return this._tooltipProperty.getPropertyName(); | ||
} | ||
|
||
getRawValue(): string | undefined { | ||
return this._tooltipProperty.getRawValue(); | ||
} | ||
|
||
_getIndexPatternField(): IFieldType | undefined { | ||
return this._indexPattern.fields.getByName(this._field.getRootName()); | ||
} | ||
|
||
getHtmlDisplayValue(): string { | ||
if (typeof this.getRawValue() === 'undefined') { | ||
return '-'; | ||
} | ||
|
||
const indexPatternField = this._getIndexPatternField(); | ||
if (!indexPatternField || !this._field.canValueBeFormatted()) { | ||
return _.escape(this.getRawValue()); | ||
} | ||
|
||
const htmlConverter = indexPatternField.format.getConverterFor('html'); | ||
return htmlConverter | ||
? htmlConverter(this.getRawValue()) | ||
: indexPatternField.format.convert(this.getRawValue()); | ||
} | ||
|
||
isFilterable(): boolean { | ||
const indexPatternField = this._getIndexPatternField(); | ||
return ( | ||
!!indexPatternField && | ||
(indexPatternField.type === 'string' || | ||
indexPatternField.type === 'date' || | ||
indexPatternField.type === 'ip' || | ||
indexPatternField.type === 'number') | ||
); | ||
} | ||
|
||
async getESFilters(): Promise<PhraseFilter[]> { | ||
const indexPatternField = this._getIndexPatternField(); | ||
if (!indexPatternField) { | ||
return []; | ||
} | ||
|
||
return [esFilters.buildPhraseFilter(indexPatternField, this.getRawValue(), this._indexPattern)]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
x-pack/legacy/plugins/maps/public/layers/tooltips/tooltip_property.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imho use declaration file like everywhere else. so either rename to
inner_join.d.ts
or rename the others tojoin.js
andjoin.test.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the interface description should be in a file called
join.ts
. The interface is for join, not the implementation that we have. I would like to leave as is.