Add in differing buttons for differing environments (branches)
and fix tests
This commit is contained in:
parent
f96e23c8ec
commit
bff86487b2
|
@ -1,17 +1,63 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
|
||||
|
||||
import { GitMergeDialogComponent } from './git-merge-dialog.component';
|
||||
import {HttpClientTestingModule, HttpTestingController} from "@angular/common/http/testing";
|
||||
import {BrowserAnimationsModule, NoopAnimationsModule} from "@angular/platform-browser/animations";
|
||||
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
|
||||
import {MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef} from "@angular/material/dialog";
|
||||
import {MatFormFieldModule} from "@angular/material/form-field";
|
||||
import {MatIconModule} from "@angular/material/icon";
|
||||
import {MatInputModule} from "@angular/material/input";
|
||||
import {RouterTestingModule} from "@angular/router/testing";
|
||||
import {OpenFileDialogComponent} from "../_dialogs/open-file-dialog/open-file-dialog.component";
|
||||
import {ApiService, MockEnvironment} from "../../../../sartography-libraries/dist/sartography-workflow-lib";
|
||||
import {APP_BASE_HREF} from "@angular/common";
|
||||
import {Router} from "@angular/router";
|
||||
|
||||
describe('GitMergeDialogComponent', () => {
|
||||
let component: GitMergeDialogComponent;
|
||||
let fixture: ComponentFixture<GitMergeDialogComponent>;
|
||||
const mockRouter = {navigate: jasmine.createSpy('navigate')};
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ GitMergeDialogComponent ]
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
BrowserAnimationsModule,
|
||||
FormsModule,
|
||||
HttpClientTestingModule,
|
||||
MatDialogModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
NoopAnimationsModule,
|
||||
ReactiveFormsModule,
|
||||
RouterTestingModule,
|
||||
],
|
||||
declarations: [ OpenFileDialogComponent ],
|
||||
providers: [
|
||||
ApiService,
|
||||
{provide: 'APP_ENVIRONMENT', useClass: MockEnvironment},
|
||||
{provide: APP_BASE_HREF, useValue: ''},
|
||||
{
|
||||
provide: MatDialogRef,
|
||||
useValue: {
|
||||
close: (dialogResult: any) => {
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
provide: MatDialog,
|
||||
useValue: {
|
||||
close: (dialogResult: any) => {
|
||||
}
|
||||
}
|
||||
},
|
||||
{provide: MAT_DIALOG_DATA, useValue: []},
|
||||
{provide: Router, useValue: mockRouter},
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(GitMergeDialogComponent);
|
||||
|
|
|
@ -1,17 +1,64 @@
|
|||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
|
||||
|
||||
import { GitRepoDialogComponent } from './git-repo-dialog.component';
|
||||
import {BrowserAnimationsModule, NoopAnimationsModule} from "@angular/platform-browser/animations";
|
||||
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
|
||||
import {HttpClientTestingModule} from "@angular/common/http/testing";
|
||||
import {MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef} from "@angular/material/dialog";
|
||||
import {MatFormFieldModule} from "@angular/material/form-field";
|
||||
import {MatIconModule} from "@angular/material/icon";
|
||||
import {MatInputModule} from "@angular/material/input";
|
||||
import {RouterTestingModule} from "@angular/router/testing";
|
||||
import {OpenFileDialogComponent} from "../_dialogs/open-file-dialog/open-file-dialog.component";
|
||||
import {ApiService, MockEnvironment} from "../../../../sartography-libraries/dist/sartography-workflow-lib";
|
||||
import {APP_BASE_HREF} from "@angular/common";
|
||||
import {Router} from "@angular/router";
|
||||
|
||||
describe('GitRepoDialogComponent', () => {
|
||||
let component: GitRepoDialogComponent;
|
||||
let fixture: ComponentFixture<GitRepoDialogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ GitRepoDialogComponent ]
|
||||
const mockRouter = {navigate: jasmine.createSpy('navigate')};
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
BrowserAnimationsModule,
|
||||
FormsModule,
|
||||
HttpClientTestingModule,
|
||||
MatDialogModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
NoopAnimationsModule,
|
||||
ReactiveFormsModule,
|
||||
RouterTestingModule,
|
||||
],
|
||||
declarations: [ OpenFileDialogComponent ],
|
||||
providers: [
|
||||
ApiService,
|
||||
{provide: 'APP_ENVIRONMENT', useClass: MockEnvironment},
|
||||
{provide: APP_BASE_HREF, useValue: ''},
|
||||
{
|
||||
provide: MatDialogRef,
|
||||
useValue: {
|
||||
close: (dialogResult: any) => {
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
provide: MatDialog,
|
||||
useValue: {
|
||||
close: (dialogResult: any) => {
|
||||
}
|
||||
}
|
||||
},
|
||||
{provide: MAT_DIALOG_DATA, useValue: []},
|
||||
{provide: Router, useValue: mockRouter},
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(GitRepoDialogComponent);
|
||||
|
|
|
@ -8,10 +8,20 @@
|
|||
<label><input matInput type="search" placeholder="Search Workflows" fxLayoutAlign="start" style="margin-top: 0;" class="form-control" [formControl]="searchField"></label>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayoutAlign="end center" fxLayoutGap="5px">
|
||||
<button mat-raised-button color="accent" (click)="gitPush()" >Push</button>
|
||||
<button mat-raised-button color="accent" (click)="gitPull()"> Pull</button>
|
||||
<button mat-raised-button color="primary" (click)="gitMerge()"> Merge from {{merge_branch}}</button>
|
||||
<div fxLayoutAlign="end center" fxLayoutGap="5px" *ngIf="branch === 'testing'">
|
||||
<button mat-raised-button color="accent" (click)="gitPush()" >Publish</button>
|
||||
</div>
|
||||
<div fxLayoutAlign="end center" fxLayoutGap="5px" *ngIf="branch === 'staging'">
|
||||
<button mat-raised-button color="accent" (click)="gitPush()" >Publish</button>
|
||||
<button mat-raised-button color="primary" (click)="gitMerge(true)"> Pull Testing State</button>
|
||||
</div>
|
||||
<div fxLayoutAlign="end center" fxLayoutGap="5px" *ngIf="branch === 'production'">
|
||||
<button mat-raised-button color="accent" (click)="gitMerge(true)"> Pull Staging State</button>
|
||||
</div>
|
||||
<div fxLayoutAlign="end center" fxLayoutGap="5px" *ngIf="branch !=='production' && branch !=='staging' && branch !=='testing'">
|
||||
<button mat-raised-button color="accent" (click)="gitPush()" >Push</button>
|
||||
<button mat-raised-button color="accent" (click)="gitPull()"> Pull</button>
|
||||
<button mat-raised-button color="primary" (click)="gitMerge(false)"> Merge </button>
|
||||
</div>
|
||||
</div>
|
||||
<mat-drawer-container class="example-container" autosize>
|
||||
|
|
|
@ -137,6 +137,9 @@ describe('WorkflowSpecListComponent', () => {
|
|||
specReq.flush(mockWorkflowSpecs);
|
||||
fixture.detectChanges();
|
||||
expect(component.workflowSpecs.length).toBeGreaterThan(0);
|
||||
|
||||
const gitReq = httpMock.expectOne('apiRoot/git_repo');
|
||||
expect(gitReq.request.method).toEqual('GET');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
|
|
@ -6,7 +6,6 @@ import { cloneDeep } from 'lodash';
|
|||
import {
|
||||
ApiErrorsComponent,
|
||||
ApiService,
|
||||
isNumberDefined,
|
||||
// moveArrayElementDown,
|
||||
// moveArrayElementUp,
|
||||
WorkflowSpec,
|
||||
|
@ -60,6 +59,7 @@ export class WorkflowSpecListComponent implements OnInit {
|
|||
searchField: FormControl;
|
||||
library_toggle: boolean;
|
||||
merge_branch: string = 'branch'
|
||||
branch: string = 'branch'
|
||||
|
||||
constructor(
|
||||
private api: ApiService,
|
||||
|
@ -82,9 +82,12 @@ export class WorkflowSpecListComponent implements OnInit {
|
|||
});
|
||||
|
||||
this.api.gitRepo().subscribe(gitRepo => {
|
||||
if (gitRepo.merge_branch && gitRepo.merge_branch != 'all') {
|
||||
if (gitRepo.merge_branch) {
|
||||
this.merge_branch = gitRepo.merge_branch;
|
||||
}
|
||||
if (gitRepo.branch) {
|
||||
this.branch = gitRepo.branch;
|
||||
}
|
||||
})
|
||||
|
||||
this.searchField = new FormControl();
|
||||
|
@ -109,9 +112,11 @@ export class WorkflowSpecListComponent implements OnInit {
|
|||
}
|
||||
|
||||
setCatByID(cat_id: string) {
|
||||
this.api.getWorkflowSpecCategory(cat_id).subscribe( cat => {
|
||||
this.selectedCat = cat;
|
||||
})
|
||||
if (cat_id) {
|
||||
this.api.getWorkflowSpecCategory(cat_id).subscribe(cat => {
|
||||
this.selectedCat = cat;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
isSelected(cat: WorkflowSpecCategoryGroup) {
|
||||
|
@ -129,7 +134,7 @@ export class WorkflowSpecListComponent implements OnInit {
|
|||
|
||||
editWorkflowSpec(state: String, selectedSpec?: WorkflowSpec) {
|
||||
|
||||
const hasDisplayOrder = selectedSpec && isNumberDefined(selectedSpec.display_order);
|
||||
const hasDisplayOrder = selectedSpec && selectedSpec.display_order;
|
||||
const dialogData: WorkflowSpecDialogData = {
|
||||
id: selectedSpec ? selectedSpec.id : '',
|
||||
display_name: selectedSpec ? selectedSpec.display_name : '',
|
||||
|
@ -246,9 +251,13 @@ export class WorkflowSpecListComponent implements OnInit {
|
|||
editCategoryDisplayOrder(catId: string, direction: string) {
|
||||
this.api.reorderWorkflowCategory(catId, direction).subscribe(cat_change => {
|
||||
this.workflowSpecsByCategory = this.workflowSpecsByCategory.map(cat => {
|
||||
let new_cat = (cat_change.find(i2 => i2.id === cat.id));
|
||||
cat.display_order = new_cat.display_order;
|
||||
return cat;
|
||||
if (typeof cat_change.find == 'function') {
|
||||
let new_cat = cat_change.find(i2 => i2.id === cat.id);
|
||||
cat.display_order = new_cat.display_order;
|
||||
return cat;
|
||||
} else {
|
||||
return cat;
|
||||
}
|
||||
});
|
||||
this.workflowSpecsByCategory.sort((x,y) => x.display_order - y.display_order);
|
||||
});
|
||||
|
@ -404,7 +413,7 @@ export class WorkflowSpecListComponent implements OnInit {
|
|||
this._displayMessage(`Successfully pulled the Git state`);
|
||||
}
|
||||
|
||||
gitMerge() {
|
||||
gitMerge(pull?: boolean) {
|
||||
const dialogRef = this.dialog.open(GitMergeDialogComponent, {
|
||||
height: '75vh',
|
||||
width: '40vw',
|
||||
|
@ -416,6 +425,9 @@ export class WorkflowSpecListComponent implements OnInit {
|
|||
this._displayMessage('Merged in new branch.');
|
||||
});
|
||||
}
|
||||
if (pull) {
|
||||
this.gitPull();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue