You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ak...@apache.org on 2019/02/11 21:49:40 UTC

[incubator-pinot] branch master updated: [TE] yaml-editor - makes yaml autocomplete insert dataset field correctly (#3817)

This is an automated email from the ASF dual-hosted git repository.

akshayrai09 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new a51d418  [TE] yaml-editor - makes yaml autocomplete insert dataset field correctly (#3817)
a51d418 is described below

commit a51d41825756c2447104c4471016bd0d2bbbeea8
Author: Harley Jackson <ha...@gmail.com>
AuthorDate: Mon Feb 11 13:49:35 2019 -0800

    [TE] yaml-editor - makes yaml autocomplete insert dataset field correctly (#3817)
---
 .../app/pods/components/yaml-editor/component.js      | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/component.js b/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/component.js
index 4e90924..435ad59 100644
--- a/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/component.js
+++ b/thirdeye/thirdeye-frontend/app/pods/components/yaml-editor/component.js
@@ -176,14 +176,25 @@ export default Component.extend({
                 id: metric.id,
                 completer:{
                   insertMatch: (editor, data) => {
+                    // replace metric row with selected metric
                     editor.session.replace({
                       start: { row: data.row, column: 0 },
                       end: { row: data.row, column: Number.MAX_VALUE }},
                     `metric: ${data.metricname}`);
-                    editor.session.replace({
-                      start: { row: data.row+2, column: 0},
-                      end: { row: data.row+2, column: Number.MAX_VALUE }},
-                    `dataset: ${data.dataset}`);
+                    // find dataset: field in text
+                    const datasetLocation = editor.find('dataset:');
+                    // if found, replace with dataset
+                    if (datasetLocation) {
+                      editor.session.replace({
+                        start: { row: datasetLocation.start.row, column: 0},
+                        end: { row: datasetLocation.end.row, column: Number.MAX_VALUE }},
+                      `dataset: ${data.dataset}`);
+                      // otherwise, add it to the line below the metric field
+                    } else {
+                      editor.session.insert({
+                        row: data.row + 1, column: 0 },
+                      `dataset: ${data.dataset}\n`);
+                    }
                     editor.metricId = data.id;
                   }
                 }};


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org