Skip to content

Commit 319ee21

Browse files
Show disabled screens with query param "hide=none" (#507)
* Show disabled screens with query param "hide=none"
1 parent f327c5a commit 319ee21

File tree

6 files changed

+106
-95
lines changed

6 files changed

+106
-95
lines changed

packages/devtools/lib/src/framework/framework.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,22 +327,23 @@ abstract class Screen {
327327
@required this.name,
328328
@required this.id,
329329
this.iconClass,
330-
this.disabled = false,
331330
this.disabledTooltip = 'This screen is not available',
332-
}) : helpStatus = createLinkStatusItem(
331+
bool disabled = false,
332+
}) : helpStatus = createLinkStatusItem(
333333
span()
334334
..add(span(text: '$name', c: 'optional-700'))
335335
..add(span(text: ' Docs')),
336336
href: 'https://flutter.github.io/devtools/$id',
337337
title: 'Documentation on using the $name page',
338-
);
338+
),
339+
disabled = allTabsEnabledByQuery ? false : disabled;
339340

340341
final String name;
341342
final String id;
342343
final String iconClass;
343344
final StatusItem helpStatus;
344-
final bool disabled;
345345
final String disabledTooltip;
346+
final bool disabled;
346347

347348
bool needsResizing = false;
348349

packages/devtools/lib/src/main.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ class PerfToolFramework extends Framework {
152152
? 'This screen is disabled because you are not running a Flutter '
153153
'application'
154154
: 'This screen is disabled because you are running a profile build '
155-
'of your application',
155+
'of your application',
156156
));
157157
addScreen(TimelineScreen(
158158
disabled: !_isFlutterApp,
159159
disabledTooltip: _isFlutterWebApp
160160
? 'This screen is disabled because it is not yet ready for Flutter'
161161
' Web'
162162
: 'This screen is disabled because you are not running a '
163-
'Flutter application',
163+
'Flutter application',
164164
));
165165
addScreen(MemoryScreen(
166166
disabled: _isFlutterWebApp,
@@ -172,8 +172,9 @@ class PerfToolFramework extends Framework {
172172
addScreen(PerformanceScreen());
173173
}
174174
addScreen(DebuggerScreen(
175-
disabled:
176-
_isFlutterWebApp || _isProfileBuild || tabDisabledByQuery('debugger'),
175+
disabled: _isFlutterWebApp ||
176+
_isProfileBuild ||
177+
isTabDisabledByQuery('debugger'),
177178
disabledTooltip: getDebuggerDisabledTooltip(),
178179
));
179180
addScreen(LoggingScreen());

packages/devtools/lib/src/ui/fake_flutter/dart_ui/geometry.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ class Radius {
986986
return x == y
987987
? 'Radius.circular(${x.toStringAsFixed(1)})'
988988
: 'Radius.elliptical(${x.toStringAsFixed(1)}, '
989-
'${y.toStringAsFixed(1)})';
989+
'${y.toStringAsFixed(1)})';
990990
}
991991
}
992992

packages/devtools/lib/src/ui/ui_utils.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,25 @@ class RegisteredServiceExtensionButton {
254254
}
255255
}
256256

