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

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


The following commit(s) were added to refs/heads/master by this push:
     new 9595adb  [bugfix] Fix language switch (#6166)
9595adb is described below

commit 9595adb452c6e653a9146cbef783569750db74f5
Author: Krist Wongsuphasawat <krist.wo...@gmail.com>
AuthorDate: Tue Oct 23 09:11:34 2018 -0700

    [bugfix] Fix language switch (#6166)
    
    * Extract SupersetClient setup into a separate file and fix translation link
    
    * sort'
---
 superset/assets/src/common.js            | 27 +++++++++------------------
 superset/assets/src/setup/setupClient.js | 17 +++++++++++++++++
 2 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/superset/assets/src/common.js b/superset/assets/src/common.js
index f4f6621..d183d9c 100644
--- a/superset/assets/src/common.js
+++ b/superset/assets/src/common.js
@@ -1,10 +1,14 @@
-/* eslint global-require: 0, no-console: 0 */
+/* eslint global-require: 0 */
 import $ from 'jquery';
 import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';
 import { SupersetClient } from '@superset-ui/core';
 import { toggleCheckbox } from './modules/utils';
+import setupClient from './setup/setupClient';
 import setupColors from './setup/setupColors';
 
+setupClient();
+setupColors();
+
 $(document).ready(function () {
   $(':checkbox[data-checkbox-api-prefix]').change(function () {
     const $this = $(this);
@@ -16,33 +20,20 @@ $(document).ready(function () {
   // for language picker dropdown
   $('#language-picker a').click(function (ev) {
     ev.preventDefault();
-
-    SupersetClient.get({ endpoint: ev.currentTarget.href })
+    SupersetClient.get({
+      endpoint: ev.currentTarget.getAttribute('href'),
+      parseMethod: null,
+    })
       .then(() => {
         location.reload();
       });
   });
 });
 
-setupColors();
-
 export function appSetup() {
   // A set of hacks to allow apps to run within a FAB template
   // this allows for the server side generated menus to function
   window.$ = $;
   window.jQuery = $;
   require('bootstrap');
-
-  const csrfNode = document.querySelector('#csrf_token');
-  const csrfToken = csrfNode ? csrfNode.value : null;
-
-  SupersetClient.configure({
-    protocol: (window.location && window.location.protocol) || '',
-    host: (window.location && window.location.host) || '',
-    csrfToken,
-  })
-    .init()
-    .catch((error) => {
-      console.warn('Error initializing SupersetClient', error);
-    });
 }
diff --git a/superset/assets/src/setup/setupClient.js 
b/superset/assets/src/setup/setupClient.js
new file mode 100644
index 0000000..1165b01
--- /dev/null
+++ b/superset/assets/src/setup/setupClient.js
@@ -0,0 +1,17 @@
+/* eslint no-console: 0 */
+import { SupersetClient } from '@superset-ui/core';
+
+export default function setupClient() {
+  const csrfNode = document.querySelector('#csrf_token');
+  const csrfToken = csrfNode ? csrfNode.value : null;
+
+  SupersetClient.configure({
+    protocol: (window.location && window.location.protocol) || '',
+    host: (window.location && window.location.host) || '',
+    csrfToken,
+  })
+    .init()
+    .catch((error) => {
+      console.warn('Error initializing SupersetClient', error);
+    });
+}

Reply via email to