Skip to content
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

Merged
merged 73 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
7c23033
Content tree navigation (#23593)
Oct 21, 2022
5978d37
AnimatedBuilders instead of StatefulWidgets in unit & group (#23593)
Nov 4, 2022
8807c00
fixed _getNodeAncestors (#23593)
Nov 5, 2022
8e8d8c9
get sdkId (#23593)
Nov 5, 2022
2ab4b3b
addressing comments (#23593)
Nov 8, 2022
57800ee
sdkId getter & StatelessExpansionTile (#23593)
Nov 9, 2022
28cb6b8
expand & collapse group (#23593)
Nov 9, 2022
85e1234
StatelessExpansionTile (#23593)
Nov 9, 2022
8dc7719
license (#23593)
Nov 10, 2022
e4dee7b
ValueChanged and ValueKey in StatelessExpansionTile (#23593)
Nov 11, 2022
5b07e91
optional SDK selector in tour scaffold
Nov 14, 2022
497ff7c
AppNotifier
Nov 14, 2022
83c9c0e
moved AppNotifier into _initializeState
Nov 15, 2022
9d1f49b
StorageKeys
Nov 15, 2022
b78bbd3
remove listener
Nov 16, 2022
5297d25
auth, complete unit, user progress
Oct 19, 2022
d25eaf5
Merge branch 'master' into issue23692_auth
nausharipov Nov 18, 2022
12a685d
unit file fix
Nov 18, 2022
3c534d8
Merge remote-tracking branch 'origin/tour-header-sdk-selector' into a…
nausharipov Nov 18, 2022
de0f7c3
sdk selection works with auth
Nov 18, 2022
3a10e8d
show sdk selector in welcome screen
Nov 18, 2022
de273ba
hide back button after navigating from welcome
Nov 18, 2022
70c0d61
comments (0)
Nov 19, 2022
6f53e30
cache license
Nov 21, 2022
4aedd5a
SDK selector with fixed comments
Nov 21, 2022
5ad067f
non-nullable onChanged
Nov 21, 2022
10b287b
Merge pull request #324 from akvelon/tour-header-sdk-selector
nausharipov Nov 21, 2022
a6597d4
untested refinement
Nov 21, 2022
2068ce9
deleted show sdk selector
Nov 21, 2022
52838e5
notifier objects naming
Nov 21, 2022
3df27bc
untested refinement (1)
Nov 22, 2022
0b6fc8f
candidate repository
Nov 22, 2022
7fbaf38
new configs & todos
Nov 23, 2022
64965a1
canCompleteCurrentUnit (#23692)
Nov 24, 2022
6d21e1e
kOpenLoginOverlay (#23692)
Nov 24, 2022
2c90ced
login_overlay (#23692)
Nov 24, 2022
6ed38ac
unused import (#23692)
Nov 24, 2022
adbdeb6
deleted file (#23692)
Nov 24, 2022
c2f74a5
review comments (2)
Nov 27, 2022
a575717
deleted pubspec.lock
Nov 28, 2022
8607808
pubspec.lock in gitignore
Nov 28, 2022
1bbc092
comment fixes (3)
Nov 28, 2022
65dc521
updating & blocking complete unit button (#23692)
Nov 28, 2022
d55622e
missing await
Nov 28, 2022
c6004b0
no final else
Nov 28, 2022
0a76b40
pubspec.lock ignored only in PGC
Nov 29, 2022
749d8b1
pubspec.lock
Nov 29, 2022
fb1fea1
comment fixes (4)
Nov 29, 2022
ef63740
rearranged completeUnit (#23692)
Nov 29, 2022
4b2d855
renamed user progress model to unit progress (#23692)
Nov 29, 2022
27b26e4
clearUpdatingUnitId (#23692)
Nov 29, 2022
b6c4e3e
added async (#23692)
Nov 29, 2022
1e38328
removed "fix exception" todo after filing an issue (#23692)
Nov 29, 2022
96e41f7
Merge from master
Nov 30, 2022
e215ec4
generated files
Nov 30, 2022
a107952
renamed user progress cache to unit progress (#23692)
Dec 1, 2022
8b639d0
all caches extend cache (#23692)
Dec 1, 2022
c8db1ef
refined open overlay (#23692)
Dec 1, 2022
869b40c
extracted overlay body (#23692)
Dec 1, 2022
9720c13
moved dismissible overlay (#23692)
Dec 1, 2022
9e1bbb0
specific imports (#23692)
Dec 1, 2022
af936d0
added firebase_options.dart into gradle rat exclusions & added a miss…
Dec 1, 2022
d060372
removed padding from user menu (#23692)
Dec 6, 2022
a988404
documentation update (#23692)
Dec 7, 2022
943391d
Merge branch 'master' into issue23692_auth
Dec 23, 2022
dbcf032
Merge branch 'master' into issue23692_auth
Dec 26, 2022
d8b5c11
removed goToContextLine
Jan 6, 2023
ff8d32b
sdk getter (#23692)
Jan 6, 2023
256d7b7
todo: remove sdkId getter and setter (#23692)
Jan 6, 2023
6dd0a3b
todo: add unit and integration tests (#23692)
Jan 6, 2023
fddeaee
updated readme (#23692)
Jan 6, 2023
dc4e142
Merge branch 'master' into issue23692_auth
Jan 9, 2023
f33a4c2
addressing comments (#23692)
Jan 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ tasks.rat {
"learning/tour-of-beam/frontend/**/*.gen.dart",
"learning/tour-of-beam/frontend/.metadata",
"learning/tour-of-beam/frontend/pubspec.lock",
"learning/tour-of-beam/frontend/lib/firebase_options.dart",

// Ignore .gitkeep file
"**/.gitkeep",
Expand Down
27 changes: 27 additions & 0 deletions learning/tour-of-beam/frontend/lib/auth/method.dart
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the firebase_auth_platform_interface package and now logIn takes AuthProvider as an argument.

google,
github,
}
162 changes: 162 additions & 0 deletions learning/tour-of-beam/frontend/lib/auth/method.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions learning/tour-of-beam/frontend/lib/auth/notifier.dart
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();
}
}
27 changes: 27 additions & 0 deletions learning/tour-of-beam/frontend/lib/cache/cache.dart
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});
}
14 changes: 5 additions & 9 deletions learning/tour-of-beam/frontend/lib/cache/content_tree.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does a ContentTreeCache cache? Would code comments help explain this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment to the Cache class.

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];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about containsKey?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if (future == null) {
Expand Down
13 changes: 5 additions & 8 deletions learning/tour-of-beam/frontend/lib/cache/sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,19 @@

import 'dart:async';

import 'package:flutter/widgets.dart';
import 'package:playground_components/playground_components.dart';

import '../repositories/client/client.dart';
import '../repositories/models/get_sdks_response.dart';
import 'cache.dart';

class SdkCache extends ChangeNotifier {
final TobClient client;
class SdkCache extends Cache {
SdkCache({
required super.client,
});

final _sdks = <Sdk>[];
Future<GetSdksResponse>? _future;

SdkCache({
required this.client,
});

List<Sdk> getSdks() {
if (_future == null) {
unawaited(_loadSdks());
Expand Down
14 changes: 5 additions & 9 deletions learning/tour-of-beam/frontend/lib/cache/unit_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,17 @@

import 'dart:async';

import 'package:flutter/widgets.dart';

import '../models/unit_content.dart';
import '../repositories/client/client.dart';
import 'cache.dart';

class UnitContentCache extends ChangeNotifier {
final TobClient client;
class UnitContentCache extends Cache {
UnitContentCache({
required super.client,
});

final _unitContents = <String, Map<String, UnitContentModel>>{};
final _futures = <String, Map<String, Future<UnitContentModel>>>{};

UnitContentCache({
required this.client,
});

UnitContentModel? getUnitContent(String sdkId, String unitId) {
final future = _futures[sdkId]?[unitId];
if (future == null) {
Expand Down
Loading