Skip to content

Commit f4a3811

Browse files
author
Amineta Lo
committed
fix(pfEmptyState): Ability for urlAction in empty state component
1 parent 64bad5a commit f4a3811

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/views/empty-state.component.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
* <li>.icon - (string) class for main icon. Ex. 'pficon pficon-add-circle-o'
1212
* <li>.title - (string) Text for the main title
1313
* <li>.info - (string) Text for the main informational paragraph
14+
* <li>.helpLink - (object) Contains url specific properties and actions
15+
* <ul style='list-style-type: none'>
16+
* <li>.label - (string) Optional text label which appears before the urlLabel
17+
* <li>.urlLabel - (string) Optional text for the clickable portion of the link
18+
* <li>.url - (string) Optional text for url path
19+
* <li>.urlAction - (function) Optional function to invoke a url action when a callback method is specified.
20+
* When both urlAction and url are specified the component will first execute urlAction then nagivate to the url.
21+
* </ul>
1422
* </ul>
1523
* @param {array} actionButtons Buttons to display under the icon, title, and informational paragraph.
1624
* <ul style='list-style-type: none'>

src/views/empty-state.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <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">
11+
<p id="blank-state-pf-helpLink-{{$id}}" class="blank-state-pf-helpLink" ng-if="$ctrl.config.helpLink" ng-click="$ctrl.config.helpLink.urlAction()">
1212
{{$ctrl.config.helpLink.label}} <a href="{{$ctrl.config.helpLink.url}}">{{$ctrl.config.helpLink.urlLabel}}</a>.
1313
</p>
1414
<div ng-if="$ctrl.hasMainActions()" class="blank-slate-pf-main-action">

test/views/empty-state.spec.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ describe('Component: pfEmptyState', function () {
22
var $scope;
33
var $compile;
44
var element;
5-
var performedAction;
6-
var updateCount;
75

86
// load the controller's module
97
beforeEach(function () {
@@ -24,14 +22,20 @@ describe('Component: pfEmptyState', function () {
2422
};
2523

2624
beforeEach(function () {
25+
26+
var performEmptyStateAction = function () {
27+
$scope.eventText = 'Empty State Action Executed';
28+
};
29+
2730
$scope.config = {
2831
icon: 'pficon-add-circle-o',
2932
title: 'Empty State Title',
3033
info: "This is the Empty State component. The goal of a empty state pattern is to provide a good first impression that helps users to achieve their goals. It should be used when a view is empty because no objects exists and you want to guide the user to perform specific actions.",
3134
helpLink: {
3235
label: 'For more information please see',
3336
urlLabel: 'pfExample',
34-
url : '#/api/patternfly.views.component:pfEmptyState'
37+
url : '#/api/patternfly.views.component:pfEmptyState',
38+
urlAction: performEmptyStateAction
3539
}
3640
};
3741

@@ -73,6 +77,8 @@ describe('Component: pfEmptyState', function () {
7377
expect(element.find('.blank-state-pf-helpLink').text()).toContain('For more information please see');
7478
expect(element.find('a').text()).toContain('pfExample');
7579
expect(element.find('a').prop('href')).toContain('#/api/patternfly.views.component:pfEmptyState');
80+
element.find('.blank-state-pf-helpLink').click();
81+
expect($scope.eventText).toBe('Empty State Action Executed');
7682

7783
var buttons = element.find('button');
7884
expect(buttons.length).toBe(4);

0 commit comments

Comments
 (0)