Skip to content

Commit

Permalink
Merge pull request #468 from PermanentOrg/PER-9863-create-archive-for…
Browse files Browse the repository at this point in the history
…-me-2-archives

PER-9863: Create archive for me - 2 archives
  • Loading branch information
crisnicandrei authored Oct 16, 2024
2 parents 25395f7 + ebf2a95 commit f6b1bff
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,18 @@ <h2>Lastly, we’re curious -- what brought you to Permanent.org?</h2>
<button
(click)="onSubmit()"
class="btn btn-primary next-button create-archive"
[disabled]="!selectedReasons.length || loading"
[disabled]="!selectedReasons.length || loading || isArchiveSubmitted"
>
Create my archive
</button>
</div>
</div>
<div *ngIf="!isGlam && screen !== 'create' && screen !== 'name-archive'">
<button (click)="skipStep()" class="btn btn-link">Skip this step</button>
<button
[disabled]="isArchiveSubmitted"
(click)="skipStep()"
class="btn btn-link skip-step"
>
Skip this step
</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,18 @@ describe('CreateNewArchiveComponent #onboarding', () => {

expect(button.disabled).toBe(true);
});

it('should disable the Skip This Step and submit buttons when the archive has been submitted', async () => {
const { find, instance, fixture } = await shallow.render();
instance.screen = 'reasons';
instance.isArchiveSubmitted = true;

fixture.detectChanges();
const submitButton = find('.create-archive').nativeElement;

const skipStepButton = find('.skip-step').nativeElement;

expect(submitButton.disabled).toBe(true);
expect(skipStepButton.disabled).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class CreateNewArchiveComponent implements OnInit {
public archiveName: string = '';
public screen: NewArchiveScreen = 'start';
public loading: boolean = false;
public isArchiveSubmitted: boolean = false;
public selectedGoals: string[] = [];
public selectedReasons: string[] = [];
public selectedValue: string = '';
Expand Down Expand Up @@ -153,6 +154,7 @@ export class CreateNewArchiveComponent implements OnInit {
public async onSubmit(): Promise<void> {
try {
this.loading = true;
this.isArchiveSubmitted = true;
const fullName = this.name;
const archive = new ArchiveVO({
fullName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
[variant]="'secondary'"
[icon]="'/accept'"
[size]="'fill'"
[disabled]="isArchiveSubmitted"
(buttonClick)="finalizeArchive()"
>Done</pr-button
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,14 @@ describe('FinalizeArchiveCreationScreenComponent', () => {

expect(instance.finalizeArchive).toHaveBeenCalled();
});

it('should disable the done button when it is clicked', async () => {
const { instance, fixture, find } = await shallow.render();
const doneButton = find('pr-button');
doneButton.triggerEventHandler('buttonClick', null);

fixture.detectChanges();

expect(instance.isArchiveSubmitted).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import { Component, Input, Output, EventEmitter } from '@angular/core';
export class FinalizeArchiveCreationScreenComponent {
@Input() name: string = '';
@Output() finalizeArchiveOutput = new EventEmitter<string>();
public isArchiveSubmitted: boolean = false;

finalizeArchive() {
this.isArchiveSubmitted = true;
this.finalizeArchiveOutput.emit();
}
}

0 comments on commit f6b1bff

Please sign in to comment.