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

View File

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

View File

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

View File

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

View File

@ -16,15 +16,27 @@ const Immutable = require("devtools/client/shared/vendor/immutable");
const UiState = Immutable.Record({
filterBarVisible: false,
filteredMessageVisible: false,
autoscroll: true,
timestampsVisible: true,
});
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) {
case FILTER_BAR_TOGGLE:
return state.set("filterBarVisible", !state.filterBarVisible);
case TIMESTAMPS_TOGGLE:
return state.set("timestampsVisible", action.visible);
}
return state;

View File

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