Sfoglia il codice sorgente

HUE-8818 [editor] Set the active language ref dialect based on active snippet type

Johan Ahlen 6 anni fa
parent
commit
f737381042
1 ha cambiato i file con 15 aggiunte e 0 eliminazioni
  1. 15 0
      desktop/core/src/desktop/templates/assist.mako

+ 15 - 0
desktop/core/src/desktop/templates/assist.mako

@@ -2414,6 +2414,21 @@ from desktop.views import _ko
           self.allTopics.hive.push(new LanguageReferenceTopic(topLevelItem, window.HIVE_DOC_INDEX));
         });
 
+        var updateType = function (type) {
+          if (self.availableTypes.indexOf(type) !== -1) {
+            self.sourceType(type);
+          }
+        };
+
+        var activeSnippetTypeSub = huePubSub.subscribe('active.snippet.type.changed', function (details) { updateType(details.type) });
+
+        self.disposals.push(function () {
+          activeSnippetTypeSub.remove();
+        });
+
+        huePubSub.subscribeOnce('set.active.snippet.type', updateType);
+        huePubSub.publish('get.active.snippet.type');
+
         self.topics = ko.pureComputed(function () {
           return self.allTopics[self.sourceType()];
         });