зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1380709 - Fetch Map/Set entries when expanding the Object Inspector. r=bgrins
Add getObjectEntries and loadObjectEntries as props for the ObjectInspector so we can display entries on Maps and Sets. MozReview-Commit-ID: Cy6SjxwclHI --HG-- extra : rebase_source : df3e2cd1c0be550322953cb6141948b5893a2370
This commit is contained in:
Родитель
bd22ff789d
Коммит
a9d80db97b
|
@ -21,6 +21,7 @@ const {
|
||||||
MESSAGE_TYPE,
|
MESSAGE_TYPE,
|
||||||
MESSAGE_TABLE_RECEIVE,
|
MESSAGE_TABLE_RECEIVE,
|
||||||
MESSAGE_OBJECT_PROPERTIES_RECEIVE,
|
MESSAGE_OBJECT_PROPERTIES_RECEIVE,
|
||||||
|
MESSAGE_OBJECT_ENTRIES_RECEIVE,
|
||||||
} = require("../constants");
|
} = require("../constants");
|
||||||
|
|
||||||
const defaultIdGenerator = new IdGenerator();
|
const defaultIdGenerator = new IdGenerator();
|
||||||
|
@ -126,6 +127,17 @@ function messageObjectPropertiesLoad(id, client, grip) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function messageObjectEntriesLoad(id, client, grip) {
|
||||||
|
return (dispatch) => {
|
||||||
|
client.enumEntries(enumResponse => {
|
||||||
|
const {iterator} = enumResponse;
|
||||||
|
iterator.slice(0, iterator.count, sliceResponse => {
|
||||||
|
dispatch(messageObjectEntriesReceive(id, grip.actor, sliceResponse));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This action is dispatched when properties of a grip are loaded.
|
* This action is dispatched when properties of a grip are loaded.
|
||||||
*
|
*
|
||||||
|
@ -143,6 +155,23 @@ function messageObjectPropertiesReceive(id, actor, properties) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This action is dispatched when entries of a grip are loaded.
|
||||||
|
*
|
||||||
|
* @param {string} id - The message id the grip is in.
|
||||||
|
* @param {string} actor - The actor id of the grip the properties were loaded from.
|
||||||
|
* @param {object} entries - A RDP packet that contains the entries of the grip.
|
||||||
|
* @returns {object}
|
||||||
|
*/
|
||||||
|
function messageObjectEntriesReceive(id, actor, entries) {
|
||||||
|
return {
|
||||||
|
type: MESSAGE_OBJECT_ENTRIES_RECEIVE,
|
||||||
|
id,
|
||||||
|
actor,
|
||||||
|
entries
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
messageAdd,
|
messageAdd,
|
||||||
messagesClear,
|
messagesClear,
|
||||||
|
@ -151,8 +180,10 @@ module.exports = {
|
||||||
messageTableDataGet,
|
messageTableDataGet,
|
||||||
networkMessageUpdate,
|
networkMessageUpdate,
|
||||||
messageObjectPropertiesLoad,
|
messageObjectPropertiesLoad,
|
||||||
|
messageObjectEntriesLoad,
|
||||||
// for test purpose only.
|
// for test purpose only.
|
||||||
messageTableDataReceive,
|
messageTableDataReceive,
|
||||||
messageObjectPropertiesReceive,
|
messageObjectPropertiesReceive,
|
||||||
|
messageObjectEntriesReceive,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ const {
|
||||||
getAllMessagesUiById,
|
getAllMessagesUiById,
|
||||||
getAllMessagesTableDataById,
|
getAllMessagesTableDataById,
|
||||||
getAllMessagesObjectPropertiesById,
|
getAllMessagesObjectPropertiesById,
|
||||||
|
getAllMessagesObjectEntriesById,
|
||||||
getAllNetworkMessagesUpdateById,
|
getAllNetworkMessagesUpdateById,
|
||||||
getVisibleMessages,
|
getVisibleMessages,
|
||||||
getAllRepeatById,
|
getAllRepeatById,
|
||||||
|
@ -38,6 +39,7 @@ const ConsoleOutput = createClass({
|
||||||
timestampsVisible: PropTypes.bool,
|
timestampsVisible: PropTypes.bool,
|
||||||
messagesTableData: PropTypes.object.isRequired,
|
messagesTableData: PropTypes.object.isRequired,
|
||||||
messagesObjectProperties: PropTypes.object.isRequired,
|
messagesObjectProperties: PropTypes.object.isRequired,
|
||||||
|
messagesObjectEntries: PropTypes.object.isRequired,
|
||||||
messagesRepeat: PropTypes.object.isRequired,
|
messagesRepeat: PropTypes.object.isRequired,
|
||||||
networkMessagesUpdate: PropTypes.object.isRequired,
|
networkMessagesUpdate: PropTypes.object.isRequired,
|
||||||
visibleMessages: PropTypes.array.isRequired,
|
visibleMessages: PropTypes.array.isRequired,
|
||||||
|
@ -85,6 +87,7 @@ const ConsoleOutput = createClass({
|
||||||
messagesUi,
|
messagesUi,
|
||||||
messagesTableData,
|
messagesTableData,
|
||||||
messagesObjectProperties,
|
messagesObjectProperties,
|
||||||
|
messagesObjectEntries,
|
||||||
messagesRepeat,
|
messagesRepeat,
|
||||||
networkMessagesUpdate,
|
networkMessagesUpdate,
|
||||||
serviceContainer,
|
serviceContainer,
|
||||||
|
@ -103,6 +106,7 @@ const ConsoleOutput = createClass({
|
||||||
networkMessageUpdate: networkMessagesUpdate[messageId],
|
networkMessageUpdate: networkMessagesUpdate[messageId],
|
||||||
getMessage: () => messages.get(messageId),
|
getMessage: () => messages.get(messageId),
|
||||||
loadedObjectProperties: messagesObjectProperties.get(messageId),
|
loadedObjectProperties: messagesObjectProperties.get(messageId),
|
||||||
|
loadedObjectEntries: messagesObjectEntries.get(messageId),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -136,6 +140,7 @@ function mapStateToProps(state, props) {
|
||||||
messagesUi: getAllMessagesUiById(state),
|
messagesUi: getAllMessagesUiById(state),
|
||||||
messagesTableData: getAllMessagesTableDataById(state),
|
messagesTableData: getAllMessagesTableDataById(state),
|
||||||
messagesObjectProperties: getAllMessagesObjectPropertiesById(state),
|
messagesObjectProperties: getAllMessagesObjectPropertiesById(state),
|
||||||
|
messagesObjectEntries: getAllMessagesObjectEntriesById(state),
|
||||||
messagesRepeat: getAllRepeatById(state),
|
messagesRepeat: getAllRepeatById(state),
|
||||||
networkMessagesUpdate: getAllNetworkMessagesUpdateById(state),
|
networkMessagesUpdate: getAllNetworkMessagesUpdateById(state),
|
||||||
timestampsVisible: state.ui.timestampsVisible,
|
timestampsVisible: state.ui.timestampsVisible,
|
||||||
|
|
|
@ -45,6 +45,7 @@ GripMessageBody.propTypes = {
|
||||||
useQuotes: PropTypes.bool,
|
useQuotes: PropTypes.bool,
|
||||||
escapeWhitespace: PropTypes.bool,
|
escapeWhitespace: PropTypes.bool,
|
||||||
loadedObjectProperties: PropTypes.object,
|
loadedObjectProperties: PropTypes.object,
|
||||||
|
loadedObjectEntries: PropTypes.object,
|
||||||
type: PropTypes.string,
|
type: PropTypes.string,
|
||||||
helperType: PropTypes.string,
|
helperType: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
@ -64,6 +65,7 @@ function GripMessageBody(props) {
|
||||||
escapeWhitespace,
|
escapeWhitespace,
|
||||||
mode = MODE.LONG,
|
mode = MODE.LONG,
|
||||||
loadedObjectProperties,
|
loadedObjectProperties,
|
||||||
|
loadedObjectEntries,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
let styleObject;
|
let styleObject;
|
||||||
|
@ -106,6 +108,11 @@ function GripMessageBody(props) {
|
||||||
const client = new ObjectClient(serviceContainer.hudProxyClient, object);
|
const client = new ObjectClient(serviceContainer.hudProxyClient, object);
|
||||||
dispatch(actions.messageObjectPropertiesLoad(messageId, client, object));
|
dispatch(actions.messageObjectPropertiesLoad(messageId, client, object));
|
||||||
},
|
},
|
||||||
|
getObjectEntries: actor => loadedObjectEntries && loadedObjectEntries[actor],
|
||||||
|
loadObjectEntries: object => {
|
||||||
|
const client = new ObjectClient(serviceContainer.hudProxyClient, object);
|
||||||
|
dispatch(actions.messageObjectEntriesLoad(messageId, client, object));
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof grip === "string" || grip.type === "longString") {
|
if (typeof grip === "string" || grip.type === "longString") {
|
||||||
|
|
|
@ -39,6 +39,7 @@ const MessageContainer = createClass({
|
||||||
networkMessageUpdate: PropTypes.object,
|
networkMessageUpdate: PropTypes.object,
|
||||||
getMessage: PropTypes.func.isRequired,
|
getMessage: PropTypes.func.isRequired,
|
||||||
loadedObjectProperties: PropTypes.object,
|
loadedObjectProperties: PropTypes.object,
|
||||||
|
loadedObjectEntries: PropTypes.object,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function () {
|
getDefaultProps: function () {
|
||||||
|
@ -57,13 +58,16 @@ const MessageContainer = createClass({
|
||||||
this.props.networkMessageUpdate !== nextProps.networkMessageUpdate;
|
this.props.networkMessageUpdate !== nextProps.networkMessageUpdate;
|
||||||
const loadedObjectPropertiesChanged =
|
const loadedObjectPropertiesChanged =
|
||||||
this.props.loadedObjectProperties !== nextProps.loadedObjectProperties;
|
this.props.loadedObjectProperties !== nextProps.loadedObjectProperties;
|
||||||
|
const loadedObjectEntriesChanged =
|
||||||
|
this.props.loadedObjectEntries !== nextProps.loadedObjectEntries;
|
||||||
|
|
||||||
return repeatChanged
|
return repeatChanged
|
||||||
|| openChanged
|
|| openChanged
|
||||||
|| tableDataChanged
|
|| tableDataChanged
|
||||||
|| timestampVisibleChanged
|
|| timestampVisibleChanged
|
||||||
|| networkMessageUpdateChanged
|
|| networkMessageUpdateChanged
|
||||||
|| loadedObjectPropertiesChanged;
|
|| loadedObjectPropertiesChanged
|
||||||
|
|| loadedObjectEntriesChanged;
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -27,6 +27,7 @@ ConsoleApiCall.propTypes = {
|
||||||
serviceContainer: PropTypes.object.isRequired,
|
serviceContainer: PropTypes.object.isRequired,
|
||||||
timestampsVisible: PropTypes.bool.isRequired,
|
timestampsVisible: PropTypes.bool.isRequired,
|
||||||
loadedObjectProperties: PropTypes.object,
|
loadedObjectProperties: PropTypes.object,
|
||||||
|
loadedObjectEntries: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
ConsoleApiCall.defaultProps = {
|
ConsoleApiCall.defaultProps = {
|
||||||
|
@ -43,6 +44,7 @@ function ConsoleApiCall(props) {
|
||||||
timestampsVisible,
|
timestampsVisible,
|
||||||
repeat,
|
repeat,
|
||||||
loadedObjectProperties,
|
loadedObjectProperties,
|
||||||
|
loadedObjectEntries,
|
||||||
} = props;
|
} = props;
|
||||||
const {
|
const {
|
||||||
id: messageId,
|
id: messageId,
|
||||||
|
@ -62,6 +64,7 @@ function ConsoleApiCall(props) {
|
||||||
const messageBodyConfig = {
|
const messageBodyConfig = {
|
||||||
dispatch,
|
dispatch,
|
||||||
loadedObjectProperties,
|
loadedObjectProperties,
|
||||||
|
loadedObjectEntries,
|
||||||
messageId,
|
messageId,
|
||||||
parameters,
|
parameters,
|
||||||
userProvidedStyles,
|
userProvidedStyles,
|
||||||
|
@ -129,6 +132,7 @@ function formatReps(options = {}) {
|
||||||
const {
|
const {
|
||||||
dispatch,
|
dispatch,
|
||||||
loadedObjectProperties,
|
loadedObjectProperties,
|
||||||
|
loadedObjectEntries,
|
||||||
messageId,
|
messageId,
|
||||||
parameters,
|
parameters,
|
||||||
serviceContainer,
|
serviceContainer,
|
||||||
|
@ -148,6 +152,7 @@ function formatReps(options = {}) {
|
||||||
serviceContainer,
|
serviceContainer,
|
||||||
useQuotes: false,
|
useQuotes: false,
|
||||||
loadedObjectProperties,
|
loadedObjectProperties,
|
||||||
|
loadedObjectEntries,
|
||||||
type,
|
type,
|
||||||
}))
|
}))
|
||||||
// Interleave spaces.
|
// Interleave spaces.
|
||||||
|
|
|
@ -22,6 +22,7 @@ EvaluationResult.propTypes = {
|
||||||
timestampsVisible: PropTypes.bool.isRequired,
|
timestampsVisible: PropTypes.bool.isRequired,
|
||||||
serviceContainer: PropTypes.object,
|
serviceContainer: PropTypes.object,
|
||||||
loadedObjectProperties: PropTypes.object,
|
loadedObjectProperties: PropTypes.object,
|
||||||
|
loadedObjectEntries: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
function EvaluationResult(props) {
|
function EvaluationResult(props) {
|
||||||
|
@ -31,6 +32,7 @@ function EvaluationResult(props) {
|
||||||
serviceContainer,
|
serviceContainer,
|
||||||
timestampsVisible,
|
timestampsVisible,
|
||||||
loadedObjectProperties,
|
loadedObjectProperties,
|
||||||
|
loadedObjectEntries,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -66,6 +68,7 @@ function EvaluationResult(props) {
|
||||||
useQuotes: true,
|
useQuotes: true,
|
||||||
escapeWhitespace: false,
|
escapeWhitespace: false,
|
||||||
loadedObjectProperties,
|
loadedObjectProperties,
|
||||||
|
loadedObjectEntries,
|
||||||
type,
|
type,
|
||||||
helperType,
|
helperType,
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,6 +14,7 @@ const actionTypes = {
|
||||||
NETWORK_MESSAGE_UPDATE: "NETWORK_MESSAGE_UPDATE",
|
NETWORK_MESSAGE_UPDATE: "NETWORK_MESSAGE_UPDATE",
|
||||||
MESSAGE_TABLE_RECEIVE: "MESSAGE_TABLE_RECEIVE",
|
MESSAGE_TABLE_RECEIVE: "MESSAGE_TABLE_RECEIVE",
|
||||||
MESSAGE_OBJECT_PROPERTIES_RECEIVE: "MESSAGE_OBJECT_PROPERTIES_RECEIVE",
|
MESSAGE_OBJECT_PROPERTIES_RECEIVE: "MESSAGE_OBJECT_PROPERTIES_RECEIVE",
|
||||||
|
MESSAGE_OBJECT_ENTRIES_RECEIVE: "MESSAGE_OBJECT_ENTRIES_RECEIVE",
|
||||||
REMOVED_ACTORS_CLEAR: "REMOVED_ACTORS_CLEAR",
|
REMOVED_ACTORS_CLEAR: "REMOVED_ACTORS_CLEAR",
|
||||||
TIMESTAMPS_TOGGLE: "TIMESTAMPS_TOGGLE",
|
TIMESTAMPS_TOGGLE: "TIMESTAMPS_TOGGLE",
|
||||||
FILTER_TOGGLE: "FILTER_TOGGLE",
|
FILTER_TOGGLE: "FILTER_TOGGLE",
|
||||||
|
|
|
@ -32,6 +32,11 @@ const MessageState = Immutable.Record({
|
||||||
// This map is consumed by the ObjectInspector so we only load properties once,
|
// This map is consumed by the ObjectInspector so we only load properties once,
|
||||||
// when needed (when an ObjectInspector node is expanded), and then caches them.
|
// when needed (when an ObjectInspector node is expanded), and then caches them.
|
||||||
messagesObjectPropertiesById: Immutable.Map(),
|
messagesObjectPropertiesById: Immutable.Map(),
|
||||||
|
// Map of the form {messageId : {[actor]: entries}}, where `entries` is
|
||||||
|
// a RDP packet containing the entries of the ${actor} grip.
|
||||||
|
// This map is consumed by the ObjectInspector so we only load entries once,
|
||||||
|
// when needed (when an ObjectInspector node is expanded), and then caches them.
|
||||||
|
messagesObjectEntriesById: Immutable.Map(),
|
||||||
// Map of the form {groupMessageId : groupArray},
|
// Map of the form {groupMessageId : groupArray},
|
||||||
// where groupArray is the list of of all the parent groups' ids of the groupMessageId.
|
// where groupArray is the list of of all the parent groups' ids of the groupMessageId.
|
||||||
groupsById: Immutable.Map(),
|
groupsById: Immutable.Map(),
|
||||||
|
@ -54,6 +59,7 @@ function messages(state = new MessageState(), action, filtersState, prefsState)
|
||||||
messagesUiById,
|
messagesUiById,
|
||||||
messagesTableDataById,
|
messagesTableDataById,
|
||||||
messagesObjectPropertiesById,
|
messagesObjectPropertiesById,
|
||||||
|
messagesObjectEntriesById,
|
||||||
networkMessagesUpdateById,
|
networkMessagesUpdateById,
|
||||||
groupsById,
|
groupsById,
|
||||||
currentGroup,
|
currentGroup,
|
||||||
|
@ -207,6 +213,16 @@ function messages(state = new MessageState(), action, filtersState, prefsState)
|
||||||
}, messagesObjectPropertiesById.get(action.id))
|
}, messagesObjectPropertiesById.get(action.id))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
case constants.MESSAGE_OBJECT_ENTRIES_RECEIVE:
|
||||||
|
return state.set(
|
||||||
|
"messagesObjectEntriesById",
|
||||||
|
messagesObjectEntriesById.set(
|
||||||
|
action.id,
|
||||||
|
Object.assign({
|
||||||
|
[action.actor]: action.entries
|
||||||
|
}, messagesObjectEntriesById.get(action.id))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
case constants.NETWORK_MESSAGE_UPDATE:
|
case constants.NETWORK_MESSAGE_UPDATE:
|
||||||
return state.set(
|
return state.set(
|
||||||
|
@ -356,6 +372,10 @@ function limitTopLevelMessageCount(state, record, logLimit) {
|
||||||
record.set("messagesObjectPropertiesById",
|
record.set("messagesObjectPropertiesById",
|
||||||
record.messagesObjectPropertiesById.withMutations(cleanUpCollection));
|
record.messagesObjectPropertiesById.withMutations(cleanUpCollection));
|
||||||
}
|
}
|
||||||
|
if (mapHasRemovedIdKey(record.messagesObjectEntriesById)) {
|
||||||
|
record.set("messagesObjectEntriesById",
|
||||||
|
record.messagesObjectEntriesById.withMutations(cleanUpCollection));
|
||||||
|
}
|
||||||
if (objectHasRemovedIdKey(record.repeatById)) {
|
if (objectHasRemovedIdKey(record.repeatById)) {
|
||||||
record.set("repeatById", cleanUpObject(record.repeatById));
|
record.set("repeatById", cleanUpObject(record.repeatById));
|
||||||
}
|
}
|
||||||
|
@ -395,6 +415,11 @@ function getAllActorsInMessage(message, state) {
|
||||||
actors.push(...Object.keys(loadedProperties));
|
actors.push(...Object.keys(loadedProperties));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const loadedEntries = state.messagesObjectEntriesById.get(message.id);
|
||||||
|
if (loadedEntries) {
|
||||||
|
actors.push(...Object.keys(loadedEntries));
|
||||||
|
}
|
||||||
|
|
||||||
return actors;
|
return actors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,10 @@ function getAllMessagesObjectPropertiesById(state) {
|
||||||
return state.messages.messagesObjectPropertiesById;
|
return state.messages.messagesObjectPropertiesById;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAllMessagesObjectEntriesById(state) {
|
||||||
|
return state.messages.messagesObjectEntriesById;
|
||||||
|
}
|
||||||
|
|
||||||
function getAllGroupsById(state) {
|
function getAllGroupsById(state) {
|
||||||
return state.messages.groupsById;
|
return state.messages.groupsById;
|
||||||
}
|
}
|
||||||
|
@ -56,4 +60,5 @@ module.exports = {
|
||||||
getAllRepeatById,
|
getAllRepeatById,
|
||||||
getAllNetworkMessagesUpdateById,
|
getAllNetworkMessagesUpdateById,
|
||||||
getAllMessagesObjectPropertiesById,
|
getAllMessagesObjectPropertiesById,
|
||||||
|
getAllMessagesObjectEntriesById,
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче