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

HUE-7018 [jb] disable_killing_jobs option is not supported in the new job browser

Ying Chen 8 жил өмнө
parent
commit
fa67a5b

+ 5 - 0
apps/jobbrowser/src/jobbrowser/api2.py

@@ -21,8 +21,10 @@ import logging
 from django.utils.translation import ugettext as _
 from desktop.lib.i18n import smart_unicode
 from desktop.lib.django_util import JsonResponse
+from desktop.views import serve_403_error
 
 from jobbrowser.apis.base_api import get_api
+from jobbrowser.conf import DISABLE_KILLING_JOBS
 
 
 LOG = logging.getLogger(__name__)
@@ -82,6 +84,9 @@ def action(request):
   app_ids = json.loads(request.POST.get('app_ids'))
   operation = json.loads(request.POST.get('operation'))
 
+  if operation.get('action') == 'kill' and DISABLE_KILLING_JOBS.get():
+    return serve_403_error(request)
+
   response['operation'] = operation
   response.update(get_api(request.user, interface).action(app_ids, operation))
 

+ 3 - 1
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -18,7 +18,7 @@
 
   from desktop import conf
   from desktop.views import commonheader, commonfooter, _ko
-  from jobbrowser.conf import MAX_JOB_FETCH
+  from jobbrowser.conf import DISABLE_KILLING_JOBS, MAX_JOB_FETCH
 %>
 
 <%
@@ -943,12 +943,14 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
     </button>
     <!-- /ko -->
 
+    % if not DISABLE_KILLING_JOBS.get():
     <!-- ko if: hasKill -->
     <button class="btn btn-danger disable-feedback" title="${_('Stop selected')}" data-bind="click: function() { control('kill'); }, enable: killEnabled">
       ## TODO confirmation
       <i class="fa fa-times"></i> <!-- ko ifnot: $root.isMini -->${_('Kill')}<!-- /ko -->
     </button>
     <!-- /ko -->
+    % endif
 
     <!-- ko if: hasIgnore -->
     <button class="btn btn-danger disable-feedback" title="${_('Ignore selected')}" data-bind="click: function() { control('ignore'); }, enable: ignoreEnabled">