Selaa lähdekoodia

HUE-3160 [metastore] Adding a comment to a column doesn’t give an error if there are no permissions

Romain Rigaux 9 vuotta sitten
vanhempi
commit
ad8333b50b

+ 14 - 8
apps/metastore/src/metastore/static/metastore/js/metastore.ko.js

@@ -364,9 +364,9 @@
 
   MetastoreTable.prototype.showImportData = function () {
     var self = this;
-    $.get('/metastore/table/' + self.database.name + '/' + self.name + '/load', function (response) {
+    $.get('/metastore/table/' + self.database.name + '/' + self.name + '/load', function (data) {
       if (data.status == 0) {
-        $("#import-data-modal").html(response['data']);
+        $("#import-data-modal").html(data['data']);
         $("#import-data-modal").modal("show");
       } else {
         $(document).trigger("error", data.message);
@@ -403,12 +403,18 @@
       $.post('/metastore/table/' + self.table.database.name + '/' + self.table.name + '/alter_column', {
         column: self.name(),
         comment: newValue
-      }, function () {
-        huePubSub.publish('assist.clear.db.cache', {
-          sourceType: 'hive',
-          databaseName: self.table.database.name,
-          tableName: self.table.name
-        });
+      }, function (data) {
+        if (data.status == 0) {
+          huePubSub.publish('assist.clear.db.cache', {
+            sourceType: 'hive',
+            databaseName: self.table.database.name,
+            tableName: self.table.name
+          });
+        } else {
+          $(document).trigger("error", data.message);
+        }
+      }).fail(function (xhr, textStatus, errorThrown) {
+        $(document).trigger("error", xhr.responseText);
       });
     })
   }

+ 2 - 2
apps/metastore/src/metastore/views.py

@@ -285,7 +285,7 @@ def alter_table(request, database, table):
 @require_http_methods(["POST"])
 def alter_column(request, database, table):
   db = dbms.get(request.user)
-  response = {'status': -1, 'data': ''}
+  response = {'status': -1, 'message': ''}
   try:
     column = request.POST.get('column', None)
 
@@ -311,7 +311,7 @@ def alter_column(request, database, table):
       raise PopupException(_('Column `%s`.`%s` `%s` not found') % (database, table, column))
   except Exception, ex:
     response['status'] = 1
-    response['data'] = _("Failed to alter column `%s`.`%s` `%s`: %s") % (database, table, column, str(ex))
+    response['message'] = _("Failed to alter column `%s`.`%s` `%s`: %s") % (database, table, column, str(ex))
 
   return JsonResponse(response)