Add changeset info in side panel
Summary: the side panel displays information with the changesets that were applied for each section Reviewed By: adityasharat Differential Revision: D16131069 fbshipit-source-id: d03547148e483e196600191291e58a13acf505c3
This commit is contained in:
committed by
Facebook Github Bot
parent
c69f3e3103
commit
0d4e2e6eb3
@@ -8,12 +8,15 @@ package com.facebook.flipper.plugins.sections;
|
|||||||
|
|
||||||
import com.facebook.flipper.core.FlipperArray;
|
import com.facebook.flipper.core.FlipperArray;
|
||||||
import com.facebook.flipper.core.FlipperObject;
|
import com.facebook.flipper.core.FlipperObject;
|
||||||
|
import com.facebook.litho.sections.Change;
|
||||||
import com.facebook.litho.sections.ChangesInfo;
|
import com.facebook.litho.sections.ChangesInfo;
|
||||||
import com.facebook.litho.sections.ChangesetDebugConfiguration;
|
import com.facebook.litho.sections.ChangesetDebugConfiguration;
|
||||||
import com.facebook.litho.sections.ChangesetDebugConfiguration.ChangesetDebugListener;
|
import com.facebook.litho.sections.ChangesetDebugConfiguration.ChangesetDebugListener;
|
||||||
import com.facebook.litho.sections.Section;
|
import com.facebook.litho.sections.Section;
|
||||||
import com.facebook.litho.sections.SectionsLogEventUtils;
|
import com.facebook.litho.sections.SectionsLogEventUtils;
|
||||||
import com.facebook.litho.sections.SectionsLogEventUtils.ApplyNewChangeSet;
|
import com.facebook.litho.sections.SectionsLogEventUtils.ApplyNewChangeSet;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class ChangesetDebug implements ChangesetDebugListener {
|
public class ChangesetDebug implements ChangesetDebugListener {
|
||||||
@@ -55,6 +58,7 @@ public class ChangesetDebug implements ChangesetDebugListener {
|
|||||||
final FlipperObject.Builder changesetData = new FlipperObject.Builder();
|
final FlipperObject.Builder changesetData = new FlipperObject.Builder();
|
||||||
|
|
||||||
final String sourceName = SectionsLogEventUtils.applyNewChangeSetSourceToString(attribution);
|
final String sourceName = SectionsLogEventUtils.applyNewChangeSetSourceToString(attribution);
|
||||||
|
extractSidePanelChangesetData(changesInfo, changesetData, rootSection.getGlobalKey());
|
||||||
|
|
||||||
createSectionTree(rootSection, "", tree, oldSection);
|
createSectionTree(rootSection, "", tree, oldSection);
|
||||||
|
|
||||||
@@ -77,6 +81,52 @@ public class ChangesetDebug implements ChangesetDebugListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Extract the changesets for this section tree. */
|
||||||
|
private static void extractSidePanelChangesetData(
|
||||||
|
ChangesInfo changesInfo, FlipperObject.Builder changesetData, String globalKey) {
|
||||||
|
final FlipperObject.Builder sectionChangesetInfo = new FlipperObject.Builder();
|
||||||
|
|
||||||
|
final List<Change> changeList = changesInfo.getAllChanges();
|
||||||
|
|
||||||
|
final FlipperObject.Builder changesets = new FlipperObject.Builder();
|
||||||
|
for (int i = 0; i < changeList.size(); i++) {
|
||||||
|
final Change change = changeList.get(i);
|
||||||
|
final FlipperObject.Builder changeData = new FlipperObject.Builder();
|
||||||
|
changeData.put("type", Change.changeTypeToString(change.getType()));
|
||||||
|
changeData.put("index", change.getIndex());
|
||||||
|
if (change.getToIndex() >= 0) {
|
||||||
|
changeData.put("toIndex", change.getToIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
changeData.put("count", change.getCount());
|
||||||
|
|
||||||
|
changeData.put("render_infos", ChangesetDebugConfiguration.getRenderInfoNames(change));
|
||||||
|
|
||||||
|
changeData.put("prev_data", getDataNamesFromChange(change.getPrevData()));
|
||||||
|
|
||||||
|
changeData.put("next_data", getDataNamesFromChange(change.getNextData()));
|
||||||
|
|
||||||
|
changesets.put(i + "", changeData.build());
|
||||||
|
}
|
||||||
|
sectionChangesetInfo.put("changesets", changesets.build());
|
||||||
|
|
||||||
|
changesetData.put(globalKey, sectionChangesetInfo.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> getDataNamesFromChange(List<?> data) {
|
||||||
|
final List<String> names = new ArrayList<>();
|
||||||
|
|
||||||
|
if (data == null) {
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < data.size(); i++) {
|
||||||
|
names.add(data.get(i).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
/** Finds the section with the same global key in the previous tree, if it existed. */
|
/** Finds the section with the same global key in the previous tree, if it existed. */
|
||||||
private static Section findSectionInPreviousTree(Section previousRoot, String globalKey) {
|
private static Section findSectionInPreviousTree(Section previousRoot, String globalKey) {
|
||||||
if (previousRoot == null) {
|
if (previousRoot == null) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ POM_DEVELOPER_ID=facebook
|
|||||||
POM_DEVELOPER_NAME=facebook
|
POM_DEVELOPER_NAME=facebook
|
||||||
|
|
||||||
# Shared version numbers
|
# Shared version numbers
|
||||||
LITHO_VERSION=0.28.0
|
LITHO_VERSION=0.29.0
|
||||||
ANDROIDX_VERSION=1.0.0
|
ANDROIDX_VERSION=1.0.0
|
||||||
KOTLIN_VERSION=1.3.31
|
KOTLIN_VERSION=1.3.31
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user