зеркало из 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_TABLE_RECEIVE,
|
||||
MESSAGE_OBJECT_PROPERTIES_RECEIVE,
|
||||
MESSAGE_OBJECT_ENTRIES_RECEIVE,
|
||||
} = require("../constants");
|
||||
|
||||
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.
|
||||
*
|
||||
|
@ -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 = {
|
||||
messageAdd,
|
||||
messagesClear,
|
||||
|
@ -151,8 +180,10 @@ module.exports = {
|
|||
messageTableDataGet,
|
||||
networkMessageUpdate,
|
||||
messageObjectPropertiesLoad,
|
||||
messageObjectEntriesLoad,
|
||||
// for test purpose only.
|
||||
messageTableDataReceive,
|
||||
messageObjectPropertiesReceive,
|
||||
messageObjectEntriesReceive,
|
||||
};
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ const {
|
|||
getAllMessagesUiById,
|
||||
getAllMessagesTableDataById,
|
||||
getAllMessagesObjectPropertiesById,
|
||||
getAllMessagesObjectEntriesById,
|
||||
getAllNetworkMessagesUpdateById,
|
||||
getVisibleMessages,
|
||||
getAllRepeatById,
|
||||
|
@ -38,6 +39,7 @@ const ConsoleOutput = createClass({
|
|||
timestampsVisible: PropTypes.bool,
|
||||
messagesTableData: PropTypes.object.isRequired,
|
||||
messagesObjectProperties: PropTypes.object.isRequired,
|
||||
messagesObjectEntries: PropTypes.object.isRequired,
|
||||
messagesRepeat: PropTypes.object.isRequired,
|
||||
networkMessagesUpdate: PropTypes.object.isRequired,
|
||||
visibleMessages: PropTypes.array.isRequired,
|
||||
|
@ -85,6 +87,7 @@ const ConsoleOutput = createClass({
|
|||
messagesUi,
|
||||
messagesTableData,
|
||||
messagesObjectProperties,
|
||||
messagesObjectEntries,
|
||||
messagesRepeat,
|
||||
networkMessagesUpdate,
|
||||
serviceContainer,
|
||||
|
@ -103,6 +106,7 @@ const ConsoleOutput = createClass({
|
|||
networkMessageUpdate: networkMessagesUpdate[messageId],
|
||||
getMessage: () => messages.get(messageId),
|
||||
loadedObjectProperties: messagesObjectProperties.get(messageId),
|
||||
loadedObjectEntries: messagesObjectEntries.get(messageId),
|
||||
}));
|
||||
|
||||
return (
|
||||
|
@ -136,6 +140,7 @@ function mapStateToProps(state, props) {
|
|||
messagesUi: getAllMessagesUiById(state),
|
||||
messagesTableData: getAllMessagesTableDataById(state),
|
||||
messagesObjectProperties: getAllMessagesObjectPropertiesById(state),
|
||||
messagesObjectEntries: getAllMessagesObjectEntriesById(state),
|
||||
messagesRepeat: getAllRepeatById(state),
|
||||
networkMessagesUpdate: getAllNetworkMessagesUpdateById(state),
|
||||
timestampsVisible: state.ui.timestampsVisible,
|
||||
|
|
|
@ -45,6 +45,7 @@ GripMessageBody.propTypes = {
|
|||
useQuotes: PropTypes.bool,
|
||||
escapeWhitespace: PropTypes.bool,
|
||||
loadedObjectProperties: PropTypes.object,
|
||||
loadedObjectEntries: PropTypes.object,
|
||||
type: PropTypes.string,
|
||||
helperType: PropTypes.string,
|
||||
};
|
||||
|
@ -64,6 +65,7 @@ function GripMessageBody(props) {
|
|||
escapeWhitespace,
|
||||
mode = MODE.LONG,
|
||||
loadedObjectProperties,
|
||||
loadedObjectEntries,
|
||||
} = props;
|
||||
|
||||
let styleObject;
|
||||
|
@ -106,6 +108,11 @@ function GripMessageBody(props) {
|
|||
const client = new ObjectClient(serviceContainer.hudProxyClient, 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") {
|
||||
|
|
|
@ -39,6 +39,7 @@ const MessageContainer = createClass({
|
|||
networkMessageUpdate: PropTypes.object,
|
||||
getMessage: PropTypes.func.isRequired,
|
||||
loadedObjectProperties: PropTypes.object,
|
||||
loadedObjectEntries: PropTypes.object,
|
||||
},
|
||||
|
||||
getDefaultProps: function () {
|
||||
|
@ -57,13 +58,16 @@ const MessageContainer = createClass({
|
|||
this.props.networkMessageUpdate !== nextProps.networkMessageUpdate;
|
||||
const loadedObjectPropertiesChanged =
|
||||
this.props.loadedObjectProperties !== nextProps.loadedObjectProperties;
|
||||
const loadedObjectEntriesChanged =
|
||||
this.props.loadedObjectEntries !== nextProps.loadedObjectEntries;
|
||||
|
||||
return repeatChanged
|
||||
|| openChanged
|
||||
|| tableDataChanged
|
||||
|| timestampVisibleChanged
|
||||
|| networkMessageUpdateChanged
|
||||
|| loadedObjectPropertiesChanged;
|
||||
|| loadedObjectPropertiesChanged
|
||||
|| loadedObjectEntriesChanged;
|
||||
},
|
||||
|
||||
render() {
|
||||
|
|
|
@ -27,6 +27,7 @@ ConsoleApiCall.propTypes = {
|
|||
serviceContainer: PropTypes.object.isRequired,
|
||||
timestampsVisible: PropTypes.bool.isRequired,
|
||||
loadedObjectProperties: PropTypes.object,
|
||||
loadedObjectEntries: PropTypes.object,
|
||||
};
|
||||
|
||||
ConsoleApiCall.defaultProps = {
|
||||
|
@ -43,6 +44,7 @@ function ConsoleApiCall(props) {
|
|||
timestampsVisible,
|
||||
repeat,
|
||||
loadedObjectProperties,
|
||||
loadedObjectEntries,
|
||||
} = props;
|
||||
const {
|
||||
id: messageId,
|
||||
|
@ -62,6 +64,7 @@ function ConsoleApiCall(props) {
|
|||
const messageBodyConfig = {
|
||||
dispatch,
|
||||
loadedObjectProperties,
|
||||
loadedObjectEntries,
|
||||
messageId,
|
||||
parameters,
|
||||
userProvidedStyles,
|
||||
|
@ -129,6 +132,7 @@ function formatReps(options = {}) {
|
|||
const {
|
||||
dispatch,
|
||||
loadedObjectProperties,
|
||||
loadedObjectEntries,
|
||||
messageId,
|
||||
parameters,
|
||||
serviceContainer,
|
||||
|
@ -148,6 +152,7 @@ function formatReps(options = {}) {
|
|||
serviceContainer,
|
||||
useQuotes: false,
|
||||
loadedObjectProperties,
|
||||
loadedObjectEntries,
|
||||
type,
|
||||
}))
|
||||
// Interleave spaces.
|
||||
|
|
|
@ -22,6 +22,7 @@ EvaluationResult.propTypes = {
|
|||
timestampsVisible: PropTypes.bool.isRequired,
|
||||
serviceContainer: PropTypes.object,
|
||||
loadedObjectProperties: PropTypes.object,
|
||||
loadedObjectEntries: PropTypes.object,
|
||||
};
|
||||
|
||||
function EvaluationResult(props) {
|
||||
|
@ -31,6 +32,7 @@ function EvaluationResult(props) {
|
|||
serviceContainer,
|
||||
timestampsVisible,
|
||||
loadedObjectProperties,
|
||||
loadedObjectEntries,
|
||||
} = props;
|
||||
|
||||
const {
|
||||
|
@ -66,6 +68,7 @@ function EvaluationResult(props) {
|
|||
useQuotes: true,
|
||||
escapeWhitespace: false,
|
||||
loadedObjectProperties,
|
||||
loadedObjectEntries,
|
||||
type,
|
||||
helperType,
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ const actionTypes = {
|
|||
NETWORK_MESSAGE_UPDATE: "NETWORK_MESSAGE_UPDATE",
|
||||
MESSAGE_TABLE_RECEIVE: "MESSAGE_TABLE_RECEIVE",
|
||||
MESSAGE_OBJECT_PROPERTIES_RECEIVE: "MESSAGE_OBJECT_PROPERTIES_RECEIVE",
|
||||
MESSAGE_OBJECT_ENTRIES_RECEIVE: "MESSAGE_OBJECT_ENTRIES_RECEIVE",
|
||||
REMOVED_ACTORS_CLEAR: "REMOVED_ACTORS_CLEAR",
|
||||
TIMESTAMPS_TOGGLE: "TIMESTAMPS_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,
|
||||
// when needed (when an ObjectInspector node is expanded), and then caches them.
|
||||
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},
|
||||
// where groupArray is the list of of all the parent groups' ids of the groupMessageId.
|
||||
groupsById: Immutable.Map(),
|
||||
|
@ -54,6 +59,7 @@ function messages(state = new MessageState(), action, filtersState, prefsState)
|
|||
messagesUiById,
|
||||
messagesTableDataById,
|
||||
messagesObjectPropertiesById,
|
||||
messagesObjectEntriesById,
|
||||
networkMessagesUpdateById,
|
||||
groupsById,
|
||||
currentGroup,
|
||||
|
@ -207,6 +213,16 @@ function messages(state = new MessageState(), action, filtersState, prefsState)
|
|||
}, 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:
|
||||
return state.set(
|
||||
|
@ -356,6 +372,10 @@ function limitTopLevelMessageCount(state, record, logLimit) {
|
|||
record.set("messagesObjectPropertiesById",
|
||||
record.messagesObjectPropertiesById.withMutations(cleanUpCollection));
|
||||
}
|
||||
if (mapHasRemovedIdKey(record.messagesObjectEntriesById)) {
|
||||
record.set("messagesObjectEntriesById",
|
||||
record.messagesObjectEntriesById.withMutations(cleanUpCollection));
|
||||
}
|
||||
if (objectHasRemovedIdKey(record.repeatById)) {
|
||||
record.set("repeatById", cleanUpObject(record.repeatById));
|
||||
}
|
||||
|
@ -395,6 +415,11 @@ function getAllActorsInMessage(message, state) {
|
|||
actors.push(...Object.keys(loadedProperties));
|
||||
}
|
||||
|
||||
const loadedEntries = state.messagesObjectEntriesById.get(message.id);
|
||||
if (loadedEntries) {
|
||||
actors.push(...Object.keys(loadedEntries));
|
||||
}
|
||||
|
||||
return actors;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ function getAllMessagesObjectPropertiesById(state) {
|
|||
return state.messages.messagesObjectPropertiesById;
|
||||
}
|
||||
|
||||
function getAllMessagesObjectEntriesById(state) {
|
||||
return state.messages.messagesObjectEntriesById;
|
||||
}
|
||||
|
||||
function getAllGroupsById(state) {
|
||||
return state.messages.groupsById;
|
||||
}
|
||||
|
@ -56,4 +60,5 @@ module.exports = {
|
|||
getAllRepeatById,
|
||||
getAllNetworkMessagesUpdateById,
|
||||
getAllMessagesObjectPropertiesById,
|
||||
getAllMessagesObjectEntriesById,
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче