Skip to content

Commit 1b45672

Browse files
Merge pull request #2448 from jhadvig/secret-data
Automatic merge from submit-queue. Bug 1509142 - Should not display the 'Reveal Secret' link when secret is without 'data' field @spadgett PTAL
2 parents bea6783 + acd3cd3 commit 1b45672

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

app/scripts/controllers/secret.js

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ angular.module('openshiftConsole')
3030
$scope.addToApplicationVisible = false;
3131

3232
$scope.addToApplication = function() {
33+
if (!$scope.secret.data) {
34+
return;
35+
}
3336
$scope.addToApplicationVisible = true;
3437
};
3538

app/views/browse/secret.html

+8-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ <h1 class="contains-actions">
1919
<button ng-if="project.metadata.name | canIAddToProject"
2020
type="button"
2121
class="btn btn-default hidden-xs"
22+
ng-disabled="!secret.data"
2223
ng-click="addToApplication()">
2324
Add to Application
2425
</button>
@@ -32,8 +33,8 @@ <h1 class="contains-actions">
3233
class="dropdown-toggle actions-dropdown-kebab visible-xs-inline"
3334
data-toggle="dropdown"><i class="fa fa-ellipsis-v" aria-hidden="true"></i><span class="sr-only">Actions</span></a>
3435
<ul class="dropdown-menu dropdown-menu-right actions action-button">
35-
<li ng-if="project.metadata.name | canIAddToProject" class="visible-xs">
36-
<a href="" role="button" ng-click="addToApplication()">Add to Application</a>
36+
<li ng-if="(project.metadata.name | canIAddToProject)" class="visible-xs">
37+
<a href="" role="button" ng-class="{ 'disabled-link': !secret.data }" ng-attr-aria-disabled="{{!secret.data ? 'true' : undefined}}" ng-click="addToApplication()">Add to Application</a>
3738
</li>
3839
<li ng-if="'secrets' | canI : 'update'">
3940
<a ng-href="{{secret | editYamlURL}}" role="button">Edit YAML</a>
@@ -61,7 +62,7 @@ <h1 class="contains-actions">
6162
<div class="resource-details">
6263
<h2 class="mar-top-none">
6364
{{secret.type}}
64-
<small class="mar-left-sm"><a href="" ng-click="view.showSecret = !view.showSecret">{{view.showSecret ? "Hide" : "Reveal"}} Secret</a></small>
65+
<small class="mar-left-sm"><a href="" ng-if="secret.data" ng-click="view.showSecret = !view.showSecret">{{view.showSecret ? "Hide" : "Reveal"}} Secret</a></small>
6566
</h2>
6667
<dl class="secret-data left">
6768
<div ng-repeat="(secretDataName, secretData) in decodedSecretData" class="image-source-item">
@@ -90,6 +91,10 @@ <h2 class="mar-top-none">
9091
</div>
9192
</div>
9293
</dl>
94+
<div ng-if="!secret.data" class="empty-state-message text-center">
95+
<h2>No data.</h2>
96+
<p>This secret has no data.</p>
97+
</div>
9398
<annotations annotations="secret.metadata.annotations"></annotations>
9499
</div>
95100
</div><!-- /col-* -->

dist/scripts/scripts.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6460,7 +6460,7 @@ link: "project/" + e.project + "/browse/secrets"
64606460
}, {
64616461
title: n.secretName
64626462
} ], n.addToApplicationVisible = !1, n.addToApplication = function() {
6463-
n.addToApplicationVisible = !0;
6463+
n.secret.data && (n.addToApplicationVisible = !0);
64646464
}, n.closeAddToApplication = function() {
64656465
n.addToApplicationVisible = !1;
64666466
}, r.get(e.project).then(_.spread(function(e, t) {

dist/scripts/templates.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -3576,7 +3576,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
35763576
"<h1 class=\"contains-actions\">\n" +
35773577
"<div class=\"pull-right dropdown\">\n" +
35783578
"\n" +
3579-
"<button ng-if=\"project.metadata.name | canIAddToProject\" type=\"button\" class=\"btn btn-default hidden-xs\" ng-click=\"addToApplication()\">\n" +
3579+
"<button ng-if=\"project.metadata.name | canIAddToProject\" type=\"button\" class=\"btn btn-default hidden-xs\" ng-disabled=\"!secret.data\" ng-click=\"addToApplication()\">\n" +
35803580
"Add to Application\n" +
35813581
"</button>\n" +
35823582
"<button type=\"button\" class=\"dropdown-toggle btn btn-default actions-dropdown-btn hidden-xs\" data-toggle=\"dropdown\" ng-hide=\"!('secrets' | canIDoAny)\">\n" +
@@ -3586,8 +3586,8 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
35863586
"\n" +
35873587
"<a href=\"\" ng-if=\"project.metadata.name | canIAddToProject\" class=\"dropdown-toggle actions-dropdown-kebab visible-xs-inline\" data-toggle=\"dropdown\"><i class=\"fa fa-ellipsis-v\" aria-hidden=\"true\"></i><span class=\"sr-only\">Actions</span></a>\n" +
35883588
"<ul class=\"dropdown-menu dropdown-menu-right actions action-button\">\n" +
3589-
"<li ng-if=\"project.metadata.name | canIAddToProject\" class=\"visible-xs\">\n" +
3590-
"<a href=\"\" role=\"button\" ng-click=\"addToApplication()\">Add to Application</a>\n" +
3589+
"<li ng-if=\"(project.metadata.name | canIAddToProject)\" class=\"visible-xs\">\n" +
3590+
"<a href=\"\" role=\"button\" ng-class=\"{ 'disabled-link': !secret.data }\" ng-attr-aria-disabled=\"{{!secret.data ? 'true' : undefined}}\" ng-click=\"addToApplication()\">Add to Application</a>\n" +
35913591
"</li>\n" +
35923592
"<li ng-if=\"'secrets' | canI : 'update'\">\n" +
35933593
"<a ng-href=\"{{secret | editYamlURL}}\" role=\"button\">Edit YAML</a>\n" +
@@ -3611,7 +3611,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
36113611
"<div class=\"resource-details\">\n" +
36123612
"<h2 class=\"mar-top-none\">\n" +
36133613
"{{secret.type}}\n" +
3614-
"<small class=\"mar-left-sm\"><a href=\"\" ng-click=\"view.showSecret = !view.showSecret\">{{view.showSecret ? \"Hide\" : \"Reveal\"}} Secret</a></small>\n" +
3614+
"<small class=\"mar-left-sm\"><a href=\"\" ng-if=\"secret.data\" ng-click=\"view.showSecret = !view.showSecret\">{{view.showSecret ? \"Hide\" : \"Reveal\"}} Secret</a></small>\n" +
36153615
"</h2>\n" +
36163616
"<dl class=\"secret-data left\">\n" +
36173617
"<div ng-repeat=\"(secretDataName, secretData) in decodedSecretData\" class=\"image-source-item\">\n" +
@@ -3636,6 +3636,10 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
36363636
"</div>\n" +
36373637
"</div>\n" +
36383638
"</dl>\n" +
3639+
"<div ng-if=\"!secret.data\" class=\"empty-state-message text-center\">\n" +
3640+
"<h2>No data.</h2>\n" +
3641+
"<p>This secret has no data.</p>\n" +
3642+
"</div>\n" +
36393643
"<annotations annotations=\"secret.metadata.annotations\"></annotations>\n" +
36403644
"</div>\n" +
36413645
"</div>\n" +

0 commit comments

Comments
 (0)