Added in a git merge button

This commit is contained in:
alicia pritchett 2022-02-16 10:41:38 -05:00
parent d5ec33c3bf
commit 22eb4ca0f9
8 changed files with 124 additions and 3 deletions

View File

@ -40,6 +40,7 @@ import { OpenFileDialogComponent } from './_dialogs/open-file-dialog/open-file-d
import { WorkflowSpecCategoryDialogComponent } from './_dialogs/workflow-spec-category-dialog/workflow-spec-category-dialog.component';
import { WorkflowSpecDialogComponent } from './_dialogs/workflow-spec-dialog/workflow-spec-dialog.component';
import { GitRepoDialogComponent} from "./git-repo-dialog/git-repo-dialog.component";
import { GitMergeDialogComponent } from './git-merge-dialog/git-merge-dialog.component';
import { GetIconCodePipe } from './_pipes/get-icon-code.pipe';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
@ -109,6 +110,7 @@ export const getBaseHref = (platformLocation: PlatformLocation): string => platf
ConfirmDialogComponent,
SettingsComponent,
GitRepoDialogComponent,
GitMergeDialogComponent,
],
imports: [
BrowserAnimationsModule,

View File

@ -0,0 +1,16 @@
<div mat-dialog-title>
<h1>Merge Git Repo</h1>
</div>
<form [formGroup]="form">
<formly-form [model]="model" [fields]="fields" [options]="options" [form]="form"></formly-form>
</form>
<div>
<br>
<h5>Would you like to load the merge branch? </h5>
</div>
<div mat-dialog-actions>
<button [disabled]="form.invalid" (click)="onSubmit()" color="primary" mat-flat-button>Save</button>
<button (click)="onNoClick()" mat-flat-button>Cancel</button>
</div>

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { GitMergeDialogComponent } from './git-merge-dialog.component';
describe('GitMergeDialogComponent', () => {
let component: GitMergeDialogComponent;
let fixture: ComponentFixture<GitMergeDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ GitMergeDialogComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(GitMergeDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,57 @@
import { Component, OnInit } from '@angular/core';
import {ApiService} from "../../../../sartography-libraries/dist/sartography-workflow-lib";
import {MatDialogRef} from "@angular/material/dialog";
import {FormGroup} from "@angular/forms";
import {FormlyFieldConfig, FormlyFormOptions} from "@ngx-formly/core";
@Component({
selector: 'app-git-merge-dialog',
templateUrl: './git-merge-dialog.component.html',
styleUrls: ['./git-merge-dialog.component.scss']
})
export class GitMergeDialogComponent {
form: FormGroup = new FormGroup({});
model: any = {};
options: FormlyFormOptions = {};
fields: FormlyFieldConfig[] = [];
constructor(
private api: ApiService,
public dialogRef: MatDialogRef<GitMergeDialogComponent>,
) {
this.api.gitRepo().subscribe(gitRepo => {
this.fields = [
{
key: 'your_branch',
type: 'textarea',
defaultValue: gitRepo.branch,
templateOptions: {
label: 'This is your branch',
rows: 1,
readonly: true,
}
},
{
key: 'merge_branch',
type: 'textarea',
defaultValue: gitRepo.merge_branch,
templateOptions: {
label: 'This is the merge branch',
rows: 1,
readonly: gitRepo.merge_branch != 'all',
}
},
]
});
}
onNoClick() {
this.dialogRef.close();
}
onSubmit() {
this.dialogRef.close(this.model);
}
}

View File

@ -79,7 +79,6 @@ export class GitRepoDialogComponent {
}
onSubmit() {
// I think all we actually will return here is the comment
this.dialogRef.close(this.model);
}

View File

@ -11,6 +11,7 @@
<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>
</div>
<mat-drawer-container class="example-container" autosize>

View File

@ -32,6 +32,7 @@ import { SettingsService } from '../settings.service';
import { MatButtonModule } from '@angular/material/button';
import {GitRepoDialogComponent} from "../git-repo-dialog/git-repo-dialog.component";
import {GitRepo} from "sartography-workflow-lib/lib/types/git";
import {GitMergeDialogComponent} from "../git-merge-dialog/git-merge-dialog.component";
export interface WorkflowSpecCategoryGroup {
@ -58,6 +59,7 @@ export class WorkflowSpecListComponent implements OnInit {
categories: WorkflowSpecCategory[];
searchField: FormControl;
library_toggle: boolean;
merge_branch: string = 'branch'
constructor(
private api: ApiService,
@ -79,6 +81,12 @@ export class WorkflowSpecListComponent implements OnInit {
}
});
this.api.gitRepo().subscribe(gitRepo => {
if (gitRepo.merge_branch && gitRepo.merge_branch != 'all') {
this.merge_branch = gitRepo.merge_branch;
}
})
this.searchField = new FormControl();
this.searchField.valueChanges.subscribe(value => {
this._loadWorkflowSpecs(null, value);
@ -392,11 +400,25 @@ export class WorkflowSpecListComponent implements OnInit {
gitPull() {
this.api.gitRepoPull().subscribe(data => {
});
this._displayMessage(`Successfully pulled the Git state`);
}
gitMerge() {
const dialogRef = this.dialog.open(GitMergeDialogComponent, {
height: '75vh',
width: '40vw',
});
dialogRef.afterClosed().subscribe((data) => {
if (data) {
this.api.gitRepoMerge(data.merge_branch).subscribe(res => {
this._displayMessage('Merged in new branch.');
});
}
});
}
private _updateWorkflowSpec(specId: string, newSpec: WorkflowSpec) {
this.api.updateWorkflowSpecification(specId, newSpec).subscribe(_ => {
this._loadWorkflowLibraries();
@ -448,4 +470,3 @@ export class WorkflowSpecListComponent implements OnInit {
}
}