mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge remote-tracking branch 'grafana/master' into all-data-as-table
* grafana/master: (57 commits) feature(explore/table): Add tooltips to explore table (#16007) Update changelog Add check for Env before log Update index.md chore: Cleaning up implicit anys in manage_dashboard.ts and manage_dashboard.test.ts progress: #14714 chore: Cleaning up implicit anys in app.ts progress: #14714 changelog: adds note about closing #15836 changelog: adds note about closing #6359 and #15931 add partial Add check so that header is not sent for anonymous users Update config docs Add custom header with grafana user and a config switch for it changelog: adds note about closing #10816 use constants for cache type makes variables template prettier complient white space formating changelog: adds note about #15744 updates old distcache names dont allow inifinite expiration return error if cache type is invalid ...
This commit is contained in:
@@ -14,6 +14,7 @@ import { PanelEditor } from '../panel_editor/PanelEditor';
|
||||
import { PanelModel, DashboardModel } from '../state';
|
||||
import { PanelPlugin } from 'app/types';
|
||||
import { PanelResizer } from './PanelResizer';
|
||||
import { PanelTypeChangedHook } from '@grafana/ui';
|
||||
|
||||
export interface Props {
|
||||
panel: PanelModel;
|
||||
@@ -91,7 +92,11 @@ export class DashboardPanel extends PureComponent<Props, State> {
|
||||
|
||||
this.props.panel.changeType(pluginId);
|
||||
} else {
|
||||
panel.changeType(pluginId, plugin.exports.reactPanel.preserveOptions);
|
||||
let hook: PanelTypeChangedHook | null = null;
|
||||
if (plugin.exports.reactPanel) {
|
||||
hook = plugin.exports.reactPanel.panelTypeChangedHook;
|
||||
}
|
||||
panel.changeType(pluginId, hook);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import _ from 'lodash';
|
||||
|
||||
// Types
|
||||
import { Emitter } from 'app/core/utils/emitter';
|
||||
import { DataQuery, TimeSeries, Threshold, ScopedVars } from '@grafana/ui';
|
||||
import { DataQuery, TimeSeries, Threshold, ScopedVars, PanelTypeChangedHook } from '@grafana/ui';
|
||||
import { TableData } from '@grafana/ui/src';
|
||||
|
||||
export interface GridPos {
|
||||
@@ -237,7 +237,7 @@ export class PanelModel {
|
||||
});
|
||||
}
|
||||
|
||||
changeType(pluginId: string, preserveOptions?: any) {
|
||||
changeType(pluginId: string, hook?: PanelTypeChangedHook) {
|
||||
const oldOptions: any = this.getOptionsToRemember();
|
||||
const oldPluginId = this.type;
|
||||
|
||||
@@ -255,9 +255,12 @@ export class PanelModel {
|
||||
this.cachedPluginOptions[oldPluginId] = oldOptions;
|
||||
this.restorePanelOptions(pluginId);
|
||||
|
||||
if (preserveOptions && oldOptions) {
|
||||
// Callback that can validate and migrate any existing settings
|
||||
if (hook) {
|
||||
this.options = this.options || {};
|
||||
Object.assign(this.options, preserveOptions(oldPluginId, oldOptions.options));
|
||||
const old = oldOptions ? oldOptions.options : null;
|
||||
|
||||
Object.assign(this.options, hook(this.options, oldPluginId, old));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,15 @@ export default class Table extends PureComponent<TableProps> {
|
||||
const tableModel = data || EMPTY_TABLE;
|
||||
const columnNames = tableModel.columns.map(({ text }) => text);
|
||||
const columns = tableModel.columns.map(({ filterable, text }) => ({
|
||||
Header: text,
|
||||
Header: () => <span title={text}>{text}</span>,
|
||||
accessor: text,
|
||||
className: VALUE_REGEX.test(text) ? 'text-right' : '',
|
||||
show: text !== 'Time',
|
||||
Cell: row => <span className={filterable ? 'link' : ''}>{row.value}</span>,
|
||||
Cell: row => (
|
||||
<span className={filterable ? 'link' : ''} title={text + ': ' + row.value}>
|
||||
{row.value}
|
||||
</span>
|
||||
),
|
||||
}));
|
||||
const noDataText = data ? 'The queries returned no data for a table.' : '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user