mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* add support for code editor and builder * refactor cloudwatch migration * Add tooltip to editor field (#56) * add tooltip * add old tooltips * Bug bash feedback fixes (#58) * make ASC the default option * update sql preview whenever sql changes * don't allow queries without aggregation * set default value for aggregation * use new input field * cleanup * pr feedback * prevent unnecessary rerenders * use frame error instead of main error * remove not used snapshot * Use dimension filter in schema picker (#63) * use dimension key filter in group by and schema labels * add dimension filter also to code editor * add tests * fix build error * fix strict error * remove debug code * fix annotation editor (#64) * fix annotation editor * fix broken test * revert annotation backend change * PR feedback (#67) * pr feedback * removed dimension filter from group by * add spacing between common fields and rest * do not generate deep link for metric queries (#70) * update docs (#69) Co-authored-by: Erik Sundell <erik.sundell87@gmail.com> * fix lint problem caused by merge conflict Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
53 lines
2.1 KiB
TypeScript
53 lines
2.1 KiB
TypeScript
import { StatementPosition, SuggestionKind } from './types';
|
|
|
|
export function getSuggestionKinds(statementPosition: StatementPosition): SuggestionKind[] {
|
|
switch (statementPosition) {
|
|
case StatementPosition.SelectKeyword:
|
|
return [SuggestionKind.SelectKeyword];
|
|
case StatementPosition.AfterSelectKeyword:
|
|
return [SuggestionKind.FunctionsWithArguments];
|
|
case StatementPosition.AfterSelectFuncFirstArgument:
|
|
return [SuggestionKind.Metrics];
|
|
case StatementPosition.AfterFromKeyword:
|
|
return [SuggestionKind.Namespaces, SuggestionKind.SchemaKeyword];
|
|
case StatementPosition.SchemaFuncFirstArgument:
|
|
return [SuggestionKind.Namespaces];
|
|
case StatementPosition.SchemaFuncExtraArgument:
|
|
return [SuggestionKind.LabelKeys];
|
|
case StatementPosition.FromKeyword:
|
|
return [SuggestionKind.FromKeyword];
|
|
case StatementPosition.AfterFrom:
|
|
return [
|
|
SuggestionKind.WhereKeyword,
|
|
SuggestionKind.GroupByKeywords,
|
|
SuggestionKind.OrderByKeywords,
|
|
SuggestionKind.LimitKeyword,
|
|
];
|
|
case StatementPosition.WhereKey:
|
|
return [SuggestionKind.LabelKeys];
|
|
case StatementPosition.WhereComparisonOperator:
|
|
return [SuggestionKind.ComparisonOperators];
|
|
case StatementPosition.WhereValue:
|
|
return [SuggestionKind.LabelValues];
|
|
case StatementPosition.AfterWhereValue:
|
|
return [
|
|
SuggestionKind.LogicalOperators,
|
|
SuggestionKind.GroupByKeywords,
|
|
SuggestionKind.OrderByKeywords,
|
|
SuggestionKind.LimitKeyword,
|
|
];
|
|
case StatementPosition.AfterGroupByKeywords:
|
|
return [SuggestionKind.LabelKeys];
|
|
case StatementPosition.AfterGroupBy:
|
|
return [SuggestionKind.OrderByKeywords, SuggestionKind.LimitKeyword];
|
|
case StatementPosition.AfterOrderByKeywords:
|
|
return [SuggestionKind.FunctionsWithoutArguments];
|
|
case StatementPosition.AfterOrderByFunction:
|
|
return [SuggestionKind.SortOrderDirectionKeyword, SuggestionKind.LimitKeyword];
|
|
case StatementPosition.AfterOrderByDirection:
|
|
return [SuggestionKind.LimitKeyword];
|
|
}
|
|
|
|
return [];
|
|
}
|