Skip to content

Commit 4be2b16

Browse files
author
OpenShift Bot
authored
Merge pull request #2135 from spadgett/fix-copy-login-quotes
Merged by openshift-bot
2 parents ac4c834 + 4c1afda commit 4be2b16

File tree

3 files changed

+33
-32
lines changed

3 files changed

+33
-32
lines changed

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

+16-18
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ angular.module('openshiftConsole')
103103
}
104104
};
105105
})
106-
.directive('copyLoginToClipboard', function(AlertMessageService, NotificationsService) {
106+
.directive('copyLoginToClipboard', function(NotificationsService) {
107107
return {
108108
restrict: 'E',
109109
replace: true,
110110
scope: {
111-
clipboardText: "="
111+
clipboardText: "@"
112112
},
113113
template: '<a href="" data-clipboard-text="">Copy Login Command</a>',
114114
link: function($scope, element) {
@@ -121,22 +121,20 @@ angular.module('openshiftConsole')
121121
});
122122

123123
var tokenWarningAlertID = 'openshift/token-warning';
124-
if (!AlertMessageService.isAlertPermanentlyHidden(tokenWarningAlertID)) {
125-
NotificationsService.addNotification({
126-
id: tokenWarningAlertID,
127-
type: 'warning',
128-
message: 'A token is a form of a password. Do not share your API token.',
129-
links: [{
130-
href: "",
131-
label: "Don't Show Me Again",
132-
onClick: function() {
133-
AlertMessageService.permanentlyHideAlert(tokenWarningAlertID);
134-
// Return true close the existing alert.
135-
return true;
136-
}
137-
}]
138-
});
139-
}
124+
NotificationsService.addNotification({
125+
id: tokenWarningAlertID,
126+
type: 'warning',
127+
message: 'A token is a form of a password. Do not share your API token.',
128+
links: [{
129+
href: "",
130+
label: "Don't Show Me Again",
131+
onClick: function() {
132+
NotificationsService.permanentlyHideNotification(tokenWarningAlertID);
133+
// Return true close the existing notification.
134+
return true;
135+
}
136+
}]
137+
});
140138
});
141139
clipboard.on('error', function () {
142140
NotificationsService.addNotification({

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ angular.module('openshiftConsole')
88
if (!_.get(window, 'OPENSHIFT_CONSTANTS.DISABLE_COPY_LOGIN_COMMAND')) {
99
items.push({
1010
type: 'dom',
11-
node: '<li><copy-login-to-clipboard clipboard-text="\'oc login ' + DataService.openshiftAPIBaseUrl() + ' --token=' + AuthService.UserStore().getToken() + '\'"></copy-login-to-clipboard></li>'
11+
node: '<li><copy-login-to-clipboard clipboard-text="oc login ' +
12+
_.escape(DataService.openshiftAPIBaseUrl()) +
13+
' --token=' +
14+
_.escape(AuthService.UserStore().getToken()) + '"></copy-login-to-clipboard></li>'
1215
});
1316
}
1417

Diff for: dist/scripts/scripts.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -10566,42 +10566,42 @@ r.destroy();
1056610566
});
1056710567
}
1056810568
};
10569-
}).directive("copyLoginToClipboard", [ "AlertMessageService", "NotificationsService", function(e, t) {
10569+
}).directive("copyLoginToClipboard", [ "NotificationsService", function(e) {
1057010570
return {
1057110571
restrict: "E",
1057210572
replace: !0,
1057310573
scope: {
10574-
clipboardText: "="
10574+
clipboardText: "@"
1057510575
},
1057610576
template: '<a href="" data-clipboard-text="">Copy Login Command</a>',
10577-
link: function(n, a) {
10578-
var r = new Clipboard(a.get(0));
10579-
r.on("success", function() {
10580-
t.addNotification({
10577+
link: function(t, n) {
10578+
var a = new Clipboard(n.get(0));
10579+
a.on("success", function() {
10580+
e.addNotification({
1058110581
id: "copy-login-command-success",
1058210582
type: "success",
1058310583
message: "Login command copied."
1058410584
});
10585-
e.isAlertPermanentlyHidden("openshift/token-warning") || t.addNotification({
10585+
e.addNotification({
1058610586
id: "openshift/token-warning",
1058710587
type: "warning",
1058810588
message: "A token is a form of a password. Do not share your API token.",
1058910589
links: [ {
1059010590
href: "",
1059110591
label: "Don't Show Me Again",
1059210592
onClick: function() {
10593-
return e.permanentlyHideAlert("openshift/token-warning"), !0;
10593+
return e.permanentlyHideNotification("openshift/token-warning"), !0;
1059410594
}
1059510595
} ]
1059610596
});
10597-
}), r.on("error", function() {
10598-
t.addNotification({
10597+
}), a.on("error", function() {
10598+
e.addNotification({
1059910599
id: "copy-login-command-error",
1060010600
type: "error",
1060110601
message: "Unable to copy the login command."
1060210602
});
10603-
}), a.on("$destroy", function() {
10604-
r.destroy();
10603+
}), n.on("$destroy", function() {
10604+
a.destroy();
1060510605
});
1060610606
}
1060710607
};
@@ -15693,7 +15693,7 @@ e.add("nav-user-dropdown", function() {
1569315693
var e = [];
1569415694
_.get(window, "OPENSHIFT_CONSTANTS.DISABLE_COPY_LOGIN_COMMAND") || e.push({
1569515695
type: "dom",
15696-
node: "<li><copy-login-to-clipboard clipboard-text=\"'oc login " + n.openshiftAPIBaseUrl() + " --token=" + a.UserStore().getToken() + "'\"></copy-login-to-clipboard></li>"
15696+
node: '<li><copy-login-to-clipboard clipboard-text="oc login ' + _.escape(n.openshiftAPIBaseUrl()) + " --token=" + _.escape(a.UserStore().getToken()) + '"></copy-login-to-clipboard></li>'
1569715697
});
1569815698
var r = "Log Out";
1569915699
return t.user.fullName && t.user.fullName !== t.user.metadata.name && (r += " (" + t.user.metadata.name + ")"), e.push({

0 commit comments

Comments
 (0)