diff --git a/packages/grafana-data/src/types/logs.ts b/packages/grafana-data/src/types/logs.ts index 947fcc59f44..ad9ef4a5931 100644 --- a/packages/grafana-data/src/types/logs.ts +++ b/packages/grafana-data/src/types/logs.ts @@ -140,9 +140,9 @@ export interface DataSourceWithLogsContextSupport Promise; /** - * 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; }; /** diff --git a/public/app/features/explore/Logs/Logs.tsx b/public/app/features/explore/Logs/Logs.tsx index c57915b5d48..6990b7e34d3 100644 --- a/public/app/features/explore/Logs/Logs.tsx +++ b/public/app/features/explore/Logs/Logs.tsx @@ -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; diff --git a/public/app/features/explore/Logs/LogsContainer.tsx b/public/app/features/explore/Logs/LogsContainer.tsx index 98d1e27aabe..b60a620a4f8 100644 --- a/public/app/features/explore/Logs/LogsContainer.tsx +++ b/public/app/features/explore/Logs/LogsContainer.tsx @@ -206,12 +206,11 @@ class LogsContainer extends PureComponent { - 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) => { diff --git a/public/app/features/logs/components/LogRow.tsx b/public/app/features/logs/components/LogRow.tsx index 3ab307a919c..390cbd04704 100644 --- a/public/app/features/logs/components/LogRow.tsx +++ b/public/app/features/logs/components/LogRow.tsx @@ -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>; - showContextToggle?: (row?: LogRowModel) => boolean; + showContextToggle?: (row: LogRowModel) => boolean; onClickShowField?: (key: string) => void; onClickHideField?: (key: string) => void; onLogRowHover?: (row?: LogRowModel) => void; diff --git a/public/app/features/logs/components/LogRowMenuCell.tsx b/public/app/features/logs/components/LogRowMenuCell.tsx index e57e70be683..4c5f134656b 100644 --- a/public/app/features/logs/components/LogRowMenuCell.tsx +++ b/public/app/features/logs/components/LogRowMenuCell.tsx @@ -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; onPinLine?: (row: LogRowModel) => void; diff --git a/public/app/features/logs/components/LogRowMessage.tsx b/public/app/features/logs/components/LogRowMessage.tsx index 7acca5b782a..fd2cf4a7abe 100644 --- a/public/app/features/logs/components/LogRowMessage.tsx +++ b/public/app/features/logs/components/LogRowMessage.tsx @@ -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; onPinLine?: (row: LogRowModel) => void; diff --git a/public/app/features/logs/components/LogRowMessageDisplayedFields.tsx b/public/app/features/logs/components/LogRowMessageDisplayedFields.tsx index 2bed3bfd60d..2a9d154b1e8 100644 --- a/public/app/features/logs/components/LogRowMessageDisplayedFields.tsx +++ b/public/app/features/logs/components/LogRowMessageDisplayedFields.tsx @@ -13,7 +13,7 @@ export interface Props { wrapLogMessage: boolean; getFieldLinks?: (field: Field, rowIndex: number, dataFrame: DataFrame) => Array>; styles: LogRowStyles; - showContextToggle?: (row?: LogRowModel) => boolean; + showContextToggle?: (row: LogRowModel) => boolean; onOpenContext: (row: LogRowModel) => void; onPermalinkClick?: (row: LogRowModel) => Promise; onPinLine?: (row: LogRowModel) => void; diff --git a/public/app/features/logs/components/LogRows.tsx b/public/app/features/logs/components/LogRows.tsx index 7476e73f290..2b9c8d9e49e 100644 --- a/public/app/features/logs/components/LogRows.tsx +++ b/public/app/features/logs/components/LogRows.tsx @@ -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>; diff --git a/public/app/plugins/datasource/cloudwatch/datasource.ts b/public/app/plugins/datasource/cloudwatch/datasource.ts index 787b24d596d..49091013a73 100644 --- a/public/app/plugins/datasource/cloudwatch/datasource.ts +++ b/public/app/plugins/datasource/cloudwatch/datasource.ts @@ -156,10 +156,6 @@ export class CloudWatchDatasource ); } - showContextToggle() { - return true; - } - getQueryDisplayText(query: CloudWatchQuery) { if (isCloudWatchLogsQuery(query)) { return query.expression ?? ''; diff --git a/public/app/plugins/datasource/elasticsearch/datasource.ts b/public/app/plugins/datasource/elasticsearch/datasource.ts index deb2319f8fe..307329311b7 100644 --- a/public/app/plugins/datasource/elasticsearch/datasource.ts +++ b/public/app/plugins/datasource/elasticsearch/datasource.ts @@ -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) { diff --git a/public/app/plugins/datasource/loki/datasource.test.ts b/public/app/plugins/datasource/loki/datasource.test.ts index 20048a76d29..6a729aa41a0 100644 --- a/public/app/plugins/datasource/loki/datasource.test.ts +++ b/public/app/plugins/datasource/loki/datasource.test.ts @@ -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(() => { diff --git a/public/app/plugins/datasource/loki/datasource.ts b/public/app/plugins/datasource/loki/datasource.ts index d6a9959d4c9..3b900130915 100644 --- a/public/app/plugins/datasource/loki/datasource.ts +++ b/public/app/plugins/datasource/loki/datasource.ts @@ -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);