1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This Polymer element is used to show information about issues related
13 * @type {?media_router.Issue}
18 observer: 'updateActionButtonText_',
22 * Maps an issue action type to the resource identifier of the text shown
23 * in the action button.
24 * This is a property of issue-banner because it is used in tests.
25 * @type {!Array<string>}
27 issueActionTypeToButtonTextResource_: {
30 return ['dismissButton', 'learnMoreButton'];
35 * The text shown in the default action button.
38 defaultActionButtonText_: {
44 * The text shown in the secondary action button.
47 secondaryActionButtonText_: {
54 * @param {?media_router.Issue} issue
55 * @return {boolean} Whether or not to hide the blocking issue UI.
58 computeIsBlockingIssueHidden_: function(issue) {
59 return !issue || !issue.isBlocking;
63 * Returns true to hide the non-blocking issue UI, false to show it.
65 * @param {?media_router.Issue} issue
68 computeIsNonBlockingIssueHidden_: function(issue) {
69 return !issue || issue.isBlocking;
73 * @param {?media_router.Issue} issue The current issue.
74 * @return {string} The class for the overall issue-banner.
77 computeIssueClass_: function(issue) {
81 return issue.isBlocking ? 'blocking' : 'non-blocking';
85 * @param {?media_router.Issue} issue
86 * @return {boolean} Whether or not to hide the non-blocking issue UI.
89 computeOptionalActionHidden_: function(issue) {
90 return !issue || !issue.secondaryActionType;
94 * Fires an issue-action-click event.
96 * @param {number} actionType The type of issue action.
99 fireIssueActionClick_: function(actionType) {
100 this.fire('issue-action-click', {
102 actionType: actionType,
103 helpPageId: this.issue.helpPageId
108 * Called when a default issue action is clicked.
110 * @param {!Event} event The event object.
113 onClickDefaultAction_: function(event) {
114 this.fireIssueActionClick_(this.issue.defaultActionType);
118 * Called when an optional issue action is clicked.
120 * @param {!Event} event The event object.
123 onClickOptAction_: function(event) {
124 this.fireIssueActionClick_(this.issue.secondaryActionType);
128 * Called when |issue| is updated. This updates the default and secondary
129 * action button text.
133 updateActionButtonText_: function() {
134 var defaultText = '';
135 var secondaryText = '';
137 defaultText = loadTimeData.getString(
138 this.issueActionTypeToButtonTextResource_[
139 this.issue.defaultActionType]);
141 if (this.issue.secondaryActionType) {
142 secondaryText = loadTimeData.getString(
143 this.issueActionTypeToButtonTextResource_[
144 this.issue.secondaryActionType]);
148 this.defaultActionButtonText_ = defaultText;
149 this.secondaryActionButtonText_ = secondaryText;