--- a/devtools/client/netmonitor/actions/filters.js
+++ b/devtools/client/netmonitor/actions/filters.js
@@ -1,58 +1,58 @@
/* 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 {
- TOGGLE_FILTER_TYPE,
- ENABLE_FILTER_TYPE_ONLY,
- SET_FILTER_TEXT,
+ TOGGLE_REQUEST_FILTER_TYPE,
+ ENABLE_REQUEST_FILTER_TYPE_ONLY,
+ SET_REQUEST_FILTER_TEXT,
} = require("../constants");
/**
* Toggle an existing filter type state.
* If type 'all' is specified, all the other filter types are set to false.
* Available filter types are defined in filters reducer.
*
* @param {string} filter - A filter type is going to be updated
*/
-function toggleFilterType(filter) {
+function toggleRequestFilterType(filter) {
return {
- type: TOGGLE_FILTER_TYPE,
+ type: TOGGLE_REQUEST_FILTER_TYPE,
filter,
};
}
/**
* Enable filter type exclusively.
* Except filter type is set to true, all the other filter types are set
* to false.
* Available filter types are defined in filters reducer.
*
* @param {string} filter - A filter type is going to be updated
*/
-function enableFilterTypeOnly(filter) {
+function enableRequestFilterTypeOnly(filter) {
return {
- type: ENABLE_FILTER_TYPE_ONLY,
+ type: ENABLE_REQUEST_FILTER_TYPE_ONLY,
filter,
};
}
/**
* Set filter text.
*
* @param {string} text - A filter text is going to be set
*/
-function setFilterText(text) {
+function setRequestFilterText(text) {
return {
- type: SET_FILTER_TEXT,
+ type: SET_REQUEST_FILTER_TEXT,
text,
};
}
module.exports = {
- toggleFilterType,
- enableFilterTypeOnly,
- setFilterText,
+ toggleRequestFilterType,
+ enableRequestFilterTypeOnly,
+ setRequestFilterText,
};
--- a/devtools/client/netmonitor/components/filter-buttons.js
+++ b/devtools/client/netmonitor/components/filter-buttons.js
@@ -7,43 +7,43 @@
const { DOM, PropTypes } = require("devtools/client/shared/vendor/react");
const { connect } = require("devtools/client/shared/vendor/react-redux");
const { L10N } = require("../l10n");
const Actions = require("../actions/index");
const { button, div } = DOM;
function FilterButtons({
- filterTypes,
- triggerFilterType,
+ requestFilterTypes,
+ toggleRequestFilterType,
}) {
- const buttons = filterTypes.entrySeq().map(([type, checked]) => {
+ const buttons = requestFilterTypes.entrySeq().map(([type, checked]) => {
let classList = ["menu-filter-button"];
checked && classList.push("checked");
return button({
id: `requests-menu-filter-${type}-button`,
className: classList.join(" "),
"data-key": type,
- onClick: triggerFilterType,
- onKeyDown: triggerFilterType,
+ onClick: toggleRequestFilterType,
+ onKeyDown: toggleRequestFilterType,
}, L10N.getStr(`netmonitor.toolbar.filter.${type}`));
}).toArray();
return div({ id: "requests-menu-filter-buttons" }, buttons);
}
FilterButtons.propTypes = {
state: PropTypes.object.isRequired,
- triggerFilterType: PropTypes.func.iRequired,
+ toggleRequestFilterType: PropTypes.func.iRequired,
};
module.exports = connect(
- (state) => ({ filterTypes: state.filters.types }),
+ (state) => ({ requestFilterTypes: state.filters.requestFilterTypes }),
(dispatch) => ({
- triggerFilterType: (evt) => {
+ toggleRequestFilterType: (evt) => {
if (evt.type === "keydown" && (evt.key !== "" || evt.key !== "Enter")) {
return;
}
- dispatch(Actions.toggleFilterType(evt.target.dataset.key));
+ dispatch(Actions.toggleRequestFilterType(evt.target.dataset.key));
},
})
)(FilterButtons);
--- a/devtools/client/netmonitor/components/search-box.js
+++ b/devtools/client/netmonitor/components/search-box.js
@@ -14,12 +14,12 @@ module.exports = connect(
(state) => ({
delay: FREETEXT_FILTER_SEARCH_DELAY,
keyShortcut: L10N.getStr("netmonitor.toolbar.filterFreetext.key"),
placeholder: L10N.getStr("netmonitor.toolbar.filterFreetext.label"),
type: "filter",
}),
(dispatch) => ({
onChange: (url) => {
- dispatch(Actions.setFilterText(url));
+ dispatch(Actions.setRequestFilterText(url));
},
})
)(SearchBox);
--- a/devtools/client/netmonitor/constants.js
+++ b/devtools/client/netmonitor/constants.js
@@ -13,25 +13,25 @@ const general = {
const actionTypes = {
ADD_REQUEST: "ADD_REQUEST",
ADD_TIMING_MARKER: "ADD_TIMING_MARKER",
BATCH_ACTIONS: "BATCH_ACTIONS",
BATCH_ENABLE: "BATCH_ENABLE",
CLEAR_REQUESTS: "CLEAR_REQUESTS",
CLEAR_TIMING_MARKERS: "CLEAR_TIMING_MARKERS",
CLONE_SELECTED_REQUEST: "CLONE_SELECTED_REQUEST",
- ENABLE_FILTER_TYPE_ONLY: "ENABLE_FILTER_TYPE_ONLY",
+ ENABLE_REQUEST_FILTER_TYPE_ONLY: "ENABLE_REQUEST_FILTER_TYPE_ONLY",
OPEN_SIDEBAR: "OPEN_SIDEBAR",
OPEN_STATISTICS: "OPEN_STATISTICS",
PRESELECT_REQUEST: "PRESELECT_REQUEST",
REMOVE_SELECTED_CUSTOM_REQUEST: "REMOVE_SELECTED_CUSTOM_REQUEST",
SELECT_REQUEST: "SELECT_REQUEST",
- SET_FILTER_TEXT: "SET_FILTER_TEXT",
+ SET_REQUEST_FILTER_TEXT: "SET_REQUEST_FILTER_TEXT",
SORT_BY: "SORT_BY",
- TOGGLE_FILTER_TYPE: "TOGGLE_FILTER_TYPE",
+ TOGGLE_REQUEST_FILTER_TYPE: "TOGGLE_REQUEST_FILTER_TYPE",
UPDATE_REQUEST: "UPDATE_REQUEST",
WATERFALL_RESIZE: "WATERFALL_RESIZE",
};
// Descriptions for what this frontend is currently doing.
const ACTIVITY_TYPE = {
// Standing by and handling requests normally.
NONE: 0,
--- a/devtools/client/netmonitor/netmonitor-controller.js
+++ b/devtools/client/netmonitor/netmonitor-controller.js
@@ -261,17 +261,17 @@ var NetMonitorController = {
// Look for the request in the existing ones or wait for it to appear, if
// the network monitor is still loading.
let deferred = promise.defer();
let request = null;
let inspector = function () {
request = getDisplayedRequestById(gStore.getState(), requestId);
if (!request) {
// Reset filters so that the request is visible.
- gStore.dispatch(Actions.toggleFilterType("all"));
+ gStore.dispatch(Actions.toggleRequestFilterType("all"));
request = getDisplayedRequestById(gStore.getState(), requestId);
}
// If the request was found, select it. Otherwise this function will be
// called again once new requests arrive.
if (request) {
window.off(EVENTS.REQUEST_ADDED, inspector);
gStore.dispatch(Actions.selectRequest(request.id));
--- a/devtools/client/netmonitor/reducers/filters.js
+++ b/devtools/client/netmonitor/reducers/filters.js
@@ -1,19 +1,19 @@
/* 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 I = require("devtools/client/shared/vendor/immutable");
const {
- TOGGLE_FILTER_TYPE,
- ENABLE_FILTER_TYPE_ONLY,
- SET_FILTER_TEXT,
+ TOGGLE_REQUEST_FILTER_TYPE,
+ ENABLE_REQUEST_FILTER_TYPE_ONLY,
+ SET_REQUEST_FILTER_TEXT,
} = require("../constants");
const FilterTypes = I.Record({
all: false,
html: false,
css: false,
js: false,
xhr: false,
@@ -21,21 +21,21 @@ const FilterTypes = I.Record({
images: false,
media: false,
flash: false,
ws: false,
other: false,
});
const Filters = I.Record({
- types: new FilterTypes({ all: true }),
- text: "",
+ requestFilterTypes: new FilterTypes({ all: true }),
+ requestFilterText: "",
});
-function toggleFilterType(state, action) {
+function toggleRequestFilterType(state, action) {
let { filter } = action;
let newState;
// Ignore unknown filter type
if (!state.has(filter)) {
return state;
}
if (filter === "all") {
@@ -49,33 +49,35 @@ function toggleFilterType(state, action)
if (!newState.includes(true)) {
newState = new FilterTypes({ all: true });
}
return newState;
}
-function enableFilterTypeOnly(state, action) {
+function enableRequestFilterTypeOnly(state, action) {
let { filter } = action;
// Ignore unknown filter type
if (!state.has(filter)) {
return state;
}
return new FilterTypes({ [filter]: true });
}
function filters(state = new Filters(), action) {
switch (action.type) {
- case TOGGLE_FILTER_TYPE:
- return state.set("types", toggleFilterType(state.types, action));
- case ENABLE_FILTER_TYPE_ONLY:
- return state.set("types", enableFilterTypeOnly(state.types, action));
- case SET_FILTER_TEXT:
- return state.set("text", action.text);
+ case TOGGLE_REQUEST_FILTER_TYPE:
+ return state.set("requestFilterTypes",
+ toggleRequestFilterType(state.requestFilterTypes, action));
+ case ENABLE_REQUEST_FILTER_TYPE_ONLY:
+ return state.set("requestFilterTypes",
+ enableRequestFilterTypeOnly(state.requestFilterTypes, action));
+ case SET_REQUEST_FILTER_TEXT:
+ return state.set("requestFilterText", action.text);
default:
return state;
}
}
module.exports = filters;
--- a/devtools/client/netmonitor/requests-menu-view.js
+++ b/devtools/client/netmonitor/requests-menu-view.js
@@ -67,17 +67,17 @@ RequestsMenuView.prototype = {
initialize: function (store) {
dumpn("Initializing the RequestsMenuView");
this.store = store;
this.contextMenu = new RequestListContextMenu();
this.contextMenu.initialize(store);
- Prefs.filters.forEach(type => store.dispatch(Actions.toggleFilterType(type)));
+ Prefs.filters.forEach(type => store.dispatch(Actions.toggleRequestFilterType(type)));
// Watch selection changes
this.store.subscribe(storeWatcher(
null,
() => getSelectedRequest(this.store.getState()),
(newSelected, oldSelected) => this.onSelectionUpdate(newSelected, oldSelected)
));
--- a/devtools/client/netmonitor/selectors/filters.js
+++ b/devtools/client/netmonitor/selectors/filters.js
@@ -1,13 +1,14 @@
/* 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 getActiveFilters(state) {
- return state.filters.types.toSeq().filter(checked => checked).keySeq().toArray();
+ return state.filters.requestFilterTypes.toSeq()
+ .filter(checked => checked).keySeq().toArray();
}
module.exports = {
getActiveFilters
};
--- a/devtools/client/netmonitor/selectors/requests.js
+++ b/devtools/client/netmonitor/selectors/requests.js
@@ -19,20 +19,20 @@ function getOrigRequest(requests, req) {
const origId = req.id.replace(/-clone$/, "");
return requests.find(r => r.id === origId);
}
const getFilterFn = createSelector(
state => state.filters,
filters => r => {
- const matchesType = filters.types.some((enabled, filter) => {
+ const matchesType = filters.requestFilterTypes.some((enabled, filter) => {
return enabled && Filters[filter] && Filters[filter](r);
});
- return matchesType && isFreetextMatch(r, filters.text);
+ return matchesType && isFreetextMatch(r, filters.requestFilterText);
}
);
const getSortFn = createSelector(
state => state.requests.requests,
state => state.sort,
(requests, sort) => {
let dataSorter = Sorters[sort.type || "waterfall"];
--- a/devtools/client/netmonitor/statistics-view.js
+++ b/devtools/client/netmonitor/statistics-view.js
@@ -166,17 +166,17 @@ StatisticsView.prototype = {
data: data,
strings: strings,
totals: totals,
sorted: sorted
});
chart.on("click", (_, item) => {
// Reset FilterButtons and enable one filter exclusively
- this.store.dispatch(Actions.enableFilterTypeOnly(item.label));
+ this.store.dispatch(Actions.enableRequestFilterTypeOnly(item.label));
this.store.dispatch(Actions.openStatistics(false));
});
container.appendChild(chart.node);
},
/**
* Sanitizes the data source used for creating charts, to follow the
--- a/devtools/client/netmonitor/test/browser_net_filter-01.js
+++ b/devtools/client/netmonitor/test/browser_net_filter-01.js
@@ -130,17 +130,17 @@ const EXPECTED_REQUESTS = [
add_task(function* () {
let Actions = require("devtools/client/netmonitor/actions/index");
let { monitor } = yield initNetMonitor(FILTERING_URL);
let { gStore } = monitor.panelWin;
function setFreetextFilter(value) {
- gStore.dispatch(Actions.setFilterText(value));
+ gStore.dispatch(Actions.setRequestFilterText(value));
}
info("Starting test... ");
let { $, NetMonitorView } = monitor.panelWin;
let { RequestsMenu } = NetMonitorView;
RequestsMenu.lazyUpdate = false;
--- a/devtools/client/netmonitor/test/browser_net_icon-preview.js
+++ b/devtools/client/netmonitor/test/browser_net_icon-preview.js
@@ -23,17 +23,17 @@ add_task(function* () {
info("Checking the image thumbnail when all items are shown.");
checkImageThumbnail();
gStore.dispatch(Actions.sortBy("size"));
info("Checking the image thumbnail when all items are sorted.");
checkImageThumbnail();
- gStore.dispatch(Actions.toggleFilterType("images"));
+ gStore.dispatch(Actions.toggleRequestFilterType("images"));
info("Checking the image thumbnail when only images are shown.");
checkImageThumbnail();
info("Reloading the debuggee and performing all requests again...");
wait = waitForEvents();
yield reloadAndPerformRequests();
yield wait;
--- a/devtools/client/netmonitor/test/browser_net_prefs-reload.js
+++ b/devtools/client/netmonitor/test/browser_net_prefs-reload.js
@@ -29,17 +29,17 @@ add_task(function* () {
// A custom new value to be used for the verified preference.
newValue: ["html", "css"],
// Getter used to retrieve the current value from the frontend, in order
// to verify that the pref was applied properly.
validateValue: ($) => getActiveFilters(getState()),
// Predicate used to modify the frontend when setting the new pref value,
// before trying to validate the changes.
modifyFrontend: ($, value) => value.forEach(e =>
- getStore().dispatch(Actions.toggleFilterType(e)))
+ getStore().dispatch(Actions.toggleRequestFilterType(e)))
},
networkDetailsWidth: {
newValue: ~~(Math.random() * 200 + 100),
validateValue: ($) => ~~$("#details-pane").getAttribute("width"),
modifyFrontend: ($, value) => $("#details-pane").setAttribute("width", value)
},
networkDetailsHeight: {
newValue: ~~(Math.random() * 300 + 100),
--- a/devtools/client/netmonitor/test/components/filter-buttons.test.js
+++ b/devtools/client/netmonitor/test/components/filter-buttons.test.js
@@ -52,17 +52,17 @@ describe("FilterButtons::enableFilterOnl
};
const store = configureStore();
const wrapper = mount(Provider(
{ store },
FilterButtons()
));
- store.dispatch(Actions.enableFilterTypeOnly("xhr"));
+ store.dispatch(Actions.enableRequestFilterTypeOnly("xhr"));
asExpected(wrapper, expectXHRTypes, `when enableFilterOnly("xhr") is called`);
});
// integration test with redux store, action, reducer
describe("FilterButtons::toggleFilter:", () => {
const expectXHRJSTypes = {
all: false,
html: false,
@@ -78,18 +78,18 @@ describe("FilterButtons::toggleFilter:",
};
const store = configureStore();
const wrapper = mount(Provider(
{ store },
FilterButtons()
));
- store.dispatch(Actions.toggleFilterType("xhr"));
- store.dispatch(Actions.toggleFilterType("js"));
+ store.dispatch(Actions.toggleRequestFilterType("xhr"));
+ store.dispatch(Actions.toggleRequestFilterType("js"));
asExpected(wrapper, expectXHRJSTypes, `when xhr, js is toggled`);
});
function asExpected(wrapper, expectTypes, description) {
for (let type of Object.keys(expectTypes)) {
let checked = expectTypes[type] ? "checked" : "not checked";
let className = expectTypes[type] ?
"menu-filter-button checked": "menu-filter-button";
--- a/devtools/client/webconsole/test/browser_webconsole_netlogging_reset_filter.js
+++ b/devtools/client/webconsole/test/browser_webconsole_netlogging_reset_filter.js
@@ -42,17 +42,17 @@ add_task(function* () {
let panel = toolbox.getCurrentPanel();
let selected = panel.panelWin.NetMonitorView.RequestsMenu.selectedItem;
is(selected.method, htmlRequest.request.method,
"The correct request is selected");
is(selected.url, htmlRequest.request.url,
"The correct request is definitely selected");
// Filter out the HTML request.
- panel.panelWin.gStore.dispatch(Actions.toggleFilterType("js"));
+ panel.panelWin.gStore.dispatch(Actions.toggleRequestFilterType("js"));
yield toolbox.selectTool("webconsole");
is(toolbox.currentToolId, "webconsole", "Web console was selected");
yield hud.ui.openNetworkPanel(htmlRequest.actor);
panel.panelWin.NetMonitorView.RequestsMenu.selectedItem;
is(selected.method, htmlRequest.request.method,
"The correct request is selected");