Skip to content

Commit

Permalink
Add quick command to help dropdown
Browse files Browse the repository at this point in the history
Signed-off-by: Will Gordon <wgordon@redhat.com>
  • Loading branch information
wgordon17 committed Jul 26, 2017
1 parent 441f98f commit eb97643
Show file tree
Hide file tree
Showing 3 changed files with 8,733 additions and 8,537 deletions.
30 changes: 30 additions & 0 deletions app/scripts/directives/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,36 @@ angular.module('openshiftConsole')
}
};
})
.directive('copyLoginToClipboard', function(NotificationsService) {
return {
restrict: 'E',
replace: true,
scope: {
clipboardText: "="
},
template: '<a href="" data-clipboard-text="">Copy Login Command</a>',
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',
Expand Down
5 changes: 4 additions & 1 deletion app/scripts/extensions/nav/userDropdown.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
'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';
if ($rootScope.user.fullName && $rootScope.user.fullName !== $rootScope.user.metadata.name) {
msg += ' (' + $rootScope.user.metadata.name + ')';
}
return [{
type: 'dom',
node: '<li><copy-login-to-clipboard clipboard-text="\'oc login ' + DataService.openshiftAPIBaseUrl() + ' --token=' + AuthService.UserStore().getToken() + '\'"></copy-login-to-clipboard></li>'
},{
type: 'dom',
node: '<li><a href="logout">' + _.escape(msg) + '</a></li>'
}];
Expand Down
Loading

0 comments on commit eb97643

Please sign in to comment.