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

[MOBILEAPPS-1707] Open in App Dialog design changes as per new design and visibility of dialog enabled after the login and is shown in case of private files as well #3225

Merged
merged 13 commits into from
May 26, 2023
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
test cases added for open in app component, shared link view componen…
…t and name changes
jatin2008 committed May 26, 2023
commit a924f91b9dd88306b2c24902a08ef8445a5f4e9e
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { SetSelectedNodesAction } from '@alfresco/aca-shared/store';
import { AppExtensionService } from '@alfresco/aca-shared';
import { AppExtensionService, AppService } from '@alfresco/aca-shared';

describe('SharedLinkViewComponent', () => {
let component: SharedLinkViewComponent;
@@ -41,6 +41,9 @@ describe('SharedLinkViewComponent', () => {
dispatch: jasmine.createSpy('dispatch'),
select: () => of({})
};
const appServiceMock = {
openMobileAppDialog: () => {}
};

beforeEach(() => {
TestBed.configureTestingModule({
@@ -55,6 +58,10 @@ describe('SharedLinkViewComponent', () => {
snapshot: { data: { preferencePrefix: 'prefix' } },
params: of({ id: '123' })
}
},
{
provide: AppService,
useValue: appServiceMock
}
],
schemas: [NO_ERRORS_SCHEMA]
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ export class SharedLinkViewComponent implements OnInit, OnDestroy {
.subscribe(([sharedEntry, sharedId]: [SharedLinkEntry, string]) => {
if (sharedEntry) {
this.store.dispatch(new SetSelectedNodesAction([sharedEntry as any]));
this.appService.getMobileAppDialog();
this.appService.openMobileAppDialog();
}
this.sharedLinkId = sharedId;
});
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
</div>

<div class="download-app-container" *ngIf="appStoreUrl">
<button mat-button class="download-app-button" (click)="downloadIosApp()">
<button mat-button data-automation-id="download-app-button" class="download-app-button" (click)="downloadIosApp()">
<span>{{ 'APP.DIALOGS.MOBILE_APP.DOWNLOAD_APP_BUTTON_LABEL' | translate }}</span>
</button>
</div>
AleksanderSklorz marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
place-content: center;
padding: 8px 24px;
border-radius: 8px;
background-color: #0055b8;
background-color: var(--theme-primary-color);
color: var(--theme-about-panel-background-color);
margin-top: 12px;
}
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ describe('OpenInAppComponent', () => {
imports: [LibTestingModule, SharedModule.forRoot(), MatIconTestingModule],
providers: [
provideMockStore({ initialState }),
{ provide: MAT_DIALOG_DATA, useValue: { redirectUrl: 'mockRedirectUrl' } },
{ provide: MAT_DIALOG_DATA, useValue: { redirectUrl: 'mockRedirectUrl', appStoreUrl: 'mockAppStoreUrl' } },
{ provide: MatDialogRef, useValue: mockDialogRef }
]
});
@@ -78,4 +78,22 @@ describe('OpenInAppComponent', () => {
expect(sessionStorage.getItem('mobile_notification_expires_in')).not.toBeNull();
expect(mockDialogRef.close).toHaveBeenCalled();
});

it('should redirect to App Store for downloading the app in case of Ios device', async () => {
let currentLocation: string | string[];
const windowStub: Window & typeof globalThis = {
location: {
set href(value: string | string[]) {
currentLocation = value;
}
}
} as Window & typeof globalThis;
component.window = windowStub;
const downloadAppButton = fixture.debugElement.query(By.css('[data-automation-id="download-app-button"]')).nativeElement;
downloadAppButton.dispatchEvent(new Event('click'));
fixture.detectChanges();
await fixture.whenStable();

expect(currentLocation).toBe('mockAppStoreUrl');
});
});
Original file line number Diff line number Diff line change
@@ -24,7 +24,6 @@

import { Component, Inject, ViewEncapsulation } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { AcaMobileAppSwitcherService } from '../../services/aca-mobile-app-switcher.service';

export interface OpenInAppDialogOptions {
redirectUrl: string;
@@ -44,8 +43,7 @@ export class OpenInAppComponent {
constructor(
@Inject(MAT_DIALOG_DATA)
public data: OpenInAppDialogOptions,
private dialog: MatDialogRef<OpenInAppComponent>,
private acaMobileAppSwitcherService: AcaMobileAppSwitcherService
private dialog: MatDialogRef<OpenInAppComponent>
) {
if (data) {
this.redirectUrl = data.redirectUrl;
@@ -67,6 +65,5 @@ export class OpenInAppComponent {
const time: number = new Date().getTime();
sessionStorage.setItem('mobile_notification_expires_in', time.toString());
this.dialog.close();
this.acaMobileAppSwitcherService.isDialogEnable = false;
}
}
Original file line number Diff line number Diff line change
@@ -43,7 +43,6 @@ export class AcaMobileAppSwitcherService {
public redirectUrl: string;
public appStoreUrl: string;
dialogRef: MatDialogRef<OpenInAppComponent>;
DenysVuika marked this conversation as resolved.
Show resolved Hide resolved
isDialogEnable = false;

constructor(private config: AppConfigService, private dialog: MatDialog) {
this.mobileAppSwitchConfig = this.config.get<MobileAppSwitchConfigurationOptions>('mobileAppSwitch');
@@ -99,7 +98,7 @@ export class AcaMobileAppSwitcherService {
}

openDialog(redirectUrl: string, appStoreUrl?: string): void {
if (!this.isDialogEnable) {
if (this.dialogRef === null || this.dialogRef === undefined) {
AleksanderSklorz marked this conversation as resolved.
Show resolved Hide resolved
this.dialogRef = this.dialog.open(OpenInAppComponent, {
data: {
redirectUrl,
@@ -110,7 +109,6 @@ export class AcaMobileAppSwitcherService {
role: 'dialog',
position: { bottom: '0' }
});
this.isDialogEnable = true;
}
}

@@ -124,6 +122,6 @@ export class AcaMobileAppSwitcherService {

closeDialog(): void {
this.dialog.closeAll();
this.isDialogEnable = false;
this.dialogRef = null;
}
}
4 changes: 2 additions & 2 deletions projects/aca-shared/src/lib/services/app.service.ts
Original file line number Diff line number Diff line change
@@ -168,7 +168,7 @@ export class AppService implements OnDestroy {
if (isReady) {
this.loadRepositoryStatus();
this.loadUserProfile();
this.getMobileAppDialog();
this.openMobileAppDialog();
}
});

@@ -265,7 +265,7 @@ export class AppService implements OnDestroy {
document.head.appendChild(cssLinkElement);
}

public getMobileAppDialog(): void {
public openMobileAppDialog(): void {
const isMobileSwitchEnabled: boolean = this.config.get<boolean>('mobileAppSwitch.enabled', false);
if (isMobileSwitchEnabled) {
this.acaMobileAppSwitcherService.resolveExistenceOfDialog();