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

Copy login command shouldn't be wrapped in quotes #2135

Merged
merged 1 commit into from
Sep 21, 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
34 changes: 16 additions & 18 deletions app/scripts/directives/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ angular.module('openshiftConsole')
}
};
})
.directive('copyLoginToClipboard', function(AlertMessageService, NotificationsService) {
.directive('copyLoginToClipboard', function(NotificationsService) {
return {
restrict: 'E',
replace: true,
scope: {
clipboardText: "="
clipboardText: "@"
},
template: '<a href="" data-clipboard-text="">Copy Login Command</a>',
link: function($scope, element) {
Expand All @@ -121,22 +121,20 @@ angular.module('openshiftConsole')
});

var tokenWarningAlertID = 'openshift/token-warning';
if (!AlertMessageService.isAlertPermanentlyHidden(tokenWarningAlertID)) {
NotificationsService.addNotification({
id: tokenWarningAlertID,
type: 'warning',
message: 'A token is a form of a password. Do not share your API token.',
links: [{
href: "",
label: "Don't Show Me Again",
onClick: function() {
AlertMessageService.permanentlyHideAlert(tokenWarningAlertID);
// Return true close the existing alert.
return true;
}
}]
});
}
NotificationsService.addNotification({
id: tokenWarningAlertID,
type: 'warning',
message: 'A token is a form of a password. Do not share your API token.',
links: [{
href: "",
label: "Don't Show Me Again",
onClick: function() {
NotificationsService.permanentlyHideNotification(tokenWarningAlertID);
// Return true close the existing notification.
return true;
}
}]
});
});
clipboard.on('error', function () {
NotificationsService.addNotification({
Expand Down
5 changes: 4 additions & 1 deletion app/scripts/extensions/nav/userDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ angular.module('openshiftConsole')
if (!_.get(window, 'OPENSHIFT_CONSTANTS.DISABLE_COPY_LOGIN_COMMAND')) {
items.push({
type: 'dom',
node: '<li><copy-login-to-clipboard clipboard-text="\'oc login ' + DataService.openshiftAPIBaseUrl() + ' --token=' + AuthService.UserStore().getToken() + '\'"></copy-login-to-clipboard></li>'
node: '<li><copy-login-to-clipboard clipboard-text="oc login ' +
_.escape(DataService.openshiftAPIBaseUrl()) +
' --token=' +
_.escape(AuthService.UserStore().getToken()) + '"></copy-login-to-clipboard></li>'
});
}

Expand Down
26 changes: 13 additions & 13 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10566,42 +10566,42 @@ r.destroy();
});
}
};
}).directive("copyLoginToClipboard", [ "AlertMessageService", "NotificationsService", function(e, t) {
}).directive("copyLoginToClipboard", [ "NotificationsService", function(e) {
return {
restrict: "E",
replace: !0,
scope: {
clipboardText: "="
clipboardText: "@"
},
template: '<a href="" data-clipboard-text="">Copy Login Command</a>',
link: function(n, a) {
var r = new Clipboard(a.get(0));
r.on("success", function() {
t.addNotification({
link: function(t, n) {
var a = new Clipboard(n.get(0));
a.on("success", function() {
e.addNotification({
id: "copy-login-command-success",
type: "success",
message: "Login command copied."
});
e.isAlertPermanentlyHidden("openshift/token-warning") || t.addNotification({
e.addNotification({
id: "openshift/token-warning",
type: "warning",
message: "A token is a form of a password. Do not share your API token.",
links: [ {
href: "",
label: "Don't Show Me Again",
onClick: function() {
return e.permanentlyHideAlert("openshift/token-warning"), !0;
return e.permanentlyHideNotification("openshift/token-warning"), !0;
}
} ]
});
}), r.on("error", function() {
t.addNotification({
}), a.on("error", function() {
e.addNotification({
id: "copy-login-command-error",
type: "error",
message: "Unable to copy the login command."
});
}), a.on("$destroy", function() {
r.destroy();
}), n.on("$destroy", function() {
a.destroy();
});
}
};
Expand Down Expand Up @@ -15693,7 +15693,7 @@ e.add("nav-user-dropdown", function() {
var e = [];
_.get(window, "OPENSHIFT_CONSTANTS.DISABLE_COPY_LOGIN_COMMAND") || e.push({
type: "dom",
node: "<li><copy-login-to-clipboard clipboard-text=\"'oc login " + n.openshiftAPIBaseUrl() + " --token=" + a.UserStore().getToken() + "'\"></copy-login-to-clipboard></li>"
node: '<li><copy-login-to-clipboard clipboard-text="oc login ' + _.escape(n.openshiftAPIBaseUrl()) + " --token=" + _.escape(a.UserStore().getToken()) + '"></copy-login-to-clipboard></li>'
});
var r = "Log Out";
return t.user.fullName && t.user.fullName !== t.user.metadata.name && (r += " (" + t.user.metadata.name + ")"), e.push({
Expand Down