-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support to configure metadata gcs bucket (#835)
* feat: add support to configure metadata gcs bucket * test * comment changes * comment changes
- Loading branch information
1 parent
934e2b1
commit a094afc
Showing
14 changed files
with
296 additions
and
17 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
ui/dist/ui/main.1daed8e0cd5047a7.js → ui/dist/ui/main.81646f03b744d0b8.js
Large diffs are not rendered by default.
Oops, something went wrong.
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
27 changes: 27 additions & 0 deletions
27
ui/src/app/components/gcs-metadata-details-form/gcs-metadata-details-form.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,27 @@ | ||
<div mat-dialog-content> | ||
<form [formGroup]="gcsMetadataDetailsForm" class="gcs-metadata-detail-form"> | ||
<h2>GCS Metadata Storage<mat-icon class="configure" | ||
matTooltip='Specify existing or new GCS path to store metadata for migration'> | ||
info</mat-icon></h2> | ||
|
||
<mat-form-field class="full-width" appearance="outline"> | ||
<mat-label>GCS Bucket Name</mat-label> | ||
<input matInput placeholder="GCS Bucket Name" type="text" formControlName="gcsName" | ||
ng-value="TargetDetails.GcsMetadataName" /> | ||
</mat-form-field> | ||
<br> | ||
<mat-form-field class="full-width" appearance="outline"> | ||
<mat-label>Path Prefix</mat-label> | ||
<input matInput placeholder="Path Prefix" type="text" formControlName="gcsRootPath" | ||
ng-value="TargetDetails.GcsMetadataRootPath" /> | ||
</mat-form-field> | ||
<br> | ||
</form> | ||
<div mat-dialog-actions class="buttons-container"> | ||
<button mat-button color="primary" mat-dialog-close>Cancel</button> | ||
<button mat-button type="submit" color="primary" [disabled]="!(gcsMetadataDetailsForm.valid)" | ||
(click)="updateGcsPathMetadataDetails()"> | ||
Save | ||
</button> | ||
</div> | ||
</div> |
Empty file.
56 changes: 56 additions & 0 deletions
56
ui/src/app/components/gcs-metadata-details-form/gcs-metadata-details-form.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,56 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ReactiveFormsModule } from '@angular/forms'; | ||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
import { MatSnackBarModule } from '@angular/material/snack-bar'; | ||
import { GcsMetadataDetailsFormComponent } from './gcs-metadata-details-form.component'; | ||
import { TargetDetails, MigrationDetails } from 'src/app/app.constants'; | ||
|
||
describe('GcsMetadataDetailsFormComponent', () => { | ||
let component: GcsMetadataDetailsFormComponent; | ||
let fixture: ComponentFixture<GcsMetadataDetailsFormComponent>; | ||
let dialogRefSpy: jasmine.SpyObj<MatDialogRef<GcsMetadataDetailsFormComponent>>; | ||
|
||
beforeEach(async () => { | ||
dialogRefSpy = jasmine.createSpyObj('MatDialogRef', ['close']); | ||
|
||
await TestBed.configureTestingModule({ | ||
declarations: [GcsMetadataDetailsFormComponent], | ||
imports: [ReactiveFormsModule, MatSnackBarModule], | ||
providers: [ | ||
{ | ||
provide: MatDialogRef, | ||
useValue: dialogRefSpy, | ||
}, | ||
{ | ||
provide: MAT_DIALOG_DATA, | ||
useValue: {}, | ||
}, | ||
], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(GcsMetadataDetailsFormComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should update localStorage and close the dialog', () => { | ||
spyOn(localStorage, 'setItem'); | ||
component.gcsMetadataDetailsForm.setValue({ | ||
gcsName: 'testGcsName', | ||
gcsRootPath: 'testGcsRootPath' | ||
}); | ||
|
||
component.updateGcsPathMetadataDetails(); | ||
|
||
expect(localStorage.setItem).toHaveBeenCalledWith(TargetDetails.GcsMetadataName, 'testGcsName'); | ||
expect(localStorage.setItem).toHaveBeenCalledWith(TargetDetails.GcsMetadataRootPath, 'testGcsRootPath'); | ||
expect(localStorage.setItem).toHaveBeenCalledWith(MigrationDetails.IsGcsMetadataPathSet, 'true'); | ||
expect(dialogRefSpy.close).toHaveBeenCalled(); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
ui/src/app/components/gcs-metadata-details-form/gcs-metadata-details-form.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,38 @@ | ||
import { Component, OnInit } from '@angular/core' | ||
import { FormBuilder, FormGroup, Validators } from '@angular/forms' | ||
import { MatDialogRef} from '@angular/material/dialog' | ||
import { MigrationDetails, TargetDetails } from 'src/app/app.constants' | ||
|
||
@Component({ | ||
selector: 'app-gcs-metadata-details-form', | ||
templateUrl: './gcs-metadata-details-form.component.html', | ||
styleUrls: ['./gcs-metadata-details-form.component.scss'], | ||
}) | ||
export class GcsMetadataDetailsFormComponent implements OnInit { | ||
gcsMetadataDetailsForm: FormGroup | ||
|
||
constructor( | ||
private formBuilder: FormBuilder, | ||
private dialogRef: MatDialogRef<GcsMetadataDetailsFormComponent>, | ||
) { | ||
this.gcsMetadataDetailsForm = this.formBuilder.group({ | ||
gcsName: ['', [Validators.required, Validators.pattern('^(?!\.$)(?!\.\.$)(?!.*[\r\n])[^\r\n]{1,1024}$')]], | ||
gcsRootPath: [''], | ||
}) | ||
|
||
this.gcsMetadataDetailsForm.setValue({ | ||
gcsName: localStorage.getItem(TargetDetails.GcsMetadataName) || '', | ||
gcsRootPath: localStorage.getItem(TargetDetails.GcsMetadataRootPath) || '' | ||
}) | ||
} | ||
|
||
ngOnInit(): void {} | ||
|
||
updateGcsPathMetadataDetails() { | ||
let formValue = this.gcsMetadataDetailsForm.value | ||
localStorage.setItem(TargetDetails.GcsMetadataName, formValue.gcsName || '') | ||
localStorage.setItem(TargetDetails.GcsMetadataRootPath, formValue.gcsRootPath || '') | ||
localStorage.setItem(MigrationDetails.IsGcsMetadataPathSet, "true") | ||
this.dialogRef.close() | ||
} | ||
} |
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
Oops, something went wrong.