Skip to content

Commit

Permalink
9422-email-domains-interstitial-oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
leomendoza123 committed Nov 4, 2024
1 parent b800d34 commit 2503b53
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 25 deletions.
21 changes: 13 additions & 8 deletions src/app/authorize/pages/authorize/authorize.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Inject } from '@angular/core'
import { cloneDeep } from 'lodash'
import { first, tap } from 'rxjs/operators'
import { first, take, tap } from 'rxjs/operators'
import { PlatformInfo, PlatformInfoService } from 'src/app/cdk/platform-info'
import { WINDOW } from 'src/app/cdk/window'
import { UserService } from 'src/app/core'
Expand Down Expand Up @@ -45,9 +45,12 @@ export class AuthorizeComponent {
}

ngOnInit() {
this._togglz.getStateOf('OAUTH_DOMAINS_INTERSTITIAL').subscribe((value) => {
this.oauthDomainsInterstitialEnabled = value
})
this._togglz
.getStateOf('OAUTH_DOMAINS_INTERSTITIAL')
.pipe(take(1))
.subscribe((value) => {
this.oauthDomainsInterstitialEnabled = value
})
this._recordEmails
.getEmails()
.pipe(
Expand All @@ -61,13 +64,15 @@ export class AuthorizeComponent {
}

userHasPrivateEmails(value: EmailsEndpoint): boolean {
return !!value.emailDomains.find(
(domain) => domain.visibility !== 'PUBLIC'
)
return !!value.emailDomains.find((domain) => domain.visibility !== 'PUBLIC')
}

handleRedirect(url: string) {
if (url && this.userHasPrivateDomains && this.oauthDomainsInterstitialEnabled) {
if (
url &&
this.userHasPrivateDomains &&
this.oauthDomainsInterstitialEnabled
) {
this.redirectUrl = url
this.showAuthorizationComponent = false
this.showInterstital = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@
<div formArrayName="items" class="items">
<div
*ngFor="
let item of this.form.controls.items.controls;
let item of this.form.controls?.items?.controls;
let i = index;
let last = last
"
[formGroupName]="i"
>
<!-- Material Checkbox with item email/value as a label -->
<div class="checkbox-wrapper">
<mat-checkbox formControlName="selected">
{{ item.get('email').value }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing'

import { ShareEmailsDomainsComponent } from './share-emails-domains.component';
import { ShareEmailsDomainsComponent } from './share-emails-domains.component'
import { FormBuilder, FormControl, FormGroup } from '@angular/forms'
import { RecordEmailsService } from 'src/app/core/record-emails/record-emails.service'
import { PlatformInfoService } from '../../platform-info'

describe('ShareEmailsDomainsComponent', () => {
let component: ShareEmailsDomainsComponent;
let fixture: ComponentFixture<ShareEmailsDomainsComponent>;
let component: ShareEmailsDomainsComponent
let fixture: ComponentFixture<ShareEmailsDomainsComponent>

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ShareEmailsDomainsComponent]
});
fixture = TestBed.createComponent(ShareEmailsDomainsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
declarations: [ShareEmailsDomainsComponent],
providers: [
{
provide: PlatformInfoService,
useValue: {},
},
{
provide: FormBuilder,
useValue: {
array: () => [new FormControl({})],
group: () => new FormGroup({}),
},
},
{
provide: RecordEmailsService,
useValue: {},
},
],
})
fixture = TestBed.createComponent(ShareEmailsDomainsComponent)
component = fixture.componentInstance
fixture.detectChanges()
})

it('should create', () => {
expect(component).toBeTruthy();
});
});
expect(component).toBeTruthy()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ export class ShareEmailsDomainsComponent {
)
this.form = this.fb.group({
items: this.fb.array(
this.userPrivateDomains.map((item) => this.createItemFormGroup(item))
this.userPrivateDomains?.map((item) => this.createItemFormGroup(item))
),
})
}

getTop3MostRecentPrivateDomains(
value: EmailsEndpoint
): AssertionVisibilityString[] {
return value.emailDomains
return value?.emailDomains
.filter((domain) => domain.visibility !== 'PUBLIC')
.sort((a, b) => {
return b.createdDate.timestamp - a.createdDate.timestamp
Expand Down

0 comments on commit 2503b53

Please sign in to comment.