Git repo dialog component

This commit is contained in:
alicia pritchett 2022-02-15 08:22:33 -05:00
parent ce022dfce5
commit cbbccc77d2
5 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,12 @@
<div mat-dialog-title>
<h1>Git Repo</h1>
</div>
<form [formGroup]="form">
<formly-form [model]="model" [fields]="fields" [options]="options" [form]="form"></formly-form>
</form>
<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 { GitRepoDialogComponent } from './git-repo-dialog.component';
describe('GitRepoDialogComponent', () => {
let component: GitRepoDialogComponent;
let fixture: ComponentFixture<GitRepoDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ GitRepoDialogComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(GitRepoDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,60 @@
import { Component, OnInit } from '@angular/core';
import {FormGroup} from "@angular/forms";
import {FormlyFieldConfig, FormlyFormOptions} from "@ngx-formly/core";
import {MatDialogRef} from "@angular/material/dialog";
import {ApiService} from 'sartography-workflow-lib';
@Component({
selector: 'app-git-repo-dialog',
templateUrl: './git-repo-dialog.component.html',
styleUrls: ['./git-repo-dialog.component.scss']
})
export class GitRepoDialogComponent {
form: FormGroup = new FormGroup({});
model: any = {};
options: FormlyFormOptions = {};
fields: FormlyFieldConfig[] = [];
constructor(
private api: ApiService,
public dialogRef: MatDialogRef<GitRepoDialogComponent>,
) {
this.api.gitRepo().subscribe(data => {
let mockChanges = ['file1', 'file2']
this.fields = [
{
key: 'changed',
type: 'select',
templateOptions: {
multiple: true,
label: 'These are the changed files',
rows: 5,
options: this.listify(mockChanges),
}
}
]
});
}
listify(list: string[]) {
let dict = []
for (let item in list) {
dict.push({label: list[item], value: item});
}
return dict;
}
onNoClick() {
console.log('form model : ', this.model);
this.dialogRef.close();
}
onSubmit() {
// I think all we actually will return here is the comment
this.dialogRef.close(this.model);
}
}

View File

@ -30,6 +30,7 @@ import { environment } from '../../environments/environment.runtime';
import { FormControl } from '@angular/forms';
import { SettingsService } from '../settings.service';
import { MatButtonModule } from '@angular/material/button';
import {GitRepoDialogComponent} from "../git-repo-dialog/git-repo-dialog.component";
export interface WorkflowSpecCategoryGroup {
@ -375,10 +376,23 @@ export class WorkflowSpecListComponent implements OnInit {
// get the state of the repo
this.api.gitRepo().subscribe(data =>{
});
const dialogRef = this.dialog.open(GitRepoDialogComponent, {
height: '65vh',
width: '50vw',
});
// display to user the changed files
let comment = '';
let branch = 'dan'; // I think this can be set from the gitrepo call above
/**
// if they accept, call gitPush and gitMerge (i think)
this.api.gitRepoPush(comment).subscribe(data => {
this.api.gitRepoMerge(branch).subscribe(merge => {
});
});
*/
}
gitPull() {