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

[frontend] Make it possible to configure the default editor to use for all users in Hue (#3514)

- When a user visits Hue we open the editor by default after logging in. If Hue is configured to have multiple editors the first one is used by default.

- Each user have the possibility to pick the default editor by clicking the star icon in the editor header. There are cases when an organisation wants to control this for all users through configuration so we should add such a config setting in the .ini.

The order of deciding which editor to display would be:

- If the user has "stared" an editor use that one
- If there's a config for which editor to use use that one (new)
- And lastly, pick the first editor in the list

---------

Co-authored-by: Johan Åhlén <johan@johanahlen.com>
Ananya_Agarwal 2 жил өмнө
parent
commit
45667d5216

+ 4 - 0
desktop/conf.dist/hue.ini

@@ -1023,6 +1023,10 @@ tls=no
 ## Default limit to use in SELECT statements if not present. Set to 0 to disable.
 # default_limit=5000
 
+## Set the default interpreter for all users. 
+## Starred interpreters at user level will get more priority than the value below.
+# default_interpreter=
+
 # One entry for each type of snippet.
 [[interpreters]]
 # Define the name and how to connect and execute the language.

+ 4 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1006,6 +1006,10 @@
   ## Default limit to use in SELECT statements if not present. Set to 0 to disable.
   # default_limit=5000
 
+  ## Set the default interpreter for all users. 
+  ## Starred interpreters at user level will get more priority than the value below.
+  # default_interpreter=
+
   # One entry for each type of snippet.
   [[interpreters]]
     # Define the name and how to connect and execute the language.

+ 6 - 4
desktop/core/src/desktop/models.py

@@ -44,7 +44,7 @@ from hadoop.core_site import get_raz_api_url, get_raz_s3_default_bucket
 from kafka.conf import has_kafka
 from indexer.conf import ENABLE_DIRECT_UPLOAD
 from metadata.conf import get_optimizer_mode
-from notebook.conf import DEFAULT_LIMIT, SHOW_NOTEBOOKS, get_ordered_interpreters
+from notebook.conf import DEFAULT_LIMIT, SHOW_NOTEBOOKS, get_ordered_interpreters, DEFAULT_INTERPRETER
 from useradmin.models import User, Group, get_organization
 from useradmin.organization import _fitered_queryset
 
@@ -1855,9 +1855,11 @@ class ClusterConfig(object):
       LOG.exception('Could not load back default app')
 
     if default_interpreter:
-      return default_interpreter[0]
-    else:
-      return default_app
+      if DEFAULT_INTERPRETER.get():
+        for di in default_interpreter:
+          if di['name'] == DEFAULT_INTERPRETER.get():
+            return di
+    return default_interpreter[0]
 
 
   def _get_home(self):

+ 7 - 0
desktop/libs/notebook/src/notebook/conf.py

@@ -207,6 +207,13 @@ INTERPRETERS_SHOWN_ON_WHEEL = Config(
   default=[]
 )
 
+DEFAULT_INTERPRETER = Config(
+  key="default_interpreter",
+  help=_t("Set the default interpreter for all users. Starred interpreters at user level will get more priority than the value below."),
+  type=str,
+  default=''
+)
+
 DEFAULT_LIMIT = Config(
   "default_limit",
   help="Default limit to use in SELECT statements if not present. Set to 0 to disable.",