-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ToB] [Frontend] Authentication, unit progress, complete unit, SDK selection #24457
Changes from 72 commits
7c23033
5978d37
8807c00
8e8d8c9
2ab4b3b
57800ee
28cb6b8
85e1234
8dc7719
e4dee7b
5b07e91
497ff7c
83c9c0e
9d1f49b
b78bbd3
5297d25
d25eaf5
12a685d
3c534d8
de0f7c3
3a10e8d
de273ba
70c0d61
6f53e30
4aedd5a
5ad067f
10b287b
a6597d4
2068ce9
52838e5
3df27bc
0b6fc8f
7fbaf38
64965a1
6d21e1e
2c90ced
6ed38ac
adbdeb6
c2f74a5
a575717
8607808
1bbc092
65dc521
d55622e
c6004b0
0a76b40
749d8b1
fb1fea1
ef63740
4b2d855
27b26e4
b6c4e3e
1e38328
96e41f7
e215ec4
a107952
8b639d0
c8db1ef
869b40c
9720c13
9e1bbb0
af936d0
d060372
a988404
943391d
dbcf032
d8b5c11
ff8d32b
256d7b7
6dd0a3b
fddeaee
dc4e142
f33a4c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,47 +17,67 @@ | |
under the License. | ||
--> | ||
|
||
# Tour of Beam | ||
These are the main sources of the Tour of Beam website. | ||
# Tour of Beam | ||
|
||
# About | ||
These are the main sources of the Tour of Beam website. | ||
|
||
# About | ||
|
||
## Getting started | ||
Running, debugging, and testing all require this first step that fetches | ||
dependencies and generates code: | ||
|
||
This project relies on generated code for some functionality: | ||
deserializers, test mocks, constants for asset files, | ||
extracted Beam symbols for the editor, etc. | ||
|
||
All generated files are version-controlled, so after checkout the project is immediately runnable. | ||
However, after changes you may need to re-run code generation: | ||
|
||
```bash | ||
cd ../../../playground/frontend/playground_components | ||
flutter pub get | ||
flutter pub run build_runner build | ||
cd ../../../learning/tour-of-beam/frontend | ||
flutter pub get | ||
cd beam | ||
./gradlew :playground:frontend:playground_components:generateCode | ||
cd learning/tour-of-beam/frontend | ||
flutter pub run build_runner build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additionally, why is there a need for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just above it reads
|
||
``` | ||
|
||
### Run | ||
|
||
The following command is used to build and serve the frontend app locally: | ||
|
||
`$ flutter run -d chrome` | ||
```bash | ||
flutter run -d chrome | ||
``` | ||
|
||
### Backend Selection | ||
|
||
To change the Google Project that is used as the backend: | ||
|
||
1. Update Firebase configuration: | ||
https://firebase.google.com/docs/flutter/setup?platform=web | ||
|
||
2. In `/lib/config.dart`, update: | ||
1. Google Project ID and region. | ||
2. Playground's backend URLs. | ||
|
||
# Deployment | ||
|
||
# Tests | ||
|
||
Install ChromeDriver to run integration tests in a browser: https://docs.flutter.dev/testing/integration-tests#running-in-a-browser | ||
Run integration tests: | ||
flutter drive \ | ||
--driver=test_driver/integration_test.dart \ | ||
--target=integration_test/counter_test.dart \ | ||
-d web-server | ||
|
||
# Deployment | ||
# Packages | ||
|
||
# Tests | ||
Install ChromeDriver to run integration tests in a browser: https://docs.flutter.dev/testing/integration-tests#running-in-a-browser | ||
Run integration tests: | ||
flutter drive \ | ||
--driver=test_driver/integration_test.dart \ | ||
--target=integration_test/counter_test.dart \ | ||
-d web-server | ||
`flutter pub get` | ||
|
||
# Packages | ||
`flutter pub get` | ||
# Contribution guide | ||
|
||
# Contribution guide | ||
For checks: `./gradlew rat` | ||
For checks: `./gradlew rat` | ||
Exclusions for file checks can be added in the Tour of Beam section of this file: `beam/build.gradle.kts` | ||
|
||
# Additional resources | ||
# Additional resources | ||
|
||
# Troubleshooting | ||
# Troubleshooting |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
*/ | ||
|
||
import 'package:enum_map/enum_map.dart'; | ||
|
||
part 'method.g.dart'; | ||
|
||
@unmodifiableEnumMap | ||
enum AuthMethod { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we instead just rely on which https://pub.dev/documentation/firebase_auth_platform_interface/latest/firebase_auth_platform_interface/AuthProvider-class.html is referenced with a particular button action? If someone clicks the Google button, it initializes Auth flow via Google. If someone clicks the Github button, it initializes Auth flow via Github. The code only seems to use the AuthMethod.google. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added the |
||
google, | ||
github, | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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:async'; | ||
|
||
import 'package:firebase_auth/firebase_auth.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'method.dart'; | ||
|
||
class AuthNotifier extends ChangeNotifier { | ||
final _authProviders = UnmodifiableAuthMethodMap( | ||
google: GoogleAuthProvider(), | ||
github: GithubAuthProvider(), | ||
); | ||
|
||
AuthNotifier() { | ||
FirebaseAuth.instance.authStateChanges().listen((user) { | ||
notifyListeners(); | ||
}); | ||
} | ||
|
||
bool get isAuthenticated => FirebaseAuth.instance.currentUser != null; | ||
|
||
Future<String?> getToken() async { | ||
return await FirebaseAuth.instance.currentUser?.getIdToken(); | ||
} | ||
|
||
Future<void> logIn(AuthMethod authMethod) async { | ||
await FirebaseAuth.instance.signInWithPopup(_authProviders.get(authMethod)); | ||
} | ||
|
||
Future<void> logOut() async { | ||
await FirebaseAuth.instance.signOut(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,21 +18,17 @@ | |
|
||
import 'dart:async'; | ||
|
||
import 'package:flutter/widgets.dart'; | ||
|
||
import '../models/content_tree.dart'; | ||
import '../repositories/client/client.dart'; | ||
import 'cache.dart'; | ||
|
||
class ContentTreeCache extends ChangeNotifier { | ||
final TobClient client; | ||
class ContentTreeCache extends Cache { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does a ContentTreeCache cache? Would code comments help explain this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added a comment to the |
||
ContentTreeCache({ | ||
required super.client, | ||
}); | ||
|
||
final _treesBySdkId = <String, ContentTreeModel>{}; | ||
final _futuresBySdkId = <String, Future<ContentTreeModel>>{}; | ||
|
||
ContentTreeCache({ | ||
required this.client, | ||
}); | ||
|
||
ContentTreeModel? getContentTree(String sdkId) { | ||
final future = _futuresBySdkId[sdkId]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
if (future == null) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert? Looks like it is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexeyinkin and I have updated README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the instructions, received the following error:
So ran,
flutter pub get
. FYI I saw a new file to be staged in git:Then followed the original instructions:
flutter pub run build_runner build
and received the error:Steps to reproduce:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added
flutter pub run build_runner build --delete-conflicting-outputs
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've committed a fresh
pubspec.lock
file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damondouglas this README is anyway temporary because Gradle tasks are also in the line for the review: