You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by pa...@apache.org on 2022/06/06 18:53:13 UTC
[beam] branch master updated: [Playground] [Hotfix] Remove autoscrolling from embedded editor (#21717)
This is an automated email from the ASF dual-hosted git repository.
pabloem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 3c623abd631 [Playground] [Hotfix] Remove autoscrolling from embedded editor (#21717)
3c623abd631 is described below
commit 3c623abd631b493c8a71d05fe591065754c75d0c
Author: Alexander Zhuravlev <al...@akvelon.com>
AuthorDate: Mon Jun 6 22:53:06 2022 +0400
[Playground] [Hotfix] Remove autoscrolling from embedded editor (#21717)
* [Playground] Removed autoscrolling from embedded editor
* [Playground] Fixed GRPC getGraph errors in console, removed unnecessary requests from embedded iframe
---
playground/frontend/lib/constants/params.dart | 1 +
.../modules/editor/components/editor_textarea.dart | 6 +++++-
.../components/embedded_editor.dart | 1 +
.../components/playground_page_providers.dart | 3 ++-
.../lib/pages/playground/states/examples_state.dart | 20 +++++++++++++++++++-
5 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/playground/frontend/lib/constants/params.dart b/playground/frontend/lib/constants/params.dart
index 430782d66d0..9d14e44c3cd 100644
--- a/playground/frontend/lib/constants/params.dart
+++ b/playground/frontend/lib/constants/params.dart
@@ -20,5 +20,6 @@ const kExampleParam = 'example';
const kIsEditable = 'enabled';
const kSourceCode = 'code';
const kContextLine = 'line';
+const kIsEmbedded = 'embedded';
const kQuickStartCategoryName = 'quick start';
diff --git a/playground/frontend/lib/modules/editor/components/editor_textarea.dart b/playground/frontend/lib/modules/editor/components/editor_textarea.dart
index bf06302decd..cb75c35de13 100644
--- a/playground/frontend/lib/modules/editor/components/editor_textarea.dart
+++ b/playground/frontend/lib/modules/editor/components/editor_textarea.dart
@@ -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,
@@ -54,6 +55,7 @@ class EditorTextArea extends StatefulWidget {
this.onSourceChange,
required this.enabled,
required this.isEditable,
+ this.isEmbedded = false,
}) : super(key: key);
@override
@@ -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,
diff --git a/playground/frontend/lib/pages/embedded_playground/components/embedded_editor.dart b/playground/frontend/lib/pages/embedded_playground/components/embedded_editor.dart
index 1a190b895e3..094a12fe618 100644
--- a/playground/frontend/lib/pages/embedded_playground/components/embedded_editor.dart
+++ b/playground/frontend/lib/pages/embedded_playground/components/embedded_editor.dart
@@ -36,6 +36,7 @@ class EmbeddedEditor extends StatelessWidget {
example: state.selectedExample,
onSourceChange: state.setSource,
isEditable: isEditable,
+ isEmbedded: true,
);
}
}
diff --git a/playground/frontend/lib/pages/playground/components/playground_page_providers.dart b/playground/frontend/lib/pages/playground/components/playground_page_providers.dart
index 3fc209ffb3e..e2455f4f0b1 100644
--- a/playground/frontend/lib/pages/playground/components/playground_page_providers.dart
+++ b/playground/frontend/lib/pages/playground/components/playground_page_providers.dart
@@ -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,
diff --git a/playground/frontend/lib/pages/playground/states/examples_state.dart b/playground/frontend/lib/pages/playground/states/examples_state.dart
index 9875adfdeeb..3e7bdf95258 100644
--- a/playground/frontend/lib/pages/playground/states/examples_state.dart
+++ b/playground/frontend/lib/pages/playground/states/examples_state.dart
@@ -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';
@@ -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) {
@@ -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),