Skip to content

Commit

Permalink
Show disabled screens with query param "hide=none" (#507)
Browse files Browse the repository at this point in the history
* Show disabled screens with query param "hide=none"
  • Loading branch information
kenzieschmoll authored Apr 10, 2019
1 parent f327c5a commit 319ee21
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 95 deletions.
9 changes: 5 additions & 4 deletions packages/devtools/lib/src/framework/framework.dart
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,23 @@ abstract class Screen {
@required this.name,
@required this.id,
this.iconClass,
this.disabled = false,
this.disabledTooltip = 'This screen is not available',
}) : helpStatus = createLinkStatusItem(
bool disabled = false,
}) : helpStatus = createLinkStatusItem(
span()
..add(span(text: '$name', c: 'optional-700'))
..add(span(text: ' Docs')),
href: 'https://flutter.github.io/devtools/$id',
title: 'Documentation on using the $name page',
);
),
disabled = allTabsEnabledByQuery ? false : disabled;

final String name;
final String id;
final String iconClass;
final StatusItem helpStatus;
final bool disabled;
final String disabledTooltip;
final bool disabled;

bool needsResizing = false;

Expand Down
9 changes: 5 additions & 4 deletions packages/devtools/lib/src/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ class PerfToolFramework extends Framework {
? 'This screen is disabled because you are not running a Flutter '
'application'
: 'This screen is disabled because you are running a profile build '
'of your application',
'of your application',
));
addScreen(TimelineScreen(
disabled: !_isFlutterApp,
disabledTooltip: _isFlutterWebApp
? 'This screen is disabled because it is not yet ready for Flutter'
' Web'
: 'This screen is disabled because you are not running a '
'Flutter application',
'Flutter application',
));
addScreen(MemoryScreen(
disabled: _isFlutterWebApp,
Expand All @@ -172,8 +172,9 @@ class PerfToolFramework extends Framework {
addScreen(PerformanceScreen());
}
addScreen(DebuggerScreen(
disabled:
_isFlutterWebApp || _isProfileBuild || tabDisabledByQuery('debugger'),
disabled: _isFlutterWebApp ||
_isProfileBuild ||
isTabDisabledByQuery('debugger'),
disabledTooltip: getDebuggerDisabledTooltip(),
));
addScreen(LoggingScreen());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ class Radius {
return x == y
? 'Radius.circular(${x.toStringAsFixed(1)})'
: 'Radius.elliptical(${x.toStringAsFixed(1)}, '
'${y.toStringAsFixed(1)})';
'${y.toStringAsFixed(1)})';
}
}

Expand Down
17 changes: 13 additions & 4 deletions packages/devtools/lib/src/ui/ui_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,25 @@ class RegisteredServiceExtensionButton {
}
}

