Backed out changeset 7b9687c90aea (bug 1368022) for eslint failures, e.g. in console-output.js. r=backout

This commit is contained in:
Sebastian Hengst 2017-05-29 18:08:01 +02:00
parent d94844731c
commit 6f73ea710d
6 changed files with 34 additions and 6 deletions

View File

@ -16,6 +16,7 @@ const {
getAllMessagesUiById, getAllMessagesUiById,
getAllMessagesTableDataById, getAllMessagesTableDataById,
} = require("devtools/client/webconsole/new-console-output/selectors/messages"); } = require("devtools/client/webconsole/new-console-output/selectors/messages");
const { getScrollSetting } = require("devtools/client/webconsole/new-console-output/selectors/ui");
const MessageContainer = createFactory(require("devtools/client/webconsole/new-console-output/components/message-container").MessageContainer); const MessageContainer = createFactory(require("devtools/client/webconsole/new-console-output/components/message-container").MessageContainer);
const ConsoleOutput = createClass({ const ConsoleOutput = createClass({
@ -30,6 +31,7 @@ const ConsoleOutput = createClass({
openContextMenu: PropTypes.func.isRequired, openContextMenu: PropTypes.func.isRequired,
sourceMapService: PropTypes.object, sourceMapService: PropTypes.object,
}), }),
autoscroll: PropTypes.bool.isRequired,
dispatch: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired,
timestampsVisible: PropTypes.bool, timestampsVisible: PropTypes.bool,
messagesTableData: PropTypes.object.isRequired, messagesTableData: PropTypes.object.isRequired,
@ -45,16 +47,17 @@ const ConsoleOutput = createClass({
}, },
componentWillUpdate(nextProps, nextState) { componentWillUpdate(nextProps, nextState) {
const outputNode = this.outputNode; if (!this.outputNode) {
if (!outputNode || !outputNode.lastChild) { return;
return;
} }
const outputNode = this.outputNode;
// Figure out if we are at the bottom. If so, then any new message should be scrolled // Figure out if we are at the bottom. If so, then any new message should be scrolled
// into view. // into view.
const lastChild = outputNode.lastChild; if (this.props.autoscroll && outputNode.lastChild) {
const delta = nextProps.messages.size - this.props.messages.size; this.shouldScrollBottom = isScrolledToBottom(outputNode.lastChild, outputNode);
this.shouldScrollBottom = delta > 0 && isScrolledToBottom(lastChild, outputNode); }
}, },
componentDidUpdate() { componentDidUpdate() {
@ -72,6 +75,7 @@ const ConsoleOutput = createClass({
render() { render() {
let { let {
dispatch, dispatch,
autoscroll,
messages, messages,
messagesUi, messagesUi,
messagesTableData, messagesTableData,
@ -88,6 +92,7 @@ const ConsoleOutput = createClass({
serviceContainer, serviceContainer,
open: messagesUi.includes(message.id), open: messagesUi.includes(message.id),
tableData: messagesTableData.get(message.id), tableData: messagesTableData.get(message.id),
autoscroll,
indent: message.indent, indent: message.indent,
timestampsVisible, timestampsVisible,
}) })
@ -123,6 +128,7 @@ function mapStateToProps(state, props) {
messages: getAllMessages(state), messages: getAllMessages(state),
messagesUi: getAllMessagesUiById(state), messagesUi: getAllMessagesUiById(state),
messagesTableData: getAllMessagesTableDataById(state), messagesTableData: getAllMessagesTableDataById(state),
autoscroll: getScrollSetting(state),
timestampsVisible: state.ui.timestampsVisible, timestampsVisible: state.ui.timestampsVisible,
}; };
} }

View File

@ -34,6 +34,7 @@ const MessageContainer = createClass({
message: PropTypes.object.isRequired, message: PropTypes.object.isRequired,
open: PropTypes.bool.isRequired, open: PropTypes.bool.isRequired,
serviceContainer: PropTypes.object.isRequired, serviceContainer: PropTypes.object.isRequired,
autoscroll: PropTypes.bool.isRequired,
indent: PropTypes.number.isRequired, indent: PropTypes.number.isRequired,
tableData: PropTypes.object, tableData: PropTypes.object,
timestampsVisible: PropTypes.bool.isRequired, timestampsVisible: PropTypes.bool.isRequired,

View File

@ -17,6 +17,7 @@ ConsoleCommand.displayName = "ConsoleCommand";
ConsoleCommand.propTypes = { ConsoleCommand.propTypes = {
message: PropTypes.object.isRequired, message: PropTypes.object.isRequired,
autoscroll: PropTypes.bool.isRequired,
indent: PropTypes.number.isRequired, indent: PropTypes.number.isRequired,
timestampsVisible: PropTypes.bool.isRequired, timestampsVisible: PropTypes.bool.isRequired,
serviceContainer: PropTypes.object, serviceContainer: PropTypes.object,
@ -31,6 +32,7 @@ ConsoleCommand.defaultProps = {
*/ */
function ConsoleCommand(props) { function ConsoleCommand(props) {
const { const {
autoscroll,
indent, indent,
message, message,
timestampsVisible, timestampsVisible,
@ -50,6 +52,7 @@ function ConsoleCommand(props) {
level, level,
topLevelClasses: [], topLevelClasses: [],
messageBody, messageBody,
scrollToMessage: autoscroll,
serviceContainer, serviceContainer,
indent, indent,
timestampsVisible, timestampsVisible,

View File

@ -76,6 +76,7 @@ function EvaluationResult(props) {
topLevelClasses, topLevelClasses,
messageBody, messageBody,
messageId, messageId,
scrollToMessage: props.autoscroll,
serviceContainer, serviceContainer,
exceptionDocURL, exceptionDocURL,
frame, frame,

View File

@ -16,15 +16,27 @@ const Immutable = require("devtools/client/shared/vendor/immutable");
const UiState = Immutable.Record({ const UiState = Immutable.Record({
filterBarVisible: false, filterBarVisible: false,
filteredMessageVisible: false, filteredMessageVisible: false,
autoscroll: true,
timestampsVisible: true, timestampsVisible: true,
}); });
function ui(state = new UiState(), action) { function ui(state = new UiState(), action) {
// Autoscroll should be set for all action types. If the last action was not message
// add, then turn it off. This prevents us from scrolling after someone toggles a
// filter, or to the bottom of the attachment when an expandable message at the bottom
// of the list is expanded. It does depend on the MESSAGE_ADD action being the last in
// its batch, though.
// It also depends on REMOVED_MESSAGES_CLEAR action being sent after MESSAGE_ADD
// if number of messages reached the maximum limit.
let autoscroll = action.type == MESSAGE_ADD || action.type == REMOVED_MESSAGES_CLEAR;
state = state.set("autoscroll", autoscroll);
switch (action.type) { switch (action.type) {
case FILTER_BAR_TOGGLE: case FILTER_BAR_TOGGLE:
return state.set("filterBarVisible", !state.filterBarVisible); return state.set("filterBarVisible", !state.filterBarVisible);
case TIMESTAMPS_TOGGLE: case TIMESTAMPS_TOGGLE:
return state.set("timestampsVisible", action.visible); return state.set("timestampsVisible", action.visible);
} }
return state; return state;

View File

@ -10,6 +10,11 @@ function getAllUi(state) {
return state.ui; return state.ui;
} }
function getScrollSetting(state) {
return getAllUi(state).autoscroll;
}
module.exports = { module.exports = {
getAllUi, getAllUi,
getScrollSetting,
}; };