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

[7.x] TypeScript cleanup in visualizations plugin (#78428) | Implement tagcloud renderer (#77910) | Fix types (#78619) #78666

Merged
merged 4 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@

import { i18n } from '@kbn/i18n';

import { BaseVisTypeOptions } from 'src/plugins/visualizations/public';
import { createInputControlVisController } from './vis_controller';
import { getControlsTab } from './components/editor/controls_tab';
import { OptionsTab } from './components/editor/options_tab';
import { InputControlVisDependencies } from './plugin';

export function createInputControlVisTypeDefinition(deps: InputControlVisDependencies) {
export function createInputControlVisTypeDefinition(
deps: InputControlVisDependencies
): BaseVisTypeOptions {
const InputControlVisController = createInputControlVisController(deps);
const ControlsTab = getControlsTab(deps);

Expand Down
12 changes: 6 additions & 6 deletions src/plugins/input_control_vis/public/vis_controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import { RangeControl } from './control/range_control_factory';
import { ListControl } from './control/list_control_factory';
import { InputControlVisDependencies } from './plugin';
import { FilterManager, Filter } from '../../data/public';
import { VisParams, Vis } from '../../visualizations/public';
import { VisParams, ExprVis } from '../../visualizations/public';

export const createInputControlVisController = (deps: InputControlVisDependencies) => {
return class InputControlVisController {
private I18nContext?: I18nStart['Context'];
private isLoaded = false;
private _isLoaded = false;

controls: Array<RangeControl | ListControl>;
queryBarUpdateHandler: () => void;
Expand All @@ -45,7 +45,7 @@ export const createInputControlVisController = (deps: InputControlVisDependencie
timeFilterSubscription: Subscription;
visParams?: VisParams;

constructor(public el: Element, public vis: Vis) {
constructor(public el: Element, public vis: ExprVis) {
this.controls = [];

this.queryBarUpdateHandler = this.updateControlsFromKbn.bind(this);
Expand All @@ -58,7 +58,7 @@ export const createInputControlVisController = (deps: InputControlVisDependencie
.getTimeUpdate$()
.subscribe(() => {
if (this.visParams?.useTimeFilter) {
this.isLoaded = false;
this._isLoaded = false;
}
});
}
Expand All @@ -68,11 +68,11 @@ export const createInputControlVisController = (deps: InputControlVisDependencie
const [{ i18n }] = await deps.core.getStartServices();
this.I18nContext = i18n.Context;
}
if (!this.isLoaded || !isEqual(visParams, this.visParams)) {
if (!this._isLoaded || !isEqual(visParams, this.visParams)) {
this.visParams = visParams;
this.controls = [];
this.controls = await this.initControls();
this.isLoaded = true;
this._isLoaded = true;
}
this.drawVis();
}
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/vis_type_metric/public/metric_vis_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
*/

import { i18n } from '@kbn/i18n';
import { BaseVisTypeOptions } from 'src/plugins/visualizations/public';
import { MetricVisOptions } from './components/metric_vis_options';
import { ColorSchemas, colorSchemas, ColorModes } from '../../charts/public';
import { AggGroupNames } from '../../data/public';
import { Schemas } from '../../vis_default_editor/public';
import { toExpressionAst } from './to_ast';

export const createMetricVisTypeDefinition = () => ({
export const createMetricVisTypeDefinition = (): BaseVisTypeOptions => ({
name: 'metric',
title: i18n.translate('visTypeMetric.metricTitle', { defaultMessage: 'Metric' }),
icon: 'visMetric',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('Table Vis - Controller', () => {
function getRangeVis(params?: object) {
return ({
type: tableVisTypeDefinition,
params: Object.assign({}, tableVisTypeDefinition.visConfig.defaults, params),
params: Object.assign({}, tableVisTypeDefinition.visConfig?.defaults, params),
data: {
aggs: createAggConfigs(stubIndexPattern, [
{ type: 'count', schema: 'metric' },
Expand Down
8 changes: 5 additions & 3 deletions src/plugins/vis_type_table/public/table_vis_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ import { CoreSetup, PluginInitializerContext } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { AggGroupNames } from '../../data/public';
import { Schemas } from '../../vis_default_editor/public';
import { Vis } from '../../visualizations/public';
import { BaseVisTypeOptions, Vis } from '../../visualizations/public';
import { tableVisResponseHandler } from './table_vis_response_handler';
// @ts-ignore
import tableVisTemplate from './table_vis.html';
import { TableOptions } from './components/table_vis_options_lazy';
import { getTableVisualizationControllerClass } from './vis_controller';
import { VIS_EVENT_TO_TRIGGER } from '../../../plugins/visualizations/public';

export function getTableVisTypeDefinition(core: CoreSetup, context: PluginInitializerContext) {
export function getTableVisTypeDefinition(
core: CoreSetup,
context: PluginInitializerContext
): BaseVisTypeOptions {
return {
type: 'table',
name: 'table',
title: i18n.translate('visTypeTable.tableVisTitle', {
defaultMessage: 'Data Table',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vis_type_table/public/vis_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function getTableVisualizationControllerClass(
}
}

async render(esResponse: object, visParams: VisParams) {
async render(esResponse: object, visParams: VisParams): Promise<void> {
getKibanaLegacy().loadFontAwesome();
await this.initLocalAngular();

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

171 changes: 171 additions & 0 deletions src/plugins/vis_type_tagcloud/public/__snapshots__/to_ast.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 0 additions & 14 deletions src/plugins/vis_type_tagcloud/public/_tag_cloud.scss

This file was deleted.

2 changes: 1 addition & 1 deletion src/plugins/vis_type_tagcloud/public/components/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Label extends Component {
render() {
return (
<div
className="tgcVisLabel"
className="tgcChart__label"
style={{ display: this.state.shouldShowLabel ? 'block' : 'none' }}
>
{this.state.label}
Expand Down
26 changes: 26 additions & 0 deletions src/plugins/vis_type_tagcloud/public/components/tag_cloud.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Prefix all styles with "tgc" to avoid conflicts.
// Examples
// tgcChart
// tgcChart__legend
// tgcChart__legend--small
// tgcChart__legend-isLoading

.tgcChart__container, .tgcChart__wrapper {
flex: 1 1 0;
display: flex;
}

.tgcChart {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
}

.tgcChart__label {
width: 100%;
text-align: center;
font-weight: $euiFontWeightBold;
}
Loading