/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; const React = require("devtools/client/shared/vendor/react"); const Immutable = require("devtools/client/shared/vendor/immutable"); const { LocalizationHelper } = require("devtools/shared/l10n"); const l10n = new LocalizationHelper("devtools/client/locales/components.properties"); // Shortcuts const { PropTypes, createClass, DOM } = React; const { div, span, button } = DOM; // Priority Levels const PriorityLevels = { PRIORITY_INFO_LOW: 1, PRIORITY_INFO_MEDIUM: 2, PRIORITY_INFO_HIGH: 3, PRIORITY_WARNING_LOW: 4, PRIORITY_WARNING_MEDIUM: 5, PRIORITY_WARNING_HIGH: 6, PRIORITY_CRITICAL_LOW: 7, PRIORITY_CRITICAL_MEDIUM: 8, PRIORITY_CRITICAL_HIGH: 9, PRIORITY_CRITICAL_BLOCK: 10, }; /** * This component represents Notification Box - HTML alternative for * binding. * * See also MDN for more info about : * https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/notificationbox */ var NotificationBox = createClass({ displayName: "NotificationBox", propTypes: { // List of notifications appended into the box. notifications: PropTypes.arrayOf(PropTypes.shape({ // label to appear on the notification. label: PropTypes.string.isRequired, // Value used to identify the notification value: PropTypes.string.isRequired, // URL of image to appear on the notification. If "" then an icon // appropriate for the priority level is used. image: PropTypes.string.isRequired, // Notification priority; see Priority Levels. priority: PropTypes.number.isRequired, // Array of button descriptions to appear on the notification. buttons: PropTypes.arrayOf(PropTypes.shape({ // Function to be called when the button is activated. // This function is passed three arguments: // 1) the NotificationBox component the button is associated with // 2) the button description as passed to appendNotification. // 3) the element which was the target of the button press event. // If the return value from this function is not True, then the // notification is closed. The notification is also not closed // if an error is thrown. callback: PropTypes.func.isRequired, // The label to appear on the button. label: PropTypes.string.isRequired, // The accesskey attribute set on the