Skip to content

Commit b4196ee

Browse files
author
OpenShift Bot
authoredSep 18, 2017
Merge pull request #1788 from wgordon17/login-shortcut
Merged by openshift-bot
2 parents 164ae0a + 23d188b commit b4196ee

File tree

3 files changed

+66
-3
lines changed

3 files changed

+66
-3
lines changed
 

Diff for: ‎app/scripts/directives/util.js

+30
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,36 @@ angular.module('openshiftConsole')
103103
}
104104
};
105105
})
106+
.directive('copyLoginToClipboard', function(NotificationsService) {
107+
return {
108+
restrict: 'E',
109+
replace: true,
110+
scope: {
111+
clipboardText: "="
112+
},
113+
template: '<a href="" data-clipboard-text="">Copy Login Command</a>',
114+
link: function($scope, element) {
115+
var clipboard = new Clipboard( element.get(0) );
116+
clipboard.on('success', function () {
117+
NotificationsService.addNotification({
118+
id: 'copied_to_clipboard_toast_success',
119+
type: 'warning',
120+
message: 'Do not share the API token in your clipboard. A token is a form of a password.'
121+
});
122+
});
123+
clipboard.on('error', function () {
124+
NotificationsService.addNotification({
125+
id: 'copied_to_clipboard_toast_error',
126+
type: 'error',
127+
message: 'Unable to copy.'
128+
});
129+
});
130+
element.on('$destroy', function() {
131+
clipboard.destroy();
132+
});
133+
}
134+
};
135+
})
106136
.directive('shortId', function() {
107137
return {
108138
restrict:'E',

Diff for: ‎app/scripts/extensions/nav/userDropdown.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
'use strict';
22

33
angular.module('openshiftConsole')
4-
.run(function(extensionRegistry, $rootScope) {
4+
.run(function(extensionRegistry, $rootScope, DataService, AuthService) {
55
extensionRegistry
66
.add('nav-user-dropdown', function() {
77
var msg = 'Log out';
88
if ($rootScope.user.fullName && $rootScope.user.fullName !== $rootScope.user.metadata.name) {
99
msg += ' (' + $rootScope.user.metadata.name + ')';
1010
}
1111
return [{
12+
type: 'dom',
13+
node: '<li><copy-login-to-clipboard clipboard-text="\'oc login ' + DataService.openshiftAPIBaseUrl() + ' --token=' + AuthService.UserStore().getToken() + '\'"></copy-login-to-clipboard></li>'
14+
},{
1215
type: 'dom',
1316
node: '<li><a href="logout">' + _.escape(msg) + '</a></li>'
1417
}];

Diff for: ‎dist/scripts/scripts.js

+32-2
Original file line numberDiff line numberDiff line change
@@ -10382,7 +10382,34 @@ r.destroy();
1038210382
});
1038310383
}
1038410384
};
10385-
}).directive("shortId", function() {
10385+
}).directive("copyLoginToClipboard", [ "NotificationsService", function(e) {
10386+
return {
10387+
restrict: "E",
10388+
replace: !0,
10389+
scope: {
10390+
clipboardText: "="
10391+
},
10392+
template: '<a href="" data-clipboard-text="">Copy Login Command</a>',
10393+
link: function(t, n) {
10394+
var a = new Clipboard(n.get(0));
10395+
a.on("success", function() {
10396+
e.addNotification({
10397+
id: "copied_to_clipboard_toast_success",
10398+
type: "warning",
10399+
message: "Do not share the API token in your clipboard. A token is a form of a password."
10400+
});
10401+
}), a.on("error", function() {
10402+
e.addNotification({
10403+
id: "copied_to_clipboard_toast_error",
10404+
type: "error",
10405+
message: "Unable to copy."
10406+
});
10407+
}), n.on("$destroy", function() {
10408+
a.destroy();
10409+
});
10410+
}
10411+
};
10412+
} ]).directive("shortId", function() {
1038610413
return {
1038710414
restrict: "E",
1038810415
scope: {
@@ -15445,11 +15472,14 @@ type: "dom",
1544515472
node: '<li><a href="about">About</a></li>'
1544615473
}), e;
1544715474
});
15448-
} ]), angular.module("openshiftConsole").run([ "extensionRegistry", "$rootScope", function(e, t) {
15475+
} ]), angular.module("openshiftConsole").run([ "extensionRegistry", "$rootScope", "DataService", "AuthService", function(e, t, n, a) {
1544915476
e.add("nav-user-dropdown", function() {
1545015477
var e = "Log out";
1545115478
return t.user.fullName && t.user.fullName !== t.user.metadata.name && (e += " (" + t.user.metadata.name + ")"), [ {
1545215479
type: "dom",
15480+
node: "<li><copy-login-to-clipboard clipboard-text=\"'oc login " + n.openshiftAPIBaseUrl() + " --token=" + a.UserStore().getToken() + "'\"></copy-login-to-clipboard></li>"
15481+
}, {
15482+
type: "dom",
1545315483
node: '<li><a href="logout">' + _.escape(e) + "</a></li>"
1545415484
} ];
1545515485
});

0 commit comments

Comments
 (0)
Please sign in to comment.