Skip to content

Commit cc5c185

Browse files
committed
fix(pfEmptyState): avoid 'unsafe:javascript(void)' for empty helpLink url
1 parent 4c33e58 commit cc5c185

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

src/views/empty-state.component.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ angular.module('patternfly.views').component('pfEmptyState', {
123123
ctrl.updateConfig = function () {
124124
prevConfig = angular.copy(ctrl.config);
125125
_.defaults(ctrl.config, ctrl.defaultConfig);
126-
if (ctrl.config && ctrl.config.helpLink && angular.isUndefined(ctrl.config.helpLink.url)) {
127-
// if no url specified, set url to not redirect. ie. just do urlAction
128-
ctrl.config.helpLink.url = "javascript:void(0)";
129-
}
130126
};
131127

132128
ctrl.$onChanges = function (changesObj) {

src/views/empty-state.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ <h4 id="blank-state-pf-title-{{$id}}" class="h1 blank-state-pf-title">
88
<p id="blank-state-pf-info-{{$id}}" class="blank-state-pf-info" ng-if="$ctrl.config.info">
99
{{$ctrl.config.info}}
1010
</p>
11-
<p id="blank-state-pf-helpLink-{{$id}}" class="blank-state-pf-helpLink" ng-if="$ctrl.config.helpLink" ng-click="$ctrl.config.helpLink.urlAction()">
12-
{{$ctrl.config.helpLink.label}} <a href="{{$ctrl.config.helpLink.url}}">{{$ctrl.config.helpLink.urlLabel}}</a>.
11+
<p id="blank-state-pf-helpLink-{{$id}}" class="blank-state-pf-helpLink-label" ng-if="$ctrl.config.helpLink">
12+
{{$ctrl.config.helpLink.label}}
13+
<a ng-if="$ctrl.config.helpLink.url" class="blank-state-pf-helpLink" ng-click="$ctrl.config.helpLink.urlAction()" href="{{$ctrl.config.helpLink.url}}">{{$ctrl.config.helpLink.urlLabel}}</a>
14+
<button ng-if="!$ctrl.config.helpLink.url" class="btn blank-state-pf-helpbutton btn-link" ng-click="$ctrl.config.helpLink.urlAction()">{{$ctrl.config.helpLink.urlLabel}}</button>.
1315
</p>
1416
<div ng-if="$ctrl.hasMainActions()" class="blank-slate-pf-main-action">
1517
<button class="btn btn-primary btn-lg"

src/views/views.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@
108108
button {
109109
margin-right: 4px;
110110
}
111+
.blank-state-pf-helpbutton {
112+
padding-left: 0;
113+
padding-right: 0;
114+
vertical-align: baseline;
115+
}
111116
}
112117
/* overriding pf base so that buttons have spaces between them */
113118
.pf-expand-placeholder {

test/views/empty-state.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('Component: pfEmptyState', function () {
7474
expect(element.find('.pficon-add-circle-o').length).toBe(1);
7575
expect(element.find('.blank-state-pf-title').text()).toContain('Empty State Title');
7676
expect(element.find('.blank-state-pf-info').text()).toContain('This is the Empty State component');
77-
expect(element.find('.blank-state-pf-helpLink').text()).toContain('For more information please see');
77+
expect(element.find('.blank-state-pf-helpLink-label').text()).toContain('For more information please see');
7878
expect(element.find('a').text()).toContain('pfExample');
7979
expect(element.find('a').prop('href')).toContain('#/api/patternfly.views.component:pfEmptyState');
8080
element.find('.blank-state-pf-helpLink').click();

0 commit comments

Comments
 (0)