bool tabDisabledByQuery(String key) {
Set<String> _hiddenPages;

Set<String> get hiddenPages {
return _hiddenPages ??= _lookupHiddenPages();
}

Set<String> _lookupHiddenPages() {
final queryString = html.window.location.search;
if (queryString == null || queryString.length <= 1) {
return false;
return {};
}

final qsParams = Uri.splitQueryString(queryString.substring(1));
return qsParams['hide']?.split(',')?.contains(key) ?? false;
return (qsParams['hide'] ?? '').split(',').toSet();
}

bool isTabDisabledByQuery(String key) => hiddenPages.contains(key);

bool get allTabsEnabledByQuery => hiddenPages.contains('none');

/// Creates a canvas scaled to match the device's devicePixelRatio.
///
/// A default canvas will look pixelated on high devicePixelRatio screens so it
Expand Down
70 changes: 35 additions & 35 deletions packages/devtools/test/inspector_controller_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,13 @@ void main() async {
tree.toStringDeep(),
equalsIgnoringHashCodes(
'▼[R] root ]\n'
' ▼[M] MyApp\n'
' ▼[M] MaterialApp\n'
' ▼[S] Scaffold\n'
' ├───▼[C] Center\n'
' │ ▼[/icons/inspector/textArea.png] Text\n'
' └─▼[A] AppBar\n'
' ▼[/icons/inspector/textArea.png] Text\n',
' ▼[M] MyApp\n'
' ▼[M] MaterialApp\n'
' ▼[S] Scaffold\n'
' ├───▼[C] Center\n'
' │ ▼[/icons/inspector/textArea.png] Text\n'
' └─▼[A] AppBar\n'
' ▼[/icons/inspector/textArea.png] Text\n',
));

expect(
Expand Down Expand Up @@ -464,13 +464,13 @@ void main() async {
tree.toStringDeep(),
equalsIgnoringHashCodes(
'▼[R] root ]\n'
' ▼[M] MyApp\n'
' ▼[M] MaterialApp\n'
' ▼[S] Scaffold <-- selected\n'
' ├───▼[C] Center\n'
' │ ▼[/icons/inspector/textArea.png] Text\n'
' └─▼[A] AppBar\n'
' ▼[/icons/inspector/textArea.png] Text\n',
' ▼[M] MyApp\n'
' ▼[M] MaterialApp\n'
' ▼[S] Scaffold <-- selected\n'
' ├───▼[C] Center\n'
' │ ▼[/icons/inspector/textArea.png] Text\n'
' └─▼[A] AppBar\n'
' ▼[/icons/inspector/textArea.png] Text\n',
));

await detailsTree.nextUiFrame;
Expand All @@ -490,13 +490,13 @@ void main() async {
tree.toStringDeep(),
equalsIgnoringHashCodes(
'▼[R] root ]\n'
' ▼[M] MyApp\n'
' ▼[M] MaterialApp\n'
' ▼[S] Scaffold\n'
' ├───▼[C] Center <-- selected\n'
' │ ▼[/icons/inspector/textArea.png] Text\n'
' └─▼[A] AppBar\n'
' ▼[/icons/inspector/textArea.png] Text\n',
' ▼[M] MyApp\n'
' ▼[M] MaterialApp\n'
' ▼[S] Scaffold\n'
' ├───▼[C] Center <-- selected\n'
' │ ▼[/icons/inspector/textArea.png] Text\n'
' └─▼[A] AppBar\n'
' ▼[/icons/inspector/textArea.png] Text\n',
));

await detailsTree.nextUiFrame;
Expand All @@ -513,13 +513,13 @@ void main() async {
tree.toStringDeep(),
equalsIgnoringHashCodes(
'▼[R] root ]\n'
' ▼[M] MyApp\n'
' ▼[M] MaterialApp\n'
' ▼[S] Scaffold <-- selected\n'
' ├───▼[C] Center\n'
' │ ▼[/icons/inspector/textArea.png] Text\n'
' └─▼[A] AppBar\n'
' ▼[/icons/inspector/textArea.png] Text\n',
' ▼[M] MyApp\n'
' ▼[M] MaterialApp\n'
' ▼[S] Scaffold <-- selected\n'
' ├───▼[C] Center\n'
' │ ▼[/icons/inspector/textArea.png] Text\n'
' └─▼[A] AppBar\n'
' ▼[/icons/inspector/textArea.png] Text\n',
));

// Verify that the details tree scrolled back as well.
Expand Down Expand Up @@ -552,13 +552,13 @@ void main() async {
tree.toStringDeep(),
equalsIgnoringHashCodes(
'▼[R] root ]\n'
' ▼[M] MyApp\n'
' ▼[M] MaterialApp\n'
' ▼[S] Scaffold\n'
' ├───▼[C] Center\n'
' │ ▼[/icons/inspector/textArea.png] Text\n'
' └─▼[A] AppBar\n'
' ▼[/icons/inspector/textArea.png] Text\n',
' ▼[M] MyApp\n'
' ▼[M] MaterialApp\n'
' ▼[S] Scaffold\n'
' ├───▼[C] Center\n'
' │ ▼[/icons/inspector/textArea.png] Text\n'
' └─▼[A] AppBar\n'
' ▼[/icons/inspector/textArea.png] Text\n',
));

// TODO(jacobr): would be nice to have some tests that trigger a hot
Expand Down
94 changes: 47 additions & 47 deletions packages/devtools/test/inspector_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ void main() async {
treeToDebugString(root),
equalsIgnoringHashCodes(
'[root]\n'
' └─MyApp\n'
' └─MaterialApp\n'
' └─Scaffold\n'
' ├─Center\n'
' │ └─Text\n'
' └─AppBar\n'
' └─Text\n',
' └─MyApp\n'
' └─MaterialApp\n'
' └─Scaffold\n'
' ├─Center\n'
' │ └─Text\n'
' └─AppBar\n'
' └─Text\n',
),
);
RemoteDiagnosticsNode nodeInSummaryTree =
Expand All @@ -119,11 +119,11 @@ void main() async {
treeToDebugString(nodeInSummaryTree),
equalsIgnoringHashCodes(
'MaterialApp\n'
' └─Scaffold\n'
' ├─Center\n'
' │ └─Text\n'
' └─AppBar\n'
' └─Text\n',
' └─Scaffold\n'
' ├─Center\n'
' │ └─Text\n'
' └─AppBar\n'
' └─Text\n',
),
);
RemoteDiagnosticsNode nodeInDetailsTree =
Expand All @@ -149,22 +149,22 @@ void main() async {
treeToDebugString(nodeInDetailsTree),
equalsIgnoringHashCodes(
'Text\n'
' │ data: "Hello, World!"\n'
' │ textAlign: null\n'
' │ textDirection: null\n'
' │ locale: null\n'
' │ softWrap: null\n'
' │ overflow: null\n'
' │ textScaleFactor: null\n'
' │ maxLines: null\n'
' │ dependencies: [DefaultTextStyle, MediaQuery]\n'
' │\n'
' └─RichText\n'
' softWrap: wrapping at box width\n'
' maxLines: unlimited\n'
' text: "Hello, World!"\n'
' dependencies: [_LocalizationsScope-[GlobalKey#00000], Directionality]\n'
' renderObject: RenderParagraph#00000 relayoutBoundary=up2\n',
' │ data: "Hello, World!"\n'
' │ textAlign: null\n'
' │ textDirection: null\n'
' │ locale: null\n'
' │ softWrap: null\n'
' │ overflow: null\n'
' │ textScaleFactor: null\n'
' │ maxLines: null\n'
' │ dependencies: [DefaultTextStyle, MediaQuery]\n'
' │\n'
' └─RichText\n'
' softWrap: wrapping at box width\n'
' maxLines: unlimited\n'
' text: "Hello, World!"\n'
' dependencies: [_LocalizationsScope-[GlobalKey#00000], Directionality]\n'
' renderObject: RenderParagraph#00000 relayoutBoundary=up2\n',
),
);
expect(nodeInDetailsTree.valueRef, equals(nodeInSummaryTree.valueRef));
Expand All @@ -178,7 +178,7 @@ void main() async {
treeToDebugString(selection),
equalsIgnoringHashCodes(
'Text\n'
' └─RichText\n',
' └─RichText\n',
),
);

Expand All @@ -189,7 +189,7 @@ void main() async {
treeToDebugString(selection),
equalsIgnoringHashCodes(
'RenderParagraph#00000 relayoutBoundary=up2\n'
' └─text: TextSpan\n',
' └─text: TextSpan\n',
),
);

Expand All @@ -212,7 +212,7 @@ void main() async {
treeToDebugString(root),
equalsIgnoringHashCodes(
'RenderView#00000\n'
' └─child: RenderSemanticsAnnotations#00000\n',
' └─child: RenderSemanticsAnnotations#00000\n',
),
);
final child = findNodeMatching(root, 'RenderSemanticsAnnotations');
Expand All @@ -222,21 +222,21 @@ void main() async {
treeToDebugString(childDetailsSubtree),
equalsIgnoringHashCodes(
'child: RenderSemanticsAnnotations#00000\n'
' │ parentData: <none>\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │\n'
' └─child: RenderCustomPaint#00000\n'
' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │\n'
' └─child: RenderPointerListener#00000\n'
' parentData: <none> (can use size)\n'
' constraints: BoxConstraints(w=800.0, h=600.0)\n'
' size: Size(800.0, 600.0)\n'
' behavior: deferToChild\n'
' listeners: down, up, cancel\n',
' │ parentData: <none>\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │\n'
' └─child: RenderCustomPaint#00000\n'
' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │\n'
' └─child: RenderPointerListener#00000\n'
' parentData: <none> (can use size)\n'
' constraints: BoxConstraints(w=800.0, h=600.0)\n'
' size: Size(800.0, 600.0)\n'
' behavior: deferToChild\n'
' listeners: down, up, cancel\n',
),
);

Expand All @@ -249,7 +249,7 @@ void main() async {
treeToDebugString(selection),
equalsIgnoringHashCodes(
'RenderSemanticsAnnotations#00000\n'
' └─child: RenderCustomPaint#00000\n',
' └─child: RenderCustomPaint#00000\n',
),
);
});
Expand Down

0 comments on commit 319ee21

Please sign in to comment.