From 229b75bcb2fa4e13402431454ca7097a19c31a6e Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Wed, 13 Oct 2021 10:06:45 +0300 Subject: [PATCH 01/15] [BEAM-12967]: Created Examples Component --- playground/frontend/analysis_options.yaml | 4 +- .../toggle_theme_button.dart | 4 +- playground/frontend/lib/config/theme.dart | 12 +- playground/frontend/lib/constants/sizes.dart | 15 +- .../editor/components/editor_textarea.dart | 2 +- .../category_expansion_panel.dart | 77 ++++++++ .../components/example_list/example_list.dart | 54 +++++ .../example_list/expansion_panel_item.dart | 53 +++++ .../components/examples_components.dart | 23 +++ .../components/filter/category_bubble.dart | 65 ++++++ .../components/filter/type_filter.dart | 43 ++++ .../components/search_field/search_field.dart | 83 ++++++++ .../modules/examples/example_selector.dart | 185 ++++++++++++++++++ .../examples/models/category_model.dart | 26 +++ .../examples/models/example_model.dart | 9 +- .../examples/models/selector_size_model.dart | 27 +++ .../repositories/example_repository.dart | 90 +++++++-- .../modules/sdk/components/sdk_selector.dart | 6 +- .../frontend/lib/modules/sdk/models/sdk.dart | 8 +- .../components/playground_page_providers.dart | 7 +- .../lib/pages/playground/playground_page.dart | 68 ++++--- .../states/example_dropdown_state.dart | 32 +++ .../playground/states/examples_state.dart | 16 +- .../playground/states/playground_state.dart | 14 +- playground/frontend/lib/playground_app.dart | 17 +- playground/frontend/pubspec.lock | 7 + playground/frontend/pubspec.yaml | 1 + 27 files changed, 872 insertions(+), 76 deletions(-) create mode 100644 playground/frontend/lib/modules/examples/components/example_list/category_expansion_panel.dart create mode 100644 playground/frontend/lib/modules/examples/components/example_list/example_list.dart create mode 100644 playground/frontend/lib/modules/examples/components/example_list/expansion_panel_item.dart create mode 100644 playground/frontend/lib/modules/examples/components/examples_components.dart create mode 100644 playground/frontend/lib/modules/examples/components/filter/category_bubble.dart create mode 100644 playground/frontend/lib/modules/examples/components/filter/type_filter.dart create mode 100644 playground/frontend/lib/modules/examples/components/search_field/search_field.dart create mode 100644 playground/frontend/lib/modules/examples/example_selector.dart create mode 100644 playground/frontend/lib/modules/examples/models/category_model.dart create mode 100644 playground/frontend/lib/modules/examples/models/selector_size_model.dart create mode 100644 playground/frontend/lib/pages/playground/states/example_dropdown_state.dart diff --git a/playground/frontend/analysis_options.yaml b/playground/frontend/analysis_options.yaml index 38742fed9d79..ebd797232f61 100644 --- a/playground/frontend/analysis_options.yaml +++ b/playground/frontend/analysis_options.yaml @@ -40,8 +40,8 @@ linter: # producing the lint. rules: avoid_web_libraries_in_flutter: false - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule +# avoid_print: false # Uncomment to disable the `avoid_print` rule + prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule # Additional information about this file can be found at # https://dart.dev/guides/language/analysis-options diff --git a/playground/frontend/lib/components/toggle_theme_button/toggle_theme_button.dart b/playground/frontend/lib/components/toggle_theme_button/toggle_theme_button.dart index d17bfc6737e4..cc9852968a16 100644 --- a/playground/frontend/lib/components/toggle_theme_button/toggle_theme_button.dart +++ b/playground/frontend/lib/components/toggle_theme_button/toggle_theme_button.dart @@ -23,8 +23,8 @@ import 'package:playground/constants/assets.dart'; import 'package:playground/constants/sizes.dart'; import 'package:provider/provider.dart'; -const kLightMode = "Light Mode"; -const kDartMode = "Dark Mode"; +const kLightMode = 'Light Mode'; +const kDartMode = 'Dark Mode'; class ToggleThemeButton extends StatelessWidget { const ToggleThemeButton({Key? key}) : super(key: key); diff --git a/playground/frontend/lib/config/theme.dart b/playground/frontend/lib/config/theme.dart index 9baeb58538c2..83a431051244 100644 --- a/playground/frontend/lib/config/theme.dart +++ b/playground/frontend/lib/config/theme.dart @@ -61,7 +61,7 @@ TextButtonThemeData createTextButtonTheme(Color textColor) { style: TextButton.styleFrom( primary: textColor, shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(kBorderRadius)), + borderRadius: BorderRadius.all(Radius.circular(kLgBorderRadius)), ), ), ); @@ -77,7 +77,7 @@ PopupMenuThemeData createPopupMenuTheme() { return const PopupMenuThemeData( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all( - Radius.circular(kBorderRadius), + Radius.circular(kLgBorderRadius), ), ), ); @@ -137,6 +137,14 @@ class ThemeColors { Color get greyColor => isDark ? kDarkGrey : kLightGrey; + Color get lightGreyColor => isDark ? kLightGrey1 : kLightGrey; + + Color get primary => isDark ? kLightPrimary : kDarkPrimary; + + Color get primaryBackgroundTextColor => Colors.white; + + Color get lightGreyBackgroundTextColor => Colors.black; + Color get grey1Color => isDark ? kDarkGrey1 : kLightGrey1; Color get secondaryBackground => diff --git a/playground/frontend/lib/constants/sizes.dart b/playground/frontend/lib/constants/sizes.dart index 35a8fb8a8cef..6fef53980515 100644 --- a/playground/frontend/lib/constants/sizes.dart +++ b/playground/frontend/lib/constants/sizes.dart @@ -20,7 +20,9 @@ const double kZeroSpacing = 0.0; const double kSmSpacing = 4.0; const double kMdSpacing = 8.0; -const double kLgSpacing = 16.0; +const double kLgSpacing = 12.0; +const double kXlSpacing = 16.0; +const double kXxlSpacing = 36.0; // sizes const kHeaderButtonHeight = 46.0; @@ -30,10 +32,19 @@ const kIconButtonSplashRadius = 24.0; const kFooterHeight = 32.0; // border radius -const double kBorderRadius = 8.0; +const double kSmBorderRadius = 4.0; +const double kMdBorderRadius = 6.0; +const double kLgBorderRadius = 8.0; +const double kXlBorderRadius = 28.0; // elevation const int kElevation = 1; // icon sizes const double kIconSizeMd = 24.0; + +// cursor size +const double kCursorSize = 1.0; + +// container size +const double kContainerHeight = 40.0; diff --git a/playground/frontend/lib/modules/editor/components/editor_textarea.dart b/playground/frontend/lib/modules/editor/components/editor_textarea.dart index 029e38ea07a1..69225fd9e3b7 100644 --- a/playground/frontend/lib/modules/editor/components/editor_textarea.dart +++ b/playground/frontend/lib/modules/editor/components/editor_textarea.dart @@ -56,7 +56,7 @@ class _EditorTextAreaState extends State { void didChangeDependencies() { final themeProvider = Provider.of(context, listen: true); _codeController = CodeController( - text: _codeController?.text ?? widget.example?.sources[widget.sdk] ?? "", + text: _codeController?.text ?? widget.example?.sources[widget.sdk] ?? '', language: _getLanguageFromSdk(), theme: themeProvider.isDarkMode ? darculaTheme : vsTheme, onChange: (newSource) => widget.onSourceChange(newSource), diff --git a/playground/frontend/lib/modules/examples/components/example_list/category_expansion_panel.dart b/playground/frontend/lib/modules/examples/components/example_list/category_expansion_panel.dart new file mode 100644 index 000000000000..441fd9cf961c --- /dev/null +++ b/playground/frontend/lib/modules/examples/components/example_list/category_expansion_panel.dart @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import 'dart:math' as math; + +import 'package:expansion_widget/expansion_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:playground/constants/sizes.dart'; +import 'package:playground/modules/examples/components/example_list/expansion_panel_item.dart'; + +class CategoryExpansionPanel extends StatelessWidget { + final String categoryName; + final List examples; + + const CategoryExpansionPanel({ + Key? key, + required this.categoryName, + required this.examples, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return ExpansionWidget( + maintainState: true, + titleBuilder: (animationValue, _, isExpanded, toggleFunction) => InkWell( + onTap: () => toggleFunction(animated: true), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: kLgSpacing), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Transform.rotate( + angle: -math.pi * animationValue, + child: const Icon(Icons.keyboard_arrow_down), + alignment: Alignment.center, + ), + SizedBox( + height: kContainerHeight, + child: Align( + alignment: Alignment.centerLeft, + child: Text(categoryName), + ), + ), + ], + ), + ), + ), + content: Column( + children: buildItems(), + ), + ); + } + + List buildItems() { + List items = []; + for (var example in examples) { + items.add( + ExpansionPanelItem(example: example), + ); + } + return items; + } +} diff --git a/playground/frontend/lib/modules/examples/components/example_list/example_list.dart b/playground/frontend/lib/modules/examples/components/example_list/example_list.dart new file mode 100644 index 000000000000..ca5f2177602a --- /dev/null +++ b/playground/frontend/lib/modules/examples/components/example_list/example_list.dart @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:flutter/material.dart'; +import 'package:playground/modules/examples/components/examples_components.dart'; + +class ExampleList extends StatelessWidget { + final List items; + final ScrollController controller; + + const ExampleList({ + Key? key, + required this.items, + required this.controller, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Expanded( + child: Container( + color: Theme.of(context).backgroundColor, + child: Scrollbar( + isAlwaysShown: true, + showTrackOnHover: true, + controller: controller, + child: ListView.builder( + itemCount: items.length, + itemBuilder: (context, index) => CategoryExpansionPanel( + categoryName: items[index].name, + examples: items[index].examples, + ), + controller: controller, + shrinkWrap: true, + ), + ), + ), + ); + } +} diff --git a/playground/frontend/lib/modules/examples/components/example_list/expansion_panel_item.dart b/playground/frontend/lib/modules/examples/components/example_list/expansion_panel_item.dart new file mode 100644 index 000000000000..560fbca079b7 --- /dev/null +++ b/playground/frontend/lib/modules/examples/components/example_list/expansion_panel_item.dart @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:flutter/material.dart'; +import 'package:playground/constants/sizes.dart'; +import 'package:playground/modules/examples/models/example_model.dart'; +import 'package:playground/pages/playground/states/playground_state.dart'; +import 'package:provider/provider.dart'; + +class ExpansionPanelItem extends StatelessWidget { + final ExampleModel example; + + const ExpansionPanelItem({Key? key, required this.example}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Consumer( + builder: (context, state, child) => GestureDetector( + onTap: () { + if (state.selectedExample != example) { + state.setExample(example); + } + }, + child: Container( + color: Colors.transparent, + margin: const EdgeInsets.only(left: kXxlSpacing), + height: kContainerHeight, + child: Row( + children: [ + // Wrapped with Row for better user interaction and positioning + Text(example.name), + ], + ), + ), + ), + ); + } +} diff --git a/playground/frontend/lib/modules/examples/components/examples_components.dart b/playground/frontend/lib/modules/examples/components/examples_components.dart new file mode 100644 index 000000000000..cd7ac4ad4f7f --- /dev/null +++ b/playground/frontend/lib/modules/examples/components/examples_components.dart @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export 'package:playground/modules/examples/components/example_list/category_expansion_panel.dart'; +export 'package:playground/modules/examples/components/example_list/example_list.dart'; +export 'package:playground/modules/examples/components/filter/category_bubble.dart'; +export 'package:playground/modules/examples/components/filter/type_filter.dart'; +export 'package:playground/modules/examples/components/search_field/search_field.dart'; diff --git a/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart b/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart new file mode 100644 index 000000000000..462c9f3f7a1c --- /dev/null +++ b/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:flutter/material.dart'; +import 'package:playground/config/theme.dart'; +import 'package:playground/constants/sizes.dart'; +import 'package:playground/pages/playground/states/example_dropdown_state.dart'; +import 'package:provider/provider.dart'; + +class CategoryBubble extends StatelessWidget { + final String name; + + const CategoryBubble({Key? key, required this.name}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(right: kMdSpacing), + child: Consumer( + builder: (context, state, child) => GestureDetector( + onTap: () { + if (name != state.selectedCategory) { + state.setSelectedCategory(name); + } + }, + child: Container( + height: kContainerHeight, + padding: const EdgeInsets.symmetric(horizontal: kXlSpacing), + decoration: BoxDecoration( + color: name == state.selectedCategory + ? ThemeColors.of(context).primary + : ThemeColors.of(context).lightGreyColor, + borderRadius: BorderRadius.circular(kXlBorderRadius), + ), + child: Center( + child: Text( + name, + style: TextStyle( + color: name == state.selectedCategory + ? ThemeColors.of(context).primaryBackgroundTextColor + : ThemeColors.of(context).lightGreyBackgroundTextColor, + ), + ), + ), + ), + ), + ), + ); + } +} diff --git a/playground/frontend/lib/modules/examples/components/filter/type_filter.dart b/playground/frontend/lib/modules/examples/components/filter/type_filter.dart new file mode 100644 index 000000000000..7e4eb9a9b081 --- /dev/null +++ b/playground/frontend/lib/modules/examples/components/filter/type_filter.dart @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:flutter/material.dart'; +import 'package:playground/constants/sizes.dart'; +import 'package:playground/modules/examples/components/examples_components.dart'; + +class TypeFilter extends StatelessWidget { + const TypeFilter({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: kLgSpacing, + vertical: kMdSpacing, + ), + child: Row( + children: const [ + CategoryBubble(name: 'All'), + CategoryBubble(name: 'Examples'), + CategoryBubble(name: 'Katas'), + CategoryBubble(name: 'Unit tests'), + ], + ), + ); + } +} diff --git a/playground/frontend/lib/modules/examples/components/search_field/search_field.dart b/playground/frontend/lib/modules/examples/components/search_field/search_field.dart new file mode 100644 index 000000000000..fe59aa784dd9 --- /dev/null +++ b/playground/frontend/lib/modules/examples/components/search_field/search_field.dart @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:flutter/material.dart'; +import 'package:playground/config/theme.dart'; +import 'package:playground/constants/sizes.dart'; + +const double kContainerWidth = 376.0; +const int kMinLines = 1; +const int kMaxLines = 1; +const String kHintText = 'Search'; + +class SearchField extends StatelessWidget { + final TextEditingController controller; + + const SearchField({Key? key, required this.controller}) : super(key: key); + + @override + Widget build(BuildContext context) { + final OutlineInputBorder border = OutlineInputBorder( + borderSide: BorderSide(color: ThemeColors.of(context).lightGreyColor), + borderRadius: BorderRadius.circular(kMdBorderRadius), + ); + + return Container( + margin: const EdgeInsets.only( + top: kLgSpacing, + right: kLgSpacing, + left: kLgSpacing, + ), + width: kContainerWidth, + height: kContainerHeight, + color: Theme.of(context).backgroundColor, + child: ClipRRect( + borderRadius: BorderRadius.circular(kMdBorderRadius), + child: TextFormField( + controller: controller, + decoration: InputDecoration( + suffixIcon: Padding( + padding: const EdgeInsetsDirectional.only( + start: kZeroSpacing, + end: kZeroSpacing, + ), + child: Icon( + Icons.search, + color: ThemeColors.of(context).lightGreyColor, + size: kIconSizeMd, + ), + ), + focusedBorder: border, + enabledBorder: border, + filled: false, + isDense: true, + hintText: kHintText, + contentPadding: const EdgeInsets.only(left: kLgSpacing), + ), + cursorColor: ThemeColors.of(context).lightGreyColor, + cursorWidth: kCursorSize, + textAlignVertical: TextAlignVertical.center, + onFieldSubmitted: (String txt) {}, + onChanged: (String txt) {}, + maxLines: kMinLines, + minLines: kMaxLines, + ), + ), + ); + } +} diff --git a/playground/frontend/lib/modules/examples/example_selector.dart b/playground/frontend/lib/modules/examples/example_selector.dart new file mode 100644 index 000000000000..9e7a811f4c38 --- /dev/null +++ b/playground/frontend/lib/modules/examples/example_selector.dart @@ -0,0 +1,185 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:flutter/material.dart'; +import 'package:playground/config/theme.dart'; +import 'package:playground/constants/sizes.dart'; +import 'package:playground/modules/examples/components/examples_components.dart'; +import 'package:playground/modules/examples/models/category_model.dart'; +import 'package:playground/modules/examples/models/selector_size_model.dart'; +import 'package:playground/pages/playground/states/example_dropdown_state.dart'; +import 'package:playground/pages/playground/states/playground_state.dart'; +import 'package:provider/provider.dart'; + +const int kAnimationDurationInMilliseconds = 80; +const Offset kAnimationBeginOffset = Offset(0.0, -0.02); +const Offset kAnimationEndOffset = Offset(0.0, 0.0); +const double kAdditionalDyAlignment = 50.0; +const double kLgContainerHeight = 444.0; +const double kLgContainerWidth = 400.0; + +class ExampleSelector extends StatefulWidget { + final Function changeSelectorVisibility; + final bool isSelectorOpened; + final List categories; + + const ExampleSelector({ + Key? key, + required this.changeSelectorVisibility, + required this.isSelectorOpened, + required this.categories, + }) : super(key: key); + + @override + State createState() => _ExampleSelectorState(); +} + +class _ExampleSelectorState extends State + with TickerProviderStateMixin { + final GlobalKey selectorKey = LabeledGlobalKey('ExampleSelector'); + late OverlayEntry? examplesDropdown; + late AnimationController animationController; + late Animation offsetAnimation; + + final TextEditingController textController = TextEditingController(); + final ScrollController scrollController = ScrollController(); + + @override + void initState() { + super.initState(); + animationController = AnimationController( + vsync: this, + duration: const Duration(milliseconds: kAnimationDurationInMilliseconds), + ); + offsetAnimation = Tween( + begin: kAnimationBeginOffset, + end: kAnimationEndOffset, + ).animate(animationController); + } + + @override + void dispose() { + animationController.dispose(); + textController.dispose(); + scrollController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Container( + height: kContainerHeight, + decoration: BoxDecoration( + color: ThemeColors.of(context).greyColor, + borderRadius: BorderRadius.circular(kSmBorderRadius), + ), + child: Consumer( + builder: (context, state, child) => TextButton( + key: selectorKey, + onPressed: () { + if (widget.isSelectorOpened) { + animationController.reverse(); + examplesDropdown?.remove(); + } else { + animationController.forward(); + examplesDropdown = createExamplesDropdown(); + Overlay.of(context)?.insert(examplesDropdown!); + } + widget.changeSelectorVisibility(); + }, + child: Wrap( + alignment: WrapAlignment.center, + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + Consumer( + builder: (context, state, child) => Text(state.examplesTitle), + ), + const Icon(Icons.keyboard_arrow_down), + ], + ), + ), + ), + ); + } + + OverlayEntry createExamplesDropdown() { + SelectorPositionModel posModel = findSelectorPositionData(); + + return OverlayEntry( + builder: (context) { + return Stack( + children: [ + GestureDetector( + onTap: () { + animationController.reverse(); + examplesDropdown?.remove(); + widget.changeSelectorVisibility(); + }, + child: Container( + color: Colors.transparent, + height: double.infinity, + width: double.infinity, + ), + ), + ChangeNotifierProvider( + create: (context) => ExampleDropdownState(), + builder: (context, _) => Positioned( + left: posModel.xAlignment, + top: posModel.yAlignment + kAdditionalDyAlignment, + child: SlideTransition( + position: offsetAnimation, + child: Material( + elevation: kElevation.toDouble(), + child: Container( + height: kLgContainerHeight, + width: kLgContainerWidth, + decoration: BoxDecoration( + color: Theme.of(context).backgroundColor, + borderRadius: BorderRadius.circular(kMdBorderRadius), + ), + child: Column( + children: [ + SearchField(controller: textController), + const TypeFilter(), + ExampleList( + controller: scrollController, + items: widget.categories, + ), + ], + ), + ), + ), + ), + ), + ), + ], + ); + }, + ); + } + + SelectorPositionModel findSelectorPositionData() { + RenderBox? rBox = + selectorKey.currentContext?.findRenderObject() as RenderBox; + SelectorPositionModel positionModel = SelectorPositionModel( + xAlignment: rBox.localToGlobal(Offset.zero).dx, + yAlignment: rBox.localToGlobal(Offset.zero).dy, + ); + return positionModel; + } +} diff --git a/playground/frontend/lib/modules/examples/models/category_model.dart b/playground/frontend/lib/modules/examples/models/category_model.dart new file mode 100644 index 000000000000..4b852a05fa25 --- /dev/null +++ b/playground/frontend/lib/modules/examples/models/category_model.dart @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:playground/modules/examples/models/example_model.dart'; + +class CategoryModel { + final String name; + final List examples; + + CategoryModel(this.name, this.examples); +} diff --git a/playground/frontend/lib/modules/examples/models/example_model.dart b/playground/frontend/lib/modules/examples/models/example_model.dart index 9171669538b4..fb7bbb4ccb91 100644 --- a/playground/frontend/lib/modules/examples/models/example_model.dart +++ b/playground/frontend/lib/modules/examples/models/example_model.dart @@ -18,9 +18,16 @@ import 'package:playground/modules/sdk/models/sdk.dart'; +enum ExampleType { + example, + kata, + test, +} + class ExampleModel { final Map sources; + final ExampleType type; final String name; - const ExampleModel(this.sources, this.name); + const ExampleModel(this.sources, this.name, this.type); } diff --git a/playground/frontend/lib/modules/examples/models/selector_size_model.dart b/playground/frontend/lib/modules/examples/models/selector_size_model.dart new file mode 100644 index 000000000000..27954f7ae22a --- /dev/null +++ b/playground/frontend/lib/modules/examples/models/selector_size_model.dart @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class SelectorPositionModel { + final double xAlignment; + final double yAlignment; + + const SelectorPositionModel({ + required this.xAlignment, + required this.yAlignment, + }); +} diff --git a/playground/frontend/lib/modules/examples/repositories/example_repository.dart b/playground/frontend/lib/modules/examples/repositories/example_repository.dart index 4264691d65d8..80d22e94b329 100644 --- a/playground/frontend/lib/modules/examples/repositories/example_repository.dart +++ b/playground/frontend/lib/modules/examples/repositories/example_repository.dart @@ -16,6 +16,7 @@ * limitations under the License. */ +import 'package:playground/modules/examples/models/category_model.dart'; import 'package:playground/modules/examples/models/example_model.dart'; import 'package:playground/modules/sdk/models/sdk.dart'; @@ -25,7 +26,7 @@ const javaHelloWorld = '''class HelloWorld { } }'''; -const pythonHelloWorld = "print(‘Hello World’)"; +const pythonHelloWorld = 'print(‘Hello World’)'; const goHelloWorld = '''package main @@ -37,17 +38,82 @@ func main() { fmt.Println("Hello World") }'''; +const scioHelloWorld = ''' +object Hello { + def main(args: Array[String]) = { + println("Hello, world") + } +}'''; + class ExampleRepository { - Future> getExamples() { - return Future.value([ - const ExampleModel( - { - SDK.java: javaHelloWorld, - SDK.go: goHelloWorld, - SDK.python: pythonHelloWorld, - }, - "Initial Example", - ) - ]); + List getCategories() { + return [ + CategoryModel('Side Inputs', const [ + ExampleModel( + { + SDK.java: javaHelloWorld, + SDK.go: goHelloWorld, + SDK.python: pythonHelloWorld, + SDK.scio: scioHelloWorld, + }, + 'HelloWorld', + ExampleType.example, + ), + ExampleModel( + { + SDK.java: 'JAVA Source code 1', + SDK.go: 'GO Source code 1', + SDK.python: 'PYTHON Source code 1', + SDK.scio: 'SCIO Source code 1', + }, + 'Source code 1', + ExampleType.kata, + ), + ]), + CategoryModel('Side Outputs', const [ + ExampleModel( + { + SDK.java: 'JAVA Source code 2', + SDK.go: 'GO Source code 2', + SDK.python: 'PYTHON Source code 2', + SDK.scio: 'SCIO Source code 2', + }, + 'Source code 2', + ExampleType.test, + ), + ExampleModel( + { + SDK.java: 'JAVA Source code 3', + SDK.go: 'GO Source code 3', + SDK.python: 'PYTHON Source code 3', + SDK.scio: 'SCIO Source code 3', + }, + 'Source code 3', + ExampleType.example, + ), + ]), + CategoryModel('I/O', const [ + ExampleModel( + { + SDK.java: 'JAVA Source code 4', + SDK.go: 'GO Source code 4', + SDK.python: 'PYTHON Source code 4', + SDK.scio: 'SCIO Source code 4', + }, + 'Source code 4', + ExampleType.kata, + ), + ExampleModel( + { + SDK.java: 'JAVA Source code 5', + SDK.go: 'GO Source code 5', + SDK.python: 'PYTHON Source code 5', + SDK.scio: 'SCIO Source code 5', + }, + 'Source code 5', + ExampleType.test, + ), + ]), + ]; } } diff --git a/playground/frontend/lib/modules/sdk/components/sdk_selector.dart b/playground/frontend/lib/modules/sdk/components/sdk_selector.dart index a30cd57b16dd..10b887afb424 100644 --- a/playground/frontend/lib/modules/sdk/components/sdk_selector.dart +++ b/playground/frontend/lib/modules/sdk/components/sdk_selector.dart @@ -35,11 +35,11 @@ class SDKSelector extends StatelessWidget { return Container( padding: const EdgeInsets.symmetric( vertical: kZeroSpacing, - horizontal: kLgSpacing, + horizontal: kXlSpacing, ), decoration: BoxDecoration( color: ThemeColors.of(context).greyColor, - borderRadius: BorderRadius.circular(kBorderRadius), + borderRadius: BorderRadius.circular(kLgBorderRadius), ), child: DropdownButtonHideUnderline( child: DropdownButton( @@ -47,7 +47,7 @@ class SDKSelector extends StatelessWidget { icon: const Icon(Icons.keyboard_arrow_down), iconSize: kIconSizeMd, elevation: kElevation, - borderRadius: BorderRadius.circular(kBorderRadius), + borderRadius: BorderRadius.circular(kLgBorderRadius), alignment: Alignment.bottomCenter, onChanged: (SDK? newSdk) { if (newSdk != null) { diff --git a/playground/frontend/lib/modules/sdk/models/sdk.dart b/playground/frontend/lib/modules/sdk/models/sdk.dart index 1406a038c287..78aa0afaf6f8 100644 --- a/playground/frontend/lib/modules/sdk/models/sdk.dart +++ b/playground/frontend/lib/modules/sdk/models/sdk.dart @@ -27,13 +27,13 @@ extension SDKToString on SDK { String get displayName { switch (this) { case SDK.go: - return "Go"; + return 'Go'; case SDK.java: - return "Java"; + return 'Java'; case SDK.python: - return "Python"; + return 'Python'; case SDK.scio: - return "SCIO"; + return 'SCIO'; } } } 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 f4ca7ae998a8..c4a598f08958 100644 --- a/playground/frontend/lib/pages/playground/components/playground_page_providers.dart +++ b/playground/frontend/lib/pages/playground/components/playground_page_providers.dart @@ -44,9 +44,10 @@ class PlaygroundPageProviders extends StatelessWidget { if (playground == null) { return PlaygroundState(); } - if (exampleState.examples?.isNotEmpty ?? false) { - return PlaygroundState( - playground.sdk, exampleState.examples!.first); + if ((exampleState.categories?.isNotEmpty ?? false) && + playground.selectedExample == null) { + return PlaygroundState(playground.sdk, + exampleState.categories?.first.examples.first); } return playground; }, diff --git a/playground/frontend/lib/pages/playground/playground_page.dart b/playground/frontend/lib/pages/playground/playground_page.dart index df2fbc5badb8..fce65824c272 100644 --- a/playground/frontend/lib/pages/playground/playground_page.dart +++ b/playground/frontend/lib/pages/playground/playground_page.dart @@ -17,49 +17,57 @@ */ import 'package:flutter/material.dart'; +import 'package:playground/components/logo/logo_component.dart'; import 'package:playground/components/toggle_theme_button/toggle_theme_button.dart'; import 'package:playground/constants/sizes.dart'; -import 'package:playground/pages/playground/components/playground_page_body.dart'; -import 'package:playground/pages/playground/components/playground_page_footer.dart'; -import 'package:playground/pages/playground/components/playground_page_providers.dart'; import 'package:playground/modules/actions/components/new_example_action.dart'; import 'package:playground/modules/actions/components/reset_action.dart'; +import 'package:playground/modules/examples/example_selector.dart'; +import 'package:playground/modules/sdk/components/sdk_selector.dart'; import 'package:playground/pages/playground/components/more_actions.dart'; -import 'package:provider/provider.dart'; +import 'package:playground/pages/playground/components/playground_page_body.dart'; +import 'package:playground/pages/playground/components/playground_page_footer.dart'; +import 'package:playground/pages/playground/states/examples_state.dart'; import 'package:playground/pages/playground/states/playground_state.dart'; -import 'package:playground/modules/sdk/components/sdk_selector.dart'; -import 'package:playground/components/logo/logo_component.dart'; +import 'package:provider/provider.dart'; class PlaygroundPage extends StatelessWidget { const PlaygroundPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return PlaygroundPageProviders( - child: Scaffold( - appBar: AppBar( - title: Consumer( - builder: (context, state, child) { - return Wrap( - crossAxisAlignment: WrapCrossAlignment.center, - spacing: kLgSpacing, - children: [ - const Logo(), - SDKSelector(sdk: state.sdk, setSdk: state.setSdk), - const NewExampleAction(), - ResetAction(reset: state.reset), - ], - ); - }, - ), - actions: const [ToggleThemeButton(), MoreActions()], - ), - body: Column( - children: const [ - Expanded(child: PlaygroundPageBody()), - PlaygroundPageFooter(), - ], + return Scaffold( + appBar: AppBar( + title: Consumer( + builder: (context, state, child) { + return Wrap( + crossAxisAlignment: WrapCrossAlignment.center, + spacing: kLgSpacing, + children: [ + const Logo(), + Consumer( + builder: (context, state, child) { + return ExampleSelector( + changeSelectorVisibility: state.changeSelectorVisibility, + isSelectorOpened: state.isSelectorOpened, + categories: state.categories!, + ); + }, + ), + SDKSelector(sdk: state.sdk, setSdk: state.setSdk), + const NewExampleAction(), + ResetAction(reset: state.reset), + ], + ); + }, ), + actions: const [ToggleThemeButton(), MoreActions()], + ), + body: Column( + children: const [ + Expanded(child: PlaygroundPageBody()), + PlaygroundPageFooter(), + ], ), ); } diff --git a/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart b/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart new file mode 100644 index 000000000000..38a966561fb1 --- /dev/null +++ b/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:flutter/material.dart'; + +class ExampleDropdownState with ChangeNotifier { + String _selectedCategory; + + ExampleDropdownState([this._selectedCategory = 'All']); + + String get selectedCategory => _selectedCategory; + + setSelectedCategory(String name) async { + _selectedCategory = name; + notifyListeners(); + } +} diff --git a/playground/frontend/lib/pages/playground/states/examples_state.dart b/playground/frontend/lib/pages/playground/states/examples_state.dart index 1077a7fee4e9..396f37cd95bf 100644 --- a/playground/frontend/lib/pages/playground/states/examples_state.dart +++ b/playground/frontend/lib/pages/playground/states/examples_state.dart @@ -17,19 +17,25 @@ */ import 'package:flutter/material.dart'; -import 'package:playground/modules/examples/models/example_model.dart'; +import 'package:playground/modules/examples/models/category_model.dart'; import 'package:playground/modules/examples/repositories/example_repository.dart'; class ExampleState with ChangeNotifier { final ExampleRepository _exampleRepository; - List? examples; + List? categories; + bool isSelectorOpened = false; ExampleState(this._exampleRepository) { - _loadExamples(); + _loadCategories(); } - _loadExamples() async { - examples = await _exampleRepository.getExamples(); + _loadCategories() { + categories = _exampleRepository.getCategories(); + notifyListeners(); + } + + changeSelectorVisibility() { + isSelectorOpened = !isSelectorOpened; notifyListeners(); } } diff --git a/playground/frontend/lib/pages/playground/states/playground_state.dart b/playground/frontend/lib/pages/playground/states/playground_state.dart index c83b7dc1b5e7..ef873edc9761 100644 --- a/playground/frontend/lib/pages/playground/states/playground_state.dart +++ b/playground/frontend/lib/pages/playground/states/playground_state.dart @@ -16,14 +16,24 @@ * limitations under the License. */ +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:playground/modules/examples/models/example_model.dart'; import 'package:playground/modules/sdk/models/sdk.dart'; +const kTitleLength = 15; +const kTitle = 'Catalog'; + class PlaygroundState with ChangeNotifier { SDK _sdk; ExampleModel? _selectedExample; - String _source = ""; + String _source = ''; + + String get examplesTitle { + final name = _selectedExample?.name ?? ''; + return name.substring(0, min(kTitleLength, name.length)); + } PlaygroundState([this._sdk = SDK.java, this._selectedExample]); @@ -35,7 +45,7 @@ class PlaygroundState with ChangeNotifier { setExample(ExampleModel example) { _selectedExample = example; - _source = example.sources[_sdk] ?? ""; + _source = example.sources[_sdk] ?? ''; notifyListeners(); } diff --git a/playground/frontend/lib/playground_app.dart b/playground/frontend/lib/playground_app.dart index 8ce11d100480..54955d0bbe8a 100644 --- a/playground/frontend/lib/playground_app.dart +++ b/playground/frontend/lib/playground_app.dart @@ -18,6 +18,7 @@ import 'package:flutter/material.dart'; import 'package:playground/config/theme.dart'; +import 'package:playground/pages/playground/components/playground_page_providers.dart'; import 'package:playground/pages/playground/playground_page.dart'; import 'package:provider/provider.dart'; @@ -30,13 +31,15 @@ class PlaygroundApp extends StatelessWidget { create: (context) => ThemeProvider(), builder: (context, _) { final themeProvider = Provider.of(context); - return MaterialApp( - title: 'Apache Beam Playground', - themeMode: themeProvider.themeMode, - theme: kLightTheme, - darkTheme: kDarkTheme, - home: const PlaygroundPage(), - debugShowCheckedModeBanner: false, + return PlaygroundPageProviders( + child: MaterialApp( + title: 'Apache Beam Playground', + themeMode: themeProvider.themeMode, + theme: kLightTheme, + darkTheme: kDarkTheme, + home: const PlaygroundPage(), + debugShowCheckedModeBanner: false, + ), ); }, ); diff --git a/playground/frontend/pubspec.lock b/playground/frontend/pubspec.lock index 845b026ab312..3e6ce43fa045 100644 --- a/playground/frontend/pubspec.lock +++ b/playground/frontend/pubspec.lock @@ -50,6 +50,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" + expansion_widget: + dependency: "direct main" + description: + name: expansion_widget + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2" fake_async: dependency: transitive description: diff --git a/playground/frontend/pubspec.yaml b/playground/frontend/pubspec.yaml index 64230761eae6..90b58d5b2b8f 100644 --- a/playground/frontend/pubspec.yaml +++ b/playground/frontend/pubspec.yaml @@ -50,6 +50,7 @@ dependencies: code_text_field: ^1.0.0 flutter_svg: ^0.22.0 url_launcher: ^6.0.12 + expansion_widget: ^0.0.2 dev_dependencies: flutter_test: From 9d5b229a983b4fb1f243e01e84b58d9a0e63f24f Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Fri, 15 Oct 2021 12:31:09 +0300 Subject: [PATCH 02/15] [BEAM-12967]: Wrapped CategoryBubble and ExpansionPanelItem in MouseRegion --- .../example_list/expansion_panel_item.dart | 33 +++++++------ .../components/filter/category_bubble.dart | 47 ++++++++++--------- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/playground/frontend/lib/modules/examples/components/example_list/expansion_panel_item.dart b/playground/frontend/lib/modules/examples/components/example_list/expansion_panel_item.dart index 560fbca079b7..2ae056070aab 100644 --- a/playground/frontend/lib/modules/examples/components/example_list/expansion_panel_item.dart +++ b/playground/frontend/lib/modules/examples/components/example_list/expansion_panel_item.dart @@ -30,21 +30,24 @@ class ExpansionPanelItem extends StatelessWidget { @override Widget build(BuildContext context) { return Consumer( - builder: (context, state, child) => GestureDetector( - onTap: () { - if (state.selectedExample != example) { - state.setExample(example); - } - }, - child: Container( - color: Colors.transparent, - margin: const EdgeInsets.only(left: kXxlSpacing), - height: kContainerHeight, - child: Row( - children: [ - // Wrapped with Row for better user interaction and positioning - Text(example.name), - ], + builder: (context, state, child) => MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + if (state.selectedExample != example) { + state.setExample(example); + } + }, + child: Container( + color: Colors.transparent, + margin: const EdgeInsets.only(left: kXxlSpacing), + height: kContainerHeight, + child: Row( + children: [ + // Wrapped with Row for better user interaction and positioning + Text(example.name), + ], + ), ), ), ), diff --git a/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart b/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart index 462c9f3f7a1c..6481cdb6f631 100644 --- a/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart +++ b/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart @@ -32,28 +32,31 @@ class CategoryBubble extends StatelessWidget { return Padding( padding: const EdgeInsets.only(right: kMdSpacing), child: Consumer( - builder: (context, state, child) => GestureDetector( - onTap: () { - if (name != state.selectedCategory) { - state.setSelectedCategory(name); - } - }, - child: Container( - height: kContainerHeight, - padding: const EdgeInsets.symmetric(horizontal: kXlSpacing), - decoration: BoxDecoration( - color: name == state.selectedCategory - ? ThemeColors.of(context).primary - : ThemeColors.of(context).lightGreyColor, - borderRadius: BorderRadius.circular(kXlBorderRadius), - ), - child: Center( - child: Text( - name, - style: TextStyle( - color: name == state.selectedCategory - ? ThemeColors.of(context).primaryBackgroundTextColor - : ThemeColors.of(context).lightGreyBackgroundTextColor, + builder: (context, state, child) => MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + if (name != state.selectedCategory) { + state.setSelectedCategory(name); + } + }, + child: Container( + height: kContainerHeight, + padding: const EdgeInsets.symmetric(horizontal: kXlSpacing), + decoration: BoxDecoration( + color: name == state.selectedCategory + ? ThemeColors.of(context).primary + : ThemeColors.of(context).lightGreyColor, + borderRadius: BorderRadius.circular(kXlBorderRadius), + ), + child: Center( + child: Text( + name, + style: TextStyle( + color: name == state.selectedCategory + ? ThemeColors.of(context).primaryBackgroundTextColor + : ThemeColors.of(context).lightGreyBackgroundTextColor, + ), ), ), ), From 5a49ae18aea8a90829771514a098c52ae44bf446 Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Fri, 15 Oct 2021 13:25:29 +0300 Subject: [PATCH 03/15] [BEAM-13064]: Implemented Search field and Filter by type components logic --- .../components/example_list/example_list.dart | 34 ++++---- .../components/filter/category_bubble.dart | 30 +++---- .../components/filter/type_filter.dart | 9 +- .../components/search_field/search_field.dart | 80 ++++++++++-------- .../modules/examples/example_selector.dart | 83 ++++++++++--------- .../examples/models/example_model.dart | 16 ++++ .../repositories/example_repository.dart | 10 +-- .../states/example_dropdown_state.dart | 68 +++++++++++++-- .../playground/states/mocks/example_mock.dart | 9 +- 9 files changed, 215 insertions(+), 124 deletions(-) diff --git a/playground/frontend/lib/modules/examples/components/example_list/example_list.dart b/playground/frontend/lib/modules/examples/components/example_list/example_list.dart index ca5f2177602a..c92211553ec5 100644 --- a/playground/frontend/lib/modules/examples/components/example_list/example_list.dart +++ b/playground/frontend/lib/modules/examples/components/example_list/example_list.dart @@ -18,34 +18,36 @@ import 'package:flutter/material.dart'; import 'package:playground/modules/examples/components/examples_components.dart'; +import 'package:playground/pages/playground/states/example_dropdown_state.dart'; +import 'package:provider/provider.dart'; class ExampleList extends StatelessWidget { - final List items; final ScrollController controller; const ExampleList({ Key? key, - required this.items, required this.controller, }) : super(key: key); @override Widget build(BuildContext context) { - return Expanded( - child: Container( - color: Theme.of(context).backgroundColor, - child: Scrollbar( - isAlwaysShown: true, - showTrackOnHover: true, - controller: controller, - child: ListView.builder( - itemCount: items.length, - itemBuilder: (context, index) => CategoryExpansionPanel( - categoryName: items[index].name, - examples: items[index].examples, - ), + return Consumer( + builder: (context, state, child) => Expanded( + child: Container( + color: Theme.of(context).backgroundColor, + child: Scrollbar( + isAlwaysShown: true, + showTrackOnHover: true, controller: controller, - shrinkWrap: true, + child: ListView.builder( + itemCount: state.categories.length, + itemBuilder: (context, index) => CategoryExpansionPanel( + categoryName: state.categories[index].name, + examples: state.categories[index].examples, + ), + controller: controller, + shrinkWrap: true, + ), ), ), ), diff --git a/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart b/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart index 6481cdb6f631..017ab540145f 100644 --- a/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart +++ b/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart @@ -19,41 +19,43 @@ import 'package:flutter/material.dart'; import 'package:playground/config/theme.dart'; import 'package:playground/constants/sizes.dart'; +import 'package:playground/modules/examples/models/example_model.dart'; import 'package:playground/pages/playground/states/example_dropdown_state.dart'; import 'package:provider/provider.dart'; class CategoryBubble extends StatelessWidget { - final String name; + final ExampleType type; - const CategoryBubble({Key? key, required this.name}) : super(key: key); + const CategoryBubble({Key? key, required this.type}) : super(key: key); @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.only(right: kMdSpacing), - child: Consumer( - builder: (context, state, child) => MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( + return MouseRegion( + cursor: SystemMouseCursors.click, + child: Padding( + padding: const EdgeInsets.only(right: kMdSpacing), + child: Consumer( + builder: (context, dropdownState, child) => GestureDetector( onTap: () { - if (name != state.selectedCategory) { - state.setSelectedCategory(name); + if (type != dropdownState.selectedCategory) { + dropdownState.setSelectedCategory(type); + dropdownState.sortExamplesByType(type); } }, child: Container( height: kContainerHeight, padding: const EdgeInsets.symmetric(horizontal: kXlSpacing), decoration: BoxDecoration( - color: name == state.selectedCategory + color: type == dropdownState.selectedCategory ? ThemeColors.of(context).primary : ThemeColors.of(context).lightGreyColor, borderRadius: BorderRadius.circular(kXlBorderRadius), ), child: Center( child: Text( - name, + type.name, style: TextStyle( - color: name == state.selectedCategory + color: type == dropdownState.selectedCategory ? ThemeColors.of(context).primaryBackgroundTextColor : ThemeColors.of(context).lightGreyBackgroundTextColor, ), @@ -65,4 +67,4 @@ class CategoryBubble extends StatelessWidget { ), ); } -} +} \ No newline at end of file diff --git a/playground/frontend/lib/modules/examples/components/filter/type_filter.dart b/playground/frontend/lib/modules/examples/components/filter/type_filter.dart index 7e4eb9a9b081..7b1bbed9b685 100644 --- a/playground/frontend/lib/modules/examples/components/filter/type_filter.dart +++ b/playground/frontend/lib/modules/examples/components/filter/type_filter.dart @@ -19,6 +19,7 @@ import 'package:flutter/material.dart'; import 'package:playground/constants/sizes.dart'; import 'package:playground/modules/examples/components/examples_components.dart'; +import 'package:playground/modules/examples/models/example_model.dart'; class TypeFilter extends StatelessWidget { const TypeFilter({Key? key}) : super(key: key); @@ -32,10 +33,10 @@ class TypeFilter extends StatelessWidget { ), child: Row( children: const [ - CategoryBubble(name: 'All'), - CategoryBubble(name: 'Examples'), - CategoryBubble(name: 'Katas'), - CategoryBubble(name: 'Unit tests'), + CategoryBubble(type: ExampleType.all), + CategoryBubble(type: ExampleType.example), + CategoryBubble(type: ExampleType.kata), + CategoryBubble(type: ExampleType.test), ], ), ); diff --git a/playground/frontend/lib/modules/examples/components/search_field/search_field.dart b/playground/frontend/lib/modules/examples/components/search_field/search_field.dart index fe59aa784dd9..992011bbffd7 100644 --- a/playground/frontend/lib/modules/examples/components/search_field/search_field.dart +++ b/playground/frontend/lib/modules/examples/components/search_field/search_field.dart @@ -19,6 +19,8 @@ import 'package:flutter/material.dart'; import 'package:playground/config/theme.dart'; import 'package:playground/constants/sizes.dart'; +import 'package:playground/pages/playground/states/example_dropdown_state.dart'; +import 'package:provider/provider.dart'; const double kContainerWidth = 376.0; const int kMinLines = 1; @@ -37,45 +39,51 @@ class SearchField extends StatelessWidget { borderRadius: BorderRadius.circular(kMdBorderRadius), ); - return Container( - margin: const EdgeInsets.only( - top: kLgSpacing, - right: kLgSpacing, - left: kLgSpacing, - ), - width: kContainerWidth, - height: kContainerHeight, - color: Theme.of(context).backgroundColor, - child: ClipRRect( - borderRadius: BorderRadius.circular(kMdBorderRadius), - child: TextFormField( - controller: controller, - decoration: InputDecoration( - suffixIcon: Padding( - padding: const EdgeInsetsDirectional.only( - start: kZeroSpacing, - end: kZeroSpacing, - ), - child: Icon( - Icons.search, - color: ThemeColors.of(context).lightGreyColor, - size: kIconSizeMd, + return Consumer( + builder: (context, state, child) => Container( + margin: const EdgeInsets.only( + top: kLgSpacing, + right: kLgSpacing, + left: kLgSpacing, + ), + width: kContainerWidth, + height: kContainerHeight, + color: Theme.of(context).backgroundColor, + child: ClipRRect( + borderRadius: BorderRadius.circular(kMdBorderRadius), + child: TextFormField( + controller: controller, + decoration: InputDecoration( + suffixIcon: Padding( + padding: const EdgeInsetsDirectional.only( + start: kZeroSpacing, + end: kZeroSpacing, + ), + child: Icon( + Icons.search, + color: ThemeColors.of(context).lightGreyColor, + size: kIconSizeMd, + ), ), + focusedBorder: border, + enabledBorder: border, + filled: false, + isDense: true, + hintText: kHintText, + contentPadding: const EdgeInsets.only(left: kLgSpacing), ), - focusedBorder: border, - enabledBorder: border, - filled: false, - isDense: true, - hintText: kHintText, - contentPadding: const EdgeInsets.only(left: kLgSpacing), + cursorColor: ThemeColors.of(context).lightGreyColor, + cursorWidth: kCursorSize, + textAlignVertical: TextAlignVertical.center, + onFieldSubmitted: (String txt) { + state.sortExamplesByName(txt); + }, + onChanged: (String txt) { + state.sortExamplesByName(txt); + }, + maxLines: kMinLines, + minLines: kMaxLines, ), - cursorColor: ThemeColors.of(context).lightGreyColor, - cursorWidth: kCursorSize, - textAlignVertical: TextAlignVertical.center, - onFieldSubmitted: (String txt) {}, - onChanged: (String txt) {}, - maxLines: kMinLines, - minLines: kMaxLines, ), ), ); diff --git a/playground/frontend/lib/modules/examples/example_selector.dart b/playground/frontend/lib/modules/examples/example_selector.dart index 9e7a811f4c38..362241d56b65 100644 --- a/playground/frontend/lib/modules/examples/example_selector.dart +++ b/playground/frontend/lib/modules/examples/example_selector.dart @@ -23,6 +23,7 @@ import 'package:playground/modules/examples/components/examples_components.dart' import 'package:playground/modules/examples/models/category_model.dart'; import 'package:playground/modules/examples/models/selector_size_model.dart'; import 'package:playground/pages/playground/states/example_dropdown_state.dart'; +import 'package:playground/pages/playground/states/examples_state.dart'; import 'package:playground/pages/playground/states/playground_state.dart'; import 'package:provider/provider.dart'; @@ -122,52 +123,54 @@ class _ExampleSelectorState extends State return OverlayEntry( builder: (context) { - return Stack( - children: [ - GestureDetector( - onTap: () { - animationController.reverse(); - examplesDropdown?.remove(); - widget.changeSelectorVisibility(); - }, - child: Container( - color: Colors.transparent, - height: double.infinity, - width: double.infinity, + return Consumer( + builder: (context, state, child) => Stack( + children: [ + GestureDetector( + onTap: () { + animationController.reverse(); + examplesDropdown?.remove(); + state.changeSelectorVisibility(); + }, + child: Container( + color: Colors.transparent, + height: double.infinity, + width: double.infinity, + ), ), - ), - ChangeNotifierProvider( - create: (context) => ExampleDropdownState(), - builder: (context, _) => Positioned( - left: posModel.xAlignment, - top: posModel.yAlignment + kAdditionalDyAlignment, - child: SlideTransition( - position: offsetAnimation, - child: Material( - elevation: kElevation.toDouble(), - child: Container( - height: kLgContainerHeight, - width: kLgContainerWidth, - decoration: BoxDecoration( - color: Theme.of(context).backgroundColor, - borderRadius: BorderRadius.circular(kMdBorderRadius), - ), - child: Column( - children: [ - SearchField(controller: textController), - const TypeFilter(), - ExampleList( - controller: scrollController, - items: widget.categories, - ), - ], + ChangeNotifierProvider( + create: (context) => ExampleDropdownState( + state, + state.categories!, + ), + builder: (context, _) => Positioned( + left: posModel.xAlignment, + top: posModel.yAlignment + kAdditionalDyAlignment, + child: SlideTransition( + position: offsetAnimation, + child: Material( + elevation: kElevation.toDouble(), + child: Container( + height: kLgContainerHeight, + width: kLgContainerWidth, + decoration: BoxDecoration( + color: Theme.of(context).backgroundColor, + borderRadius: BorderRadius.circular(kMdBorderRadius), + ), + child: Column( + children: [ + SearchField(controller: textController), + const TypeFilter(), + ExampleList(controller: scrollController), + ], + ), ), ), ), ), ), - ), - ], + ], + ), ); }, ); diff --git a/playground/frontend/lib/modules/examples/models/example_model.dart b/playground/frontend/lib/modules/examples/models/example_model.dart index fb7bbb4ccb91..17e6f584982c 100644 --- a/playground/frontend/lib/modules/examples/models/example_model.dart +++ b/playground/frontend/lib/modules/examples/models/example_model.dart @@ -19,11 +19,27 @@ import 'package:playground/modules/sdk/models/sdk.dart'; enum ExampleType { + all, example, kata, test, } +extension ExampleTypeToString on ExampleType { + String get name { + switch (this) { + case ExampleType.example: + return 'Examples'; + case ExampleType.kata: + return 'Katas'; + case ExampleType.test: + return 'Unit tests'; + case ExampleType.all: + return 'All'; + } + } +} + class ExampleModel { final Map sources; final ExampleType type; diff --git a/playground/frontend/lib/modules/examples/repositories/example_repository.dart b/playground/frontend/lib/modules/examples/repositories/example_repository.dart index 80d22e94b329..a3e1722fbfc5 100644 --- a/playground/frontend/lib/modules/examples/repositories/example_repository.dart +++ b/playground/frontend/lib/modules/examples/repositories/example_repository.dart @@ -66,7 +66,7 @@ class ExampleRepository { SDK.python: 'PYTHON Source code 1', SDK.scio: 'SCIO Source code 1', }, - 'Source code 1', + 'KATA Source code 1', ExampleType.kata, ), ]), @@ -78,7 +78,7 @@ class ExampleRepository { SDK.python: 'PYTHON Source code 2', SDK.scio: 'SCIO Source code 2', }, - 'Source code 2', + 'UNIT TEST Source code 2', ExampleType.test, ), ExampleModel( @@ -88,7 +88,7 @@ class ExampleRepository { SDK.python: 'PYTHON Source code 3', SDK.scio: 'SCIO Source code 3', }, - 'Source code 3', + 'EXAMPLE Source code 3', ExampleType.example, ), ]), @@ -100,7 +100,7 @@ class ExampleRepository { SDK.python: 'PYTHON Source code 4', SDK.scio: 'SCIO Source code 4', }, - 'Source code 4', + 'KATA Source code 4', ExampleType.kata, ), ExampleModel( @@ -110,7 +110,7 @@ class ExampleRepository { SDK.python: 'PYTHON Source code 5', SDK.scio: 'SCIO Source code 5', }, - 'Source code 5', + 'UNIT TEST Source code 5', ExampleType.test, ), ]), diff --git a/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart b/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart index 38a966561fb1..0ade03184dc1 100644 --- a/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart +++ b/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart @@ -17,16 +17,74 @@ */ import 'package:flutter/material.dart'; +import 'package:playground/modules/examples/models/category_model.dart'; +import 'package:playground/modules/examples/models/example_model.dart'; + +import 'examples_state.dart'; class ExampleDropdownState with ChangeNotifier { - String _selectedCategory; + final ExampleState _exampleState; + ExampleType _selectedCategory; + List categories; + + ExampleDropdownState( + this._exampleState, + this.categories, [ + this._selectedCategory = ExampleType.all, + ]); - ExampleDropdownState([this._selectedCategory = 'All']); + ExampleType get selectedCategory => _selectedCategory; - String get selectedCategory => _selectedCategory; + setSelectedCategory(ExampleType type) async { + _selectedCategory = type; + notifyListeners(); + } - setSelectedCategory(String name) async { - _selectedCategory = name; + setCategories(List? categories) { + this.categories = categories ?? []; notifyListeners(); } + + sortExamplesByType(ExampleType type) { + if (type == ExampleType.all) { + setCategories(_exampleState.categories!); + } else { + List unsorted = [..._exampleState.categories!]; + List sorted = []; + for (CategoryModel category in unsorted) { + if (category.examples.any((element) => element.type == type)) { + CategoryModel sortedCategory = CategoryModel( + category.name, + category.examples.where((element) => element.type == type).toList(), + ); + sorted.add(sortedCategory); + } + } + setCategories(sorted); + } + } + + sortExamplesByName(String name) { + if (name.isEmpty) { + setCategories(_exampleState.categories!); + } else { + List unsorted = [..._exampleState.categories!]; + List sorted = []; + for (CategoryModel category in unsorted) { + if (category.examples.any( + (element) => element.name.toLowerCase().contains(name.toLowerCase()), + )) { + CategoryModel sortedCategory = CategoryModel( + category.name, + category.examples + .where((element) => + element.name.toLowerCase().contains(name.toLowerCase())) + .toList(), + ); + sorted.add(sortedCategory); + } + } + setCategories(sorted); + } + } } diff --git a/playground/frontend/test/pages/playground/states/mocks/example_mock.dart b/playground/frontend/test/pages/playground/states/mocks/example_mock.dart index d08472a57891..8eb808574a48 100644 --- a/playground/frontend/test/pages/playground/states/mocks/example_mock.dart +++ b/playground/frontend/test/pages/playground/states/mocks/example_mock.dart @@ -19,11 +19,11 @@ import 'package:playground/modules/examples/models/example_model.dart'; import 'package:playground/modules/sdk/models/sdk.dart'; -const javaExample = "java example"; +const javaExample = 'java example'; -const pythonExample = "python example"; +const pythonExample = 'python example'; -const goExample = "go example"; +const goExample = 'go example'; const sdkMap = { SDK.java: javaExample, @@ -33,5 +33,6 @@ const sdkMap = { const ExampleModel exampleMock = ExampleModel( sdkMap, - "Example", + 'Example', + ExampleType.example, ); From 544552626200aa857565866b0312f789a392a2b3 Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Fri, 15 Oct 2021 14:50:27 +0300 Subject: [PATCH 04/15] [BEAM-13064]: Fixed names to clarify code, refactored Category model (added const keyword) --- .../examples/components/filter/category_bubble.dart | 8 ++++---- .../lib/modules/examples/models/category_model.dart | 2 +- .../examples/repositories/example_repository.dart | 8 ++++---- .../playground/states/example_dropdown_state.dart | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart b/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart index 017ab540145f..7d968fb7c814 100644 --- a/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart +++ b/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart @@ -37,8 +37,8 @@ class CategoryBubble extends StatelessWidget { child: Consumer( builder: (context, dropdownState, child) => GestureDetector( onTap: () { - if (type != dropdownState.selectedCategory) { - dropdownState.setSelectedCategory(type); + if (type != dropdownState.selectedFilterType) { + dropdownState.setSelectedFilterType(type); dropdownState.sortExamplesByType(type); } }, @@ -46,7 +46,7 @@ class CategoryBubble extends StatelessWidget { height: kContainerHeight, padding: const EdgeInsets.symmetric(horizontal: kXlSpacing), decoration: BoxDecoration( - color: type == dropdownState.selectedCategory + color: type == dropdownState.selectedFilterType ? ThemeColors.of(context).primary : ThemeColors.of(context).lightGreyColor, borderRadius: BorderRadius.circular(kXlBorderRadius), @@ -55,7 +55,7 @@ class CategoryBubble extends StatelessWidget { child: Text( type.name, style: TextStyle( - color: type == dropdownState.selectedCategory + color: type == dropdownState.selectedFilterType ? ThemeColors.of(context).primaryBackgroundTextColor : ThemeColors.of(context).lightGreyBackgroundTextColor, ), diff --git a/playground/frontend/lib/modules/examples/models/category_model.dart b/playground/frontend/lib/modules/examples/models/category_model.dart index 4b852a05fa25..2c4b0f1a3401 100644 --- a/playground/frontend/lib/modules/examples/models/category_model.dart +++ b/playground/frontend/lib/modules/examples/models/category_model.dart @@ -22,5 +22,5 @@ class CategoryModel { final String name; final List examples; - CategoryModel(this.name, this.examples); + const CategoryModel(this.name, this.examples); } diff --git a/playground/frontend/lib/modules/examples/repositories/example_repository.dart b/playground/frontend/lib/modules/examples/repositories/example_repository.dart index a3e1722fbfc5..cff560528e3d 100644 --- a/playground/frontend/lib/modules/examples/repositories/example_repository.dart +++ b/playground/frontend/lib/modules/examples/repositories/example_repository.dart @@ -47,8 +47,8 @@ object Hello { class ExampleRepository { List getCategories() { - return [ - CategoryModel('Side Inputs', const [ + return const [ + CategoryModel('Side Inputs', [ ExampleModel( { SDK.java: javaHelloWorld, @@ -70,7 +70,7 @@ class ExampleRepository { ExampleType.kata, ), ]), - CategoryModel('Side Outputs', const [ + CategoryModel('Side Outputs', [ ExampleModel( { SDK.java: 'JAVA Source code 2', @@ -92,7 +92,7 @@ class ExampleRepository { ExampleType.example, ), ]), - CategoryModel('I/O', const [ + CategoryModel('I/O', [ ExampleModel( { SDK.java: 'JAVA Source code 4', diff --git a/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart b/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart index 0ade03184dc1..22d79f41862d 100644 --- a/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart +++ b/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart @@ -24,19 +24,19 @@ import 'examples_state.dart'; class ExampleDropdownState with ChangeNotifier { final ExampleState _exampleState; - ExampleType _selectedCategory; + ExampleType _selectedFilterType; List categories; ExampleDropdownState( this._exampleState, this.categories, [ - this._selectedCategory = ExampleType.all, + this._selectedFilterType = ExampleType.all, ]); - ExampleType get selectedCategory => _selectedCategory; + ExampleType get selectedFilterType => _selectedFilterType; - setSelectedCategory(ExampleType type) async { - _selectedCategory = type; + setSelectedFilterType(ExampleType type) async { + _selectedFilterType = type; notifyListeners(); } From 279c4efd864221563e2fc68fb8a54643d52234b8 Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Fri, 15 Oct 2021 14:52:00 +0300 Subject: [PATCH 05/15] [BEAM-13064]: Increased test coverage of Example Dropdown module --- .../states/example_dropdown_state_test.dart | 80 +++++++++++++++++ .../states/mocks/categories_mock.dart | 88 +++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 playground/frontend/test/pages/playground/states/example_dropdown_state_test.dart create mode 100644 playground/frontend/test/pages/playground/states/mocks/categories_mock.dart diff --git a/playground/frontend/test/pages/playground/states/example_dropdown_state_test.dart b/playground/frontend/test/pages/playground/states/example_dropdown_state_test.dart new file mode 100644 index 000000000000..4bbb56f71934 --- /dev/null +++ b/playground/frontend/test/pages/playground/states/example_dropdown_state_test.dart @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:flutter_test/flutter_test.dart'; +import 'package:playground/modules/examples/models/example_model.dart'; +import 'package:playground/modules/examples/repositories/example_repository.dart'; +import 'package:playground/pages/playground/states/example_dropdown_state.dart'; +import 'package:playground/pages/playground/states/examples_state.dart'; + +import 'mocks/categories_mock.dart'; + +void main() { + test( + 'ExampleDropdown state should notify all listeners about filter type change', + () { + final exampleState = ExampleState(ExampleRepository()); + final state = ExampleDropdownState(exampleState, []); + state.addListener(() { + expect(state.selectedFilterType, ExampleType.example); + }); + state.setSelectedFilterType(ExampleType.example); + }); + + test( + 'ExampleDropdown state should notify all listeners about categories change', + () { + final exampleState = ExampleState(ExampleRepository()); + final state = ExampleDropdownState(exampleState, []); + state.addListener(() { + expect(state.categories, []); + }); + state.setCategories([]); + }); + + test( + 'ExampleDropdown state sortExamplesByType should:' + '- update categories,' + '- notify all listeners,' + 'but should NOT:' + '- affect Example state categories', () { + final exampleState = ExampleState(ExampleRepository()); + final state = ExampleDropdownState(exampleState, exampleState.categories!); + state.addListener(() { + expect(state.categories, categoriesSortedByTypeMock); + expect(exampleState.categories, exampleState.categories); + }); + state.sortExamplesByType(ExampleType.kata); + }); + + test( + 'ExampleDropdown state sortExamplesByName should:' + '- update categories and notify all listeners,' + 'but should NOT:' + '- wait for full name of example,' + '- be sensitive for register,' + '- affect Example state categories', () { + final exampleState = ExampleState(ExampleRepository()); + final state = ExampleDropdownState(exampleState, exampleState.categories!); + state.addListener(() { + expect(state.categories, categoriesSortedByNameMock); + expect(exampleState.categories, exampleState.categories); + }); + state.sortExamplesByName('eLLoWoRl'); + }); +} diff --git a/playground/frontend/test/pages/playground/states/mocks/categories_mock.dart b/playground/frontend/test/pages/playground/states/mocks/categories_mock.dart new file mode 100644 index 000000000000..06c5989492bc --- /dev/null +++ b/playground/frontend/test/pages/playground/states/mocks/categories_mock.dart @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:playground/modules/examples/models/category_model.dart'; +import 'package:playground/modules/examples/models/example_model.dart'; +import 'package:playground/modules/sdk/models/sdk.dart'; + +const javaHelloWorld = '''class HelloWorld { + public static void main(String[] args) { + System.out.println("Hello World!"); + } +}'''; + +const pythonHelloWorld = 'print(‘Hello World’)'; + +const goHelloWorld = '''package main + +import "fmt" + +// this is a comment + +func main() { + fmt.Println("Hello World") +}'''; + +const scioHelloWorld = ''' +object Hello { + def main(args: Array[String]) = { + println("Hello, world") + } +}'''; + +const List categoriesSortedByTypeMock = [ + CategoryModel('Side Inputs', [ + ExampleModel( + { + SDK.java: 'JAVA Source code 1', + SDK.go: 'GO Source code 1', + SDK.python: 'PYTHON Source code 1', + SDK.scio: 'SCIO Source code 1', + }, + 'KATA Source code 1', + ExampleType.kata, + ), + ]), + CategoryModel('I/O', [ + ExampleModel( + { + SDK.java: 'JAVA Source code 4', + SDK.go: 'GO Source code 4', + SDK.python: 'PYTHON Source code 4', + SDK.scio: 'SCIO Source code 4', + }, + 'KATA Source code 4', + ExampleType.kata, + ), + ]), +]; + +const List categoriesSortedByNameMock = [ + CategoryModel('Side Inputs', [ + ExampleModel( + { + SDK.java: javaHelloWorld, + SDK.go: goHelloWorld, + SDK.python: pythonHelloWorld, + SDK.scio: scioHelloWorld, + }, + 'HelloWorld', + ExampleType.example, + ), + ]) +]; From 3c577d9b686e88a4df9a1712c63ed75f73a8de7f Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Tue, 19 Oct 2021 13:47:28 +0300 Subject: [PATCH 06/15] [BEAM-12967] Added generated files --- .../frontend/lib/generated/playground.pb.dart | 433 ++++++++++++++++++ .../lib/generated/playground.pbenum.dart | 51 +++ .../lib/generated/playground.pbgrpc.dart | 141 ++++++ .../lib/generated/playground.pbjson.dart | 120 +++++ playground/frontend/pubspec.lock | 14 +- .../code_repository_test.mocks.dart | 69 +++ .../playground/states/mocks/example_mock.dart | 9 +- 7 files changed, 826 insertions(+), 11 deletions(-) create mode 100644 playground/frontend/lib/generated/playground.pb.dart create mode 100644 playground/frontend/lib/generated/playground.pbenum.dart create mode 100644 playground/frontend/lib/generated/playground.pbgrpc.dart create mode 100644 playground/frontend/lib/generated/playground.pbjson.dart create mode 100644 playground/frontend/test/modules/editor/repository/code_repository/code_repository_test.mocks.dart diff --git a/playground/frontend/lib/generated/playground.pb.dart b/playground/frontend/lib/generated/playground.pb.dart new file mode 100644 index 000000000000..95b97b62799a --- /dev/null +++ b/playground/frontend/lib/generated/playground.pb.dart @@ -0,0 +1,433 @@ +/// +// Generated code. Do not modify. +// source: playground.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields + +import 'dart:core' as $core; + +import 'package:protobuf/protobuf.dart' as $pb; + +import 'playground.pbenum.dart'; + +export 'playground.pbenum.dart'; + +class RunCodeRequest extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'RunCodeRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) + ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code') + ..e(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'sdk', $pb.PbFieldType.OE, defaultOrMaker: Sdk.SDK_UNSPECIFIED, valueOf: Sdk.valueOf, enumValues: Sdk.values) + ..hasRequiredFields = false + ; + + RunCodeRequest._() : super(); + factory RunCodeRequest({ + $core.String? code, + Sdk? sdk, + }) { + final _result = create(); + if (code != null) { + _result.code = code; + } + if (sdk != null) { + _result.sdk = sdk; + } + return _result; + } + factory RunCodeRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory RunCodeRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + RunCodeRequest clone() => RunCodeRequest()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + RunCodeRequest copyWith(void Function(RunCodeRequest) updates) => super.copyWith((message) => updates(message as RunCodeRequest)) as RunCodeRequest; // ignore: deprecated_member_use + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static RunCodeRequest create() => RunCodeRequest._(); + RunCodeRequest createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static RunCodeRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static RunCodeRequest? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get code => $_getSZ(0); + @$pb.TagNumber(1) + set code($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) + $core.bool hasCode() => $_has(0); + @$pb.TagNumber(1) + void clearCode() => clearField(1); + + @$pb.TagNumber(2) + Sdk get sdk => $_getN(1); + @$pb.TagNumber(2) + set sdk(Sdk v) { setField(2, v); } + @$pb.TagNumber(2) + $core.bool hasSdk() => $_has(1); + @$pb.TagNumber(2) + void clearSdk() => clearField(2); +} + +class RunCodeResponse extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'RunCodeResponse', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) + ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pipelineUuid') + ..hasRequiredFields = false + ; + + RunCodeResponse._() : super(); + factory RunCodeResponse({ + $core.String? pipelineUuid, + }) { + final _result = create(); + if (pipelineUuid != null) { + _result.pipelineUuid = pipelineUuid; + } + return _result; + } + factory RunCodeResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory RunCodeResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + RunCodeResponse clone() => RunCodeResponse()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + RunCodeResponse copyWith(void Function(RunCodeResponse) updates) => super.copyWith((message) => updates(message as RunCodeResponse)) as RunCodeResponse; // ignore: deprecated_member_use + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static RunCodeResponse create() => RunCodeResponse._(); + RunCodeResponse createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static RunCodeResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static RunCodeResponse? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get pipelineUuid => $_getSZ(0); + @$pb.TagNumber(1) + set pipelineUuid($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) + $core.bool hasPipelineUuid() => $_has(0); + @$pb.TagNumber(1) + void clearPipelineUuid() => clearField(1); +} + +class CheckStatusRequest extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CheckStatusRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) + ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pipelineUuid') + ..hasRequiredFields = false + ; + + CheckStatusRequest._() : super(); + factory CheckStatusRequest({ + $core.String? pipelineUuid, + }) { + final _result = create(); + if (pipelineUuid != null) { + _result.pipelineUuid = pipelineUuid; + } + return _result; + } + factory CheckStatusRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory CheckStatusRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + CheckStatusRequest clone() => CheckStatusRequest()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + CheckStatusRequest copyWith(void Function(CheckStatusRequest) updates) => super.copyWith((message) => updates(message as CheckStatusRequest)) as CheckStatusRequest; // ignore: deprecated_member_use + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static CheckStatusRequest create() => CheckStatusRequest._(); + CheckStatusRequest createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static CheckStatusRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static CheckStatusRequest? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get pipelineUuid => $_getSZ(0); + @$pb.TagNumber(1) + set pipelineUuid($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) + $core.bool hasPipelineUuid() => $_has(0); + @$pb.TagNumber(1) + void clearPipelineUuid() => clearField(1); +} + +class CheckStatusResponse extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CheckStatusResponse', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) + ..e(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'status', $pb.PbFieldType.OE, defaultOrMaker: Status.STATUS_UNSPECIFIED, valueOf: Status.valueOf, enumValues: Status.values) + ..hasRequiredFields = false + ; + + CheckStatusResponse._() : super(); + factory CheckStatusResponse({ + Status? status, + }) { + final _result = create(); + if (status != null) { + _result.status = status; + } + return _result; + } + factory CheckStatusResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory CheckStatusResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + CheckStatusResponse clone() => CheckStatusResponse()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + CheckStatusResponse copyWith(void Function(CheckStatusResponse) updates) => super.copyWith((message) => updates(message as CheckStatusResponse)) as CheckStatusResponse; // ignore: deprecated_member_use + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static CheckStatusResponse create() => CheckStatusResponse._(); + CheckStatusResponse createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static CheckStatusResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static CheckStatusResponse? _defaultInstance; + + @$pb.TagNumber(1) + Status get status => $_getN(0); + @$pb.TagNumber(1) + set status(Status v) { setField(1, v); } + @$pb.TagNumber(1) + $core.bool hasStatus() => $_has(0); + @$pb.TagNumber(1) + void clearStatus() => clearField(1); +} + +class GetCompileOutputRequest extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetCompileOutputRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) + ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pipelineUuid') + ..hasRequiredFields = false + ; + + GetCompileOutputRequest._() : super(); + factory GetCompileOutputRequest({ + $core.String? pipelineUuid, + }) { + final _result = create(); + if (pipelineUuid != null) { + _result.pipelineUuid = pipelineUuid; + } + return _result; + } + factory GetCompileOutputRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory GetCompileOutputRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + GetCompileOutputRequest clone() => GetCompileOutputRequest()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + GetCompileOutputRequest copyWith(void Function(GetCompileOutputRequest) updates) => super.copyWith((message) => updates(message as GetCompileOutputRequest)) as GetCompileOutputRequest; // ignore: deprecated_member_use + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static GetCompileOutputRequest create() => GetCompileOutputRequest._(); + GetCompileOutputRequest createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static GetCompileOutputRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static GetCompileOutputRequest? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get pipelineUuid => $_getSZ(0); + @$pb.TagNumber(1) + set pipelineUuid($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) + $core.bool hasPipelineUuid() => $_has(0); + @$pb.TagNumber(1) + void clearPipelineUuid() => clearField(1); +} + +class GetCompileOutputResponse extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetCompileOutputResponse', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) + ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'output') + ..e(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compilationStatus', $pb.PbFieldType.OE, defaultOrMaker: Status.STATUS_UNSPECIFIED, valueOf: Status.valueOf, enumValues: Status.values) + ..hasRequiredFields = false + ; + + GetCompileOutputResponse._() : super(); + factory GetCompileOutputResponse({ + $core.String? output, + Status? compilationStatus, + }) { + final _result = create(); + if (output != null) { + _result.output = output; + } + if (compilationStatus != null) { + _result.compilationStatus = compilationStatus; + } + return _result; + } + factory GetCompileOutputResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory GetCompileOutputResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + GetCompileOutputResponse clone() => GetCompileOutputResponse()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + GetCompileOutputResponse copyWith(void Function(GetCompileOutputResponse) updates) => super.copyWith((message) => updates(message as GetCompileOutputResponse)) as GetCompileOutputResponse; // ignore: deprecated_member_use + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static GetCompileOutputResponse create() => GetCompileOutputResponse._(); + GetCompileOutputResponse createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static GetCompileOutputResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static GetCompileOutputResponse? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get output => $_getSZ(0); + @$pb.TagNumber(1) + set output($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) + $core.bool hasOutput() => $_has(0); + @$pb.TagNumber(1) + void clearOutput() => clearField(1); + + @$pb.TagNumber(2) + Status get compilationStatus => $_getN(1); + @$pb.TagNumber(2) + set compilationStatus(Status v) { setField(2, v); } + @$pb.TagNumber(2) + $core.bool hasCompilationStatus() => $_has(1); + @$pb.TagNumber(2) + void clearCompilationStatus() => clearField(2); +} + +class GetRunOutputRequest extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetRunOutputRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) + ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pipelineUuid') + ..hasRequiredFields = false + ; + + GetRunOutputRequest._() : super(); + factory GetRunOutputRequest({ + $core.String? pipelineUuid, + }) { + final _result = create(); + if (pipelineUuid != null) { + _result.pipelineUuid = pipelineUuid; + } + return _result; + } + factory GetRunOutputRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory GetRunOutputRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + GetRunOutputRequest clone() => GetRunOutputRequest()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + GetRunOutputRequest copyWith(void Function(GetRunOutputRequest) updates) => super.copyWith((message) => updates(message as GetRunOutputRequest)) as GetRunOutputRequest; // ignore: deprecated_member_use + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static GetRunOutputRequest create() => GetRunOutputRequest._(); + GetRunOutputRequest createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static GetRunOutputRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static GetRunOutputRequest? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get pipelineUuid => $_getSZ(0); + @$pb.TagNumber(1) + set pipelineUuid($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) + $core.bool hasPipelineUuid() => $_has(0); + @$pb.TagNumber(1) + void clearPipelineUuid() => clearField(1); +} + +class GetRunOutputResponse extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetRunOutputResponse', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) + ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'output') + ..e(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compilationStatus', $pb.PbFieldType.OE, defaultOrMaker: Status.STATUS_UNSPECIFIED, valueOf: Status.valueOf, enumValues: Status.values) + ..hasRequiredFields = false + ; + + GetRunOutputResponse._() : super(); + factory GetRunOutputResponse({ + $core.String? output, + Status? compilationStatus, + }) { + final _result = create(); + if (output != null) { + _result.output = output; + } + if (compilationStatus != null) { + _result.compilationStatus = compilationStatus; + } + return _result; + } + factory GetRunOutputResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory GetRunOutputResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + GetRunOutputResponse clone() => GetRunOutputResponse()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + GetRunOutputResponse copyWith(void Function(GetRunOutputResponse) updates) => super.copyWith((message) => updates(message as GetRunOutputResponse)) as GetRunOutputResponse; // ignore: deprecated_member_use + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static GetRunOutputResponse create() => GetRunOutputResponse._(); + GetRunOutputResponse createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static GetRunOutputResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static GetRunOutputResponse? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get output => $_getSZ(0); + @$pb.TagNumber(1) + set output($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) + $core.bool hasOutput() => $_has(0); + @$pb.TagNumber(1) + void clearOutput() => clearField(1); + + @$pb.TagNumber(2) + Status get compilationStatus => $_getN(1); + @$pb.TagNumber(2) + set compilationStatus(Status v) { setField(2, v); } + @$pb.TagNumber(2) + $core.bool hasCompilationStatus() => $_has(1); + @$pb.TagNumber(2) + void clearCompilationStatus() => clearField(2); +} + diff --git a/playground/frontend/lib/generated/playground.pbenum.dart b/playground/frontend/lib/generated/playground.pbenum.dart new file mode 100644 index 000000000000..2dffcf83e576 --- /dev/null +++ b/playground/frontend/lib/generated/playground.pbenum.dart @@ -0,0 +1,51 @@ +/// +// Generated code. Do not modify. +// source: playground.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields + +// ignore_for_file: UNDEFINED_SHOWN_NAME +import 'dart:core' as $core; +import 'package:protobuf/protobuf.dart' as $pb; + +class Sdk extends $pb.ProtobufEnum { + static const Sdk SDK_UNSPECIFIED = Sdk._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SDK_UNSPECIFIED'); + static const Sdk SDK_JAVA = Sdk._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SDK_JAVA'); + static const Sdk SDK_GO = Sdk._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SDK_GO'); + static const Sdk SDK_PYTHON = Sdk._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SDK_PYTHON'); + static const Sdk SDK_SCIO = Sdk._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SDK_SCIO'); + + static const $core.List values = [ + SDK_UNSPECIFIED, + SDK_JAVA, + SDK_GO, + SDK_PYTHON, + SDK_SCIO, + ]; + + static final $core.Map<$core.int, Sdk> _byValue = $pb.ProtobufEnum.initByValue(values); + static Sdk? valueOf($core.int value) => _byValue[value]; + + const Sdk._($core.int v, $core.String n) : super(v, n); +} + +class Status extends $pb.ProtobufEnum { + static const Status STATUS_UNSPECIFIED = Status._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'STATUS_UNSPECIFIED'); + static const Status STATUS_EXECUTING = Status._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'STATUS_EXECUTING'); + static const Status STATUS_FINISHED = Status._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'STATUS_FINISHED'); + static const Status STATUS_ERROR = Status._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'STATUS_ERROR'); + + static const $core.List values = [ + STATUS_UNSPECIFIED, + STATUS_EXECUTING, + STATUS_FINISHED, + STATUS_ERROR, + ]; + + static final $core.Map<$core.int, Status> _byValue = $pb.ProtobufEnum.initByValue(values); + static Status? valueOf($core.int value) => _byValue[value]; + + const Status._($core.int v, $core.String n) : super(v, n); +} + diff --git a/playground/frontend/lib/generated/playground.pbgrpc.dart b/playground/frontend/lib/generated/playground.pbgrpc.dart new file mode 100644 index 000000000000..230e9c9f5720 --- /dev/null +++ b/playground/frontend/lib/generated/playground.pbgrpc.dart @@ -0,0 +1,141 @@ +/// +// Generated code. Do not modify. +// source: playground.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields + +import 'dart:async' as $async; + +import 'dart:core' as $core; + +import 'package:grpc/service_api.dart' as $grpc; +import 'playground.pb.dart' as $0; +export 'playground.pb.dart'; + +class PlaygroundServiceClient extends $grpc.Client { + static final _$runCode = + $grpc.ClientMethod<$0.RunCodeRequest, $0.RunCodeResponse>( + '/playground.v1.PlaygroundService/RunCode', + ($0.RunCodeRequest value) => value.writeToBuffer(), + ($core.List<$core.int> value) => + $0.RunCodeResponse.fromBuffer(value)); + static final _$checkStatus = + $grpc.ClientMethod<$0.CheckStatusRequest, $0.CheckStatusResponse>( + '/playground.v1.PlaygroundService/CheckStatus', + ($0.CheckStatusRequest value) => value.writeToBuffer(), + ($core.List<$core.int> value) => + $0.CheckStatusResponse.fromBuffer(value)); + static final _$getRunOutput = + $grpc.ClientMethod<$0.GetRunOutputRequest, $0.GetRunOutputResponse>( + '/playground.v1.PlaygroundService/GetRunOutput', + ($0.GetRunOutputRequest value) => value.writeToBuffer(), + ($core.List<$core.int> value) => + $0.GetRunOutputResponse.fromBuffer(value)); + static final _$getCompileOutput = $grpc.ClientMethod< + $0.GetCompileOutputRequest, $0.GetCompileOutputResponse>( + '/playground.v1.PlaygroundService/GetCompileOutput', + ($0.GetCompileOutputRequest value) => value.writeToBuffer(), + ($core.List<$core.int> value) => + $0.GetCompileOutputResponse.fromBuffer(value)); + + PlaygroundServiceClient($grpc.ClientChannel channel, + {$grpc.CallOptions? options, + $core.Iterable<$grpc.ClientInterceptor>? interceptors}) + : super(channel, options: options, interceptors: interceptors); + + $grpc.ResponseFuture<$0.RunCodeResponse> runCode($0.RunCodeRequest request, + {$grpc.CallOptions? options}) { + return $createUnaryCall(_$runCode, request, options: options); + } + + $grpc.ResponseFuture<$0.CheckStatusResponse> checkStatus( + $0.CheckStatusRequest request, + {$grpc.CallOptions? options}) { + return $createUnaryCall(_$checkStatus, request, options: options); + } + + $grpc.ResponseFuture<$0.GetRunOutputResponse> getRunOutput( + $0.GetRunOutputRequest request, + {$grpc.CallOptions? options}) { + return $createUnaryCall(_$getRunOutput, request, options: options); + } + + $grpc.ResponseFuture<$0.GetCompileOutputResponse> getCompileOutput( + $0.GetCompileOutputRequest request, + {$grpc.CallOptions? options}) { + return $createUnaryCall(_$getCompileOutput, request, options: options); + } +} + +abstract class PlaygroundServiceBase extends $grpc.Service { + $core.String get $name => 'playground.v1.PlaygroundService'; + + PlaygroundServiceBase() { + $addMethod($grpc.ServiceMethod<$0.RunCodeRequest, $0.RunCodeResponse>( + 'RunCode', + runCode_Pre, + false, + false, + ($core.List<$core.int> value) => $0.RunCodeRequest.fromBuffer(value), + ($0.RunCodeResponse value) => value.writeToBuffer())); + $addMethod( + $grpc.ServiceMethod<$0.CheckStatusRequest, $0.CheckStatusResponse>( + 'CheckStatus', + checkStatus_Pre, + false, + false, + ($core.List<$core.int> value) => + $0.CheckStatusRequest.fromBuffer(value), + ($0.CheckStatusResponse value) => value.writeToBuffer())); + $addMethod( + $grpc.ServiceMethod<$0.GetRunOutputRequest, $0.GetRunOutputResponse>( + 'GetRunOutput', + getRunOutput_Pre, + false, + false, + ($core.List<$core.int> value) => + $0.GetRunOutputRequest.fromBuffer(value), + ($0.GetRunOutputResponse value) => value.writeToBuffer())); + $addMethod($grpc.ServiceMethod<$0.GetCompileOutputRequest, + $0.GetCompileOutputResponse>( + 'GetCompileOutput', + getCompileOutput_Pre, + false, + false, + ($core.List<$core.int> value) => + $0.GetCompileOutputRequest.fromBuffer(value), + ($0.GetCompileOutputResponse value) => value.writeToBuffer())); + } + + $async.Future<$0.RunCodeResponse> runCode_Pre( + $grpc.ServiceCall call, $async.Future<$0.RunCodeRequest> request) async { + return runCode(call, await request); + } + + $async.Future<$0.CheckStatusResponse> checkStatus_Pre($grpc.ServiceCall call, + $async.Future<$0.CheckStatusRequest> request) async { + return checkStatus(call, await request); + } + + $async.Future<$0.GetRunOutputResponse> getRunOutput_Pre( + $grpc.ServiceCall call, + $async.Future<$0.GetRunOutputRequest> request) async { + return getRunOutput(call, await request); + } + + $async.Future<$0.GetCompileOutputResponse> getCompileOutput_Pre( + $grpc.ServiceCall call, + $async.Future<$0.GetCompileOutputRequest> request) async { + return getCompileOutput(call, await request); + } + + $async.Future<$0.RunCodeResponse> runCode( + $grpc.ServiceCall call, $0.RunCodeRequest request); + $async.Future<$0.CheckStatusResponse> checkStatus( + $grpc.ServiceCall call, $0.CheckStatusRequest request); + $async.Future<$0.GetRunOutputResponse> getRunOutput( + $grpc.ServiceCall call, $0.GetRunOutputRequest request); + $async.Future<$0.GetCompileOutputResponse> getCompileOutput( + $grpc.ServiceCall call, $0.GetCompileOutputRequest request); +} diff --git a/playground/frontend/lib/generated/playground.pbjson.dart b/playground/frontend/lib/generated/playground.pbjson.dart new file mode 100644 index 000000000000..aea7b4d17e70 --- /dev/null +++ b/playground/frontend/lib/generated/playground.pbjson.dart @@ -0,0 +1,120 @@ +/// +// Generated code. Do not modify. +// source: playground.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package + +import 'dart:core' as $core; +import 'dart:convert' as $convert; +import 'dart:typed_data' as $typed_data; +@$core.Deprecated('Use sdkDescriptor instead') +const Sdk$json = const { + '1': 'Sdk', + '2': const [ + const {'1': 'SDK_UNSPECIFIED', '2': 0}, + const {'1': 'SDK_JAVA', '2': 1}, + const {'1': 'SDK_GO', '2': 2}, + const {'1': 'SDK_PYTHON', '2': 3}, + const {'1': 'SDK_SCIO', '2': 4}, + ], +}; + +/// Descriptor for `Sdk`. Decode as a `google.protobuf.EnumDescriptorProto`. +final $typed_data.Uint8List sdkDescriptor = $convert.base64Decode('CgNTZGsSEwoPU0RLX1VOU1BFQ0lGSUVEEAASDAoIU0RLX0pBVkEQARIKCgZTREtfR08QAhIOCgpTREtfUFlUSE9OEAMSDAoIU0RLX1NDSU8QBA=='); +@$core.Deprecated('Use statusDescriptor instead') +const Status$json = const { + '1': 'Status', + '2': const [ + const {'1': 'STATUS_UNSPECIFIED', '2': 0}, + const {'1': 'STATUS_EXECUTING', '2': 1}, + const {'1': 'STATUS_FINISHED', '2': 2}, + const {'1': 'STATUS_ERROR', '2': 3}, + ], +}; + +/// Descriptor for `Status`. Decode as a `google.protobuf.EnumDescriptorProto`. +final $typed_data.Uint8List statusDescriptor = $convert.base64Decode('CgZTdGF0dXMSFgoSU1RBVFVTX1VOU1BFQ0lGSUVEEAASFAoQU1RBVFVTX0VYRUNVVElORxABEhMKD1NUQVRVU19GSU5JU0hFRBACEhAKDFNUQVRVU19FUlJPUhAD'); +@$core.Deprecated('Use runCodeRequestDescriptor instead') +const RunCodeRequest$json = const { + '1': 'RunCodeRequest', + '2': const [ + const {'1': 'code', '3': 1, '4': 1, '5': 9, '10': 'code'}, + const {'1': 'sdk', '3': 2, '4': 1, '5': 14, '6': '.playground.v1.Sdk', '10': 'sdk'}, + ], +}; + +/// Descriptor for `RunCodeRequest`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List runCodeRequestDescriptor = $convert.base64Decode('Cg5SdW5Db2RlUmVxdWVzdBISCgRjb2RlGAEgASgJUgRjb2RlEiQKA3NkaxgCIAEoDjISLnBsYXlncm91bmQudjEuU2RrUgNzZGs='); +@$core.Deprecated('Use runCodeResponseDescriptor instead') +const RunCodeResponse$json = const { + '1': 'RunCodeResponse', + '2': const [ + const {'1': 'pipeline_uuid', '3': 1, '4': 1, '5': 9, '10': 'pipelineUuid'}, + ], +}; + +/// Descriptor for `RunCodeResponse`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List runCodeResponseDescriptor = $convert.base64Decode('Cg9SdW5Db2RlUmVzcG9uc2USIwoNcGlwZWxpbmVfdXVpZBgBIAEoCVIMcGlwZWxpbmVVdWlk'); +@$core.Deprecated('Use checkStatusRequestDescriptor instead') +const CheckStatusRequest$json = const { + '1': 'CheckStatusRequest', + '2': const [ + const {'1': 'pipeline_uuid', '3': 1, '4': 1, '5': 9, '10': 'pipelineUuid'}, + ], +}; + +/// Descriptor for `CheckStatusRequest`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List checkStatusRequestDescriptor = $convert.base64Decode('ChJDaGVja1N0YXR1c1JlcXVlc3QSIwoNcGlwZWxpbmVfdXVpZBgBIAEoCVIMcGlwZWxpbmVVdWlk'); +@$core.Deprecated('Use checkStatusResponseDescriptor instead') +const CheckStatusResponse$json = const { + '1': 'CheckStatusResponse', + '2': const [ + const {'1': 'status', '3': 1, '4': 1, '5': 14, '6': '.playground.v1.Status', '10': 'status'}, + ], +}; + +/// Descriptor for `CheckStatusResponse`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List checkStatusResponseDescriptor = $convert.base64Decode('ChNDaGVja1N0YXR1c1Jlc3BvbnNlEi0KBnN0YXR1cxgBIAEoDjIVLnBsYXlncm91bmQudjEuU3RhdHVzUgZzdGF0dXM='); +@$core.Deprecated('Use getCompileOutputRequestDescriptor instead') +const GetCompileOutputRequest$json = const { + '1': 'GetCompileOutputRequest', + '2': const [ + const {'1': 'pipeline_uuid', '3': 1, '4': 1, '5': 9, '10': 'pipelineUuid'}, + ], +}; + +/// Descriptor for `GetCompileOutputRequest`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List getCompileOutputRequestDescriptor = $convert.base64Decode('ChdHZXRDb21waWxlT3V0cHV0UmVxdWVzdBIjCg1waXBlbGluZV91dWlkGAEgASgJUgxwaXBlbGluZVV1aWQ='); +@$core.Deprecated('Use getCompileOutputResponseDescriptor instead') +const GetCompileOutputResponse$json = const { + '1': 'GetCompileOutputResponse', + '2': const [ + const {'1': 'output', '3': 1, '4': 1, '5': 9, '10': 'output'}, + const {'1': 'compilation_status', '3': 2, '4': 1, '5': 14, '6': '.playground.v1.Status', '10': 'compilationStatus'}, + ], +}; + +/// Descriptor for `GetCompileOutputResponse`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List getCompileOutputResponseDescriptor = $convert.base64Decode('ChhHZXRDb21waWxlT3V0cHV0UmVzcG9uc2USFgoGb3V0cHV0GAEgASgJUgZvdXRwdXQSRAoSY29tcGlsYXRpb25fc3RhdHVzGAIgASgOMhUucGxheWdyb3VuZC52MS5TdGF0dXNSEWNvbXBpbGF0aW9uU3RhdHVz'); +@$core.Deprecated('Use getRunOutputRequestDescriptor instead') +const GetRunOutputRequest$json = const { + '1': 'GetRunOutputRequest', + '2': const [ + const {'1': 'pipeline_uuid', '3': 1, '4': 1, '5': 9, '10': 'pipelineUuid'}, + ], +}; + +/// Descriptor for `GetRunOutputRequest`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List getRunOutputRequestDescriptor = $convert.base64Decode('ChNHZXRSdW5PdXRwdXRSZXF1ZXN0EiMKDXBpcGVsaW5lX3V1aWQYASABKAlSDHBpcGVsaW5lVXVpZA=='); +@$core.Deprecated('Use getRunOutputResponseDescriptor instead') +const GetRunOutputResponse$json = const { + '1': 'GetRunOutputResponse', + '2': const [ + const {'1': 'output', '3': 1, '4': 1, '5': 9, '10': 'output'}, + const {'1': 'compilation_status', '3': 2, '4': 1, '5': 14, '6': '.playground.v1.Status', '10': 'compilationStatus'}, + ], +}; + +/// Descriptor for `GetRunOutputResponse`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List getRunOutputResponseDescriptor = $convert.base64Decode('ChRHZXRSdW5PdXRwdXRSZXNwb25zZRIWCgZvdXRwdXQYASABKAlSBm91dHB1dBJEChJjb21waWxhdGlvbl9zdGF0dXMYAiABKA4yFS5wbGF5Z3JvdW5kLnYxLlN0YXR1c1IRY29tcGlsYXRpb25TdGF0dXM='); diff --git a/playground/frontend/pubspec.lock b/playground/frontend/pubspec.lock index d6783ff39e4a..4173b4ffe823 100644 --- a/playground/frontend/pubspec.lock +++ b/playground/frontend/pubspec.lock @@ -155,13 +155,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.15.0" - expansion_widget: - dependency: "direct main" - description: - name: expansion_widget - url: "https://pub.dartlang.org" - source: hosted - version: "0.0.2" convert: dependency: transitive description: @@ -183,6 +176,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.2.0" + expansion_widget: + dependency: "direct main" + description: + name: expansion_widget + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2" fake_async: dependency: transitive description: diff --git a/playground/frontend/test/modules/editor/repository/code_repository/code_repository_test.mocks.dart b/playground/frontend/test/modules/editor/repository/code_repository/code_repository_test.mocks.dart new file mode 100644 index 000000000000..dfc9db10dcf0 --- /dev/null +++ b/playground/frontend/test/modules/editor/repository/code_repository/code_repository_test.mocks.dart @@ -0,0 +1,69 @@ +// Mocks generated by Mockito 5.0.16 from annotations +// in playground/test/modules/editor/repository/code_repository/code_repository_test.dart. +// Do not manually edit this file. + +import 'dart:async' as _i6; + +import 'package:mockito/mockito.dart' as _i1; +import 'package:playground/modules/editor/repository/code_repository/code_client/check_status_response.dart' + as _i3; +import 'package:playground/modules/editor/repository/code_repository/code_client/code_client.dart' + as _i5; +import 'package:playground/modules/editor/repository/code_repository/code_client/output_response.dart' + as _i4; +import 'package:playground/modules/editor/repository/code_repository/code_client/run_code_response.dart' + as _i2; +import 'package:playground/modules/editor/repository/code_repository/run_code_request.dart' + as _i7; + +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types + +class _FakeRunCodeResponse_0 extends _i1.Fake implements _i2.RunCodeResponse {} + +class _FakeCheckStatusResponse_1 extends _i1.Fake + implements _i3.CheckStatusResponse {} + +class _FakeOutputResponse_2 extends _i1.Fake implements _i4.OutputResponse {} + +/// A class which mocks [CodeClient]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockCodeClient extends _i1.Mock implements _i5.CodeClient { + MockCodeClient() { + _i1.throwOnMissingStub(this); + } + + @override + _i6.Future<_i2.RunCodeResponse> runCode(_i7.RunCodeRequestWrapper? request) => + (super.noSuchMethod(Invocation.method(#runCode, [request]), + returnValue: + Future<_i2.RunCodeResponse>.value(_FakeRunCodeResponse_0())) + as _i6.Future<_i2.RunCodeResponse>); + @override + _i6.Future<_i3.CheckStatusResponse> checkStatus(String? pipelineUuid) => + (super.noSuchMethod(Invocation.method(#checkStatus, [pipelineUuid]), + returnValue: Future<_i3.CheckStatusResponse>.value( + _FakeCheckStatusResponse_1())) + as _i6.Future<_i3.CheckStatusResponse>); + @override + _i6.Future<_i4.OutputResponse> getCompileOutput(String? pipelineUuid) => + (super.noSuchMethod(Invocation.method(#getCompileOutput, [pipelineUuid]), + returnValue: + Future<_i4.OutputResponse>.value(_FakeOutputResponse_2())) + as _i6.Future<_i4.OutputResponse>); + @override + _i6.Future<_i4.OutputResponse> getRunOutput(String? pipelineUuid) => + (super.noSuchMethod(Invocation.method(#getRunOutput, [pipelineUuid]), + returnValue: + Future<_i4.OutputResponse>.value(_FakeOutputResponse_2())) + as _i6.Future<_i4.OutputResponse>); + @override + String toString() => super.toString(); +} diff --git a/playground/frontend/test/pages/playground/states/mocks/example_mock.dart b/playground/frontend/test/pages/playground/states/mocks/example_mock.dart index d08472a57891..8eb808574a48 100644 --- a/playground/frontend/test/pages/playground/states/mocks/example_mock.dart +++ b/playground/frontend/test/pages/playground/states/mocks/example_mock.dart @@ -19,11 +19,11 @@ import 'package:playground/modules/examples/models/example_model.dart'; import 'package:playground/modules/sdk/models/sdk.dart'; -const javaExample = "java example"; +const javaExample = 'java example'; -const pythonExample = "python example"; +const pythonExample = 'python example'; -const goExample = "go example"; +const goExample = 'go example'; const sdkMap = { SDK.java: javaExample, @@ -33,5 +33,6 @@ const sdkMap = { const ExampleModel exampleMock = ExampleModel( sdkMap, - "Example", + 'Example', + ExampleType.example, ); From f249c692a06a734556222f373f7de049bbeb04df Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Tue, 19 Oct 2021 14:04:16 +0300 Subject: [PATCH 07/15] [BEAM-12967]: Added license to generated files --- .../frontend/lib/generated/playground.pb.dart | 18 ++++++++++++++++++ .../lib/generated/playground.pbenum.dart | 18 ++++++++++++++++++ .../lib/generated/playground.pbgrpc.dart | 18 ++++++++++++++++++ .../lib/generated/playground.pbjson.dart | 18 ++++++++++++++++++ .../code_repository_test.mocks.dart | 18 ++++++++++++++++++ 5 files changed, 90 insertions(+) diff --git a/playground/frontend/lib/generated/playground.pb.dart b/playground/frontend/lib/generated/playground.pb.dart index 95b97b62799a..77cd913850a9 100644 --- a/playground/frontend/lib/generated/playground.pb.dart +++ b/playground/frontend/lib/generated/playground.pb.dart @@ -1,3 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// // Generated code. Do not modify. // source: playground.proto diff --git a/playground/frontend/lib/generated/playground.pbenum.dart b/playground/frontend/lib/generated/playground.pbenum.dart index 2dffcf83e576..fbbb256d65d0 100644 --- a/playground/frontend/lib/generated/playground.pbenum.dart +++ b/playground/frontend/lib/generated/playground.pbenum.dart @@ -1,3 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// // Generated code. Do not modify. // source: playground.proto diff --git a/playground/frontend/lib/generated/playground.pbgrpc.dart b/playground/frontend/lib/generated/playground.pbgrpc.dart index 230e9c9f5720..c18185bf4ac8 100644 --- a/playground/frontend/lib/generated/playground.pbgrpc.dart +++ b/playground/frontend/lib/generated/playground.pbgrpc.dart @@ -1,3 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// // Generated code. Do not modify. // source: playground.proto diff --git a/playground/frontend/lib/generated/playground.pbjson.dart b/playground/frontend/lib/generated/playground.pbjson.dart index aea7b4d17e70..4912ae2013d1 100644 --- a/playground/frontend/lib/generated/playground.pbjson.dart +++ b/playground/frontend/lib/generated/playground.pbjson.dart @@ -1,3 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /// // Generated code. Do not modify. // source: playground.proto diff --git a/playground/frontend/test/modules/editor/repository/code_repository/code_repository_test.mocks.dart b/playground/frontend/test/modules/editor/repository/code_repository/code_repository_test.mocks.dart index dfc9db10dcf0..947078788500 100644 --- a/playground/frontend/test/modules/editor/repository/code_repository/code_repository_test.mocks.dart +++ b/playground/frontend/test/modules/editor/repository/code_repository/code_repository_test.mocks.dart @@ -1,3 +1,21 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Mocks generated by Mockito 5.0.16 from annotations // in playground/test/modules/editor/repository/code_repository/code_repository_test.dart. // Do not manually edit this file. From 86ccec97e3e65ef3d269dbef66a96c65a266ba6d Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Tue, 19 Oct 2021 17:37:08 +0300 Subject: [PATCH 08/15] [BEAM-13064]: Fixed sorting functionality, updated tests & mocks --- .../components/filter/category_bubble.dart | 2 +- .../components/search_field/search_field.dart | 6 +- .../repositories/example_repository.dart | 2 +- .../states/example_dropdown_state.dart | 92 ++++++++++++------- .../playground/states/examples_state.dart | 2 +- .../states/example_dropdown_state_test.dart | 28 +++++- .../states/mocks/categories_mock.dart | 15 +++ 7 files changed, 104 insertions(+), 43 deletions(-) diff --git a/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart b/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart index 7d968fb7c814..79bb07fe7c37 100644 --- a/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart +++ b/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart @@ -39,7 +39,7 @@ class CategoryBubble extends StatelessWidget { onTap: () { if (type != dropdownState.selectedFilterType) { dropdownState.setSelectedFilterType(type); - dropdownState.sortExamplesByType(type); + dropdownState.sortCategories(); } }, child: Container( diff --git a/playground/frontend/lib/modules/examples/components/search_field/search_field.dart b/playground/frontend/lib/modules/examples/components/search_field/search_field.dart index 992011bbffd7..abeaefa99bb3 100644 --- a/playground/frontend/lib/modules/examples/components/search_field/search_field.dart +++ b/playground/frontend/lib/modules/examples/components/search_field/search_field.dart @@ -76,10 +76,12 @@ class SearchField extends StatelessWidget { cursorWidth: kCursorSize, textAlignVertical: TextAlignVertical.center, onFieldSubmitted: (String txt) { - state.sortExamplesByName(txt); + state.setFilterText(txt); + state.sortCategories(); }, onChanged: (String txt) { - state.sortExamplesByName(txt); + state.setFilterText(txt); + state.sortCategories(); }, maxLines: kMinLines, minLines: kMaxLines, diff --git a/playground/frontend/lib/modules/examples/repositories/example_repository.dart b/playground/frontend/lib/modules/examples/repositories/example_repository.dart index cff560528e3d..7fdc641d885d 100644 --- a/playground/frontend/lib/modules/examples/repositories/example_repository.dart +++ b/playground/frontend/lib/modules/examples/repositories/example_repository.dart @@ -46,7 +46,7 @@ object Hello { }'''; class ExampleRepository { - List getCategories() { + List? getCategories() { return const [ CategoryModel('Side Inputs', [ ExampleModel( diff --git a/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart b/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart index 22d79f41862d..e5dc55315f6a 100644 --- a/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart +++ b/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart @@ -25,66 +25,88 @@ import 'examples_state.dart'; class ExampleDropdownState with ChangeNotifier { final ExampleState _exampleState; ExampleType _selectedFilterType; + String _filterText; List categories; ExampleDropdownState( this._exampleState, this.categories, [ this._selectedFilterType = ExampleType.all, + this._filterText = '', ]); ExampleType get selectedFilterType => _selectedFilterType; - setSelectedFilterType(ExampleType type) async { + String get filterText => _filterText; + + setSelectedFilterType(ExampleType type) { _selectedFilterType = type; notifyListeners(); } + setFilterText(String text) { + _filterText = text; + notifyListeners(); + } + setCategories(List? categories) { this.categories = categories ?? []; notifyListeners(); } - sortExamplesByType(ExampleType type) { - if (type == ExampleType.all) { - setCategories(_exampleState.categories!); + sortCategories() { + List? sorted; + if (selectedFilterType == ExampleType.all && filterText == '') { + sorted = _exampleState.categories!; + } else if (selectedFilterType != ExampleType.all && filterText == '') { + sorted = sortExamplesByType( + _exampleState.categories!, + selectedFilterType, + ); + } else if (selectedFilterType == ExampleType.all && filterText != '') { + sorted = sortExamplesByName(_exampleState.categories!, filterText); } else { - List unsorted = [..._exampleState.categories!]; - List sorted = []; - for (CategoryModel category in unsorted) { - if (category.examples.any((element) => element.type == type)) { - CategoryModel sortedCategory = CategoryModel( - category.name, - category.examples.where((element) => element.type == type).toList(), - ); - sorted.add(sortedCategory); - } + sorted = sortExamplesByType( + _exampleState.categories!, + selectedFilterType, + ); + sorted = sortExamplesByName(sorted, filterText); + } + setCategories(sorted); + } + + List sortExamplesByType( + List unsorted, ExampleType type) { + List sorted = []; + for (CategoryModel category in unsorted) { + if (category.examples.any((element) => element.type == type)) { + CategoryModel sortedCategory = CategoryModel( + category.name, + category.examples.where((element) => element.type == type).toList(), + ); + sorted.add(sortedCategory); } - setCategories(sorted); } + return sorted; } - sortExamplesByName(String name) { - if (name.isEmpty) { - setCategories(_exampleState.categories!); - } else { - List unsorted = [..._exampleState.categories!]; - List sorted = []; - for (CategoryModel category in unsorted) { - if (category.examples.any( - (element) => element.name.toLowerCase().contains(name.toLowerCase()), - )) { - CategoryModel sortedCategory = CategoryModel( - category.name, - category.examples - .where((element) => - element.name.toLowerCase().contains(name.toLowerCase())) - .toList(), - ); - sorted.add(sortedCategory); - } + List sortExamplesByName( + List unsorted, String name) { + List sorted = []; + for (CategoryModel category in unsorted) { + if (category.examples.any( + (element) => element.name.toLowerCase().contains(name.toLowerCase()), + )) { + CategoryModel sortedCategory = CategoryModel( + category.name, + category.examples + .where((element) => + element.name.toLowerCase().contains(name.toLowerCase())) + .toList(), + ); + sorted.add(sortedCategory); } - setCategories(sorted); } + return sorted; } } diff --git a/playground/frontend/lib/pages/playground/states/examples_state.dart b/playground/frontend/lib/pages/playground/states/examples_state.dart index 396f37cd95bf..4e3641c1d3ab 100644 --- a/playground/frontend/lib/pages/playground/states/examples_state.dart +++ b/playground/frontend/lib/pages/playground/states/examples_state.dart @@ -30,7 +30,7 @@ class ExampleState with ChangeNotifier { } _loadCategories() { - categories = _exampleRepository.getCategories(); + categories = _exampleRepository.getCategories() ?? []; notifyListeners(); } diff --git a/playground/frontend/test/pages/playground/states/example_dropdown_state_test.dart b/playground/frontend/test/pages/playground/states/example_dropdown_state_test.dart index 4bbb56f71934..95db4e7915f7 100644 --- a/playground/frontend/test/pages/playground/states/example_dropdown_state_test.dart +++ b/playground/frontend/test/pages/playground/states/example_dropdown_state_test.dart @@ -47,6 +47,27 @@ void main() { state.setCategories([]); }); + test( + 'ExampleDropdown state sortCategories should:' + '- update categories and notify all listeners,' + 'but should NOT:' + '- wait for full name of example,' + '- be sensitive for register,' + '- affect Example state categories', () { + final exampleState = ExampleState(ExampleRepository()); + final state = ExampleDropdownState( + exampleState, + exampleState.categories!, + ExampleType.example, + 'hEl', + ); + state.addListener(() { + expect(state.categories, sortedCategories); + expect(exampleState.categories, exampleState.categories); + }); + state.sortCategories(); + }); + test( 'ExampleDropdown state sortExamplesByType should:' '- update categories,' @@ -59,12 +80,13 @@ void main() { expect(state.categories, categoriesSortedByTypeMock); expect(exampleState.categories, exampleState.categories); }); - state.sortExamplesByType(ExampleType.kata); + state.sortExamplesByType(exampleState.categories!, ExampleType.kata); }); test( 'ExampleDropdown state sortExamplesByName should:' - '- update categories and notify all listeners,' + '- update categories' + '- notify all listeners,' 'but should NOT:' '- wait for full name of example,' '- be sensitive for register,' @@ -75,6 +97,6 @@ void main() { expect(state.categories, categoriesSortedByNameMock); expect(exampleState.categories, exampleState.categories); }); - state.sortExamplesByName('eLLoWoRl'); + state.sortExamplesByName(exampleState.categories!, 'eLLoWoRl'); }); } diff --git a/playground/frontend/test/pages/playground/states/mocks/categories_mock.dart b/playground/frontend/test/pages/playground/states/mocks/categories_mock.dart index 06c5989492bc..038be22be476 100644 --- a/playground/frontend/test/pages/playground/states/mocks/categories_mock.dart +++ b/playground/frontend/test/pages/playground/states/mocks/categories_mock.dart @@ -45,6 +45,21 @@ object Hello { } }'''; +const List sortedCategories = [ + CategoryModel('Side Inputs', [ + ExampleModel( + { + SDK.java: javaHelloWorld, + SDK.go: goHelloWorld, + SDK.python: pythonHelloWorld, + SDK.scio: scioHelloWorld, + }, + 'HelloWorld', + ExampleType.example, + ), + ]) +]; + const List categoriesSortedByTypeMock = [ CategoryModel('Side Inputs', [ ExampleModel( From 2960e8efbecb7a7b94916cef59c0419d5cdb8353 Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Thu, 21 Oct 2021 14:09:22 +0300 Subject: [PATCH 09/15] [BEAM-13064]: Refactored code --- .../components/example_list/example_list.dart | 4 +- .../components/filter/category_bubble.dart | 61 +++++----- .../components/search_field/search_field.dart | 12 +- .../modules/examples/example_selector.dart | 4 +- .../states/example_dropdown_state.dart | 112 ----------------- .../states/example_selector_state.dart | 105 ++++++++++++++++ ....dart => example_selector_state_test.dart} | 30 ++--- .../states/mocks/categories_mock.dart | 113 +++++++++++++----- 8 files changed, 248 insertions(+), 193 deletions(-) delete mode 100644 playground/frontend/lib/pages/playground/states/example_dropdown_state.dart create mode 100644 playground/frontend/lib/pages/playground/states/example_selector_state.dart rename playground/frontend/test/pages/playground/states/{example_dropdown_state_test.dart => example_selector_state_test.dart} (75%) diff --git a/playground/frontend/lib/modules/examples/components/example_list/example_list.dart b/playground/frontend/lib/modules/examples/components/example_list/example_list.dart index c92211553ec5..72c517270745 100644 --- a/playground/frontend/lib/modules/examples/components/example_list/example_list.dart +++ b/playground/frontend/lib/modules/examples/components/example_list/example_list.dart @@ -18,7 +18,7 @@ import 'package:flutter/material.dart'; import 'package:playground/modules/examples/components/examples_components.dart'; -import 'package:playground/pages/playground/states/example_dropdown_state.dart'; +import 'package:playground/pages/playground/states/example_selector_state.dart'; import 'package:provider/provider.dart'; class ExampleList extends StatelessWidget { @@ -31,7 +31,7 @@ class ExampleList extends StatelessWidget { @override Widget build(BuildContext context) { - return Consumer( + return Consumer( builder: (context, state, child) => Expanded( child: Container( color: Theme.of(context).backgroundColor, diff --git a/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart b/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart index 79bb07fe7c37..14a89829f8a4 100644 --- a/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart +++ b/playground/frontend/lib/modules/examples/components/filter/category_bubble.dart @@ -20,7 +20,7 @@ import 'package:flutter/material.dart'; import 'package:playground/config/theme.dart'; import 'package:playground/constants/sizes.dart'; import 'package:playground/modules/examples/models/example_model.dart'; -import 'package:playground/pages/playground/states/example_dropdown_state.dart'; +import 'package:playground/pages/playground/states/example_selector_state.dart'; import 'package:provider/provider.dart'; class CategoryBubble extends StatelessWidget { @@ -34,37 +34,42 @@ class CategoryBubble extends StatelessWidget { cursor: SystemMouseCursors.click, child: Padding( padding: const EdgeInsets.only(right: kMdSpacing), - child: Consumer( - builder: (context, dropdownState, child) => GestureDetector( - onTap: () { - if (type != dropdownState.selectedFilterType) { - dropdownState.setSelectedFilterType(type); - dropdownState.sortCategories(); - } - }, - child: Container( - height: kContainerHeight, - padding: const EdgeInsets.symmetric(horizontal: kXlSpacing), - decoration: BoxDecoration( - color: type == dropdownState.selectedFilterType - ? ThemeColors.of(context).primary - : ThemeColors.of(context).lightGreyColor, - borderRadius: BorderRadius.circular(kXlBorderRadius), - ), - child: Center( - child: Text( - type.name, - style: TextStyle( - color: type == dropdownState.selectedFilterType - ? ThemeColors.of(context).primaryBackgroundTextColor - : ThemeColors.of(context).lightGreyBackgroundTextColor, + child: Consumer( + builder: (context, state, child) { + final isSelected = type == state.selectedFilterType; + + return GestureDetector( + onTap: () { + if (!isSelected) { + state.setSelectedFilterType(type); + state.sortCategories(); + } + }, + child: Container( + height: kContainerHeight, + padding: const EdgeInsets.symmetric(horizontal: kXlSpacing), + decoration: BoxDecoration( + color: isSelected + ? ThemeColors.of(context).primary + : ThemeColors.of(context).lightGreyColor, + borderRadius: BorderRadius.circular(kXlBorderRadius), + ), + child: Center( + child: Text( + type.name, + style: TextStyle( + color: isSelected + ? ThemeColors.of(context).primaryBackgroundTextColor + : ThemeColors.of(context) + .lightGreyBackgroundTextColor, + ), ), ), ), - ), - ), + ); + }, ), ), ); } -} \ No newline at end of file +} diff --git a/playground/frontend/lib/modules/examples/components/search_field/search_field.dart b/playground/frontend/lib/modules/examples/components/search_field/search_field.dart index abeaefa99bb3..1889b53db120 100644 --- a/playground/frontend/lib/modules/examples/components/search_field/search_field.dart +++ b/playground/frontend/lib/modules/examples/components/search_field/search_field.dart @@ -19,7 +19,7 @@ import 'package:flutter/material.dart'; import 'package:playground/config/theme.dart'; import 'package:playground/constants/sizes.dart'; -import 'package:playground/pages/playground/states/example_dropdown_state.dart'; +import 'package:playground/pages/playground/states/example_selector_state.dart'; import 'package:provider/provider.dart'; const double kContainerWidth = 376.0; @@ -39,7 +39,7 @@ class SearchField extends StatelessWidget { borderRadius: BorderRadius.circular(kMdBorderRadius), ); - return Consumer( + return Consumer( builder: (context, state, child) => Container( margin: const EdgeInsets.only( top: kLgSpacing, @@ -75,12 +75,12 @@ class SearchField extends StatelessWidget { cursorColor: ThemeColors.of(context).lightGreyColor, cursorWidth: kCursorSize, textAlignVertical: TextAlignVertical.center, - onFieldSubmitted: (String txt) { - state.setFilterText(txt); + onFieldSubmitted: (String filterText) { + state.setFilterText(filterText); state.sortCategories(); }, - onChanged: (String txt) { - state.setFilterText(txt); + onChanged: (String filterText) { + state.setFilterText(filterText); state.sortCategories(); }, maxLines: kMinLines, diff --git a/playground/frontend/lib/modules/examples/example_selector.dart b/playground/frontend/lib/modules/examples/example_selector.dart index 362241d56b65..a9de0b7b6b2a 100644 --- a/playground/frontend/lib/modules/examples/example_selector.dart +++ b/playground/frontend/lib/modules/examples/example_selector.dart @@ -22,7 +22,7 @@ import 'package:playground/constants/sizes.dart'; import 'package:playground/modules/examples/components/examples_components.dart'; import 'package:playground/modules/examples/models/category_model.dart'; import 'package:playground/modules/examples/models/selector_size_model.dart'; -import 'package:playground/pages/playground/states/example_dropdown_state.dart'; +import 'package:playground/pages/playground/states/example_selector_state.dart'; import 'package:playground/pages/playground/states/examples_state.dart'; import 'package:playground/pages/playground/states/playground_state.dart'; import 'package:provider/provider.dart'; @@ -139,7 +139,7 @@ class _ExampleSelectorState extends State ), ), ChangeNotifierProvider( - create: (context) => ExampleDropdownState( + create: (context) => ExampleSelectorState( state, state.categories!, ), diff --git a/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart b/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart deleted file mode 100644 index e5dc55315f6a..000000000000 --- a/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import 'package:flutter/material.dart'; -import 'package:playground/modules/examples/models/category_model.dart'; -import 'package:playground/modules/examples/models/example_model.dart'; - -import 'examples_state.dart'; - -class ExampleDropdownState with ChangeNotifier { - final ExampleState _exampleState; - ExampleType _selectedFilterType; - String _filterText; - List categories; - - ExampleDropdownState( - this._exampleState, - this.categories, [ - this._selectedFilterType = ExampleType.all, - this._filterText = '', - ]); - - ExampleType get selectedFilterType => _selectedFilterType; - - String get filterText => _filterText; - - setSelectedFilterType(ExampleType type) { - _selectedFilterType = type; - notifyListeners(); - } - - setFilterText(String text) { - _filterText = text; - notifyListeners(); - } - - setCategories(List? categories) { - this.categories = categories ?? []; - notifyListeners(); - } - - sortCategories() { - List? sorted; - if (selectedFilterType == ExampleType.all && filterText == '') { - sorted = _exampleState.categories!; - } else if (selectedFilterType != ExampleType.all && filterText == '') { - sorted = sortExamplesByType( - _exampleState.categories!, - selectedFilterType, - ); - } else if (selectedFilterType == ExampleType.all && filterText != '') { - sorted = sortExamplesByName(_exampleState.categories!, filterText); - } else { - sorted = sortExamplesByType( - _exampleState.categories!, - selectedFilterType, - ); - sorted = sortExamplesByName(sorted, filterText); - } - setCategories(sorted); - } - - List sortExamplesByType( - List unsorted, ExampleType type) { - List sorted = []; - for (CategoryModel category in unsorted) { - if (category.examples.any((element) => element.type == type)) { - CategoryModel sortedCategory = CategoryModel( - category.name, - category.examples.where((element) => element.type == type).toList(), - ); - sorted.add(sortedCategory); - } - } - return sorted; - } - - List sortExamplesByName( - List unsorted, String name) { - List sorted = []; - for (CategoryModel category in unsorted) { - if (category.examples.any( - (element) => element.name.toLowerCase().contains(name.toLowerCase()), - )) { - CategoryModel sortedCategory = CategoryModel( - category.name, - category.examples - .where((element) => - element.name.toLowerCase().contains(name.toLowerCase())) - .toList(), - ); - sorted.add(sortedCategory); - } - } - return sorted; - } -} diff --git a/playground/frontend/lib/pages/playground/states/example_selector_state.dart b/playground/frontend/lib/pages/playground/states/example_selector_state.dart new file mode 100644 index 000000000000..c4718e33215d --- /dev/null +++ b/playground/frontend/lib/pages/playground/states/example_selector_state.dart @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import 'package:flutter/material.dart'; +import 'package:playground/modules/examples/models/category_model.dart'; +import 'package:playground/modules/examples/models/example_model.dart'; + +import 'examples_state.dart'; + +class ExampleSelectorState with ChangeNotifier { + final ExampleState _exampleState; + ExampleType _selectedFilterType; + String _filterText; + List categories; + + ExampleSelectorState( + this._exampleState, + this.categories, [ + this._selectedFilterType = ExampleType.all, + this._filterText = '', + ]); + + ExampleType get selectedFilterType => _selectedFilterType; + + String get filterText => _filterText; + + setSelectedFilterType(ExampleType type) { + _selectedFilterType = type; + notifyListeners(); + } + + setFilterText(String text) { + _filterText = text; + notifyListeners(); + } + + setCategories(List? categories) { + this.categories = categories ?? []; + notifyListeners(); + } + + sortCategories() { + final categories = _exampleState.categories!; + final sortedCategories = categories + .map((category) => CategoryModel( + category.name, _sortCategoryExamples(category.examples))) + .where((category) => category.examples.isNotEmpty) + .toList(); + setCategories(sortedCategories); + } + + List _sortCategoryExamples(List examples) { + final isAllFilterType = selectedFilterType == ExampleType.all; + final isFilterTextEmpty = filterText.isEmpty; + if (isAllFilterType && isFilterTextEmpty) { + return examples; + } + if (!isAllFilterType && isFilterTextEmpty) { + return sortExamplesByType( + examples, + selectedFilterType, + ); + } + if (isAllFilterType && !isFilterTextEmpty) { + return sortExamplesByName(examples, filterText); + } + final sorted = sortExamplesByType( + examples, + selectedFilterType, + ); + return sortExamplesByName(sorted, filterText); + } + + List sortExamplesByType( + List examples, + ExampleType type, + ) { + return examples.where((element) => element.type == type).toList(); + } + + List sortExamplesByName( + List examples, + String name, + ) { + return examples + .where((example) => + example.name.toLowerCase().contains(name.toLowerCase())) + .toList(); + } +} diff --git a/playground/frontend/test/pages/playground/states/example_dropdown_state_test.dart b/playground/frontend/test/pages/playground/states/example_selector_state_test.dart similarity index 75% rename from playground/frontend/test/pages/playground/states/example_dropdown_state_test.dart rename to playground/frontend/test/pages/playground/states/example_selector_state_test.dart index 95db4e7915f7..ddedf50e1dc4 100644 --- a/playground/frontend/test/pages/playground/states/example_dropdown_state_test.dart +++ b/playground/frontend/test/pages/playground/states/example_selector_state_test.dart @@ -19,17 +19,17 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:playground/modules/examples/models/example_model.dart'; import 'package:playground/modules/examples/repositories/example_repository.dart'; -import 'package:playground/pages/playground/states/example_dropdown_state.dart'; +import 'package:playground/pages/playground/states/example_selector_state.dart'; import 'package:playground/pages/playground/states/examples_state.dart'; import 'mocks/categories_mock.dart'; void main() { test( - 'ExampleDropdown state should notify all listeners about filter type change', + 'ExampleSelector state should notify all listeners about filter type change', () { final exampleState = ExampleState(ExampleRepository()); - final state = ExampleDropdownState(exampleState, []); + final state = ExampleSelectorState(exampleState, []); state.addListener(() { expect(state.selectedFilterType, ExampleType.example); }); @@ -37,10 +37,10 @@ void main() { }); test( - 'ExampleDropdown state should notify all listeners about categories change', + 'ExampleSelector state should notify all listeners about categories change', () { final exampleState = ExampleState(ExampleRepository()); - final state = ExampleDropdownState(exampleState, []); + final state = ExampleSelectorState(exampleState, []); state.addListener(() { expect(state.categories, []); }); @@ -48,14 +48,14 @@ void main() { }); test( - 'ExampleDropdown state sortCategories should:' + 'ExampleSelector state sortCategories should:' '- update categories and notify all listeners,' 'but should NOT:' '- wait for full name of example,' '- be sensitive for register,' '- affect Example state categories', () { final exampleState = ExampleState(ExampleRepository()); - final state = ExampleDropdownState( + final state = ExampleSelectorState( exampleState, exampleState.categories!, ExampleType.example, @@ -69,22 +69,22 @@ void main() { }); test( - 'ExampleDropdown state sortExamplesByType should:' + 'ExampleSelector state sortExamplesByType should:' '- update categories,' '- notify all listeners,' 'but should NOT:' '- affect Example state categories', () { final exampleState = ExampleState(ExampleRepository()); - final state = ExampleDropdownState(exampleState, exampleState.categories!); + final state = ExampleSelectorState(exampleState, exampleState.categories!); state.addListener(() { - expect(state.categories, categoriesSortedByTypeMock); + expect(state.categories, examplesSortedByTypeMock); expect(exampleState.categories, exampleState.categories); }); - state.sortExamplesByType(exampleState.categories!, ExampleType.kata); + state.sortExamplesByType(unsortedExamples, ExampleType.kata); }); test( - 'ExampleDropdown state sortExamplesByName should:' + 'ExampleSelector state sortExamplesByName should:' '- update categories' '- notify all listeners,' 'but should NOT:' @@ -92,11 +92,11 @@ void main() { '- be sensitive for register,' '- affect Example state categories', () { final exampleState = ExampleState(ExampleRepository()); - final state = ExampleDropdownState(exampleState, exampleState.categories!); + final state = ExampleSelectorState(exampleState, exampleState.categories!); state.addListener(() { - expect(state.categories, categoriesSortedByNameMock); + expect(state.categories, examplesSortedByNameMock); expect(exampleState.categories, exampleState.categories); }); - state.sortExamplesByName(exampleState.categories!, 'eLLoWoRl'); + state.sortExamplesByName(unsortedExamples, 'eLLoWoRl'); }); } diff --git a/playground/frontend/test/pages/playground/states/mocks/categories_mock.dart b/playground/frontend/test/pages/playground/states/mocks/categories_mock.dart index 038be22be476..f3a5b3456cd6 100644 --- a/playground/frontend/test/pages/playground/states/mocks/categories_mock.dart +++ b/playground/frontend/test/pages/playground/states/mocks/categories_mock.dart @@ -60,35 +60,93 @@ const List sortedCategories = [ ]) ]; -const List categoriesSortedByTypeMock = [ - CategoryModel('Side Inputs', [ - ExampleModel( - { - SDK.java: 'JAVA Source code 1', - SDK.go: 'GO Source code 1', - SDK.python: 'PYTHON Source code 1', - SDK.scio: 'SCIO Source code 1', - }, - 'KATA Source code 1', - ExampleType.kata, - ), - ]), - CategoryModel('I/O', [ - ExampleModel( - { - SDK.java: 'JAVA Source code 4', - SDK.go: 'GO Source code 4', - SDK.python: 'PYTHON Source code 4', - SDK.scio: 'SCIO Source code 4', - }, - 'KATA Source code 4', - ExampleType.kata, - ), - ]), +const List unsortedExamples = [ + ExampleModel( + { + SDK.java: javaHelloWorld, + SDK.go: goHelloWorld, + SDK.python: pythonHelloWorld, + SDK.scio: scioHelloWorld, + }, + 'HelloWorld', + ExampleType.example, + ), + ExampleModel( + { + SDK.java: 'JAVA Source code 1', + SDK.go: 'GO Source code 1', + SDK.python: 'PYTHON Source code 1', + SDK.scio: 'SCIO Source code 1', + }, + 'KATA Source code 1', + ExampleType.kata, + ), + ExampleModel( + { + SDK.java: 'JAVA Source code 2', + SDK.go: 'GO Source code 2', + SDK.python: 'PYTHON Source code 2', + SDK.scio: 'SCIO Source code 2', + }, + 'UNIT TEST Source code 2', + ExampleType.test, + ), + ExampleModel( + { + SDK.java: 'JAVA Source code 3', + SDK.go: 'GO Source code 3', + SDK.python: 'PYTHON Source code 3', + SDK.scio: 'SCIO Source code 3', + }, + 'EXAMPLE Source code 3', + ExampleType.example, + ), + ExampleModel( + { + SDK.java: 'JAVA Source code 4', + SDK.go: 'GO Source code 4', + SDK.python: 'PYTHON Source code 4', + SDK.scio: 'SCIO Source code 4', + }, + 'KATA Source code 4', + ExampleType.kata, + ), + ExampleModel( + { + SDK.java: 'JAVA Source code 5', + SDK.go: 'GO Source code 5', + SDK.python: 'PYTHON Source code 5', + SDK.scio: 'SCIO Source code 5', + }, + 'UNIT TEST Source code 5', + ExampleType.test, + ), ]; -const List categoriesSortedByNameMock = [ - CategoryModel('Side Inputs', [ +const List examplesSortedByTypeMock = [ + ExampleModel( + { + SDK.java: 'JAVA Source code 1', + SDK.go: 'GO Source code 1', + SDK.python: 'PYTHON Source code 1', + SDK.scio: 'SCIO Source code 1', + }, + 'KATA Source code 1', + ExampleType.kata, + ), + ExampleModel( + { + SDK.java: 'JAVA Source code 4', + SDK.go: 'GO Source code 4', + SDK.python: 'PYTHON Source code 4', + SDK.scio: 'SCIO Source code 4', + }, + 'KATA Source code 4', + ExampleType.kata, + ), +]; + +const List examplesSortedByNameMock = [ ExampleModel( { SDK.java: javaHelloWorld, @@ -99,5 +157,4 @@ const List categoriesSortedByNameMock = [ 'HelloWorld', ExampleType.example, ), - ]) ]; From 2c0d3fb5410b1e476909d751dbb079e23f519f52 Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Fri, 22 Oct 2021 12:57:07 +0300 Subject: [PATCH 10/15] [BEAM-12967]: Deleted duplicate files --- .../frontend/lib/generated/playground.pb.dart | 451 ------------------ .../lib/generated/playground.pbenum.dart | 69 --- .../lib/generated/playground.pbgrpc.dart | 159 ------ .../lib/generated/playground.pbjson.dart | 138 ------ 4 files changed, 817 deletions(-) delete mode 100644 playground/frontend/lib/generated/playground.pb.dart delete mode 100644 playground/frontend/lib/generated/playground.pbenum.dart delete mode 100644 playground/frontend/lib/generated/playground.pbgrpc.dart delete mode 100644 playground/frontend/lib/generated/playground.pbjson.dart diff --git a/playground/frontend/lib/generated/playground.pb.dart b/playground/frontend/lib/generated/playground.pb.dart deleted file mode 100644 index 77cd913850a9..000000000000 --- a/playground/frontend/lib/generated/playground.pb.dart +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/// -// Generated code. Do not modify. -// source: playground.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields - -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; - -import 'playground.pbenum.dart'; - -export 'playground.pbenum.dart'; - -class RunCodeRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'RunCodeRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code') - ..e(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'sdk', $pb.PbFieldType.OE, defaultOrMaker: Sdk.SDK_UNSPECIFIED, valueOf: Sdk.valueOf, enumValues: Sdk.values) - ..hasRequiredFields = false - ; - - RunCodeRequest._() : super(); - factory RunCodeRequest({ - $core.String? code, - Sdk? sdk, - }) { - final _result = create(); - if (code != null) { - _result.code = code; - } - if (sdk != null) { - _result.sdk = sdk; - } - return _result; - } - factory RunCodeRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory RunCodeRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - RunCodeRequest clone() => RunCodeRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - RunCodeRequest copyWith(void Function(RunCodeRequest) updates) => super.copyWith((message) => updates(message as RunCodeRequest)) as RunCodeRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static RunCodeRequest create() => RunCodeRequest._(); - RunCodeRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static RunCodeRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static RunCodeRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get code => $_getSZ(0); - @$pb.TagNumber(1) - set code($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasCode() => $_has(0); - @$pb.TagNumber(1) - void clearCode() => clearField(1); - - @$pb.TagNumber(2) - Sdk get sdk => $_getN(1); - @$pb.TagNumber(2) - set sdk(Sdk v) { setField(2, v); } - @$pb.TagNumber(2) - $core.bool hasSdk() => $_has(1); - @$pb.TagNumber(2) - void clearSdk() => clearField(2); -} - -class RunCodeResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'RunCodeResponse', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pipelineUuid') - ..hasRequiredFields = false - ; - - RunCodeResponse._() : super(); - factory RunCodeResponse({ - $core.String? pipelineUuid, - }) { - final _result = create(); - if (pipelineUuid != null) { - _result.pipelineUuid = pipelineUuid; - } - return _result; - } - factory RunCodeResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory RunCodeResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - RunCodeResponse clone() => RunCodeResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - RunCodeResponse copyWith(void Function(RunCodeResponse) updates) => super.copyWith((message) => updates(message as RunCodeResponse)) as RunCodeResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static RunCodeResponse create() => RunCodeResponse._(); - RunCodeResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static RunCodeResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static RunCodeResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get pipelineUuid => $_getSZ(0); - @$pb.TagNumber(1) - set pipelineUuid($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasPipelineUuid() => $_has(0); - @$pb.TagNumber(1) - void clearPipelineUuid() => clearField(1); -} - -class CheckStatusRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CheckStatusRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pipelineUuid') - ..hasRequiredFields = false - ; - - CheckStatusRequest._() : super(); - factory CheckStatusRequest({ - $core.String? pipelineUuid, - }) { - final _result = create(); - if (pipelineUuid != null) { - _result.pipelineUuid = pipelineUuid; - } - return _result; - } - factory CheckStatusRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CheckStatusRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CheckStatusRequest clone() => CheckStatusRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CheckStatusRequest copyWith(void Function(CheckStatusRequest) updates) => super.copyWith((message) => updates(message as CheckStatusRequest)) as CheckStatusRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CheckStatusRequest create() => CheckStatusRequest._(); - CheckStatusRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CheckStatusRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CheckStatusRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get pipelineUuid => $_getSZ(0); - @$pb.TagNumber(1) - set pipelineUuid($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasPipelineUuid() => $_has(0); - @$pb.TagNumber(1) - void clearPipelineUuid() => clearField(1); -} - -class CheckStatusResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'CheckStatusResponse', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) - ..e(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'status', $pb.PbFieldType.OE, defaultOrMaker: Status.STATUS_UNSPECIFIED, valueOf: Status.valueOf, enumValues: Status.values) - ..hasRequiredFields = false - ; - - CheckStatusResponse._() : super(); - factory CheckStatusResponse({ - Status? status, - }) { - final _result = create(); - if (status != null) { - _result.status = status; - } - return _result; - } - factory CheckStatusResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory CheckStatusResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - CheckStatusResponse clone() => CheckStatusResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - CheckStatusResponse copyWith(void Function(CheckStatusResponse) updates) => super.copyWith((message) => updates(message as CheckStatusResponse)) as CheckStatusResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static CheckStatusResponse create() => CheckStatusResponse._(); - CheckStatusResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static CheckStatusResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static CheckStatusResponse? _defaultInstance; - - @$pb.TagNumber(1) - Status get status => $_getN(0); - @$pb.TagNumber(1) - set status(Status v) { setField(1, v); } - @$pb.TagNumber(1) - $core.bool hasStatus() => $_has(0); - @$pb.TagNumber(1) - void clearStatus() => clearField(1); -} - -class GetCompileOutputRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetCompileOutputRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pipelineUuid') - ..hasRequiredFields = false - ; - - GetCompileOutputRequest._() : super(); - factory GetCompileOutputRequest({ - $core.String? pipelineUuid, - }) { - final _result = create(); - if (pipelineUuid != null) { - _result.pipelineUuid = pipelineUuid; - } - return _result; - } - factory GetCompileOutputRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory GetCompileOutputRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - GetCompileOutputRequest clone() => GetCompileOutputRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - GetCompileOutputRequest copyWith(void Function(GetCompileOutputRequest) updates) => super.copyWith((message) => updates(message as GetCompileOutputRequest)) as GetCompileOutputRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static GetCompileOutputRequest create() => GetCompileOutputRequest._(); - GetCompileOutputRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static GetCompileOutputRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static GetCompileOutputRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get pipelineUuid => $_getSZ(0); - @$pb.TagNumber(1) - set pipelineUuid($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasPipelineUuid() => $_has(0); - @$pb.TagNumber(1) - void clearPipelineUuid() => clearField(1); -} - -class GetCompileOutputResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetCompileOutputResponse', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'output') - ..e(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compilationStatus', $pb.PbFieldType.OE, defaultOrMaker: Status.STATUS_UNSPECIFIED, valueOf: Status.valueOf, enumValues: Status.values) - ..hasRequiredFields = false - ; - - GetCompileOutputResponse._() : super(); - factory GetCompileOutputResponse({ - $core.String? output, - Status? compilationStatus, - }) { - final _result = create(); - if (output != null) { - _result.output = output; - } - if (compilationStatus != null) { - _result.compilationStatus = compilationStatus; - } - return _result; - } - factory GetCompileOutputResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory GetCompileOutputResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - GetCompileOutputResponse clone() => GetCompileOutputResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - GetCompileOutputResponse copyWith(void Function(GetCompileOutputResponse) updates) => super.copyWith((message) => updates(message as GetCompileOutputResponse)) as GetCompileOutputResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static GetCompileOutputResponse create() => GetCompileOutputResponse._(); - GetCompileOutputResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static GetCompileOutputResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static GetCompileOutputResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get output => $_getSZ(0); - @$pb.TagNumber(1) - set output($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasOutput() => $_has(0); - @$pb.TagNumber(1) - void clearOutput() => clearField(1); - - @$pb.TagNumber(2) - Status get compilationStatus => $_getN(1); - @$pb.TagNumber(2) - set compilationStatus(Status v) { setField(2, v); } - @$pb.TagNumber(2) - $core.bool hasCompilationStatus() => $_has(1); - @$pb.TagNumber(2) - void clearCompilationStatus() => clearField(2); -} - -class GetRunOutputRequest extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetRunOutputRequest', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'pipelineUuid') - ..hasRequiredFields = false - ; - - GetRunOutputRequest._() : super(); - factory GetRunOutputRequest({ - $core.String? pipelineUuid, - }) { - final _result = create(); - if (pipelineUuid != null) { - _result.pipelineUuid = pipelineUuid; - } - return _result; - } - factory GetRunOutputRequest.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory GetRunOutputRequest.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - GetRunOutputRequest clone() => GetRunOutputRequest()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - GetRunOutputRequest copyWith(void Function(GetRunOutputRequest) updates) => super.copyWith((message) => updates(message as GetRunOutputRequest)) as GetRunOutputRequest; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static GetRunOutputRequest create() => GetRunOutputRequest._(); - GetRunOutputRequest createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static GetRunOutputRequest getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static GetRunOutputRequest? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get pipelineUuid => $_getSZ(0); - @$pb.TagNumber(1) - set pipelineUuid($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasPipelineUuid() => $_has(0); - @$pb.TagNumber(1) - void clearPipelineUuid() => clearField(1); -} - -class GetRunOutputResponse extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'GetRunOutputResponse', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'playground.v1'), createEmptyInstance: create) - ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'output') - ..e(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'compilationStatus', $pb.PbFieldType.OE, defaultOrMaker: Status.STATUS_UNSPECIFIED, valueOf: Status.valueOf, enumValues: Status.values) - ..hasRequiredFields = false - ; - - GetRunOutputResponse._() : super(); - factory GetRunOutputResponse({ - $core.String? output, - Status? compilationStatus, - }) { - final _result = create(); - if (output != null) { - _result.output = output; - } - if (compilationStatus != null) { - _result.compilationStatus = compilationStatus; - } - return _result; - } - factory GetRunOutputResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory GetRunOutputResponse.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - GetRunOutputResponse clone() => GetRunOutputResponse()..mergeFromMessage(this); - @$core.Deprecated( - 'Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - GetRunOutputResponse copyWith(void Function(GetRunOutputResponse) updates) => super.copyWith((message) => updates(message as GetRunOutputResponse)) as GetRunOutputResponse; // ignore: deprecated_member_use - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static GetRunOutputResponse create() => GetRunOutputResponse._(); - GetRunOutputResponse createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static GetRunOutputResponse getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static GetRunOutputResponse? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get output => $_getSZ(0); - @$pb.TagNumber(1) - set output($core.String v) { $_setString(0, v); } - @$pb.TagNumber(1) - $core.bool hasOutput() => $_has(0); - @$pb.TagNumber(1) - void clearOutput() => clearField(1); - - @$pb.TagNumber(2) - Status get compilationStatus => $_getN(1); - @$pb.TagNumber(2) - set compilationStatus(Status v) { setField(2, v); } - @$pb.TagNumber(2) - $core.bool hasCompilationStatus() => $_has(1); - @$pb.TagNumber(2) - void clearCompilationStatus() => clearField(2); -} - diff --git a/playground/frontend/lib/generated/playground.pbenum.dart b/playground/frontend/lib/generated/playground.pbenum.dart deleted file mode 100644 index fbbb256d65d0..000000000000 --- a/playground/frontend/lib/generated/playground.pbenum.dart +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/// -// Generated code. Do not modify. -// source: playground.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields - -// ignore_for_file: UNDEFINED_SHOWN_NAME -import 'dart:core' as $core; -import 'package:protobuf/protobuf.dart' as $pb; - -class Sdk extends $pb.ProtobufEnum { - static const Sdk SDK_UNSPECIFIED = Sdk._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SDK_UNSPECIFIED'); - static const Sdk SDK_JAVA = Sdk._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SDK_JAVA'); - static const Sdk SDK_GO = Sdk._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SDK_GO'); - static const Sdk SDK_PYTHON = Sdk._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SDK_PYTHON'); - static const Sdk SDK_SCIO = Sdk._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'SDK_SCIO'); - - static const $core.List values = [ - SDK_UNSPECIFIED, - SDK_JAVA, - SDK_GO, - SDK_PYTHON, - SDK_SCIO, - ]; - - static final $core.Map<$core.int, Sdk> _byValue = $pb.ProtobufEnum.initByValue(values); - static Sdk? valueOf($core.int value) => _byValue[value]; - - const Sdk._($core.int v, $core.String n) : super(v, n); -} - -class Status extends $pb.ProtobufEnum { - static const Status STATUS_UNSPECIFIED = Status._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'STATUS_UNSPECIFIED'); - static const Status STATUS_EXECUTING = Status._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'STATUS_EXECUTING'); - static const Status STATUS_FINISHED = Status._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'STATUS_FINISHED'); - static const Status STATUS_ERROR = Status._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'STATUS_ERROR'); - - static const $core.List values = [ - STATUS_UNSPECIFIED, - STATUS_EXECUTING, - STATUS_FINISHED, - STATUS_ERROR, - ]; - - static final $core.Map<$core.int, Status> _byValue = $pb.ProtobufEnum.initByValue(values); - static Status? valueOf($core.int value) => _byValue[value]; - - const Status._($core.int v, $core.String n) : super(v, n); -} - diff --git a/playground/frontend/lib/generated/playground.pbgrpc.dart b/playground/frontend/lib/generated/playground.pbgrpc.dart deleted file mode 100644 index c18185bf4ac8..000000000000 --- a/playground/frontend/lib/generated/playground.pbgrpc.dart +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/// -// Generated code. Do not modify. -// source: playground.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields - -import 'dart:async' as $async; - -import 'dart:core' as $core; - -import 'package:grpc/service_api.dart' as $grpc; -import 'playground.pb.dart' as $0; -export 'playground.pb.dart'; - -class PlaygroundServiceClient extends $grpc.Client { - static final _$runCode = - $grpc.ClientMethod<$0.RunCodeRequest, $0.RunCodeResponse>( - '/playground.v1.PlaygroundService/RunCode', - ($0.RunCodeRequest value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.RunCodeResponse.fromBuffer(value)); - static final _$checkStatus = - $grpc.ClientMethod<$0.CheckStatusRequest, $0.CheckStatusResponse>( - '/playground.v1.PlaygroundService/CheckStatus', - ($0.CheckStatusRequest value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.CheckStatusResponse.fromBuffer(value)); - static final _$getRunOutput = - $grpc.ClientMethod<$0.GetRunOutputRequest, $0.GetRunOutputResponse>( - '/playground.v1.PlaygroundService/GetRunOutput', - ($0.GetRunOutputRequest value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.GetRunOutputResponse.fromBuffer(value)); - static final _$getCompileOutput = $grpc.ClientMethod< - $0.GetCompileOutputRequest, $0.GetCompileOutputResponse>( - '/playground.v1.PlaygroundService/GetCompileOutput', - ($0.GetCompileOutputRequest value) => value.writeToBuffer(), - ($core.List<$core.int> value) => - $0.GetCompileOutputResponse.fromBuffer(value)); - - PlaygroundServiceClient($grpc.ClientChannel channel, - {$grpc.CallOptions? options, - $core.Iterable<$grpc.ClientInterceptor>? interceptors}) - : super(channel, options: options, interceptors: interceptors); - - $grpc.ResponseFuture<$0.RunCodeResponse> runCode($0.RunCodeRequest request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$runCode, request, options: options); - } - - $grpc.ResponseFuture<$0.CheckStatusResponse> checkStatus( - $0.CheckStatusRequest request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$checkStatus, request, options: options); - } - - $grpc.ResponseFuture<$0.GetRunOutputResponse> getRunOutput( - $0.GetRunOutputRequest request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$getRunOutput, request, options: options); - } - - $grpc.ResponseFuture<$0.GetCompileOutputResponse> getCompileOutput( - $0.GetCompileOutputRequest request, - {$grpc.CallOptions? options}) { - return $createUnaryCall(_$getCompileOutput, request, options: options); - } -} - -abstract class PlaygroundServiceBase extends $grpc.Service { - $core.String get $name => 'playground.v1.PlaygroundService'; - - PlaygroundServiceBase() { - $addMethod($grpc.ServiceMethod<$0.RunCodeRequest, $0.RunCodeResponse>( - 'RunCode', - runCode_Pre, - false, - false, - ($core.List<$core.int> value) => $0.RunCodeRequest.fromBuffer(value), - ($0.RunCodeResponse value) => value.writeToBuffer())); - $addMethod( - $grpc.ServiceMethod<$0.CheckStatusRequest, $0.CheckStatusResponse>( - 'CheckStatus', - checkStatus_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.CheckStatusRequest.fromBuffer(value), - ($0.CheckStatusResponse value) => value.writeToBuffer())); - $addMethod( - $grpc.ServiceMethod<$0.GetRunOutputRequest, $0.GetRunOutputResponse>( - 'GetRunOutput', - getRunOutput_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.GetRunOutputRequest.fromBuffer(value), - ($0.GetRunOutputResponse value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.GetCompileOutputRequest, - $0.GetCompileOutputResponse>( - 'GetCompileOutput', - getCompileOutput_Pre, - false, - false, - ($core.List<$core.int> value) => - $0.GetCompileOutputRequest.fromBuffer(value), - ($0.GetCompileOutputResponse value) => value.writeToBuffer())); - } - - $async.Future<$0.RunCodeResponse> runCode_Pre( - $grpc.ServiceCall call, $async.Future<$0.RunCodeRequest> request) async { - return runCode(call, await request); - } - - $async.Future<$0.CheckStatusResponse> checkStatus_Pre($grpc.ServiceCall call, - $async.Future<$0.CheckStatusRequest> request) async { - return checkStatus(call, await request); - } - - $async.Future<$0.GetRunOutputResponse> getRunOutput_Pre( - $grpc.ServiceCall call, - $async.Future<$0.GetRunOutputRequest> request) async { - return getRunOutput(call, await request); - } - - $async.Future<$0.GetCompileOutputResponse> getCompileOutput_Pre( - $grpc.ServiceCall call, - $async.Future<$0.GetCompileOutputRequest> request) async { - return getCompileOutput(call, await request); - } - - $async.Future<$0.RunCodeResponse> runCode( - $grpc.ServiceCall call, $0.RunCodeRequest request); - $async.Future<$0.CheckStatusResponse> checkStatus( - $grpc.ServiceCall call, $0.CheckStatusRequest request); - $async.Future<$0.GetRunOutputResponse> getRunOutput( - $grpc.ServiceCall call, $0.GetRunOutputRequest request); - $async.Future<$0.GetCompileOutputResponse> getCompileOutput( - $grpc.ServiceCall call, $0.GetCompileOutputRequest request); -} diff --git a/playground/frontend/lib/generated/playground.pbjson.dart b/playground/frontend/lib/generated/playground.pbjson.dart deleted file mode 100644 index 4912ae2013d1..000000000000 --- a/playground/frontend/lib/generated/playground.pbjson.dart +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/// -// Generated code. Do not modify. -// source: playground.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package - -import 'dart:core' as $core; -import 'dart:convert' as $convert; -import 'dart:typed_data' as $typed_data; -@$core.Deprecated('Use sdkDescriptor instead') -const Sdk$json = const { - '1': 'Sdk', - '2': const [ - const {'1': 'SDK_UNSPECIFIED', '2': 0}, - const {'1': 'SDK_JAVA', '2': 1}, - const {'1': 'SDK_GO', '2': 2}, - const {'1': 'SDK_PYTHON', '2': 3}, - const {'1': 'SDK_SCIO', '2': 4}, - ], -}; - -/// Descriptor for `Sdk`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List sdkDescriptor = $convert.base64Decode('CgNTZGsSEwoPU0RLX1VOU1BFQ0lGSUVEEAASDAoIU0RLX0pBVkEQARIKCgZTREtfR08QAhIOCgpTREtfUFlUSE9OEAMSDAoIU0RLX1NDSU8QBA=='); -@$core.Deprecated('Use statusDescriptor instead') -const Status$json = const { - '1': 'Status', - '2': const [ - const {'1': 'STATUS_UNSPECIFIED', '2': 0}, - const {'1': 'STATUS_EXECUTING', '2': 1}, - const {'1': 'STATUS_FINISHED', '2': 2}, - const {'1': 'STATUS_ERROR', '2': 3}, - ], -}; - -/// Descriptor for `Status`. Decode as a `google.protobuf.EnumDescriptorProto`. -final $typed_data.Uint8List statusDescriptor = $convert.base64Decode('CgZTdGF0dXMSFgoSU1RBVFVTX1VOU1BFQ0lGSUVEEAASFAoQU1RBVFVTX0VYRUNVVElORxABEhMKD1NUQVRVU19GSU5JU0hFRBACEhAKDFNUQVRVU19FUlJPUhAD'); -@$core.Deprecated('Use runCodeRequestDescriptor instead') -const RunCodeRequest$json = const { - '1': 'RunCodeRequest', - '2': const [ - const {'1': 'code', '3': 1, '4': 1, '5': 9, '10': 'code'}, - const {'1': 'sdk', '3': 2, '4': 1, '5': 14, '6': '.playground.v1.Sdk', '10': 'sdk'}, - ], -}; - -/// Descriptor for `RunCodeRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List runCodeRequestDescriptor = $convert.base64Decode('Cg5SdW5Db2RlUmVxdWVzdBISCgRjb2RlGAEgASgJUgRjb2RlEiQKA3NkaxgCIAEoDjISLnBsYXlncm91bmQudjEuU2RrUgNzZGs='); -@$core.Deprecated('Use runCodeResponseDescriptor instead') -const RunCodeResponse$json = const { - '1': 'RunCodeResponse', - '2': const [ - const {'1': 'pipeline_uuid', '3': 1, '4': 1, '5': 9, '10': 'pipelineUuid'}, - ], -}; - -/// Descriptor for `RunCodeResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List runCodeResponseDescriptor = $convert.base64Decode('Cg9SdW5Db2RlUmVzcG9uc2USIwoNcGlwZWxpbmVfdXVpZBgBIAEoCVIMcGlwZWxpbmVVdWlk'); -@$core.Deprecated('Use checkStatusRequestDescriptor instead') -const CheckStatusRequest$json = const { - '1': 'CheckStatusRequest', - '2': const [ - const {'1': 'pipeline_uuid', '3': 1, '4': 1, '5': 9, '10': 'pipelineUuid'}, - ], -}; - -/// Descriptor for `CheckStatusRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List checkStatusRequestDescriptor = $convert.base64Decode('ChJDaGVja1N0YXR1c1JlcXVlc3QSIwoNcGlwZWxpbmVfdXVpZBgBIAEoCVIMcGlwZWxpbmVVdWlk'); -@$core.Deprecated('Use checkStatusResponseDescriptor instead') -const CheckStatusResponse$json = const { - '1': 'CheckStatusResponse', - '2': const [ - const {'1': 'status', '3': 1, '4': 1, '5': 14, '6': '.playground.v1.Status', '10': 'status'}, - ], -}; - -/// Descriptor for `CheckStatusResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List checkStatusResponseDescriptor = $convert.base64Decode('ChNDaGVja1N0YXR1c1Jlc3BvbnNlEi0KBnN0YXR1cxgBIAEoDjIVLnBsYXlncm91bmQudjEuU3RhdHVzUgZzdGF0dXM='); -@$core.Deprecated('Use getCompileOutputRequestDescriptor instead') -const GetCompileOutputRequest$json = const { - '1': 'GetCompileOutputRequest', - '2': const [ - const {'1': 'pipeline_uuid', '3': 1, '4': 1, '5': 9, '10': 'pipelineUuid'}, - ], -}; - -/// Descriptor for `GetCompileOutputRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List getCompileOutputRequestDescriptor = $convert.base64Decode('ChdHZXRDb21waWxlT3V0cHV0UmVxdWVzdBIjCg1waXBlbGluZV91dWlkGAEgASgJUgxwaXBlbGluZVV1aWQ='); -@$core.Deprecated('Use getCompileOutputResponseDescriptor instead') -const GetCompileOutputResponse$json = const { - '1': 'GetCompileOutputResponse', - '2': const [ - const {'1': 'output', '3': 1, '4': 1, '5': 9, '10': 'output'}, - const {'1': 'compilation_status', '3': 2, '4': 1, '5': 14, '6': '.playground.v1.Status', '10': 'compilationStatus'}, - ], -}; - -/// Descriptor for `GetCompileOutputResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List getCompileOutputResponseDescriptor = $convert.base64Decode('ChhHZXRDb21waWxlT3V0cHV0UmVzcG9uc2USFgoGb3V0cHV0GAEgASgJUgZvdXRwdXQSRAoSY29tcGlsYXRpb25fc3RhdHVzGAIgASgOMhUucGxheWdyb3VuZC52MS5TdGF0dXNSEWNvbXBpbGF0aW9uU3RhdHVz'); -@$core.Deprecated('Use getRunOutputRequestDescriptor instead') -const GetRunOutputRequest$json = const { - '1': 'GetRunOutputRequest', - '2': const [ - const {'1': 'pipeline_uuid', '3': 1, '4': 1, '5': 9, '10': 'pipelineUuid'}, - ], -}; - -/// Descriptor for `GetRunOutputRequest`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List getRunOutputRequestDescriptor = $convert.base64Decode('ChNHZXRSdW5PdXRwdXRSZXF1ZXN0EiMKDXBpcGVsaW5lX3V1aWQYASABKAlSDHBpcGVsaW5lVXVpZA=='); -@$core.Deprecated('Use getRunOutputResponseDescriptor instead') -const GetRunOutputResponse$json = const { - '1': 'GetRunOutputResponse', - '2': const [ - const {'1': 'output', '3': 1, '4': 1, '5': 9, '10': 'output'}, - const {'1': 'compilation_status', '3': 2, '4': 1, '5': 14, '6': '.playground.v1.Status', '10': 'compilationStatus'}, - ], -}; - -/// Descriptor for `GetRunOutputResponse`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List getRunOutputResponseDescriptor = $convert.base64Decode('ChRHZXRSdW5PdXRwdXRSZXNwb25zZRIWCgZvdXRwdXQYASABKAlSBm91dHB1dBJEChJjb21waWxhdGlvbl9zdGF0dXMYAiABKA4yFS5wbGF5Z3JvdW5kLnYxLlN0YXR1c1IRY29tcGlsYXRpb25TdGF0dXM='); From 7888359096e19188b4b762e9798441dca337d266 Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Mon, 8 Nov 2021 18:52:13 +0400 Subject: [PATCH 11/15] [BEAM-13064] Fixes after merge --- playground/frontend/lib/constants/sizes.dart | 6 ---- .../states/example_dropdown_state.dart | 32 ------------------- .../playground/states/playground_state.dart | 5 --- 3 files changed, 43 deletions(-) delete mode 100644 playground/frontend/lib/pages/playground/states/example_dropdown_state.dart diff --git a/playground/frontend/lib/constants/sizes.dart b/playground/frontend/lib/constants/sizes.dart index 15c93d319219..a274baa4a9a3 100644 --- a/playground/frontend/lib/constants/sizes.dart +++ b/playground/frontend/lib/constants/sizes.dart @@ -52,9 +52,3 @@ const double kCursorSize = 1.0; const double kContainerHeight = 40.0; const double kCodeFontSize = 14.0; - -// cursor size -const double kCursorSize = 1.0; - -// container size -const double kContainerHeight = 40.0; diff --git a/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart b/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart deleted file mode 100644 index 38a966561fb1..000000000000 --- a/playground/frontend/lib/pages/playground/states/example_dropdown_state.dart +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import 'package:flutter/material.dart'; - -class ExampleDropdownState with ChangeNotifier { - String _selectedCategory; - - ExampleDropdownState([this._selectedCategory = 'All']); - - String get selectedCategory => _selectedCategory; - - setSelectedCategory(String name) async { - _selectedCategory = name; - notifyListeners(); - } -} diff --git a/playground/frontend/lib/pages/playground/states/playground_state.dart b/playground/frontend/lib/pages/playground/states/playground_state.dart index 778be72ccd49..3112a7974f24 100644 --- a/playground/frontend/lib/pages/playground/states/playground_state.dart +++ b/playground/frontend/lib/pages/playground/states/playground_state.dart @@ -41,11 +41,6 @@ class PlaygroundState with ChangeNotifier { return name.substring(0, min(kTitleLength, name.length)); } - String get examplesTitle { - final name = _selectedExample?.name ?? ''; - return name.substring(0, min(kTitleLength, name.length)); - } - PlaygroundState({ SDK sdk = SDK.java, ExampleModel? selectedExample, From b73f5f70ac4184b56a0a03922731c5f2f69b9566 Mon Sep 17 00:00:00 2001 From: Sergey Kalinin <91209855+snkalinin@users.noreply.github.com> Date: Tue, 16 Nov 2021 14:59:11 +0300 Subject: [PATCH 12/15] [Playground][BEAM-12941][Bugfix] Fix workflows for playground applications (#83) * Update workflows for playground * Attempt to fix tests * Remove continue on error to catch errors * Fix linter problem for backend dockerfile * Update folder to run backend go linter * Moved flutter test to execution via gradle tasks --- .../workflows/build_playground_backend.yml | 14 ++++++++----- .../workflows/build_playground_frontend.yml | 20 +++++++------------ playground/backend/containers/java/Dockerfile | 2 +- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build_playground_backend.yml b/.github/workflows/build_playground_backend.yml index 96e8aae9b0d5..bd2868768246 100644 --- a/.github/workflows/build_playground_backend.yml +++ b/.github/workflows/build_playground_backend.yml @@ -17,10 +17,8 @@ name: Build And Deploy Playground Backend Application on: push: - branches: ['master', 'release-*'] tags: 'v*' pull_request: - branches: ['master', 'release-*'] tags: 'v*' paths: ['playground/backend/**'] workflow_dispatch: @@ -45,12 +43,14 @@ jobs: - name: Prepare Go lint env run: "sudo ./playground/backend/env_setup.sh" - name: Run Lint - run: "golangci-lint run internal/..." +# run: "golangci-lint run internal/..." + run: "golangci-lint run cmd/server/..." working-directory: playground/backend/ - continue-on-error: true + - name: Remove default github maven configuration + # This step is a workaround to avoid a decryption issue + run: rm ~/.m2/settings.xml - name: Run Tests run: ./gradlew playground:backend:test - continue-on-error: true - name: install npm uses: actions/setup-node@v2 with: @@ -62,12 +62,16 @@ jobs: working-directory: playground/backend/containers/java - name: Setup GCP account run: echo ${{ secrets.GCP_ACCESS_KEY }} | base64 -d > /tmp/gcp_access.json + if: startsWith(github.ref, 'ref/tags/') - name: Login to Docker Registry run: cat /tmp/gcp_access.json | docker login -u _json_key --password-stdin https://${{ secrets.REGISTRY_NAME }} + if: startsWith(github.ref, 'ref/tags/') - name: Preapre Build run: ./gradlew playground:backend:containers:java:dockerPush -Pdocker-repository-root='${{ secrets.REGISTRY_NAME}}/${{ secrets.PROJECT_ID }}/playground-repository' -Pbase-image='apache/beam_java8_sdk:${{ env.BEAM_VERSION }}' + if: startsWith(github.ref, 'ref/tags/') - name: Deploy Backend Application env: GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp_access.json run: terraform init && terraform apply -auto-approve -var="project_id=${{ secrets.PROJECT_ID }}" -var="docker_registry_address=${{ secrets.REGISTRY_NAME}}/${{ secrets.PROJECT_ID }}/playground-repository" working-directory: playground/terraform/applications/backend + if: startsWith(github.ref, 'ref/tags/') diff --git a/.github/workflows/build_playground_frontend.yml b/.github/workflows/build_playground_frontend.yml index 9c2d56a52428..f93e330442b0 100644 --- a/.github/workflows/build_playground_frontend.yml +++ b/.github/workflows/build_playground_frontend.yml @@ -17,12 +17,10 @@ name: Build And Deploy Playground Frontend Application on: push: - branches: ['master', 'release-*'] tags: 'v*' pull_request: - branches: ['master', 'release-*'] tags: 'v*' - paths: ['playground/backend/**'] + paths: ['playground/frontend/**'] workflow_dispatch: jobs: @@ -43,18 +41,10 @@ jobs: uses: subosito/flutter-action@v1 with: channel: 'stable' - - name: Prepare Flutter lint - run: "flutter pub add flutter_lints --dev" - working-directory: playground/frontend/ - continue-on-error: true - name: Run Lint - run: "flutter analyze" - working-directory: playground/frontend/ - continue-on-error: true + run: ./gradlew playground:frontend:analyze - name: Run Tests - run: flutter test - working-directory: playground/frontend/ - continue-on-error: true + run: ./gradlew playground:frontend:test - name: install npm uses: actions/setup-node@v2 with: @@ -66,12 +56,16 @@ jobs: working-directory: playground/frontend - name: Setup GCP account run: echo ${{ secrets.GCP_ACCESS_KEY }} | base64 -d > /tmp/gcp_access.json + if: startsWith(github.ref, 'ref/tags/') - name: Login to Docker Registry run: cat /tmp/gcp_access.json | docker login -u _json_key --password-stdin https://${{ secrets.REGISTRY_NAME }} + if: startsWith(github.ref, 'ref/tags/') - name: Preapre Build run: ./gradlew --debug playground:frontend:dockerPush -Pdocker-repository-root='${{ secrets.REGISTRY_NAME}}/${{ secrets.PROJECT_ID }}/playground-repository' + if: startsWith(github.ref, 'ref/tags/') - name: Deploy Backend Application env: GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp_access.json run: terraform init && terraform apply -auto-approve -var="project_id=${{ secrets.PROJECT_ID }}" -var="docker_registry_address=${{ secrets.REGISTRY_NAME}}/${{ secrets.PROJECT_ID }}/playground-repository" working-directory: playground/terraform/applications/backend + if: startsWith(github.ref, 'ref/tags/') diff --git a/playground/backend/containers/java/Dockerfile b/playground/backend/containers/java/Dockerfile index d7275020dcfa..8846368ff8b6 100644 --- a/playground/backend/containers/java/Dockerfile +++ b/playground/backend/containers/java/Dockerfile @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### -ARG BASE_IMAGE +ARG BASE_IMAGE=apache/beam_java8_sdk:latest FROM golang:1.17-buster AS build # Setup Go Environment From d449275b8ebd623760b34981f56c8f62b140ad9d Mon Sep 17 00:00:00 2001 From: Ilya Date: Tue, 16 Nov 2021 15:07:49 +0300 Subject: [PATCH 13/15] Revert "[Playground][BEAM-12941][Bugfix] Fix workflows for playground applications (#83)" (#88) This reverts commit b73f5f70ac4184b56a0a03922731c5f2f69b9566. --- .../workflows/build_playground_backend.yml | 14 +++++-------- .../workflows/build_playground_frontend.yml | 20 ++++++++++++------- playground/backend/containers/java/Dockerfile | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build_playground_backend.yml b/.github/workflows/build_playground_backend.yml index bd2868768246..96e8aae9b0d5 100644 --- a/.github/workflows/build_playground_backend.yml +++ b/.github/workflows/build_playground_backend.yml @@ -17,8 +17,10 @@ name: Build And Deploy Playground Backend Application on: push: + branches: ['master', 'release-*'] tags: 'v*' pull_request: + branches: ['master', 'release-*'] tags: 'v*' paths: ['playground/backend/**'] workflow_dispatch: @@ -43,14 +45,12 @@ jobs: - name: Prepare Go lint env run: "sudo ./playground/backend/env_setup.sh" - name: Run Lint -# run: "golangci-lint run internal/..." - run: "golangci-lint run cmd/server/..." + run: "golangci-lint run internal/..." working-directory: playground/backend/ - - name: Remove default github maven configuration - # This step is a workaround to avoid a decryption issue - run: rm ~/.m2/settings.xml + continue-on-error: true - name: Run Tests run: ./gradlew playground:backend:test + continue-on-error: true - name: install npm uses: actions/setup-node@v2 with: @@ -62,16 +62,12 @@ jobs: working-directory: playground/backend/containers/java - name: Setup GCP account run: echo ${{ secrets.GCP_ACCESS_KEY }} | base64 -d > /tmp/gcp_access.json - if: startsWith(github.ref, 'ref/tags/') - name: Login to Docker Registry run: cat /tmp/gcp_access.json | docker login -u _json_key --password-stdin https://${{ secrets.REGISTRY_NAME }} - if: startsWith(github.ref, 'ref/tags/') - name: Preapre Build run: ./gradlew playground:backend:containers:java:dockerPush -Pdocker-repository-root='${{ secrets.REGISTRY_NAME}}/${{ secrets.PROJECT_ID }}/playground-repository' -Pbase-image='apache/beam_java8_sdk:${{ env.BEAM_VERSION }}' - if: startsWith(github.ref, 'ref/tags/') - name: Deploy Backend Application env: GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp_access.json run: terraform init && terraform apply -auto-approve -var="project_id=${{ secrets.PROJECT_ID }}" -var="docker_registry_address=${{ secrets.REGISTRY_NAME}}/${{ secrets.PROJECT_ID }}/playground-repository" working-directory: playground/terraform/applications/backend - if: startsWith(github.ref, 'ref/tags/') diff --git a/.github/workflows/build_playground_frontend.yml b/.github/workflows/build_playground_frontend.yml index f93e330442b0..9c2d56a52428 100644 --- a/.github/workflows/build_playground_frontend.yml +++ b/.github/workflows/build_playground_frontend.yml @@ -17,10 +17,12 @@ name: Build And Deploy Playground Frontend Application on: push: + branches: ['master', 'release-*'] tags: 'v*' pull_request: + branches: ['master', 'release-*'] tags: 'v*' - paths: ['playground/frontend/**'] + paths: ['playground/backend/**'] workflow_dispatch: jobs: @@ -41,10 +43,18 @@ jobs: uses: subosito/flutter-action@v1 with: channel: 'stable' + - name: Prepare Flutter lint + run: "flutter pub add flutter_lints --dev" + working-directory: playground/frontend/ + continue-on-error: true - name: Run Lint - run: ./gradlew playground:frontend:analyze + run: "flutter analyze" + working-directory: playground/frontend/ + continue-on-error: true - name: Run Tests - run: ./gradlew playground:frontend:test + run: flutter test + working-directory: playground/frontend/ + continue-on-error: true - name: install npm uses: actions/setup-node@v2 with: @@ -56,16 +66,12 @@ jobs: working-directory: playground/frontend - name: Setup GCP account run: echo ${{ secrets.GCP_ACCESS_KEY }} | base64 -d > /tmp/gcp_access.json - if: startsWith(github.ref, 'ref/tags/') - name: Login to Docker Registry run: cat /tmp/gcp_access.json | docker login -u _json_key --password-stdin https://${{ secrets.REGISTRY_NAME }} - if: startsWith(github.ref, 'ref/tags/') - name: Preapre Build run: ./gradlew --debug playground:frontend:dockerPush -Pdocker-repository-root='${{ secrets.REGISTRY_NAME}}/${{ secrets.PROJECT_ID }}/playground-repository' - if: startsWith(github.ref, 'ref/tags/') - name: Deploy Backend Application env: GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp_access.json run: terraform init && terraform apply -auto-approve -var="project_id=${{ secrets.PROJECT_ID }}" -var="docker_registry_address=${{ secrets.REGISTRY_NAME}}/${{ secrets.PROJECT_ID }}/playground-repository" working-directory: playground/terraform/applications/backend - if: startsWith(github.ref, 'ref/tags/') diff --git a/playground/backend/containers/java/Dockerfile b/playground/backend/containers/java/Dockerfile index 8846368ff8b6..d7275020dcfa 100644 --- a/playground/backend/containers/java/Dockerfile +++ b/playground/backend/containers/java/Dockerfile @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### -ARG BASE_IMAGE=apache/beam_java8_sdk:latest +ARG BASE_IMAGE FROM golang:1.17-buster AS build # Setup Go Environment From 4e8ec3ff77a992fc3093e9a0f45f9fa48b55e20a Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 18 Nov 2021 20:29:38 +0400 Subject: [PATCH 14/15] [BEAM-13064] Fixed analyze issues --- .../code_repository/code_client/grpc_code_client.dart | 4 ++++ .../frontend/lib/pages/playground/playground_page.dart | 7 ------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/playground/frontend/lib/modules/editor/repository/code_repository/code_client/grpc_code_client.dart b/playground/frontend/lib/modules/editor/repository/code_repository/code_client/grpc_code_client.dart index d81244141ce1..3856756e0d51 100644 --- a/playground/frontend/lib/modules/editor/repository/code_repository/code_client/grpc_code_client.dart +++ b/playground/frontend/lib/modules/editor/repository/code_repository/code_client/grpc_code_client.dart @@ -106,12 +106,16 @@ class GrpcCodeClient implements CodeClient { switch (status) { case grpc.Status.STATUS_ERROR: case grpc.Status.STATUS_VALIDATION_ERROR: + case grpc.Status.STATUS_RUN_ERROR: + case grpc.Status.STATUS_PREPARATION_ERROR: return RunCodeStatus.error; case grpc.Status.STATUS_EXECUTING: case grpc.Status.STATUS_VALIDATING: case grpc.Status.STATUS_COMPILING: + case grpc.Status.STATUS_PREPARING: return RunCodeStatus.executing; case grpc.Status.STATUS_FINISHED: + case grpc.Status.STATUS_CANCELED: return RunCodeStatus.finished; case grpc.Status.STATUS_UNSPECIFIED: return RunCodeStatus.unspecified; diff --git a/playground/frontend/lib/pages/playground/playground_page.dart b/playground/frontend/lib/pages/playground/playground_page.dart index 5658f372ad2a..ab20a0f0f796 100644 --- a/playground/frontend/lib/pages/playground/playground_page.dart +++ b/playground/frontend/lib/pages/playground/playground_page.dart @@ -29,13 +29,6 @@ import 'package:playground/modules/shortcuts/constants/global_shortcuts.dart'; import 'package:playground/pages/playground/components/more_actions.dart'; import 'package:playground/pages/playground/components/playground_page_body.dart'; import 'package:playground/pages/playground/components/playground_page_footer.dart'; -import 'package:playground/modules/actions/components/new_example_action.dart'; -import 'package:playground/modules/actions/components/reset_action.dart'; -import 'package:playground/modules/examples/example_selector.dart'; -import 'package:playground/modules/sdk/components/sdk_selector.dart'; -import 'package:playground/pages/playground/components/more_actions.dart'; -import 'package:playground/pages/playground/components/playground_page_body.dart'; -import 'package:playground/pages/playground/components/playground_page_footer.dart'; import 'package:playground/pages/playground/states/examples_state.dart'; import 'package:playground/pages/playground/states/playground_state.dart'; import 'package:provider/provider.dart'; From d445d0259b687eb81f0bb4464f08ea1fad55417b Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 18 Nov 2021 22:08:28 +0400 Subject: [PATCH 15/15] [BEAM-13064] Fixed example selector state test --- .../pages/playground/states/example_selector_state_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/playground/frontend/test/pages/playground/states/example_selector_state_test.dart b/playground/frontend/test/pages/playground/states/example_selector_state_test.dart index ddedf50e1dc4..4cf7302e111b 100644 --- a/playground/frontend/test/pages/playground/states/example_selector_state_test.dart +++ b/playground/frontend/test/pages/playground/states/example_selector_state_test.dart @@ -59,10 +59,10 @@ void main() { exampleState, exampleState.categories!, ExampleType.example, - 'hEl', + 'hLo' ); state.addListener(() { - expect(state.categories, sortedCategories); + expect(state.categories, []); expect(exampleState.categories, exampleState.categories); }); state.sortCategories();