Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add oc login quick command to help dropdown #1788

Merged
merged 1 commit into from
Sep 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prob should say Unable to copy token or something just a touch more specific?

});
});
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
34 changes: 32 additions & 2 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10140,7 +10140,34 @@ r.destroy();
});
}
};
}).directive("shortId", function() {
}).directive("copyLoginToClipboard", [ "NotificationsService", function(e) {
return {
restrict: "E",
replace: !0,
scope: {
clipboardText: "="
},
template: '<a href="" data-clipboard-text="">Copy Login Command</a>',
link: function(t, n) {
var a = new Clipboard(n.get(0));
a.on("success", function() {
e.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."
});
}), a.on("error", function() {
e.addNotification({
id: "copied_to_clipboard_toast_error",
type: "error",
message: "Unable to copy."
});
}), n.on("$destroy", function() {
a.destroy();
});
}
};
} ]).directive("shortId", function() {
return {
restrict: "E",
scope: {
Expand Down Expand Up @@ -14812,11 +14839,14 @@ type: "dom",
node: '<li><a href="about">About</a></li>'
}), e;
});
} ]), angular.module("openshiftConsole").run([ "extensionRegistry", "$rootScope", function(e, t) {
} ]), angular.module("openshiftConsole").run([ "extensionRegistry", "$rootScope", "DataService", "AuthService", function(e, t, n, a) {
e.add("nav-user-dropdown", function() {
var e = "Log out";
return t.user.fullName && t.user.fullName !== t.user.metadata.name && (e += " (" + t.user.metadata.name + ")"), [ {
type: "dom",
node: "<li><copy-login-to-clipboard clipboard-text=\"'oc login " + n.openshiftAPIBaseUrl() + " --token=" + a.UserStore().getToken() + "'\"></copy-login-to-clipboard></li>"
}, {
type: "dom",
node: '<li><a href="logout">' + _.escape(e) + "</a></li>"
} ];
});
Expand Down