mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Renamed initialQueries to queries
This commit is contained in:
parent
f74ebdade6
commit
2c255fd85a
@ -56,7 +56,7 @@ export interface QueryEditorProps<DSType extends DataSourceApi, TQuery extends D
|
|||||||
|
|
||||||
export interface ExploreQueryFieldProps<DSType extends DataSourceApi, TQuery extends DataQuery> {
|
export interface ExploreQueryFieldProps<DSType extends DataSourceApi, TQuery extends DataQuery> {
|
||||||
datasource: DSType;
|
datasource: DSType;
|
||||||
initialQuery: TQuery;
|
query: TQuery;
|
||||||
error?: string | JSX.Element;
|
error?: string | JSX.Element;
|
||||||
hint?: QueryHint;
|
hint?: QueryHint;
|
||||||
history: any[];
|
history: any[];
|
||||||
|
@ -35,7 +35,7 @@ interface QueryRowProps {
|
|||||||
highlightLogsExpressionAction: typeof highlightLogsExpressionAction;
|
highlightLogsExpressionAction: typeof highlightLogsExpressionAction;
|
||||||
history: HistoryItem[];
|
history: HistoryItem[];
|
||||||
index: number;
|
index: number;
|
||||||
initialQuery: DataQuery;
|
query: DataQuery;
|
||||||
modifyQueries: typeof modifyQueries;
|
modifyQueries: typeof modifyQueries;
|
||||||
queryTransactions: QueryTransaction[];
|
queryTransactions: QueryTransaction[];
|
||||||
exploreEvents: Emitter;
|
exploreEvents: Emitter;
|
||||||
@ -95,7 +95,7 @@ export class QueryRow extends PureComponent<QueryRowProps> {
|
|||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { datasourceInstance, history, index, initialQuery, queryTransactions, exploreEvents, range } = this.props;
|
const { datasourceInstance, history, index, query, queryTransactions, exploreEvents, range } = this.props;
|
||||||
const transactions = queryTransactions.filter(t => t.rowIndex === index);
|
const transactions = queryTransactions.filter(t => t.rowIndex === index);
|
||||||
const transactionWithError = transactions.find(t => t.error !== undefined);
|
const transactionWithError = transactions.find(t => t.error !== undefined);
|
||||||
const hint = getFirstHintFromTransactions(transactions);
|
const hint = getFirstHintFromTransactions(transactions);
|
||||||
@ -110,7 +110,7 @@ export class QueryRow extends PureComponent<QueryRowProps> {
|
|||||||
{QueryField ? (
|
{QueryField ? (
|
||||||
<QueryField
|
<QueryField
|
||||||
datasource={datasourceInstance}
|
datasource={datasourceInstance}
|
||||||
initialQuery={initialQuery}
|
query={query}
|
||||||
error={queryError}
|
error={queryError}
|
||||||
hint={hint}
|
hint={hint}
|
||||||
history={history}
|
history={history}
|
||||||
@ -124,7 +124,7 @@ export class QueryRow extends PureComponent<QueryRowProps> {
|
|||||||
error={queryError}
|
error={queryError}
|
||||||
onQueryChange={this.onChangeQuery}
|
onQueryChange={this.onChangeQuery}
|
||||||
onExecuteQuery={this.onExecuteQuery}
|
onExecuteQuery={this.onExecuteQuery}
|
||||||
initialQuery={initialQuery}
|
initialQuery={query}
|
||||||
exploreEvents={exploreEvents}
|
exploreEvents={exploreEvents}
|
||||||
range={range}
|
range={range}
|
||||||
/>
|
/>
|
||||||
@ -155,9 +155,9 @@ export class QueryRow extends PureComponent<QueryRowProps> {
|
|||||||
function mapStateToProps(state: StoreState, { exploreId, index }) {
|
function mapStateToProps(state: StoreState, { exploreId, index }) {
|
||||||
const explore = state.explore;
|
const explore = state.explore;
|
||||||
const item: ExploreItemState = explore[exploreId];
|
const item: ExploreItemState = explore[exploreId];
|
||||||
const { datasourceInstance, history, initialQueries, queryTransactions, range } = item;
|
const { datasourceInstance, history, queries, queryTransactions, range } = item;
|
||||||
const initialQuery = initialQueries[index];
|
const query = queries[index];
|
||||||
return { datasourceInstance, history, initialQuery, queryTransactions, range };
|
return { datasourceInstance, history, query, queryTransactions, range };
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = {
|
const mapDispatchToProps = {
|
||||||
|
@ -87,7 +87,7 @@ export function changeDatasource(exploreId: ExploreId, datasource: string): Thun
|
|||||||
return async (dispatch, getState) => {
|
return async (dispatch, getState) => {
|
||||||
const newDataSourceInstance = await getDatasourceSrv().get(datasource);
|
const newDataSourceInstance = await getDatasourceSrv().get(datasource);
|
||||||
const currentDataSourceInstance = getState().explore[exploreId].datasourceInstance;
|
const currentDataSourceInstance = getState().explore[exploreId].datasourceInstance;
|
||||||
const queries = getState().explore[exploreId].initialQueries;
|
const queries = getState().explore[exploreId].queries;
|
||||||
|
|
||||||
await dispatch(importQueries(exploreId, queries, currentDataSourceInstance, newDataSourceInstance));
|
await dispatch(importQueries(exploreId, queries, currentDataSourceInstance, newDataSourceInstance));
|
||||||
|
|
||||||
@ -494,7 +494,7 @@ export function runQueries(exploreId: ExploreId, ignoreUIState = false) {
|
|||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const {
|
const {
|
||||||
datasourceInstance,
|
datasourceInstance,
|
||||||
initialQueries,
|
queries,
|
||||||
showingLogs,
|
showingLogs,
|
||||||
showingGraph,
|
showingGraph,
|
||||||
showingTable,
|
showingTable,
|
||||||
@ -503,7 +503,7 @@ export function runQueries(exploreId: ExploreId, ignoreUIState = false) {
|
|||||||
supportsTable,
|
supportsTable,
|
||||||
} = getState().explore[exploreId];
|
} = getState().explore[exploreId];
|
||||||
|
|
||||||
if (!hasNonEmptyQuery(initialQueries)) {
|
if (!hasNonEmptyQuery(queries)) {
|
||||||
dispatch(runQueriesEmptyAction({ exploreId }));
|
dispatch(runQueriesEmptyAction({ exploreId }));
|
||||||
dispatch(stateSave()); // Remember to saves to state and update location
|
dispatch(stateSave()); // Remember to saves to state and update location
|
||||||
return;
|
return;
|
||||||
@ -565,14 +565,7 @@ function runQueriesForType(
|
|||||||
resultGetter?: any
|
resultGetter?: any
|
||||||
) {
|
) {
|
||||||
return async (dispatch, getState) => {
|
return async (dispatch, getState) => {
|
||||||
const {
|
const { datasourceInstance, eventBridge, queries, queryIntervals, range, scanning } = getState().explore[exploreId];
|
||||||
datasourceInstance,
|
|
||||||
eventBridge,
|
|
||||||
initialQueries: queries,
|
|
||||||
queryIntervals,
|
|
||||||
range,
|
|
||||||
scanning,
|
|
||||||
} = getState().explore[exploreId];
|
|
||||||
const datasourceId = datasourceInstance.meta.id;
|
const datasourceId = datasourceInstance.meta.id;
|
||||||
|
|
||||||
// Run all queries concurrently
|
// Run all queries concurrently
|
||||||
@ -653,7 +646,7 @@ export function splitOpen(): ThunkResult<void> {
|
|||||||
const itemState = {
|
const itemState = {
|
||||||
...leftState,
|
...leftState,
|
||||||
queryTransactions: [],
|
queryTransactions: [],
|
||||||
initialQueries: leftState.initialQueries.slice(),
|
queries: leftState.queries.slice(),
|
||||||
};
|
};
|
||||||
dispatch(splitOpenAction({ itemState }));
|
dispatch(splitOpenAction({ itemState }));
|
||||||
dispatch(stateSave());
|
dispatch(stateSave());
|
||||||
@ -670,7 +663,7 @@ export function stateSave() {
|
|||||||
const urlStates: { [index: string]: string } = {};
|
const urlStates: { [index: string]: string } = {};
|
||||||
const leftUrlState: ExploreUrlState = {
|
const leftUrlState: ExploreUrlState = {
|
||||||
datasource: left.datasourceInstance.name,
|
datasource: left.datasourceInstance.name,
|
||||||
queries: left.initialQueries.map(clearQueryKeys),
|
queries: left.queries.map(clearQueryKeys),
|
||||||
range: left.range,
|
range: left.range,
|
||||||
ui: {
|
ui: {
|
||||||
showingGraph: left.showingGraph,
|
showingGraph: left.showingGraph,
|
||||||
@ -682,13 +675,9 @@ export function stateSave() {
|
|||||||
if (split) {
|
if (split) {
|
||||||
const rightUrlState: ExploreUrlState = {
|
const rightUrlState: ExploreUrlState = {
|
||||||
datasource: right.datasourceInstance.name,
|
datasource: right.datasourceInstance.name,
|
||||||
queries: right.initialQueries.map(clearQueryKeys),
|
queries: right.queries.map(clearQueryKeys),
|
||||||
range: right.range,
|
range: right.range,
|
||||||
ui: {
|
ui: { showingGraph: right.showingGraph, showingLogs: right.showingLogs, showingTable: right.showingTable },
|
||||||
showingGraph: right.showingGraph,
|
|
||||||
showingLogs: right.showingLogs,
|
|
||||||
showingTable: right.showingTable,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
urlStates.right = serializeStateToUrlParam(rightUrlState, true);
|
urlStates.right = serializeStateToUrlParam(rightUrlState, true);
|
||||||
|
@ -60,7 +60,7 @@ export const makeExploreItemState = (): ExploreItemState => ({
|
|||||||
datasourceMissing: false,
|
datasourceMissing: false,
|
||||||
exploreDatasources: [],
|
exploreDatasources: [],
|
||||||
history: [],
|
history: [],
|
||||||
initialQueries: [],
|
queries: [],
|
||||||
initialized: false,
|
initialized: false,
|
||||||
queryTransactions: [],
|
queryTransactions: [],
|
||||||
queryIntervals: { interval: '15s', intervalMs: DEFAULT_GRAPH_INTERVAL },
|
queryIntervals: { interval: '15s', intervalMs: DEFAULT_GRAPH_INTERVAL },
|
||||||
@ -92,23 +92,26 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
.addMapper({
|
.addMapper({
|
||||||
filter: addQueryRowAction,
|
filter: addQueryRowAction,
|
||||||
mapper: (state, action): ExploreItemState => {
|
mapper: (state, action): ExploreItemState => {
|
||||||
const { initialQueries, queryTransactions } = state;
|
const { queries, queryTransactions } = state;
|
||||||
const { index, query } = action.payload;
|
const { index, query } = action.payload;
|
||||||
|
|
||||||
// Add to initialQueries, which will cause a new row to be rendered
|
// Add to queries, which will cause a new row to be rendered
|
||||||
const nextQueries = [...initialQueries.slice(0, index + 1), { ...query }, ...initialQueries.slice(index + 1)];
|
const nextQueries = [...queries.slice(0, index + 1), { ...query }, ...queries.slice(index + 1)];
|
||||||
|
|
||||||
// Ongoing transactions need to update their row indices
|
// Ongoing transactions need to update their row indices
|
||||||
const nextQueryTransactions = queryTransactions.map(qt => {
|
const nextQueryTransactions = queryTransactions.map(qt => {
|
||||||
if (qt.rowIndex > index) {
|
if (qt.rowIndex > index) {
|
||||||
return { ...qt, rowIndex: qt.rowIndex + 1 };
|
return {
|
||||||
|
...qt,
|
||||||
|
rowIndex: qt.rowIndex + 1,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return qt;
|
return qt;
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
initialQueries: nextQueries,
|
queries: nextQueries,
|
||||||
logsHighlighterExpressions: undefined,
|
logsHighlighterExpressions: undefined,
|
||||||
queryTransactions: nextQueryTransactions,
|
queryTransactions: nextQueryTransactions,
|
||||||
queryKeys: getQueryKeys(nextQueries, state.datasourceInstance),
|
queryKeys: getQueryKeys(nextQueries, state.datasourceInstance),
|
||||||
@ -118,12 +121,12 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
.addMapper({
|
.addMapper({
|
||||||
filter: changeQueryAction,
|
filter: changeQueryAction,
|
||||||
mapper: (state, action): ExploreItemState => {
|
mapper: (state, action): ExploreItemState => {
|
||||||
const { initialQueries, queryTransactions } = state;
|
const { queries, queryTransactions } = state;
|
||||||
const { query, index } = action.payload;
|
const { query, index } = action.payload;
|
||||||
|
|
||||||
// Override path: queries are completely reset
|
// Override path: queries are completely reset
|
||||||
const nextQuery: DataQuery = { ...query, ...generateEmptyQuery(index) };
|
const nextQuery: DataQuery = { ...query, ...generateEmptyQuery(index) };
|
||||||
const nextQueries = [...initialQueries];
|
const nextQueries = [...queries];
|
||||||
nextQueries[index] = nextQuery;
|
nextQueries[index] = nextQuery;
|
||||||
|
|
||||||
// Discard ongoing transaction related to row query
|
// Discard ongoing transaction related to row query
|
||||||
@ -131,7 +134,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
initialQueries: nextQueries,
|
queries: nextQueries,
|
||||||
queryTransactions: nextQueryTransactions,
|
queryTransactions: nextQueryTransactions,
|
||||||
queryKeys: getQueryKeys(nextQueries, state.datasourceInstance),
|
queryKeys: getQueryKeys(nextQueries, state.datasourceInstance),
|
||||||
};
|
};
|
||||||
@ -162,7 +165,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
const queries = ensureQueries();
|
const queries = ensureQueries();
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
initialQueries: queries.slice(),
|
queries: queries.slice(),
|
||||||
queryTransactions: [],
|
queryTransactions: [],
|
||||||
showingStartPage: Boolean(state.StartPage),
|
showingStartPage: Boolean(state.StartPage),
|
||||||
queryKeys: getQueryKeys(queries, state.datasourceInstance),
|
queryKeys: getQueryKeys(queries, state.datasourceInstance),
|
||||||
@ -186,7 +189,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
eventBridge,
|
eventBridge,
|
||||||
exploreDatasources,
|
exploreDatasources,
|
||||||
range,
|
range,
|
||||||
initialQueries: queries,
|
queries,
|
||||||
initialized: true,
|
initialized: true,
|
||||||
queryKeys: getQueryKeys(queries, state.datasourceInstance),
|
queryKeys: getQueryKeys(queries, state.datasourceInstance),
|
||||||
...ui,
|
...ui,
|
||||||
@ -197,7 +200,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
filter: updateDatasourceInstanceAction,
|
filter: updateDatasourceInstanceAction,
|
||||||
mapper: (state, action): ExploreItemState => {
|
mapper: (state, action): ExploreItemState => {
|
||||||
const { datasourceInstance } = action.payload;
|
const { datasourceInstance } = action.payload;
|
||||||
return { ...state, datasourceInstance, queryKeys: getQueryKeys(state.initialQueries, datasourceInstance) };
|
return { ...state, datasourceInstance, queryKeys: getQueryKeys(state.queries, datasourceInstance) };
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.addMapper({
|
.addMapper({
|
||||||
@ -254,13 +257,13 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
.addMapper({
|
.addMapper({
|
||||||
filter: modifyQueriesAction,
|
filter: modifyQueriesAction,
|
||||||
mapper: (state, action): ExploreItemState => {
|
mapper: (state, action): ExploreItemState => {
|
||||||
const { initialQueries, queryTransactions } = state;
|
const { queries, queryTransactions } = state;
|
||||||
const { modification, index, modifier } = action.payload;
|
const { modification, index, modifier } = action.payload;
|
||||||
let nextQueries: DataQuery[];
|
let nextQueries: DataQuery[];
|
||||||
let nextQueryTransactions;
|
let nextQueryTransactions;
|
||||||
if (index === undefined) {
|
if (index === undefined) {
|
||||||
// Modify all queries
|
// Modify all queries
|
||||||
nextQueries = initialQueries.map((query, i) => ({
|
nextQueries = queries.map((query, i) => ({
|
||||||
...modifier({ ...query }, modification),
|
...modifier({ ...query }, modification),
|
||||||
...generateEmptyQuery(i),
|
...generateEmptyQuery(i),
|
||||||
}));
|
}));
|
||||||
@ -268,7 +271,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
nextQueryTransactions = [];
|
nextQueryTransactions = [];
|
||||||
} else {
|
} else {
|
||||||
// Modify query only at index
|
// Modify query only at index
|
||||||
nextQueries = initialQueries.map((query, i) => {
|
nextQueries = queries.map((query, i) => {
|
||||||
// Synchronize all queries with local query cache to ensure consistency
|
// Synchronize all queries with local query cache to ensure consistency
|
||||||
// TODO still needed?
|
// TODO still needed?
|
||||||
return i === index ? { ...modifier({ ...query }, modification), ...generateEmptyQuery(i) } : query;
|
return i === index ? { ...modifier({ ...query }, modification), ...generateEmptyQuery(i) } : query;
|
||||||
@ -286,7 +289,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
initialQueries: nextQueries,
|
queries: nextQueries,
|
||||||
queryKeys: getQueryKeys(nextQueries, state.datasourceInstance),
|
queryKeys: getQueryKeys(nextQueries, state.datasourceInstance),
|
||||||
queryTransactions: nextQueryTransactions,
|
queryTransactions: nextQueryTransactions,
|
||||||
};
|
};
|
||||||
@ -332,14 +335,14 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
.addMapper({
|
.addMapper({
|
||||||
filter: removeQueryRowAction,
|
filter: removeQueryRowAction,
|
||||||
mapper: (state, action): ExploreItemState => {
|
mapper: (state, action): ExploreItemState => {
|
||||||
const { datasourceInstance, initialQueries, queryIntervals, queryTransactions, queryKeys } = state;
|
const { datasourceInstance, queries, queryIntervals, queryTransactions, queryKeys } = state;
|
||||||
const { index } = action.payload;
|
const { index } = action.payload;
|
||||||
|
|
||||||
if (initialQueries.length <= 1) {
|
if (queries.length <= 1) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextQueries = [...initialQueries.slice(0, index), ...initialQueries.slice(index + 1)];
|
const nextQueries = [...queries.slice(0, index), ...queries.slice(index + 1)];
|
||||||
const nextQueryKeys = [...queryKeys.slice(0, index), ...queryKeys.slice(index + 1)];
|
const nextQueryKeys = [...queryKeys.slice(0, index), ...queryKeys.slice(index + 1)];
|
||||||
|
|
||||||
// Discard transactions related to row query
|
// Discard transactions related to row query
|
||||||
@ -353,7 +356,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
...results,
|
...results,
|
||||||
initialQueries: nextQueries,
|
queries: nextQueries,
|
||||||
logsHighlighterExpressions: undefined,
|
logsHighlighterExpressions: undefined,
|
||||||
queryTransactions: nextQueryTransactions,
|
queryTransactions: nextQueryTransactions,
|
||||||
queryKeys: nextQueryKeys,
|
queryKeys: nextQueryKeys,
|
||||||
@ -398,7 +401,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
const { queries } = action.payload;
|
const { queries } = action.payload;
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
initialQueries: queries.slice(),
|
queries: queries.slice(),
|
||||||
queryKeys: getQueryKeys(queries, state.datasourceInstance),
|
queryKeys: getQueryKeys(queries, state.datasourceInstance),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -452,7 +455,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|||||||
const { queries } = action.payload;
|
const { queries } = action.payload;
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
initialQueries: queries,
|
queries,
|
||||||
queryKeys: getQueryKeys(queries, state.datasourceInstance),
|
queryKeys: getQueryKeys(queries, state.datasourceInstance),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -59,7 +59,7 @@ export class LokiQueryEditor extends PureComponent<Props> {
|
|||||||
<div>
|
<div>
|
||||||
<LokiQueryField
|
<LokiQueryField
|
||||||
datasource={datasource}
|
datasource={datasource}
|
||||||
initialQuery={query}
|
query={query}
|
||||||
onQueryChange={this.onFieldChange}
|
onQueryChange={this.onFieldChange}
|
||||||
onExecuteQuery={this.onRunQuery}
|
onExecuteQuery={this.onRunQuery}
|
||||||
history={[]}
|
history={[]}
|
||||||
|
@ -162,13 +162,10 @@ export class LokiQueryField extends React.PureComponent<LokiQueryFieldProps, Lok
|
|||||||
|
|
||||||
onChangeQuery = (value: string, override?: boolean) => {
|
onChangeQuery = (value: string, override?: boolean) => {
|
||||||
// Send text change to parent
|
// Send text change to parent
|
||||||
const { initialQuery, onQueryChange, onExecuteQuery } = this.props;
|
const { query, onQueryChange, onExecuteQuery } = this.props;
|
||||||
if (onQueryChange) {
|
if (onQueryChange) {
|
||||||
const query = {
|
const nextQuery = { ...query, expr: value };
|
||||||
...initialQuery,
|
onQueryChange(nextQuery);
|
||||||
expr: value,
|
|
||||||
};
|
|
||||||
onQueryChange(query);
|
|
||||||
|
|
||||||
if (override && onExecuteQuery) {
|
if (override && onExecuteQuery) {
|
||||||
onExecuteQuery();
|
onExecuteQuery();
|
||||||
@ -217,7 +214,7 @@ export class LokiQueryField extends React.PureComponent<LokiQueryFieldProps, Lok
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { error, hint, initialQuery } = this.props;
|
const { error, hint, query } = this.props;
|
||||||
const { logLabelOptions, syntaxLoaded } = this.state;
|
const { logLabelOptions, syntaxLoaded } = this.state;
|
||||||
const cleanText = this.languageProvider ? this.languageProvider.cleanText : undefined;
|
const cleanText = this.languageProvider ? this.languageProvider.cleanText : undefined;
|
||||||
const hasLogLabels = logLabelOptions && logLabelOptions.length > 0;
|
const hasLogLabels = logLabelOptions && logLabelOptions.length > 0;
|
||||||
@ -237,7 +234,7 @@ export class LokiQueryField extends React.PureComponent<LokiQueryFieldProps, Lok
|
|||||||
<QueryField
|
<QueryField
|
||||||
additionalPlugins={this.plugins}
|
additionalPlugins={this.plugins}
|
||||||
cleanText={cleanText}
|
cleanText={cleanText}
|
||||||
initialQuery={initialQuery.expr}
|
initialQuery={query.expr}
|
||||||
onTypeahead={this.onTypeahead}
|
onTypeahead={this.onTypeahead}
|
||||||
onWillApplySuggestion={willApplySuggestion}
|
onWillApplySuggestion={willApplySuggestion}
|
||||||
onQueryChange={this.onChangeQuery}
|
onQueryChange={this.onChangeQuery}
|
||||||
|
@ -168,13 +168,10 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
|
|||||||
|
|
||||||
onChangeQuery = (value: string, override?: boolean) => {
|
onChangeQuery = (value: string, override?: boolean) => {
|
||||||
// Send text change to parent
|
// Send text change to parent
|
||||||
const { initialQuery, onQueryChange, onExecuteQuery } = this.props;
|
const { query, onQueryChange, onExecuteQuery } = this.props;
|
||||||
if (onQueryChange) {
|
if (onQueryChange) {
|
||||||
const query: PromQuery = {
|
const nextQuery: PromQuery = { ...query, expr: value };
|
||||||
...initialQuery,
|
onQueryChange(nextQuery);
|
||||||
expr: value,
|
|
||||||
};
|
|
||||||
onQueryChange(query);
|
|
||||||
|
|
||||||
if (override && onExecuteQuery) {
|
if (override && onExecuteQuery) {
|
||||||
onExecuteQuery();
|
onExecuteQuery();
|
||||||
@ -240,7 +237,7 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { error, hint, initialQuery } = this.props;
|
const { error, hint, query } = this.props;
|
||||||
const { metricsOptions, syntaxLoaded } = this.state;
|
const { metricsOptions, syntaxLoaded } = this.state;
|
||||||
const cleanText = this.languageProvider ? this.languageProvider.cleanText : undefined;
|
const cleanText = this.languageProvider ? this.languageProvider.cleanText : undefined;
|
||||||
const chooserText = syntaxLoaded ? 'Metrics' : 'Loading metrics...';
|
const chooserText = syntaxLoaded ? 'Metrics' : 'Loading metrics...';
|
||||||
@ -259,7 +256,7 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
|
|||||||
<QueryField
|
<QueryField
|
||||||
additionalPlugins={this.plugins}
|
additionalPlugins={this.plugins}
|
||||||
cleanText={cleanText}
|
cleanText={cleanText}
|
||||||
initialQuery={initialQuery.expr}
|
initialQuery={query.expr}
|
||||||
onTypeahead={this.onTypeahead}
|
onTypeahead={this.onTypeahead}
|
||||||
onWillApplySuggestion={willApplySuggestion}
|
onWillApplySuggestion={willApplySuggestion}
|
||||||
onQueryChange={this.onChangeQuery}
|
onQueryChange={this.onChangeQuery}
|
||||||
|
@ -153,10 +153,10 @@ export interface ExploreItemState {
|
|||||||
*/
|
*/
|
||||||
history: HistoryItem[];
|
history: HistoryItem[];
|
||||||
/**
|
/**
|
||||||
* Initial queries for this Explore, e.g., set via URL. Each query will be
|
* Queries for this Explore, e.g., set via URL. Each query will be
|
||||||
* converted to a query row.
|
* converted to a query row.
|
||||||
*/
|
*/
|
||||||
initialQueries: DataQuery[];
|
queries: DataQuery[];
|
||||||
/**
|
/**
|
||||||
* True if this Explore area has been initialized.
|
* True if this Explore area has been initialized.
|
||||||
* Used to distinguish URL state injection versus split view state injection.
|
* Used to distinguish URL state injection versus split view state injection.
|
||||||
|
Loading…
Reference in New Issue
Block a user