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 ['okButton', 'cancelButton', 'dismissButton',
36 * The text shown in the default action button.
39 defaultActionButtonText_: {
45 * The text shown in the secondary action button.
48 secondaryActionButtonText_: {
55 * @param {?media_router.Issue} issue
56 * @return {boolean} Whether or not to hide the blocking issue UI.
59 computeIsBlockingIssueHidden_: function(issue) {
60 return !issue || !issue.isBlocking;
64 * Returns true to hide the non-blocking issue UI, false to show it.
66 * @param {?media_router.Issue} issue
69 computeIsNonBlockingIssueHidden_: function(issue) {
70 return !issue || issue.isBlocking;
74 * @param {?media_router.Issue} issue
75 * @return {boolean} Whether or not to hide the non-blocking issue UI.
78 computeOptionalActionHidden_: function(issue) {
79 return !issue || !issue.secondaryActionType;
83 * Fires an issue-action-click event.
85 * @param {number} actionType The type of issue action.
88 fireIssueActionClick_: function(actionType) {
89 this.fire('issue-action-click', {
91 actionType: actionType,
92 helpPageId: this.issue.helpPageId
97 * Called when a default issue action is clicked.
99 * @param {!Event} event The event object.
102 onClickDefaultAction_: function(event) {
103 this.fireIssueActionClick_(this.issue.defaultActionType);
107 * Called when an optional issue action is clicked.
109 * @param {!Event} event The event object.
112 onClickOptAction_: function(event) {
113 this.fireIssueActionClick_(this.issue.secondaryActionType);
117 * Called when |issue| is updated. This updates the default and secondary
118 * action button text.
122 updateActionButtonText_: function() {
123 var defaultText = '';
124 var secondaryText = '';
126 defaultText = loadTimeData.getString(
127 this.issueActionTypeToButtonTextResource_[
128 this.issue.defaultActionType]);
130 if (this.issue.secondaryActionType) {
131 secondaryText = loadTimeData.getString(
132 this.issueActionTypeToButtonTextResource_[
133 this.issue.secondaryActionType]);
137 this.defaultActionButtonText_ = defaultText;
138 this.secondaryActionButtonText_ = secondaryText;