257-
bool tabDisabledByQuery(String key) {
257+
Set<String> _hiddenPages;
258+
259+
Set<String> get hiddenPages {
260+
return _hiddenPages ??= _lookupHiddenPages();
261+
}
262+
263+
Set<String> _lookupHiddenPages() {
258264
final queryString = html.window.location.search;
259265
if (queryString == null || queryString.length <= 1) {
260-
return false;
266+
return {};
261267
}
262-
263268
final qsParams = Uri.splitQueryString(queryString.substring(1));
264-
return qsParams['hide']?.split(',')?.contains(key) ?? false;
269+
return (qsParams['hide'] ?? '').split(',').toSet();
265270
}
266271

272+
bool isTabDisabledByQuery(String key) => hiddenPages.contains(key);
273+
274+
bool get allTabsEnabledByQuery => hiddenPages.contains('none');
275+
267276
/// Creates a canvas scaled to match the device's devicePixelRatio.
268277
///
269278
/// A default canvas will look pixelated on high devicePixelRatio screens so it

packages/devtools/test/inspector_controller_test.dart

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,13 @@ void main() async {
342342
tree.toStringDeep(),
343343
equalsIgnoringHashCodes(
344344
'▼[R] root ]\n'
345-
' ▼[M] MyApp\n'
346-
' ▼[M] MaterialApp\n'
347-
' ▼[S] Scaffold\n'
348-
' ├───▼[C] Center\n'
349-
' │ ▼[/icons/inspector/textArea.png] Text\n'
350-
' └─▼[A] AppBar\n'
351-
' ▼[/icons/inspector/textArea.png] Text\n',
345+
' ▼[M] MyApp\n'
346+
' ▼[M] MaterialApp\n'
347+
' ▼[S] Scaffold\n'
348+
' ├───▼[C] Center\n'
349+
' │ ▼[/icons/inspector/textArea.png] Text\n'
350+
' └─▼[A] AppBar\n'
351+
' ▼[/icons/inspector/textArea.png] Text\n',
352352
));
353353

354354
expect(
@@ -464,13 +464,13 @@ void main() async {
464464
tree.toStringDeep(),
465465
equalsIgnoringHashCodes(
466466
'▼[R] root ]\n'
467-
' ▼[M] MyApp\n'
468-
' ▼[M] MaterialApp\n'
469-
' ▼[S] Scaffold <-- selected\n'
470-
' ├───▼[C] Center\n'
471-
' │ ▼[/icons/inspector/textArea.png] Text\n'
472-
' └─▼[A] AppBar\n'
473-
' ▼[/icons/inspector/textArea.png] Text\n',
467+
' ▼[M] MyApp\n'
468+
' ▼[M] MaterialApp\n'
469+
' ▼[S] Scaffold <-- selected\n'
470+
' ├───▼[C] Center\n'
471+
' │ ▼[/icons/inspector/textArea.png] Text\n'
472+
' └─▼[A] AppBar\n'
473+
' ▼[/icons/inspector/textArea.png] Text\n',
474474
));
475475

476476
await detailsTree.nextUiFrame;
@@ -490,13 +490,13 @@ void main() async {
490490
tree.toStringDeep(),
491491
equalsIgnoringHashCodes(
492492
'▼[R] root ]\n'
493-
' ▼[M] MyApp\n'
494-
' ▼[M] MaterialApp\n'
495-
' ▼[S] Scaffold\n'
496-
' ├───▼[C] Center <-- selected\n'
497-
' │ ▼[/icons/inspector/textArea.png] Text\n'
498-
' └─▼[A] AppBar\n'
499-
' ▼[/icons/inspector/textArea.png] Text\n',
493+
' ▼[M] MyApp\n'
494+
' ▼[M] MaterialApp\n'
495+
' ▼[S] Scaffold\n'
496+
' ├───▼[C] Center <-- selected\n'
497+
' │ ▼[/icons/inspector/textArea.png] Text\n'
498+
' └─▼[A] AppBar\n'
499+
' ▼[/icons/inspector/textArea.png] Text\n',
500500
));
501501

502502
await detailsTree.nextUiFrame;
@@ -513,13 +513,13 @@ void main() async {
513513
tree.toStringDeep(),
514514
equalsIgnoringHashCodes(
515515
'▼[R] root ]\n'
516-
' ▼[M] MyApp\n'
517-
' ▼[M] MaterialApp\n'
518-
' ▼[S] Scaffold <-- selected\n'
519-
' ├───▼[C] Center\n'
520-
' │ ▼[/icons/inspector/textArea.png] Text\n'
521-
' └─▼[A] AppBar\n'
522-
' ▼[/icons/inspector/textArea.png] Text\n',
516+
' ▼[M] MyApp\n'
517+
' ▼[M] MaterialApp\n'
518+
' ▼[S] Scaffold <-- selected\n'
519+
' ├───▼[C] Center\n'
520+
' │ ▼[/icons/inspector/textArea.png] Text\n'
521+
' └─▼[A] AppBar\n'
522+
' ▼[/icons/inspector/textArea.png] Text\n',
523523
));
524524

525525
// Verify that the details tree scrolled back as well.
@@ -552,13 +552,13 @@ void main() async {
552552
tree.toStringDeep(),
553553
equalsIgnoringHashCodes(
554554
'▼[R] root ]\n'
555-
' ▼[M] MyApp\n'
556-
' ▼[M] MaterialApp\n'
557-
' ▼[S] Scaffold\n'
558-
' ├───▼[C] Center\n'
559-
' │ ▼[/icons/inspector/textArea.png] Text\n'
560-
' └─▼[A] AppBar\n'
561-
' ▼[/icons/inspector/textArea.png] Text\n',
555+
' ▼[M] MyApp\n'
556+
' ▼[M] MaterialApp\n'
557+
' ▼[S] Scaffold\n'
558+
' ├───▼[C] Center\n'
559+
' │ ▼[/icons/inspector/textArea.png] Text\n'
560+
' └─▼[A] AppBar\n'
561+
' ▼[/icons/inspector/textArea.png] Text\n',
562562
));
563563

564564
// TODO(jacobr): would be nice to have some tests that trigger a hot

packages/devtools/test/inspector_service_test.dart

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ void main() async {
103103
treeToDebugString(root),
104104
equalsIgnoringHashCodes(
105105
'[root]\n'
106-
' └─MyApp\n'
107-
' └─MaterialApp\n'
108-
' └─Scaffold\n'
109-
' ├─Center\n'
110-
' │ └─Text\n'
111-
' └─AppBar\n'
112-
' └─Text\n',
106+
' └─MyApp\n'
107+
' └─MaterialApp\n'
108+
' └─Scaffold\n'
109+
' ├─Center\n'
110+
' │ └─Text\n'
111+
' └─AppBar\n'
112+
' └─Text\n',
113113
),
114114
);
115115
RemoteDiagnosticsNode nodeInSummaryTree =
@@ -119,11 +119,11 @@ void main() async {
119119
treeToDebugString(nodeInSummaryTree),
120120
equalsIgnoringHashCodes(
121121
'MaterialApp\n'
122-
' └─Scaffold\n'
123-
' ├─Center\n'
124-
' │ └─Text\n'
125-
' └─AppBar\n'
126-
' └─Text\n',
122+
' └─Scaffold\n'
123+
' ├─Center\n'
124+
' │ └─Text\n'
125+
' └─AppBar\n'
126+
' └─Text\n',
127127
),
128128
);
129129
RemoteDiagnosticsNode nodeInDetailsTree =
@@ -149,22 +149,22 @@ void main() async {
149149
treeToDebugString(nodeInDetailsTree),
150150
equalsIgnoringHashCodes(
151151
'Text\n'
152-
' │ data: "Hello, World!"\n'
153-
' │ textAlign: null\n'
154-
' │ textDirection: null\n'
155-
' │ locale: null\n'
156-
' │ softWrap: null\n'
157-
' │ overflow: null\n'
158-
' │ textScaleFactor: null\n'
159-
' │ maxLines: null\n'
160-
' │ dependencies: [DefaultTextStyle, MediaQuery]\n'
161-
' │\n'
162-
' └─RichText\n'
163-
' softWrap: wrapping at box width\n'
164-
' maxLines: unlimited\n'
165-
' text: "Hello, World!"\n'
166-
' dependencies: [_LocalizationsScope-[GlobalKey#00000], Directionality]\n'
167-
' renderObject: RenderParagraph#00000 relayoutBoundary=up2\n',
152+
' │ data: "Hello, World!"\n'
153+
' │ textAlign: null\n'
154+
' │ textDirection: null\n'
155+
' │ locale: null\n'
156+
' │ softWrap: null\n'
157+
' │ overflow: null\n'
158+
' │ textScaleFactor: null\n'
159+
' │ maxLines: null\n'
160+
' │ dependencies: [DefaultTextStyle, MediaQuery]\n'
161+
' │\n'
162+
' └─RichText\n'
163+
' softWrap: wrapping at box width\n'
164+
' maxLines: unlimited\n'
165+
' text: "Hello, World!"\n'
166+
' dependencies: [_LocalizationsScope-[GlobalKey#00000], Directionality]\n'
167+
' renderObject: RenderParagraph#00000 relayoutBoundary=up2\n',
168168
),
169169
);
170170
expect(nodeInDetailsTree.valueRef, equals(nodeInSummaryTree.valueRef));
@@ -178,7 +178,7 @@ void main() async {
178178
treeToDebugString(selection),
179179
equalsIgnoringHashCodes(
180180
'Text\n'
181-
' └─RichText\n',
181+
' └─RichText\n',
182182
),
183183
);
184184

@@ -189,7 +189,7 @@ void main() async {
189189
treeToDebugString(selection),
190190
equalsIgnoringHashCodes(
191191
'RenderParagraph#00000 relayoutBoundary=up2\n'
192-
' └─text: TextSpan\n',
192+
' └─text: TextSpan\n',
193193
),
194194
);
195195

@@ -212,7 +212,7 @@ void main() async {
212212
treeToDebugString(root),
213213
equalsIgnoringHashCodes(
214214
'RenderView#00000\n'
215-
' └─child: RenderSemanticsAnnotations#00000\n',
215+
' └─child: RenderSemanticsAnnotations#00000\n',
216216
),
217217
);
218218
final child = findNodeMatching(root, 'RenderSemanticsAnnotations');
@@ -222,21 +222,21 @@ void main() async {
222222
treeToDebugString(childDetailsSubtree),
223223
equalsIgnoringHashCodes(
224224
'child: RenderSemanticsAnnotations#00000\n'
225-
' │ parentData: <none>\n'
226-
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
227-
' │ size: Size(800.0, 600.0)\n'
228-
' │\n'
229-
' └─child: RenderCustomPaint#00000\n'
230-
' │ parentData: <none> (can use size)\n'
231-
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
232-
' │ size: Size(800.0, 600.0)\n'
233-
' │\n'
234-
' └─child: RenderPointerListener#00000\n'
235-
' parentData: <none> (can use size)\n'
236-
' constraints: BoxConstraints(w=800.0, h=600.0)\n'
237-
' size: Size(800.0, 600.0)\n'
238-
' behavior: deferToChild\n'
239-
' listeners: down, up, cancel\n',
225+
' │ parentData: <none>\n'
226+
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
227+
' │ size: Size(800.0, 600.0)\n'
228+
' │\n'
229+
' └─child: RenderCustomPaint#00000\n'
230+
' │ parentData: <none> (can use size)\n'
231+
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
232+
' │ size: Size(800.0, 600.0)\n'
233+
' │\n'
234+
' └─child: RenderPointerListener#00000\n'
235+
' parentData: <none> (can use size)\n'
236+
' constraints: BoxConstraints(w=800.0, h=600.0)\n'
237+
' size: Size(800.0, 600.0)\n'
238+
' behavior: deferToChild\n'
239+
' listeners: down, up, cancel\n',
240240
),
241241
);
242242

@@ -249,7 +249,7 @@ void main() async {
249249
treeToDebugString(selection),
250250
equalsIgnoringHashCodes(
251251
'RenderSemanticsAnnotations#00000\n'
252-
' └─child: RenderCustomPaint#00000\n',
252+
' └─child: RenderCustomPaint#00000\n',
253253
),
254254
);
255255
});

0 commit comments

Comments
 (0)