-
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 64 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,62 @@ | |
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: | ||
|
||
```bash | ||
cd ../../../playground/frontend/playground_components | ||
flutter pub get | ||
flutter pub run build_runner build | ||
cd ../../../learning/tour-of-beam/frontend | ||
flutter pub get | ||
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. Revert? Looks like it is needed. 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. @alexeyinkin and I have updated README. 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. Based on the instructions, received the following error:
So ran,
Then followed the original instructions:
Steps to reproduce:
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 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 committed a fresh 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. @damondouglas this README is anyway temporary because Gradle tasks are also in the line for the review: |
||
``` | ||
|
||
### Code Generation | ||
|
||
This project relies on generated code for some functionality: | ||
deserializers, constants for asset files, Firebase configuration, 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: | ||
`flutter pub run build_runner build` | ||
|
||
Manual for re-configuring Firebase: | ||
https://firebase.google.com/docs/flutter/setup?platform=web | ||
|
||
### Run | ||
|
||
The following command is used to build and serve the frontend app locally: | ||
|
||
`$ flutter run -d chrome` | ||
|
||
# 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 |
---|---|---|
@@ -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:flutter/material.dart'; | ||
|
||
import '../repositories/client/client.dart'; | ||
|
||
abstract class Cache extends ChangeNotifier { | ||
final TobClient client; | ||
|
||
Cache({required this.client}); | ||
} |
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.
Will this work instead of these 3 lines?
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.
Or rather
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.