-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
513 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/app/item-detail/share/create-new-share-link/create-new-share-link.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.create-new-link{ | ||
margin-bottom: 1.5rem; | ||
} |
33 changes: 33 additions & 0 deletions
33
src/app/item-detail/share/create-new-share-link/create-new-share-link.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<ng-template #content let-modal> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="modal-basic-title">Add New Link</h5> | ||
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<form [formGroup]="newShareLinkForm" (ngSubmit)="onSubmit()"> | ||
<div class="modal-body"> | ||
<div class="alert alert-primary" role="alert"> | ||
<i class="fas fa-info-circle"> </i> | ||
By sharing this link you will grant anonymous access to this test run. Please add note to your link. | ||
</div> | ||
<p class="text-secondary"></p> | ||
<div class="input-group mb-3"> | ||
<div class="input-group-prepend"> | ||
<span class="input-group-text" id="inputGroup-sizing-default">Note</span> | ||
</div> | ||
<input type="input" class="form-control" formControlName="note" aria-label="Default" aria-describedby="inputGroup-sizing-default"> | ||
</div> | ||
<div class="form-control-feedback" *ngIf="note.errors && (note.dirty || note.touched)"> | ||
<p class="alert alert-danger" *ngIf="note.errors.maxlength">Note is too long.</p> | ||
</div> | ||
</div> | ||
|
||
<div class="modal-footer"> | ||
<button type="submit" class="btn btn-primary">Submit</button> | ||
</div> | ||
</form> | ||
|
||
</ng-template> | ||
|
||
<button class="btn btn-sm jtl-btn-light jtl-no-glow create-new-link" (click)="open(content)">Add new link</button> |
32 changes: 32 additions & 0 deletions
32
src/app/item-detail/share/create-new-share-link/create-new-share-link.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { HttpClientModule } from '@angular/common/http'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ReactiveFormsModule, FormsModule } from '@angular/forms'; | ||
|
||
import { CreateNewShareLinkComponent } from './create-new-share-link.component'; | ||
|
||
describe('CreateNewShareLinkComponent', () => { | ||
let component: CreateNewShareLinkComponent; | ||
let fixture: ComponentFixture<CreateNewShareLinkComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ CreateNewShareLinkComponent ], | ||
imports: [ | ||
ReactiveFormsModule, | ||
FormsModule, | ||
HttpClientModule, | ||
] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(CreateNewShareLinkComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
67 changes: 67 additions & 0 deletions
67
src/app/item-detail/share/create-new-share-link/create-new-share-link.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { FormControl, Validators, FormGroup } from '@angular/forms'; | ||
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { of } from 'rxjs'; | ||
import { catchError } from 'rxjs/internal/operators/catchError'; | ||
import { ItemsApiService } from 'src/app/items-api.service'; | ||
import { ItemsService } from 'src/app/items.service'; | ||
import { NotificationMessage } from 'src/app/notification/notification-messages'; | ||
import { ItemParams } from 'src/app/scenario/item-controls/item-controls.model'; | ||
|
||
|
||
@Component({ | ||
selector: 'app-create-new-share-link', | ||
templateUrl: './create-new-share-link.component.html', | ||
styleUrls: ['./create-new-share-link.component.css'] | ||
}) | ||
export class CreateNewShareLinkComponent implements OnInit { | ||
|
||
private note: FormControl; | ||
private newShareLinkForm: FormGroup; | ||
modal: NgbActiveModal; | ||
@Input() params: ItemParams; | ||
|
||
constructor( | ||
private modalService: NgbModal, | ||
private notification: NotificationMessage, | ||
private itemApiService: ItemsApiService, | ||
private itemService: ItemsService | ||
) { } | ||
|
||
ngOnInit() { | ||
this.createFormControls(); | ||
this.createForm(); | ||
} | ||
|
||
open(content) { | ||
this.modal = this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }); | ||
} | ||
|
||
createFormControls() { | ||
this.note = new FormControl('', [ | ||
Validators.maxLength(100), | ||
Validators.required | ||
]); | ||
} | ||
|
||
createForm() { | ||
this.newShareLinkForm = new FormGroup({ | ||
note: this.note | ||
}); | ||
} | ||
|
||
onSubmit() { | ||
const { note } = this.newShareLinkForm.value; | ||
const { projectName, scenarioName, id } = this.params; | ||
|
||
this.itemApiService.createItemShareToken(projectName, scenarioName, id, { note }) | ||
.pipe(catchError(r => of(r))) | ||
.subscribe(_ => { | ||
const message = this.notification.createItemShareLinkNotification(_); | ||
this.itemApiService.setData(message); | ||
this.itemService.fetchItemShareTokens(projectName, scenarioName, id); | ||
}); | ||
this.newShareLinkForm.reset(); | ||
this.modal.close(); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/app/item-detail/share/delete-share-link/delete-share-link.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.revoke { | ||
margin-left: 10px; | ||
} |
35 changes: 35 additions & 0 deletions
35
src/app/item-detail/share/delete-share-link/delete-share-link.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<ng-template #content let-modal> | ||
<div class="modal-header"> | ||
<h5 class="modal-title" id="modal-basic-title">Delete Share Link</h5> | ||
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<form [formGroup]="deleteShareLinkForm" (ngSubmit)="onSubmit()"> | ||
<div class="modal-body"> | ||
<div class="alert alert-danger" role="alert"> | ||
<i class="fas fa-info-circle"> </i> | ||
By deleting this link you will immediately revoke its access to this test run. | ||
</div> | ||
<p>Please enter 5 random characters to confirm this action:</p> | ||
<div class="input-group mb-3"> | ||
<div class="input-group-prepend"> | ||
<span class="input-group-text" id="inputGroup-sizing-default">Delete check</span> | ||
</div> | ||
<input type="deleteCheck" class="form-control" formControlName="deleteCheck" aria-label="Default" | ||
aria-describedby="inputGroup-sizing-default"> | ||
</div> | ||
<div class="form-control-feedback" *ngIf="deleteCheck.errors && (deleteCheck.dirty || deleteCheck.touched)"> | ||
<p class="alert alert-danger" *ngIf="deleteCheck.errors.minlength">Please enter at least 5 characters...</p> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="submit" class="btn btn-danger">Delete</button> | ||
</div> | ||
</form> | ||
|
||
</ng-template> | ||
|
||
<button class="btn btn-sm jtl-btn-light jtl-no-glow revoke" (click)="open(content)"> | ||
Delete | ||
</button> |
32 changes: 32 additions & 0 deletions
32
src/app/item-detail/share/delete-share-link/delete-share-link.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { HttpClientModule } from '@angular/common/http'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ReactiveFormsModule, FormsModule } from '@angular/forms'; | ||
|
||
import { DeleteShareLinkComponent } from './delete-share-link.component'; | ||
|
||
describe('DeleteShareLinkComponent', () => { | ||
let component: DeleteShareLinkComponent; | ||
let fixture: ComponentFixture<DeleteShareLinkComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ DeleteShareLinkComponent ], | ||
imports: [ | ||
ReactiveFormsModule, | ||
FormsModule, | ||
HttpClientModule | ||
] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DeleteShareLinkComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.