Skip to content

Commit

Permalink
feat(TestProject Import): Adds TestProject Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
manikanta-reddy-t committed Dec 19, 2022
1 parent 0be81ec commit f66fb6d
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Integrations find(Long id)
* @return
*/
public void destroy(Long id) throws IntegrationNotFoundException {
Optional<Integrations> config = integrationsRepository.findById(id);
Optional<Integrations> config = integrationsRepository.findByWorkspaceId(id);
if (!config.isPresent()) {
throw new IntegrationNotFoundException("EXTERNAL APPLICATION CONFIG NOT FOUND");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[ngClass]="activeTab== TESTSIGMA_IMPORT ? 'border-active-b-4' : 'border-white-b-4' "
[translate]="'import.form.title'">
</div>
<div
<div *ngIf="hasTestProject"
class="theme-overlay-title px-16 h-100 d-flex align-items-center"
(click)="activeTab = TEST_PROJECT_IMPORT"
[ngClass]="activeTab== TEST_PROJECT_IMPORT ? 'border-active-b-4' : 'border-white-b-4' "
Expand Down Expand Up @@ -186,8 +186,8 @@
(click)="import()"
[disabled]="isSaving"
class="theme-btn-primary"
type="button"
[translate]="isSaving ? 'Please wait...' : 'btn.common.import'">
type="button">
{{isSaving ? 'Please wait...' : 'Import'}}
</button>
</div>
</div>
17 changes: 15 additions & 2 deletions ui/src/app/components/webcomponents/import-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {WorkspaceService} from "../../services/workspace.service";
import {WorkspaceVersionService} from "../../shared/services/workspace-version.service";
import {ToastrService} from "ngx-toastr";
import {ImportGuideLinesWarningComponent} from "./import-guide-lines-warning.component";
import {IntegrationsService} from "../../shared/services/integrations.service";
import {Integrations} from "../../shared/models/integrations.model";

@Component({
selector: 'import-form-component',
Expand Down Expand Up @@ -50,6 +52,7 @@ export class ImportFormComponent extends BaseComponent implements OnInit {
public TEST_PROJECT_IMPORT = 'testProject'

public activeTab: string = this.TESTSIGMA_IMPORT ;
public integration:Integrations[];


constructor(
Expand All @@ -62,6 +65,7 @@ export class ImportFormComponent extends BaseComponent implements OnInit {
public notificationsService: NotificationsService,
public translate: TranslateService,
public toastrService: ToastrService,
public integrationsService : IntegrationsService,
@Inject(MAT_DIALOG_DATA) public option: { filterId: Number, workspaceVersionId: Number },
public dialogRef: MatDialogRef<ImportFormComponent>) {
super(authGuard, notificationsService, translate, toastrService);
Expand All @@ -70,6 +74,9 @@ export class ImportFormComponent extends BaseComponent implements OnInit {
ngOnInit() {
this.fetchApplications();
this.addControllers()
this.integrationsService.findAll().subscribe((res)=>{
this.integration = res;
})
}

addControllers() {
Expand Down Expand Up @@ -251,7 +258,13 @@ export class ImportFormComponent extends BaseComponent implements OnInit {
this.uploadedFileObject = null;
}

changeSavingStatus(value: boolean) {
this.isSaving = value;
changeSavingStatus(value: any) {
this.isSaving = value['button'];
if(value['closeDialog'])
this.dialogRef.close();
}

get hasTestProject(){
return this.integration.find((data)=>data.isTestProject)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {AuthenticationGuard} from "../../shared/guards/authentication.guard";
import {NotificationsService, NotificationType} from "angular2-notifications";
import {TranslateService} from "@ngx-translate/core";
import {BackupService} from "../../settings/services/backup.service";
import {ToastrService} from "ngx-toastr";

@Component({
selector: 'app-test-project-import',
Expand All @@ -15,17 +16,18 @@ import {BackupService} from "../../settings/services/backup.service";
})
export class TestProjectImportComponent extends BaseComponent implements OnInit {

@Output() onImportClick : EventEmitter<boolean> = new EventEmitter<boolean>();
@Output() onImportClick : EventEmitter<any > = new EventEmitter<any>();
public formGroup: FormGroup;
public uploadedFileObject : any;
public importType : string = "YAML";
constructor(
public authGuard : AuthenticationGuard,
public notificationsService : NotificationsService,
public translate : TranslateService,
private backupService : BackupService
private backupService : BackupService,
public toastService :ToastrService,
) {
super(authGuard, notificationsService, translate)
super(authGuard, notificationsService, translate, toastService)
}

ngOnInit(): void {
Expand Down Expand Up @@ -69,12 +71,12 @@ export class TestProjectImportComponent extends BaseComponent implements OnInit
}

postData(formData : FormData){
this.onImportClick.emit(true);
this.onImportClick.emit({button: true});
this.backupService.importFromTestProject(formData).subscribe(() => {
this.onImportClick.emit(false);
this.onImportClick.emit({button:false, closeDialog : true});
this.showNotification(NotificationType.Success, 'Imported Successfully, Please check Projects Section')
}, error => {
this.onImportClick.emit(false);
this.onImportClick.emit({button: false});
this.showNotification(NotificationType.Error, 'Error while importing from Test Project, Please contact Support')
console.log("Error while Sending Request to Import from Test Project");
})
Expand Down
17 changes: 17 additions & 0 deletions ui/src/app/settings/components/plugins/list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,5 +382,22 @@
<div class="item-text" [translate]="'plugins.description.code_ship'"></div>
</div>
</div>

<div class="white-border-container" *ngIf="testLab || all">
<div class="item-content">
<div class="d-flex align-items-center">
<div class="ts-col-20 test-project sm-h"></div>
<div class="item-title-text" [translate]="'plugins.test_project'"></div>
</div>
<div class="item-text" [translate]="'plugins.test_project_report'"></div>
<div class="item-action">
<mat-slide-toggle
class="mat-slide-toggle ml-auto slide-with-text"
[checked]="!!testProject"
(change)="toggleApplication($event, Integration.TestProjectImport, testProject)">
</mat-slide-toggle>
</div>
</div>
</div>
</div>
</div>
23 changes: 21 additions & 2 deletions ui/src/app/settings/components/plugins/list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class ListComponent extends BaseComponent implements OnInit {
public translate: TranslateService,
public toastrService: ToastrService,
public router: Router,
private externalApplicationConfig: IntegrationsService,
private integrationsService: IntegrationsService,
private matModal: MatDialog) {
super(authGuard, notificationsService, translate, toastrService);
}
Expand Down Expand Up @@ -117,13 +117,17 @@ export class ListComponent extends BaseComponent implements OnInit {
return this.plugins.find(plug => plug.isPrivateLab);
}

get testProject(){
return this.plugins.find(plug => plug.isTestProject);
}

ngOnInit(): void {
this.fetchPlugins();
this.pushToParent(this.route, this.route.params);
}

fetchPlugins() {
this.externalApplicationConfig.findAll().subscribe(data => {
this.integrationsService.findAll().subscribe(data => {
this.plugins = data;
}, error => console.log(error));
}
Expand All @@ -133,6 +137,21 @@ export class ListComponent extends BaseComponent implements OnInit {
this.router.navigate(['/settings', 'testsigma']);
return;
}
if(integration == Integration.TestProjectImport) {
let integrations:Integrations = new Integrations();
integrations.name = integration
integrations.workspaceId = (Object.keys(Integration).indexOf(integration) + 1);
integrations.url = integration;
integrations.username = integration;
integrations.password = integration;
if(event.checked){
this.integrationsService.create(integrations).subscribe(res => console.log(res))
console.log(event)
} else {
this.integrationsService.delete(integrations.workspaceId).subscribe();
}
return;
}
if (event.source.checked)
this.create(event, integration);
else
Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/shared/enums/integration.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ export enum Integration {
TestsigmaLab = "TestsigmaLab",
ClickUp = 'ClickUp',
PrivateGrid = 'PrivateGrid',
XrayCloud = "XrayCloud"
XrayCloud = "XrayCloud",
TestProjectImport = "TestProjectImport",
}
4 changes: 4 additions & 0 deletions ui/src/app/shared/models/integrations.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,8 @@ export class Integrations extends Base implements PageObject {
get isClickUp(): Boolean {
return this.workspace == Integration.ClickUp;
}

get isTestProject():Boolean {
return this.workspace == Integration.TestProjectImport;
}
}
2 changes: 2 additions & 0 deletions ui/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,8 @@
"plugins.private_lab.description": "Connect to your Private Selenium Grid Lab / Appium Grid account as your test lab on cloud.",
"plugins.jenkins": "Jenkins",
"plugins.code_ship": "CodeShip CI",
"plugins.test_project": "TestProject",
"plugins.test_project_report": "Import project from TestProject",
"step.action.label": "Natural Language",
"step.group.label": "Step Group",
"step.rest.label": "RESTful API",
Expand Down
Binary file added ui/src/assets/images/test_project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions ui/src/scss/_images.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1243,3 +1243,9 @@
@extend .resizeable-image;
background-image: url("~assets/images/google_cloud.svg");
}

.test-project{
@extend .resizeable-image;
background-image: url("~assets/images/test_project.png");
}

0 comments on commit f66fb6d

Please sign in to comment.