Skip to content

Commit

Permalink
[Playground] [Hotfix] Remove autoscrolling from embedded editor (#21717)
Browse files Browse the repository at this point in the history
* [Playground] Removed autoscrolling from embedded editor

* [Playground] Fixed GRPC getGraph errors in console, removed unnecessary requests from embedded iframe
  • Loading branch information
miamihotline authored Jun 6, 2022
1 parent 7445b95 commit 3c623ab
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions playground/frontend/lib/constants/params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ const kExampleParam = 'example';
const kIsEditable = 'enabled';
const kSourceCode = 'code';
const kContextLine = 'line';
const kIsEmbedded = 'embedded';

const kQuickStartCategoryName = 'quick start';
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class EditorTextArea extends StatefulWidget {
final bool enabled;
final void Function(String)? onSourceChange;
final bool isEditable;
final bool isEmbedded;

const EditorTextArea({
Key? key,
Expand All @@ -54,6 +55,7 @@ class EditorTextArea extends StatefulWidget {
this.onSourceChange,
required this.enabled,
required this.isEditable,
this.isEmbedded = false,
}) : super(key: key);

@override
Expand Down Expand Up @@ -97,7 +99,9 @@ class _EditorTextAreaState extends State<EditorTextArea> {

@override
Widget build(BuildContext context) {
WidgetsBinding.instance.addPostFrameCallback((_) => _setTextScrolling());
if (!widget.isEmbedded) {
WidgetsBinding.instance.addPostFrameCallback((_) => _setTextScrolling());
}

return Semantics(
container: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class EmbeddedEditor extends StatelessWidget {
example: state.selectedExample,
onSourceChange: state.setSource,
isEditable: isEditable,
isEmbedded: true,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class PlaygroundPageProviders extends StatelessWidget {
return PlaygroundState(codeRepository: kCodeRepository);
}

if (playground.selectedExample == null) {
if (playground.selectedExample == null &&
!Uri.base.toString().contains(kIsEmbedded)) {
final newPlayground = PlaygroundState(
codeRepository: kCodeRepository,
sdk: playground.sdk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

import 'package:flutter/material.dart';
import 'package:playground/constants/params.dart';
import 'package:playground/modules/examples/models/category_model.dart';
import 'package:playground/modules/examples/models/example_model.dart';
import 'package:playground/modules/examples/repositories/example_repository.dart';
Expand All @@ -34,7 +35,9 @@ class ExampleState with ChangeNotifier {
ExampleState(this._exampleRepository);

init() {
_loadCategories();
if (!Uri.base.toString().contains(kIsEmbedded)) {
_loadCategories();
}
}

setSdkCategories(Map<SDK, List<CategoryModel>> map) {
Expand Down Expand Up @@ -80,6 +83,21 @@ class ExampleState with ChangeNotifier {
if (example.isInfoFetched()) {
return example;
}

//GRPC GetPrecompiledGraph errors hotfix
if (example.name == 'MinimalWordCount' &&
(sdk == SDK.go || sdk == SDK.scio)) {
final exampleData = await Future.wait([
getExampleSource(example.path, sdk),
getExampleOutput(example.path, sdk),
getExampleLogs(example.path, sdk),
]);
example.setSource(exampleData[0]);
example.setOutputs(exampleData[1]);
example.setLogs(exampleData[2]);
return example;
}

final exampleData = await Future.wait([
getExampleSource(example.path, sdk),
getExampleOutput(example.path, sdk),
Expand Down

0 comments on commit 3c623ab

Please sign in to comment.