Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 995f01f

Browse files
merge: updated signin flow
2 parents bf1264a + 0f00b24 commit 995f01f

File tree

30 files changed

+445
-319
lines changed

30 files changed

+445
-319
lines changed

docs/src/app/pages/app-home/app-home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class AppHome {
4242
</ul>
4343
</section>
4444

45-
<section class="cta" text-center padding>
45+
<section class="cta ion-text-center ion-padding">
4646
<div class="cta__primary">
4747
<h2>Get started now 🔥</h2>
4848
<deckgo-highlight-code padding>

remote/src/app/modals/app-remote-connect/app-remote-connect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class AppRemoteConnect {
6060
<ion-icon name="close"></ion-icon>
6161
</ion-button>
6262
</ion-buttons>
63-
<ion-title text-uppercase>DeckDeckGo</ion-title>
63+
<ion-title class="ion-text-uppercase">DeckDeckGo</ion-title>
6464
</ion-toolbar>
6565
</ion-header>,
6666

remote/src/app/modals/app-remote-settings/app-remote-settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class AppRemoteSettings {
103103
<ion-icon name="close"></ion-icon>
104104
</ion-button>
105105
</ion-buttons>
106-
<ion-title text-uppercase>DeckDeckGo</ion-title>
106+
<ion-title class="ion-text-uppercase">DeckDeckGo</ion-title>
107107
</ion-toolbar>
108108
</ion-header>,
109109

remote/src/app/modals/app-remote-slide-picker/app-remote-slide-picker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class AppRemoteSettings {
3939
<ion-icon name="close"></ion-icon>
4040
</ion-button>
4141
</ion-buttons>
42-
<ion-title text-uppercase>DeckDeckGo</ion-title>
42+
<ion-title class="ion-text-uppercase">DeckDeckGo</ion-title>
4343
</ion-toolbar>
4444
</ion-header>,
4545
<ion-content padding>

remote/src/app/pages/app-about/app-about.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class AppAbout {
1010
return [
1111
<ion-header>
1212
<ion-toolbar color="primary">
13-
<ion-title text-uppercase>DeckDeckGo</ion-title>
13+
<ion-title class="ion-text-uppercase">DeckDeckGo</ion-title>
1414
</ion-toolbar>
1515
</ion-header>,
1616

@@ -29,7 +29,7 @@ export class AppAbout {
2929

3030
<p>DeckDeckGo is <strong>open source</strong> and its source code could be found on <a href="https://github.com/deckgo/deckdeckgo">Github <ion-icon name="logo-github"></ion-icon></a></p>
3131

32-
<div padding margin text-center class="social-links">
32+
<div class="social-links ion-padding ion-margin ion-text-center">
3333
<a href="https://deckdeckgo.com">
3434
<ion-icon name="globe"></ion-icon>
3535
</a>

remote/src/app/pages/app-remote/app-remote.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ export class AppRemote {
406406
return [
407407
<ion-header>
408408
<ion-toolbar color="primary">
409-
<ion-title text-uppercase>DeckDeckGo</ion-title>
409+
<ion-title class="ion-text-uppercase">DeckDeckGo</ion-title>
410410

411411
<ion-buttons slot="end">
412412
<ion-button onClick={() => this.openSettingsModal()}>

remote/src/app/pages/app-timer/app-timer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class AppTimer {
122122
return [
123123
<ion-header>
124124
<ion-toolbar color="primary">
125-
<ion-title text-uppercase>DeckDeckGo</ion-title>
125+
<ion-title class="ion-text-uppercase">DeckDeckGo</ion-title>
126126
</ion-toolbar>
127127
</ion-header>,
128128

studio/src/app/app-root.tsx

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
import {Component, Prop} from '@stencil/core';
1+
import {Component, Element, Prop} from '@stencil/core';
22

33
import {Subscription} from 'rxjs';
44

55
import {ErrorService} from './services/error/error.service';
6-
7-
import {AuthService, LoginModalComponentProps} from './services/auth/auth.service';
6+
import {AuthService} from './services/auth/auth.service';
7+
import {NavDirection, NavParams, NavService} from './services/nav/nav.service';
88

99
@Component({
1010
tag: 'app-root',
1111
styleUrl: 'app-root.scss'
1212
})
1313
export class AppRoot {
1414

15-
@Prop({connect: 'ion-modal-controller'}) modalController: HTMLIonModalControllerElement;
15+
@Element() el: HTMLElement;
16+
1617
@Prop({connect: 'ion-menu-controller'}) lazyMenuController!: HTMLIonMenuControllerElement;
1718
@Prop({connect: 'ion-toast-controller'}) toastController: HTMLIonToastControllerElement;
1819

1920
private errorSubscription: Subscription;
2021
private errorService: ErrorService;
2122

22-
private authSubscription: Subscription;
2323
private authService: AuthService;
2424

25+
private navSubscription: Subscription;
26+
private navService: NavService;
27+
2528
constructor() {
2629
this.errorService = ErrorService.getInstance();
2730
this.authService = AuthService.getInstance();
31+
this.navService = NavService.getInstance();
2832
}
2933

3034
async componentWillLoad() {
@@ -36,12 +40,8 @@ export class AppRoot {
3640
await this.toastError(error);
3741
});
3842

39-
this.authSubscription = this.authService.watchModal().subscribe(async (componentProps: LoginModalComponentProps) => {
40-
if (!componentProps) {
41-
return;
42-
}
43-
44-
await this.signIn(componentProps);
43+
this.navSubscription = this.navService.watch().subscribe(async (params: NavParams) => {
44+
await this.navigate(params);
4545
});
4646
}
4747

@@ -50,8 +50,8 @@ export class AppRoot {
5050
this.errorSubscription.unsubscribe();
5151
}
5252

53-
if (this.authSubscription) {
54-
this.authSubscription.unsubscribe();
53+
if (this.navSubscription) {
54+
this.navSubscription.unsubscribe();
5555
}
5656
}
5757

@@ -68,19 +68,21 @@ export class AppRoot {
6868
await popover.present();
6969
}
7070

71-
private async signIn(componentProps: LoginModalComponentProps) {
72-
const modal: HTMLIonModalElement = await this.modalController.create({
73-
component: 'app-login',
74-
componentProps: {
75-
type: componentProps.type,
76-
context: componentProps.context
77-
}
78-
});
71+
private async navigate(params: NavParams) {
72+
if (!params) {
73+
return;
74+
}
75+
76+
const router: HTMLIonRouterElement = this.el.querySelector('ion-router');
7977

80-
await modal.present();
78+
if (!router) {
79+
return;
80+
}
8181

82-
if (componentProps.onPresent) {
83-
componentProps.onPresent();
82+
if (params.direction === NavDirection.ROOT) {
83+
window.location.assign(params.url);
84+
} else {
85+
await router.push(params.url);
8486
}
8587
}
8688

@@ -89,8 +91,12 @@ export class AppRoot {
8991
<ion-app>
9092
<ion-router useHash={false}>
9193
<ion-route url="/" component="app-home"/>
94+
9295
<ion-route url="/editor" component="app-editor"/>
9396

97+
<ion-route url="/signin" component="app-signin"/>
98+
<ion-route url="/signin/:redirect" component="app-signin"/>
99+
94100
<ion-route url="/about" component="app-about"/>
95101
<ion-route url="/opensource" component="app-opensource"/>
96102
<ion-route url="/privacy" component="app-privacy"/>

studio/src/app/components/core/app-menu-user/app-menu-user.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ ion-split-pane {
1111
}
1212
}
1313
}
14+
15+
ion-button.new {
16+
--color: var(--ion-color-primary);
17+
}
1418
}
1519
}
1620
}

studio/src/app/components/core/app-menu-user/app-menu-user.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import {Component, State} from '@stencil/core';
2-
import {AuthService, LoginModalType} from '../../../services/auth/auth.service';
2+
33
import {Subscription} from 'rxjs';
4+
45
import {User} from '../../../models/user';
56

7+
import {Utils} from '../../../utils/utils';
8+
9+
import {AuthService} from '../../../services/auth/auth.service';
10+
import {NavDirection, NavService} from '../../../services/nav/nav.service';
611

712
@Component({
813
tag: 'app-menu-user',
@@ -14,11 +19,14 @@ export class AppMenuUser {
1419
private authService: AuthService;
1520
private subscription: Subscription;
1621

22+
private navService: NavService;
23+
1724
@State()
1825
private user: User;
1926

2027
constructor() {
2128
this.authService = AuthService.getInstance();
29+
this.navService = NavService.getInstance();
2230
}
2331

2432
componentWillLoad() {
@@ -34,13 +42,19 @@ export class AppMenuUser {
3442
}
3543

3644
private async signIn() {
37-
this.authService.openSignInModal({
38-
type: LoginModalType.SIGNIN
45+
this.navService.navigate({
46+
url: '/signin',
47+
direction: NavDirection.FORWARD
3948
});
4049
}
4150

4251
private async signOut() {
43-
await this.authService.logout();
52+
await this.authService.signOut();
53+
54+
this.navService.navigate({
55+
url: '/',
56+
direction: NavDirection.ROOT
57+
});
4458
}
4559

4660
render() {
@@ -50,7 +64,7 @@ export class AppMenuUser {
5064
<ion-item-divider>
5165
<ion-label>Presentations</ion-label>
5266
<ion-button size="small" slot="end" shape="round" margin-end href="/editor"
53-
routerDirection="forward">
67+
routerDirection="forward" class="new">
5468
<ion-icon name="book" slot="start"></ion-icon>
5569
<ion-label>New</ion-label>
5670
</ion-button>
@@ -64,7 +78,7 @@ export class AppMenuUser {
6478
}
6579

6680
private renderUser() {
67-
if (this.user) {
81+
if (Utils.isLoggedIn(this.user)) {
6882
return <ion-item class="user">
6983
<app-avatar slot="start" src={this.user.photo_url}></app-avatar>
7084
<ion-label>{this.user.name}</ion-label>
@@ -75,7 +89,7 @@ export class AppMenuUser {
7589
}
7690

7791
private renderPresentations() {
78-
if (this.user) {
92+
if (Utils.isLoggedIn(this.user)) {
7993
return [
8094
<ion-item href="/editor" routerDirection="forward">
8195
<ion-icon name="book" slot="start"></ion-icon>
@@ -95,7 +109,7 @@ export class AppMenuUser {
95109
}
96110

97111
private renderSignOut() {
98-
if (this.user) {
112+
if (Utils.isLoggedIn(this.user)) {
99113
return <ion-item button class="signout" onClick={() => this.signOut()}>
100114
<ion-icon name="log-out" slot="start"></ion-icon>
101115
<ion-label>Sign out</ion-label>

0 commit comments

Comments
 (0)