Эх сурвалжийг харах

HUE-8926 [frontend] Add configurable base URLs for the app-switcher

Johan Ahlen 6 жил өмнө
parent
commit
12276eb870

+ 14 - 0
desktop/core/src/desktop/conf.py

@@ -1517,6 +1517,20 @@ DISPLAY_APP_SWITCHER = Config(
   default=False
 )
 
+APP_SWITCHER_ALTUS_BASE_URL = Config(
+  key="app_switcher_altus_base_url",
+  help=_("Optional altus base url to use for the app switcher."),
+  type=str,
+  default=''
+)
+
+APP_SWITCHER_MOW_BASE_URL = Config(
+  key="app_switcher_mow_base_url",
+  help=_("Optional mow base url to use for the app switcher."),
+  type=str,
+  default=''
+)
+
 HTTP_500_DEBUG_MODE = Config(
   key='http_500_debug_mode',
   help=_('Enable or disable debugging information in the 500 internal server error response. '

+ 2 - 2
desktop/core/src/desktop/js/ko/components/appSwitcher/apps.v2.json

@@ -26,7 +26,7 @@
     "logo":"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\"><g fill=\"none\" fill-rule=\"evenodd\"><rect width=\"32\" height=\"32\" fill=\"#6F47BF\" rx=\"3.176\"/><path fill=\"#FFF\" d=\"M18.666 18.666a6.711 6.711 0 0 1-9.475 0c-1.73-1.731-2.29-4.177-1.725-6.394l3.482 3.483c.112.111.253.19.407.225l4.882 1.11a.836.836 0 0 0 1.003-1.003l-1.11-4.882a.844.844 0 0 0-.226-.407l-3.4-3.4c2.152-.465 4.49.124 6.162 1.793a6.708 6.708 0 0 1 0 9.475zm-4.093-6.75l.738 3.245-3.246-.738 2.508-2.507zm-3.733 1.363l-2.612-2.612 2.588-2.588 2.613 2.612-2.59 2.588zm10.14 6.122c2.718-3.501 2.478-8.574-.735-11.788-3.483-3.484-9.15-3.484-12.633 0-3.483 3.482-3.483 9.15 0 12.632a8.901 8.901 0 0 0 6.316 2.612 8.92 8.92 0 0 0 5.473-1.877L25.42 27 27 25.421l-6.02-6.02z\"/></g></svg>",
     "baseUrl": "mow",
     "path": "/dwx/"
-},
+  },
   {
     "name":"mlx",
     "displayName":"Machine Learning",
@@ -46,6 +46,6 @@
     "displayName": "Replication Manager",
     "logo": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\"><g fill=\"none\" fill-rule=\"evenodd\"><rect width=\"32\" height=\"32\" fill=\"#4B8AA3\" rx=\"3.176\"/><path fill=\"#FFF\" d=\"M15 7v3h2V9h7v7h-2v2h4V7H15zm-2 5v2h3.586l-4.95 4.95 1.414 1.414 4.95-4.95V19h2v-7h-7zm-7 2v11h11v-4h-2v2H8v-7h3v-2H6z\"/></g></svg>",
     "baseUrl": "mow",
-    "path": "/dlm/"
+    "path": "/dmx/"
   }
 ]

+ 8 - 7
desktop/core/src/desktop/js/ko/components/appSwitcher/environment.js

@@ -27,10 +27,11 @@ const Environment = {
  * Returns environment type based on current url.
  * E.g., PROD is returned for localhost.altus.cloudera.com
  * Default to PROD
+ * @param environmentBaseUrl
  */
-const getEnvironment = () => {
-  const hostName = window.location.hostname;
-  if (!hostName.indexOf('localhost.') > -1) {
+const getEnvironment = environmentBaseUrl => {
+  const hostName = environmentBaseUrl || window.location.hostname;
+  if (hostName.indexOf('localhost.') > -1) {
     return Environment.LOCAL;
   }
   if (hostName.indexOf('-dev.cloudera.com') > -1) {
@@ -46,7 +47,7 @@ const getEnvironment = () => {
 };
 
 export const getAltusBaseUrl = () => {
-  const environment = getEnvironment();
+  const environment = getEnvironment(window.APP_SWITCHER_ALTUS_BASE_URL);
   switch (environment) {
     case Environment.MOCK:
       return '';
@@ -59,12 +60,12 @@ export const getAltusBaseUrl = () => {
     case Environment.STAGE:
       return 'https://console.thunderhead-stage.cloudera.com';
     case Environment.PROD:
-      return 'https://console.altus.cloudera.com';
+      return window.APP_SWITCHER_ALTUS_BASE_URL || 'https://console.altus.cloudera.com';
   }
 };
 
 export const getMowBaseUrl = () => {
-  const environment = getEnvironment();
+  const environment = getEnvironment(window.APP_SWITCHER_MOW_BASE_URL);
   switch (environment) {
     case Environment.MOCK:
     case Environment.LOCAL:
@@ -75,6 +76,6 @@ export const getMowBaseUrl = () => {
     case Environment.STAGE:
       return 'https://cloudera.cdp.mow-stage.cloudera.com';
     case Environment.PROD:
-      return '';
+      return window.APP_SWITCHER_MOW_BASE_URL || '';
   }
 };

+ 3 - 1
desktop/core/src/desktop/templates/global_js_constants.mako

@@ -18,7 +18,7 @@
   from django.utils.translation import ugettext as _
 
   from desktop import conf
-  from desktop.conf import DISPLAY_APP_SWITCHER, IS_EMBEDDED, IS_K8S_ONLY, IS_MULTICLUSTER_ONLY, USE_NEW_SIDE_PANELS, VCS
+  from desktop.conf import APP_SWITCHER_ALTUS_BASE_URL, APP_SWITCHER_MOW_BASE_URL, DISPLAY_APP_SWITCHER, IS_EMBEDDED, IS_K8S_ONLY, IS_MULTICLUSTER_ONLY, USE_NEW_SIDE_PANELS, VCS
   from desktop.models import hue_version, _get_apps, get_cluster_config
 
   from beeswax.conf import LIST_PARTITIONS_LIMIT
@@ -50,6 +50,8 @@
     window.CSRF_TOKEN = '';
   %endif
 
+  window.APP_SWITCHER_ALTUS_BASE_URL = '${ APP_SWITCHER_ALTUS_BASE_URL.get() }';
+  window.APP_SWITCHER_MOW_BASE_URL = '${ APP_SWITCHER_MOW_BASE_URL.get() }';
   window.DISPLAY_APP_SWITCHER = '${ DISPLAY_APP_SWITCHER.get() }' === 'True';
 
   window.KNOX_BASE_PATH_HUE = '/KNOX_BASE_PATH_HUE';