Bug 1349561 - Add UI for disabling browser cache in Net panel; r=gasolin,Honza

MozReview-Commit-ID: 881Gy0jh20Z

--HG--
extra : rebase_source : e4a1911d75550e0c5fdcacbc6307ea057422e5ac
This commit is contained in:
Swapnesh Kumar Sahoo 2017-07-19 17:37:44 +05:30
Родитель eead13a553
Коммит a19f2c13d1
7 изменённых файлов: 98 добавлений и 1 удалений

Просмотреть файл

@ -628,6 +628,14 @@ netmonitor.toolbar.filterFreetext.label=Filter URLs
# shortcut key to focus on the toolbar url filtering textbox # shortcut key to focus on the toolbar url filtering textbox
netmonitor.toolbar.filterFreetext.key=CmdOrCtrl+F netmonitor.toolbar.filterFreetext.key=CmdOrCtrl+F
# LOCALIZATION NOTE (netmonitor.toolbar.disableCache.label): This is the label
# displayed for the checkbox for disabling browser cache.
netmonitor.toolbar.disableCache.label=Disable cache
# LOCALIZATION NOTE (netmonitor.toolbar.disableCache.tooltip): This is the tooltip
# displayed for the checkbox for disabling browser cache.
netmonitor.toolbar.disableCache.tooltip=Disable HTTP cache
# LOCALIZATION NOTE (netmonitor.toolbar.clear): This is the label displayed # LOCALIZATION NOTE (netmonitor.toolbar.clear): This is the label displayed
# in the network toolbar for the "Clear" button. # in the network toolbar for the "Clear" button.
netmonitor.toolbar.clear=Clear netmonitor.toolbar.clear=Clear

Просмотреть файл

