20032: Fix unnecessary race in test.
[arvados.git] / apps / workbench / app / assets / javascripts / users.js
index c9c69a0a64529860adf022b6925713b1a454f5bb..565ea9cbd60fb1138f91df0ebe261f427fb706c6 100644 (file)
@@ -1,8 +1,19 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
 $(document).
+    on('notifications:recount',
+       function() {
+           var menu = $('.notification-menu');
+           n = $('.notification', menu).not('.empty').length;
+           $('.notification-count', menu).html(n>0 ? n : '');
+       }).
     on('ajax:success', 'form.new_authorized_key',
        function(e, data, status, xhr) {
-           $(e.target).parents('div.daxalert').fadeOut('slow', function() {
-               $('<div class="alert alert-success daxalert"><button type="button" class="close" data-dismiss="alert">&times;</button><p>Key added.</p></div>').hide().replaceAll(this).fadeIn('slow');
+           $(e.target).parents('.notification').eq(0).fadeOut('slow', function() {
+               $('<li class="alert alert-success daxalert">SSH key added.</li>').hide().replaceAll(this).fadeIn('slow');
+               $(document).trigger('notifications:recount');
            });
        }).
     on('ajax:complete', 'form.new_authorized_key',
@@ -22,7 +33,7 @@ $(document).
            if (response.errors) {
                error_div.html($('<p/>').text(response.errors).html());
            } else {
-               error_div.html('<p>Sorry, request failed.');
+               error_div.html('<p>Sorry, request failed.</p>');
            }
            error_div.show();
            $($('input[name=disable_element]', e.target).val()).