mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-27 18:01:44 -10:00
Bug 1258661 - Make the fields property in the markers blueprint consistent, r=jsantell
This commit is contained in:
1 parent
376e3d66cd
commit
84ed8499fa
3 files changed
+21
-40
No files matched your search
@@ -52,7 +52,8 @@ exports.MarkerBlueprintUtils = {
|
||||
*/
|
||||
getMarkerLabel: function(marker) {
|
||||
let blueprint = this.getBlueprintFor(marker);
|
||||
let label = typeof blueprint.label === "function" ? blueprint.label(marker) : blueprint.label;
|
||||
let dynamic = typeof blueprint.label === "function";
|
||||
let label = dynamic ? blueprint.label(marker) : blueprint.label;
|
||||
return label;
|
||||
},
|
||||
|
||||
@@ -65,7 +66,8 @@ exports.MarkerBlueprintUtils = {
|
||||
*/
|
||||
getMarkerGenericName: function(markerName) {
|
||||
let blueprint = this.getBlueprintFor({ name: markerName });
|
||||
let generic = typeof blueprint.label === "function" ? blueprint.label() : blueprint.label;
|
||||
let dynamic = typeof blueprint.label === "function";
|
||||
let generic = dynamic ? blueprint.label() : blueprint.label;
|
||||
|
||||
// If no class name found, attempt to throw a descriptive error as to
|
||||
// how the marker implementor can fix this.
|
||||
@@ -91,22 +93,11 @@ exports.MarkerBlueprintUtils = {
|
||||
*/
|
||||
getMarkerFields: function(marker) {
|
||||
let blueprint = this.getBlueprintFor(marker);
|
||||
let dynamic = typeof blueprint.fields === "function";
|
||||
let fields = dynamic ? blueprint.fields(marker) : blueprint.fields;
|
||||
|
||||
// If blueprint.fields is a function, use that.
|
||||
if (typeof blueprint.fields === "function") {
|
||||
let fields = blueprint.fields(marker) || {};
|
||||
return Object.keys(fields).map(label => ({ label, value: fields[label] }));
|
||||
}
|
||||
|
||||
// Otherwise, iterate over the array.
|
||||
return (blueprint.fields || []).reduce((fields, field) => {
|
||||
// Ensure this marker has this field present.
|
||||
if (field.property in marker) {
|
||||
let label = field.label;
|
||||
let value = marker[field.property];
|
||||
fields.push({ label, value });
|
||||
}
|
||||
return fields;
|
||||
}, []);
|
||||
return Object.entries(fields || {})
|
||||
.filter(([_, value]) => dynamic ? true : value in marker)
|
||||
.map(([label, value]) => ({ label, value: dynamic ? value : marker[value] }));
|
||||
},
|
||||
};
|
||||
@@ -172,15 +172,13 @@ exports.Formatters = {
|
||||
|
||||
/* Group 2 - User Controlled */
|
||||
|
||||
ConsoleTimeFields: [{
|
||||
label: L10N.getStr("marker.field.consoleTimerName"),
|
||||
property: "causeName",
|
||||
}],
|
||||
ConsoleTimeFields: {
|
||||
[L10N.getStr("marker.field.consoleTimerName")]: "causeName"
|
||||
},
|
||||
|
||||
TimeStampFields: [{
|
||||
label: L10N.getStr("marker.field.label"),
|
||||
property: "causeName",
|
||||
}]
|
||||
TimeStampFields: {
|
||||
[L10N.getStr("marker.field.label")]: "causeName"
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,12 @@ const { Formatters, labelForProperty } = require("devtools/client/performance/mo
|
||||
* If you use a function for a label, it *must* handle the case where
|
||||
* no marker is provided, to get a generic label used to describe
|
||||
* all markers of this type.
|
||||
* - fields: The fields used in the marker details view to display more
|
||||
* information about a currently selected marker. Can either be an
|
||||
* object of fields, or simply a function that accepts the marker and
|
||||
* returns such an object (if you want to use properties dynamically).
|
||||
* For example, a field in the object such as { "Cause": "causeName" }
|
||||
* would render something like `Cause: ${marker.causeName}` in the UI.
|
||||
* - colorName: The label of the DevTools color used for this marker. If
|
||||
* adding a new color, be sure to check that there's an entry
|
||||
* for `.marker-color-graphs-{COLORNAME}` for the equivilent
|
||||
@@ -28,20 +34,6 @@ const { Formatters, labelForProperty } = require("devtools/client/performance/mo
|
||||
* children. Defaults to true.
|
||||
* - nestable: Whether or not this marker can be nested inside an eclipsing
|
||||
* collapsible marker. Defaults to true.
|
||||
* - fields: An optional array of fields you wish to display in the marker
|
||||
* details view. For example, a field in the array such as
|
||||
* { label: "Cause", property: "causeName" } would render a string
|
||||
* like `Cause: ${marker.causeName}` in the marker details view.
|
||||
* Each field may take the following properties:
|
||||
* - label: The name of the property that should be displayed.
|
||||
* - property: The property that must exist on the marker to render,
|
||||
* and the value of the property will be displayed.
|
||||
* Alternatively, this also be a function that returns an object.
|
||||
* Each key in that object will be rendered as one field's label,
|
||||
* with its value rendering as one field's value.
|
||||
*
|
||||
* Whenever this is changed, browser_timeline_waterfall-styles.js *must* be
|
||||
* updated as well.
|
||||
*/
|
||||
const TIMELINE_BLUEPRINT = {
|
||||
/* Default definition used for markers that occur but are not defined here.
|
||||
|
||||
Reference in new issue
Block a user