mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
Logs: Deprecated showContextToggle
in DataSourceWithLogsContextSupport (#77232)
* Logs: deprecate showContextToggle * Logs: make row mandatory on showContextToggle prop * DataSourceWithLogsContextSupport: make showContextToggle optional * Loki: update test * Update packages/grafana-data/src/types/logs.ts Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> * Prettier * showContextToggle: update deprecation --------- Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
This commit is contained in:
parent
23c0054ecc
commit
d7c50eb650
@ -140,9 +140,9 @@ export interface DataSourceWithLogsContextSupport<TQuery extends DataQuery = Dat
|
||||
getLogRowContextQuery?: (row: LogRowModel, options?: LogRowContextOptions, query?: TQuery) => Promise<TQuery | null>;
|
||||
|
||||
/**
|
||||
* This method can be used to show "context" button based on runtime conditions (for example row model data or plugin settings, etc.)
|
||||
* @deprecated Deprecated since 10.3. To display the context option and support the feature implement DataSourceWithLogsContextSupport interface instead.
|
||||
*/
|
||||
showContextToggle(row?: LogRowModel): boolean;
|
||||
showContextToggle?(row?: LogRowModel): boolean;
|
||||
|
||||
/**
|
||||
* This method can be used to display a custom UI in the context view.
|
||||
@ -157,7 +157,7 @@ export const hasLogsContextSupport = (datasource: unknown): datasource is DataSo
|
||||
return false;
|
||||
}
|
||||
|
||||
return 'getLogRowContext' in datasource && 'showContextToggle' in datasource;
|
||||
return 'getLogRowContext' in datasource;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ interface Props extends Themeable2 {
|
||||
logsVolumeData: DataQueryResponse | undefined;
|
||||
onSetLogsVolumeEnabled: (enabled: boolean) => void;
|
||||
loadLogsVolumeData: () => void;
|
||||
showContextToggle?: (row?: LogRowModel) => boolean;
|
||||
showContextToggle?: (row: LogRowModel) => boolean;
|
||||
onChangeTime: (range: AbsoluteTimeRange) => void;
|
||||
onClickFilterLabel?: (key: string, value: string, refId?: string) => void;
|
||||
onClickFilterOutLabel?: (key: string, value: string, refId?: string) => void;
|
||||
|
@ -206,12 +206,11 @@ class LogsContainer extends PureComponent<LogsContainerProps, LogsContainerState
|
||||
};
|
||||
|
||||
showContextToggle = (row?: LogRowModel): boolean => {
|
||||
if (!row || !row.dataFrame.refId || !this.state.logContextSupport[row.dataFrame.refId]) {
|
||||
if (!row?.dataFrame.refId || !this.state.logContextSupport[row.dataFrame.refId]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const ds = this.state.logContextSupport[row.dataFrame.refId];
|
||||
return ds.showContextToggle(row);
|
||||
return true;
|
||||
};
|
||||
|
||||
getFieldLinks = (field: Field, rowIndex: number, dataFrame: DataFrame) => {
|
||||
|
@ -33,7 +33,7 @@ interface Props extends Themeable2 {
|
||||
onClickFilterOutLabel?: (key: string, value: string, refId?: string) => void;
|
||||
onContextClick?: () => void;
|
||||
getFieldLinks?: (field: Field, rowIndex: number, dataFrame: DataFrame) => Array<LinkModel<Field>>;
|
||||
showContextToggle?: (row?: LogRowModel) => boolean;
|
||||
showContextToggle?: (row: LogRowModel) => boolean;
|
||||
onClickShowField?: (key: string) => void;
|
||||
onClickHideField?: (key: string) => void;
|
||||
onLogRowHover?: (row?: LogRowModel) => void;
|
||||
|
@ -8,7 +8,7 @@ import { LogRowStyles } from './getLogRowStyles';
|
||||
interface Props {
|
||||
logText: string;
|
||||
row: LogRowModel;
|
||||
showContextToggle?: (row?: LogRowModel) => boolean;
|
||||
showContextToggle?: (row: LogRowModel) => boolean;
|
||||
onOpenContext: (row: LogRowModel) => void;
|
||||
onPermalinkClick?: (row: LogRowModel) => Promise<void>;
|
||||
onPinLine?: (row: LogRowModel) => void;
|
||||
|
@ -14,7 +14,7 @@ interface Props {
|
||||
wrapLogMessage: boolean;
|
||||
prettifyLogMessage: boolean;
|
||||
app?: CoreApp;
|
||||
showContextToggle?: (row?: LogRowModel) => boolean;
|
||||
showContextToggle?: (row: LogRowModel) => boolean;
|
||||
onOpenContext: (row: LogRowModel) => void;
|
||||
onPermalinkClick?: (row: LogRowModel) => Promise<void>;
|
||||
onPinLine?: (row: LogRowModel) => void;
|
||||
|
@ -13,7 +13,7 @@ export interface Props {
|
||||
wrapLogMessage: boolean;
|
||||
getFieldLinks?: (field: Field, rowIndex: number, dataFrame: DataFrame) => Array<LinkModel<Field>>;
|
||||
styles: LogRowStyles;
|
||||
showContextToggle?: (row?: LogRowModel) => boolean;
|
||||
showContextToggle?: (row: LogRowModel) => boolean;
|
||||
onOpenContext: (row: LogRowModel) => void;
|
||||
onPermalinkClick?: (row: LogRowModel) => Promise<void>;
|
||||
onPinLine?: (row: LogRowModel) => void;
|
||||
|
@ -38,7 +38,7 @@ export interface Props extends Themeable2 {
|
||||
forceEscape?: boolean;
|
||||
displayedFields?: string[];
|
||||
app?: CoreApp;
|
||||
showContextToggle?: (row?: LogRowModel) => boolean;
|
||||
showContextToggle?: (row: LogRowModel) => boolean;
|
||||
onClickFilterLabel?: (key: string, value: string, refId?: string) => void;
|
||||
onClickFilterOutLabel?: (key: string, value: string, refId?: string) => void;
|
||||
getFieldLinks?: (field: Field, rowIndex: number, dataFrame: DataFrame) => Array<LinkModel<Field>>;
|
||||
|
@ -156,10 +156,6 @@ export class CloudWatchDatasource
|
||||
);
|
||||
}
|
||||
|
||||
showContextToggle() {
|
||||
return true;
|
||||
}
|
||||
|
||||
getQueryDisplayText(query: CloudWatchQuery) {
|
||||
if (isCloudWatchLogsQuery(query)) {
|
||||
return query.expression ?? '';
|
||||
|
@ -501,10 +501,6 @@ export class ElasticDatasource
|
||||
return text;
|
||||
}
|
||||
|
||||
showContextToggle(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
getLogRowContext = async (row: LogRowModel, options?: LogRowContextOptions): Promise<{ data: DataFrame[] }> => {
|
||||
const { enableElasticsearchBackendQuerying } = config.featureToggles;
|
||||
if (enableElasticsearchBackendQuerying) {
|
||||
|
@ -1579,14 +1579,6 @@ describe('Variable support', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('showContextToggle()', () => {
|
||||
it('always displays logs context', () => {
|
||||
const ds = createLokiDatasource(templateSrvStub);
|
||||
|
||||
expect(ds.showContextToggle()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('queryHasFilter()', () => {
|
||||
let ds: LokiDatasource;
|
||||
beforeEach(() => {
|
||||
|
@ -868,10 +868,6 @@ export class LokiDatasource
|
||||
return annotations;
|
||||
}
|
||||
|
||||
showContextToggle(row?: LogRowModel): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
addAdHocFilters(queryExpr: string) {
|
||||
const adhocFilters = this.templateSrv.getAdhocFilters(this.name);
|
||||
let expr = replaceVariables(queryExpr);
|
||||
|
Loading…
Reference in New Issue
Block a user