@ -7,6 +7,7 @@
const { const {
ACTIVITY_TYPE, ACTIVITY_TYPE,
OPEN_NETWORK_DETAILS, OPEN_NETWORK_DETAILS,
DISABLE_BROWSER_CACHE,
OPEN_STATISTICS, OPEN_STATISTICS,
RESET_COLUMNS, RESET_COLUMNS,
SELECT_DETAILS_PANEL_TAB, SELECT_DETAILS_PANEL_TAB,
@ -27,6 +28,18 @@ function openNetworkDetails(open) {
}; };
} }
/**
* Change browser cache state.
*
* @param {boolean} disabled - expected browser cache in disable state
*/
function disableBrowserCache(disabled) {
return {
type: DISABLE_BROWSER_CACHE,
disabled,
};
}
/** /**
* Change performance statistics panel open state. * Change performance statistics panel open state.
* *
@ -94,6 +107,14 @@ function toggleNetworkDetails() {
dispatch(openNetworkDetails(!getState().ui.networkDetailsOpen)); dispatch(openNetworkDetails(!getState().ui.networkDetailsOpen));
} }
/**
* Toggle browser cache status.
*/
function toggleBrowserCache() {
return (dispatch, getState) =>
dispatch(disableBrowserCache(!getState().ui.browserCacheDisabled));
}
/** /**
* Toggle performance statistics panel. * Toggle performance statistics panel.
*/ */
@ -104,11 +125,13 @@ function toggleStatistics() {
module.exports = { module.exports = {
openNetworkDetails, openNetworkDetails,
disableBrowserCache,
openStatistics, openStatistics,
resetColumns, resetColumns,
resizeWaterfall, resizeWaterfall,
selectDetailsPanelTab, selectDetailsPanelTab,
toggleColumn, toggleColumn,
toggleNetworkDetails, toggleNetworkDetails,
toggleBrowserCache,
toggleStatistics, toggleStatistics,
}; };

Просмотреть файл

@ -795,6 +795,17 @@ body,
margin: 1px 3px; margin: 1px 3px;
} }
.devtools-checkbox {
position: relative;
vertical-align: middle;
bottom: 1px;
}
.devtools-checkbox-label {
margin-inline-start: 10px;
margin-inline-end: 3px;
}
/* Empty notices in tab panels */ /* Empty notices in tab panels */
.empty-notice { .empty-notice {

Просмотреть файл

@ -4,6 +4,7 @@
"use strict"; "use strict";
const Services = require("Services");
const { const {
createClass, createClass,
createFactory, createFactory,
@ -25,7 +26,7 @@ const { L10N } = require("../utils/l10n");
// Components // Components
const SearchBox = createFactory(require("devtools/client/shared/components/search-box")); const SearchBox = createFactory(require("devtools/client/shared/components/search-box"));
const { button, div, span } = DOM; const { button, div, input, label, span } = DOM;
const COLLPASE_DETAILS_PANE = L10N.getStr("collapseDetailsPane"); const COLLPASE_DETAILS_PANE = L10N.getStr("collapseDetailsPane");
const EXPAND_DETAILS_PANE = L10N.getStr("expandDetailsPane"); const EXPAND_DETAILS_PANE = L10N.getStr("expandDetailsPane");
@ -33,6 +34,8 @@ const SEARCH_KEY_SHORTCUT = L10N.getStr("netmonitor.toolbar.filterFreetext.key")
const SEARCH_PLACE_HOLDER = L10N.getStr("netmonitor.toolbar.filterFreetext.label"); const SEARCH_PLACE_HOLDER = L10N.getStr("netmonitor.toolbar.filterFreetext.label");
const TOOLBAR_CLEAR = L10N.getStr("netmonitor.toolbar.clear"); const TOOLBAR_CLEAR = L10N.getStr("netmonitor.toolbar.clear");
const DEVTOOLS_DISABLE_CACHE_PREF = "devtools.cache.disabled";
/* /*
* Network monitor toolbar component * Network monitor toolbar component
* Toolbar contains a set of useful tools to control network requests * Toolbar contains a set of useful tools to control network requests
@ -47,6 +50,9 @@ const Toolbar = createClass({
networkDetailsToggleDisabled: PropTypes.bool.isRequired, networkDetailsToggleDisabled: PropTypes.bool.isRequired,
networkDetailsOpen: PropTypes.bool.isRequired, networkDetailsOpen: PropTypes.bool.isRequired,
toggleNetworkDetails: PropTypes.func.isRequired, toggleNetworkDetails: PropTypes.func.isRequired,
disableBrowserCache: PropTypes.func.isRequired,
toggleBrowserCache: PropTypes.func.isRequired,
browserCacheDisabled: PropTypes.bool.isRequired,
toggleRequestFilterType: PropTypes.func.isRequired, toggleRequestFilterType: PropTypes.func.isRequired,
}, },
@ -65,6 +71,8 @@ const Toolbar = createClass({
networkDetailsToggleDisabled, networkDetailsToggleDisabled,
networkDetailsOpen, networkDetailsOpen,
toggleNetworkDetails, toggleNetworkDetails,
toggleBrowserCache,
browserCacheDisabled,
} = this.props; } = this.props;
let toggleButtonClassName = [ let toggleButtonClassName = [
@ -102,6 +110,20 @@ const Toolbar = createClass({
onClick: clearRequests, onClick: clearRequests,
}), }),
div({ className: "requests-list-filter-buttons" }, buttons), div({ className: "requests-list-filter-buttons" }, buttons),
label(
{
className: "devtools-checkbox-label",
title: L10N.getStr("netmonitor.toolbar.disableCache.tooltip"),
},
input({
id: "devtools-cache-checkbox",
className: "devtools-checkbox",
type: "checkbox",
checked: browserCacheDisabled,
onClick: toggleBrowserCache,
}),
L10N.getStr("netmonitor.toolbar.disableCache.label"),
),
), ),
span({ className: "devtools-toolbar-group" }, span({ className: "devtools-toolbar-group" },
SearchBox({ SearchBox({
@ -122,6 +144,21 @@ const Toolbar = createClass({
) )
) )
); );
},
componentDidMount() {
Services.prefs.addObserver(DEVTOOLS_DISABLE_CACHE_PREF,
this.updateBrowserCacheDisabled);
},
componentWillUnmount() {
Services.prefs.removeObserver(DEVTOOLS_DISABLE_CACHE_PREF,
this.updateBrowserCacheDisabled);
},
updateBrowserCacheDisabled() {
this.props.disableBrowserCache(
Services.prefs.getBoolPref(DEVTOOLS_DISABLE_CACHE_PREF));
} }
}); });
@ -129,6 +166,7 @@ module.exports = connect(
(state) => ({ (state) => ({
networkDetailsToggleDisabled: isNetworkDetailsToggleButtonDisabled(state), networkDetailsToggleDisabled: isNetworkDetailsToggleButtonDisabled(state),
networkDetailsOpen: state.ui.networkDetailsOpen, networkDetailsOpen: state.ui.networkDetailsOpen,
browserCacheDisabled: state.ui.browserCacheDisabled,
requestFilterTypes: getRequestFilterTypes(state), requestFilterTypes: getRequestFilterTypes(state),
summary: getDisplayedRequestsSummary(state), summary: getDisplayedRequestsSummary(state),
}), }),
@ -137,5 +175,7 @@ module.exports = connect(
setRequestFilterText: (text) => dispatch(Actions.setRequestFilterText(text)), setRequestFilterText: (text) => dispatch(Actions.setRequestFilterText(text)),
toggleRequestFilterType: (type) => dispatch(Actions.toggleRequestFilterType(type)), toggleRequestFilterType: (type) => dispatch(Actions.toggleRequestFilterType(type)),
toggleNetworkDetails: () => dispatch(Actions.toggleNetworkDetails()), toggleNetworkDetails: () => dispatch(Actions.toggleNetworkDetails()),
disableBrowserCache: (disabled) => dispatch(Actions.disableBrowserCache(disabled)),
toggleBrowserCache: () => dispatch(Actions.toggleBrowserCache()),
}), }),
)(Toolbar); )(Toolbar);

Просмотреть файл

@ -14,6 +14,7 @@ const actionTypes = {
CLONE_SELECTED_REQUEST: "CLONE_SELECTED_REQUEST", CLONE_SELECTED_REQUEST: "CLONE_SELECTED_REQUEST",
ENABLE_REQUEST_FILTER_TYPE_ONLY: "ENABLE_REQUEST_FILTER_TYPE_ONLY", ENABLE_REQUEST_FILTER_TYPE_ONLY: "ENABLE_REQUEST_FILTER_TYPE_ONLY",
OPEN_NETWORK_DETAILS: "OPEN_NETWORK_DETAILS", OPEN_NETWORK_DETAILS: "OPEN_NETWORK_DETAILS",
DISABLE_BROWSER_CACHE: "DISABLE_BROWSER_CACHE",
OPEN_STATISTICS: "OPEN_STATISTICS", OPEN_STATISTICS: "OPEN_STATISTICS",
REMOVE_SELECTED_CUSTOM_REQUEST: "REMOVE_SELECTED_CUSTOM_REQUEST", REMOVE_SELECTED_CUSTOM_REQUEST: "REMOVE_SELECTED_CUSTOM_REQUEST",
RESET_COLUMNS: "RESET_COLUMNS", RESET_COLUMNS: "RESET_COLUMNS",

Просмотреть файл

@ -10,6 +10,7 @@ const {
RESET_COLUMNS, RESET_COLUMNS,
TOGGLE_COLUMN, TOGGLE_COLUMN,
TOGGLE_REQUEST_FILTER_TYPE, TOGGLE_REQUEST_FILTER_TYPE,
DISABLE_BROWSER_CACHE,
} = require("../constants"); } = require("../constants");
const { getRequestFilterTypes } = require("../selectors/index"); const { getRequestFilterTypes } = require("../selectors/index");
@ -30,6 +31,10 @@ function prefsMiddleware(store) {
Services.prefs.setCharPref( Services.prefs.setCharPref(
"devtools.netmonitor.filters", JSON.stringify(filters)); "devtools.netmonitor.filters", JSON.stringify(filters));
break; break;
case DISABLE_BROWSER_CACHE:
Services.prefs.setBoolPref(
"devtools.cache.disabled", store.getState().ui.browserCacheDisabled);
break;
case TOGGLE_COLUMN: case TOGGLE_COLUMN:
case RESET_COLUMNS: case RESET_COLUMNS:
let visibleColumns = [...store.getState().ui.columns] let visibleColumns = [...store.getState().ui.columns]

Просмотреть файл

@ -5,9 +5,11 @@
"use strict"; "use strict";
const I = require("devtools/client/shared/vendor/immutable"); const I = require("devtools/client/shared/vendor/immutable");
const Services = require("Services");
const { const {
CLEAR_REQUESTS, CLEAR_REQUESTS,
OPEN_NETWORK_DETAILS, OPEN_NETWORK_DETAILS,
DISABLE_BROWSER_CACHE,
OPEN_STATISTICS, OPEN_STATISTICS,
REMOVE_SELECTED_CUSTOM_REQUEST, REMOVE_SELECTED_CUSTOM_REQUEST,
RESET_COLUMNS, RESET_COLUMNS,
@ -51,6 +53,7 @@ const UI = I.Record({
columns: new Columns(), columns: new Columns(),
detailsPanelSelectedTab: "headers", detailsPanelSelectedTab: "headers",
networkDetailsOpen: false, networkDetailsOpen: false,
browserCacheDisabled: Services.prefs.getBoolPref("devtools.cache.disabled"),
statisticsOpen: false, statisticsOpen: false,
waterfallWidth: null, waterfallWidth: null,
}); });
@ -67,6 +70,10 @@ function openNetworkDetails(state, action) {
return state.set("networkDetailsOpen", action.open); return state.set("networkDetailsOpen", action.open);
} }
function disableBrowserCache(state, action) {
return state.set("browserCacheDisabled", action.disabled);
}
function openStatistics(state, action) { function openStatistics(state, action) {
return state.set("statisticsOpen", action.open); return state.set("statisticsOpen", action.open);
} }
@ -94,6 +101,8 @@ function ui(state = new UI(), action) {
return openNetworkDetails(state, { open: false }); return openNetworkDetails(state, { open: false });
case OPEN_NETWORK_DETAILS: case OPEN_NETWORK_DETAILS:
return openNetworkDetails(state, action); return openNetworkDetails(state, action);
case DISABLE_BROWSER_CACHE:
return disableBrowserCache(state, action);
case OPEN_STATISTICS: case OPEN_STATISTICS:
return openStatistics(state, action); return openStatistics(state, action);
case RESET_COLUMNS: case RESET_COLUMNS: