@fc-components/monaco-editor 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -866,7 +866,8 @@ var serviceUnavailable = 503;
866
866
  var CODE_MODE_SUGGESTIONS_INCOMPLETE_EVENT = 'codeModeSuggestionsIncomplete';
867
867
  var DataProvider = /*#__PURE__*/function () {
868
868
  function DataProvider(params) {
869
- var _this = this;
869
+ var _this = this,
870
+ _params$durationVaria;
870
871
  this.lookbackInterval = 60 * 60 * 1000 * 12; // 12 hours
871
872
  this.variablesNames = [];
872
873
  this.httpMethod = 'GET';
@@ -1012,6 +1013,7 @@ var DataProvider = /*#__PURE__*/function () {
1012
1013
  if (params.variablesNames) {
1013
1014
  this.variablesNames = [].concat(params.variablesNames);
1014
1015
  }
1016
+ this.durationVariablesCompletion = (_params$durationVaria = params.durationVariablesCompletion) != null ? _params$durationVaria : true;
1015
1017
  if (params.request) {
1016
1018
  this.customRequest = params.request;
1017
1019
  }
@@ -1536,7 +1538,14 @@ function _getAllFunctionsAndMetricNamesCompletions() {
1536
1538
  }));
1537
1539
  return _getAllFunctionsAndMetricNamesCompletions.apply(this, arguments);
1538
1540
  }
1539
- var DURATION_COMPLETIONS = /*#__PURE__*/['$__interval', '$__range', '$__rate_interval', '1m', '5m', '10m', '30m', '1h', '1d'].map(function (text) {
1541
+ var DURATION_COMPLETIONS = /*#__PURE__*/['1m', '5m', '10m', '30m', '1h', '1d'].map(function (text) {
1542
+ return {
1543
+ type: 'DURATION',
1544
+ label: text,
1545
+ insertText: text
1546
+ };
1547
+ });
1548
+ var DURATION_VARIABLES_COMPLETIONS = /*#__PURE__*/['$__interval', '$__range', '$__rate_interval'].map(function (text) {
1540
1549
  return {
1541
1550
  type: 'DURATION',
1542
1551
  label: text,
@@ -1764,6 +1773,9 @@ function _getLabelValuesForMetricCompletions() {
1764
1773
  function getCompletions(situation, dataProvider) {
1765
1774
  switch (situation.type) {
1766
1775
  case 'IN_DURATION':
1776
+ if (dataProvider.durationVariablesCompletion) {
1777
+ return Promise.resolve(DURATION_VARIABLES_COMPLETIONS.concat(DURATION_COMPLETIONS));
1778
+ }
1767
1779
  return Promise.resolve(DURATION_COMPLETIONS);
1768
1780
  case 'IN_FUNCTION':
1769
1781
  return getAllFunctionsAndMetricNamesCompletions(dataProvider);
@@ -2021,18 +2033,19 @@ function PromQLEditor(props) {
2021
2033
  editor$1.onDidFocusEditorText(function () {
2022
2034
  isEditorFocused.set(true);
2023
2035
  });
2024
- var dataProvider = new DataProvider({
2025
- url: props.url,
2026
- lookbackInterval: props.lookbackInterval,
2027
- variablesNames: props.variablesNames,
2028
- request: props.request,
2029
- httpMethod: props.httpMethod,
2030
- apiPrefix: props.apiPrefix,
2031
- httpErrorHandler: props.httpErrorHandler
2032
- });
2033
- dataProviderRef.current = dataProvider;
2034
- dataProvider.start();
2035
2036
  if (enableAutocomplete) {
2037
+ var dataProvider = new DataProvider({
2038
+ url: props.url,
2039
+ lookbackInterval: props.lookbackInterval,
2040
+ variablesNames: props.variablesNames,
2041
+ durationVariablesCompletion: props.durationVariablesCompletion,
2042
+ request: props.request,
2043
+ httpMethod: props.httpMethod,
2044
+ apiPrefix: props.apiPrefix,
2045
+ httpErrorHandler: props.httpErrorHandler
2046
+ });
2047
+ dataProviderRef.current = dataProvider;
2048
+ dataProvider.start();
2036
2049
  var completionProvider = getCompletionProvider(monaco, dataProvider);
2037
2050
  var filteringCompletionProvider = _extends({}, completionProvider, {
2038
2051
  provideCompletionItems: function provideCompletionItems(model, position, context, token) {