From e22f9eb967b2267d594492e3579872f7395c87ae Mon Sep 17 00:00:00 2001 From: Will Gordon Date: Fri, 30 Jun 2017 18:29:50 -0400 Subject: [PATCH] Add quick command to help dropdown Signed-off-by: Will Gordon --- app/scripts/directives/util.js | 30 +++++++++++++++++++ app/scripts/extensions/nav/userDropdown.js | 5 +++- dist/scripts/scripts.js | 34 ++++++++++++++++++++-- 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/app/scripts/directives/util.js b/app/scripts/directives/util.js index 021ca83486..6589deaf5c 100644 --- a/app/scripts/directives/util.js +++ b/app/scripts/directives/util.js @@ -103,6 +103,36 @@ angular.module('openshiftConsole') } }; }) + .directive('copyLoginToClipboard', function(NotificationsService) { + return { + restrict: 'E', + replace: true, + scope: { + clipboardText: "=" + }, + template: 'Copy Login Command', + link: function($scope, element) { + var clipboard = new Clipboard( element.get(0) ); + clipboard.on('success', function () { + NotificationsService.addNotification({ + id: 'copied_to_clipboard_toast_success', + type: 'warning', + message: 'Do not share the API token in your clipboard. A token is a form of a password.' + }); + }); + clipboard.on('error', function () { + NotificationsService.addNotification({ + id: 'copied_to_clipboard_toast_error', + type: 'error', + message: 'Unable to copy.' + }); + }); + element.on('$destroy', function() { + clipboard.destroy(); + }); + } + }; + }) .directive('shortId', function() { return { restrict:'E', diff --git a/app/scripts/extensions/nav/userDropdown.js b/app/scripts/extensions/nav/userDropdown.js index 08384c6d3c..f001a6edca 100644 --- a/app/scripts/extensions/nav/userDropdown.js +++ b/app/scripts/extensions/nav/userDropdown.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('openshiftConsole') - .run(function(extensionRegistry, $rootScope) { + .run(function(extensionRegistry, $rootScope, DataService, AuthService) { extensionRegistry .add('nav-user-dropdown', function() { var msg = 'Log out'; @@ -9,6 +9,9 @@ angular.module('openshiftConsole') msg += ' (' + $rootScope.user.metadata.name + ')'; } return [{ + type: 'dom', + node: '
  • ' + },{ type: 'dom', node: '
  • ' + _.escape(msg) + '
  • ' }]; diff --git a/dist/scripts/scripts.js b/dist/scripts/scripts.js index b8df875f74..fb5051eec6 100644 --- a/dist/scripts/scripts.js +++ b/dist/scripts/scripts.js @@ -10370,7 +10370,34 @@ e.destroy(); }); } }; -}).directive("shortId", function() { +}).directive("copyLoginToClipboard", [ "NotificationsService", function(a) { +return { +restrict:"E", +replace:!0, +scope:{ +clipboardText:"=" +}, +template:'Copy Login Command', +link:function(b, c) { +var d = new Clipboard(c.get(0)); +d.on("success", function() { +a.addNotification({ +id:"copied_to_clipboard_toast_success", +type:"warning", +message:"Do not share the API token in your clipboard. A token is a form of a password." +}); +}), d.on("error", function() { +a.addNotification({ +id:"copied_to_clipboard_toast_error", +type:"error", +message:"Unable to copy." +}); +}), c.on("$destroy", function() { +d.destroy(); +}); +} +}; +} ]).directive("shortId", function() { return { restrict:"E", scope:{ @@ -14999,11 +15026,14 @@ type:"dom", node:'
  • About
  • ' }), a; }); -} ]), angular.module("openshiftConsole").run([ "extensionRegistry", "$rootScope", function(a, b) { +} ]), angular.module("openshiftConsole").run([ "extensionRegistry", "$rootScope", "DataService", "AuthService", function(a, b, c, d) { a.add("nav-user-dropdown", function() { var a = "Log out"; return b.user.fullName && b.user.fullName !== b.user.metadata.name && (a += " (" + b.user.metadata.name + ")"), [ { type:"dom", +node:"
  • " +}, { +type:"dom", node:'
  • ' + _.escape(a) + "
  • " } ]; });