diff options
Diffstat (limited to '')
-rw-r--r-- | devtools/client/webconsole/selectors/autocomplete.js | 13 | ||||
-rw-r--r-- | devtools/client/webconsole/selectors/filters.js | 10 | ||||
-rw-r--r-- | devtools/client/webconsole/selectors/history.js | 95 | ||||
-rw-r--r-- | devtools/client/webconsole/selectors/messages.js | 93 | ||||
-rw-r--r-- | devtools/client/webconsole/selectors/moz.build | 14 | ||||
-rw-r--r-- | devtools/client/webconsole/selectors/notifications.js | 12 | ||||
-rw-r--r-- | devtools/client/webconsole/selectors/prefs.js | 17 | ||||
-rw-r--r-- | devtools/client/webconsole/selectors/ui.js | 13 |
8 files changed, 267 insertions, 0 deletions
diff --git a/devtools/client/webconsole/selectors/autocomplete.js b/devtools/client/webconsole/selectors/autocomplete.js new file mode 100644 index 0000000000..cc868031ae --- /dev/null +++ b/devtools/client/webconsole/selectors/autocomplete.js @@ -0,0 +1,13 @@ +/* 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"; + +function getAutocompleteState(state) { + return state.autocomplete; +} + +module.exports = { + getAutocompleteState, +}; diff --git a/devtools/client/webconsole/selectors/filters.js b/devtools/client/webconsole/selectors/filters.js new file mode 100644 index 0000000000..c2be779442 --- /dev/null +++ b/devtools/client/webconsole/selectors/filters.js @@ -0,0 +1,10 @@ +/* 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"; + +function getAllFilters(state) { + return state.filters; +} + +exports.getAllFilters = getAllFilters; diff --git a/devtools/client/webconsole/selectors/history.js b/devtools/client/webconsole/selectors/history.js new file mode 100644 index 0000000000..531db8b8a8 --- /dev/null +++ b/devtools/client/webconsole/selectors/history.js @@ -0,0 +1,95 @@ +/* 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 { + HISTORY_BACK, + HISTORY_FORWARD, +} = require("resource://devtools/client/webconsole/constants.js"); + +function getHistory(state) { + return state.history; +} + +function getHistoryEntries(state) { + return state.history.entries; +} + +function getHistoryValue(state, direction) { + if (direction == HISTORY_BACK) { + return getPreviousHistoryValue(state); + } + if (direction == HISTORY_FORWARD) { + return getNextHistoryValue(state); + } + return null; +} + +function getNextHistoryValue(state) { + if (state.history.position < state.history.entries.length - 1) { + return state.history.entries[state.history.position + 1]; + } + + // The user didn't pick up anything from the history and returned + // back to the previous value (if any) that was in the input box. + return state.history.originalUserValue; +} + +function getPreviousHistoryValue(state) { + if (state.history.position > 0) { + return state.history.entries[state.history.position - 1]; + } + return null; +} + +function getReverseSearchResult(state) { + const { history } = state; + const { currentReverseSearchResults, currentReverseSearchResultsPosition } = + history; + + if ( + !Array.isArray(currentReverseSearchResults) || + currentReverseSearchResults.length === 0 || + !Number.isInteger(currentReverseSearchResultsPosition) + ) { + return null; + } + return currentReverseSearchResults[currentReverseSearchResultsPosition]; +} + +function getReverseSearchResultPosition(state) { + const { history } = state; + const { currentReverseSearchResultsPosition } = history; + if (!Number.isInteger(currentReverseSearchResultsPosition)) { + return currentReverseSearchResultsPosition; + } + + return currentReverseSearchResultsPosition + 1; +} + +function getReverseSearchTotalResults(state) { + const { history } = state; + const { currentReverseSearchResults } = history; + if (!currentReverseSearchResults) { + return null; + } + + return currentReverseSearchResults.length; +} + +function getTerminalEagerResult(state) { + const { history } = state; + return history.terminalEagerResult; +} + +module.exports = { + getHistory, + getHistoryEntries, + getHistoryValue, + getReverseSearchResult, + getReverseSearchResultPosition, + getReverseSearchTotalResults, + getTerminalEagerResult, +}; diff --git a/devtools/client/webconsole/selectors/messages.js b/devtools/client/webconsole/selectors/messages.js new file mode 100644 index 0000000000..1030b62518 --- /dev/null +++ b/devtools/client/webconsole/selectors/messages.js @@ -0,0 +1,93 @@ +/* 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"; + +loader.lazyRequireGetter( + this, + ["getParentWarningGroupMessageId", "getWarningGroupType"], + "resource://devtools/client/webconsole/utils/messages.js", + true +); + +function getMutableMessagesById(state) { + return state.messages.mutableMessagesById; +} + +function getMessage(state, id) { + return getMutableMessagesById(state).get(id); +} + +function getAllMessagesUiById(state) { + return state.messages.messagesUiById; +} + +function getAllDisabledMessagesById(state) { + return state.messages.disabledMessagesById; +} + +function getAllCssMessagesMatchingElements(state) { + return state.messages.cssMessagesMatchingElements; +} + +function getAllGroupsById(state) { + return state.messages.groupsById; +} + +function getCurrentGroup(state) { + return state.messages.currentGroup; +} + +function getVisibleMessages(state) { + return state.messages.visibleMessages; +} + +function getFilteredMessagesCount(state) { + return state.messages.filteredMessagesCount; +} + +function getAllRepeatById(state) { + return state.messages.repeatById; +} + +function getAllNetworkMessagesUpdateById(state) { + return state.messages.networkMessagesUpdateById; +} + +function getGroupsById(state) { + return state.messages.groupsById; +} + +function getAllWarningGroupsById(state) { + return state.messages.warningGroupsById; +} + +function getLastMessageId(state) { + return state.messages.lastMessageId; +} + +function isMessageInWarningGroup(message, visibleMessages = []) { + if (!getWarningGroupType(message)) { + return false; + } + + return visibleMessages.includes(getParentWarningGroupMessageId(message)); +} + +module.exports = { + getAllGroupsById, + getAllWarningGroupsById, + getMutableMessagesById, + getAllCssMessagesMatchingElements, + getAllMessagesUiById, + getAllDisabledMessagesById, + getAllNetworkMessagesUpdateById, + getAllRepeatById, + getCurrentGroup, + getFilteredMessagesCount, + getGroupsById, + getLastMessageId, + getMessage, + getVisibleMessages, + isMessageInWarningGroup, +}; diff --git a/devtools/client/webconsole/selectors/moz.build b/devtools/client/webconsole/selectors/moz.build new file mode 100644 index 0000000000..61f0f5243a --- /dev/null +++ b/devtools/client/webconsole/selectors/moz.build @@ -0,0 +1,14 @@ +# vim: set filetype=python: +# 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/. + +DevToolsModules( + "autocomplete.js", + "filters.js", + "history.js", + "messages.js", + "notifications.js", + "prefs.js", + "ui.js", +) diff --git a/devtools/client/webconsole/selectors/notifications.js b/devtools/client/webconsole/selectors/notifications.js new file mode 100644 index 0000000000..5d349c2a16 --- /dev/null +++ b/devtools/client/webconsole/selectors/notifications.js @@ -0,0 +1,12 @@ +/* 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"; + +function getAllNotifications(state) { + return state.notifications.notifications; +} + +module.exports = { + getAllNotifications, +}; diff --git a/devtools/client/webconsole/selectors/prefs.js b/devtools/client/webconsole/selectors/prefs.js new file mode 100644 index 0000000000..17d911a1ab --- /dev/null +++ b/devtools/client/webconsole/selectors/prefs.js @@ -0,0 +1,17 @@ +/* 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"; + +function getAllPrefs(state) { + return state.prefs; +} + +function getLogLimit(state) { + return state.prefs.logLimit; +} + +module.exports = { + getAllPrefs, + getLogLimit, +}; diff --git a/devtools/client/webconsole/selectors/ui.js b/devtools/client/webconsole/selectors/ui.js new file mode 100644 index 0000000000..f08a2c422b --- /dev/null +++ b/devtools/client/webconsole/selectors/ui.js @@ -0,0 +1,13 @@ +/* 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"; + +function getAllUi(state) { + return state.ui; +} + +module.exports = { + getAllUi, +}; |