mirror of https://github.com/apache/nifi.git
NIFI-13926: Removed used of default branch name in favor of null in Import From Registry and Start Version Control. (#9443)
- Reset form fields as necessary when queries to load buckets, branches, etc fail. This closes #9443
This commit is contained in:
parent
f39666da16
commit
a5f2881d02
|
@ -34,7 +34,7 @@ export class RegistryService {
|
|||
return this.httpClient.get(`${RegistryService.API}/flow/registries/${registryId}/branches`);
|
||||
}
|
||||
|
||||
getBuckets(registryId: string, branch?: string): Observable<any> {
|
||||
getBuckets(registryId: string, branch?: string | null): Observable<any> {
|
||||
let params: HttpParams = new HttpParams();
|
||||
if (branch) {
|
||||
params = params.set('branch', branch);
|
||||
|
@ -42,7 +42,7 @@ export class RegistryService {
|
|||
return this.httpClient.get(`${RegistryService.API}/flow/registries/${registryId}/buckets`, { params });
|
||||
}
|
||||
|
||||
getFlows(registryId: string, bucketId: string, branch?: string): Observable<any> {
|
||||
getFlows(registryId: string, bucketId: string, branch?: string | null): Observable<any> {
|
||||
let params: HttpParams = new HttpParams();
|
||||
if (branch) {
|
||||
params = params.set('branch', branch);
|
||||
|
@ -52,7 +52,7 @@ export class RegistryService {
|
|||
});
|
||||
}
|
||||
|
||||
getFlowVersions(registryId: string, bucketId: string, flowId: string, branch?: string): Observable<any> {
|
||||
getFlowVersions(registryId: string, bucketId: string, flowId: string, branch?: string | null): Observable<any> {
|
||||
let params: HttpParams = new HttpParams();
|
||||
if (branch) {
|
||||
params = params.set('branch', branch);
|
||||
|
|
|
@ -888,7 +888,7 @@ export class FlowEffects {
|
|||
|
||||
dialogReference.componentInstance.getBuckets = (
|
||||
registryId: string,
|
||||
branch?: string
|
||||
branch?: string | null
|
||||
): Observable<BucketEntity[]> => {
|
||||
return this.registryService.getBuckets(registryId, branch).pipe(
|
||||
take(1),
|
||||
|
@ -911,7 +911,7 @@ export class FlowEffects {
|
|||
dialogReference.componentInstance.getFlows = (
|
||||
registryId: string,
|
||||
bucketId: string,
|
||||
branch?: string
|
||||
branch?: string | null
|
||||
): Observable<VersionedFlowEntity[]> => {
|
||||
return this.registryService.getFlows(registryId, bucketId, branch).pipe(
|
||||
take(1),
|
||||
|
@ -935,7 +935,7 @@ export class FlowEffects {
|
|||
registryId: string,
|
||||
bucketId: string,
|
||||
flowId: string,
|
||||
branch?: string
|
||||
branch?: string | null
|
||||
): Observable<VersionedFlowSnapshotMetadataEntity[]> => {
|
||||
return this.registryService.getFlowVersions(registryId, bucketId, flowId, branch).pipe(
|
||||
take(1),
|
||||
|
@ -3500,7 +3500,7 @@ export class FlowEffects {
|
|||
|
||||
dialogReference.componentInstance.getBuckets = (
|
||||
registryId: string,
|
||||
branch?: string
|
||||
branch?: string | null
|
||||
): Observable<BucketEntity[]> => {
|
||||
return this.registryService.getBuckets(registryId, branch).pipe(
|
||||
take(1),
|
||||
|
|
|
@ -84,13 +84,17 @@ import { ContextErrorBanner } from '../../../../../../../ui/common/context-error
|
|||
})
|
||||
export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
|
||||
@Input() getBranches: (registryId: string) => Observable<BranchEntity[]> = () => of([]);
|
||||
@Input() getBuckets!: (registryId: string, branch?: string) => Observable<BucketEntity[]>;
|
||||
@Input() getFlows!: (registryId: string, bucketId: string, branch?: string) => Observable<VersionedFlowEntity[]>;
|
||||
@Input() getBuckets!: (registryId: string, branch?: string | null) => Observable<BucketEntity[]>;
|
||||
@Input() getFlows!: (
|
||||
registryId: string,
|
||||
bucketId: string,
|
||||
branch?: string | null
|
||||
) => Observable<VersionedFlowEntity[]>;
|
||||
@Input() getFlowVersions!: (
|
||||
registryId: string,
|
||||
bucketId: string,
|
||||
flowId: string,
|
||||
branch?: string
|
||||
branch?: string | null
|
||||
) => Observable<VersionedFlowSnapshotMetadataEntity[]>;
|
||||
|
||||
saving$ = this.store.select(selectSaving);
|
||||
|
@ -151,7 +155,7 @@ export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
|
|||
|
||||
this.importFromRegistryForm = this.formBuilder.group({
|
||||
registry: new FormControl(this.registryClientOptions[0].value, Validators.required),
|
||||
branch: new FormControl('default', Validators.required),
|
||||
branch: new FormControl(null),
|
||||
bucket: new FormControl(null, Validators.required),
|
||||
flow: new FormControl(null, Validators.required),
|
||||
keepParameterContexts: new FormControl(true, Validators.required)
|
||||
|
@ -184,7 +188,7 @@ export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
|
|||
|
||||
private clearBranches(): void {
|
||||
this.branchOptions = [];
|
||||
this.importFromRegistryForm.get('branch')?.setValue('default');
|
||||
this.importFromRegistryForm.get('branch')?.setValue(null);
|
||||
this.clearBuckets();
|
||||
}
|
||||
|
||||
|
@ -211,6 +215,7 @@ export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
|
|||
this.importFromRegistryForm.get('flow')?.setValue(null);
|
||||
this.flowOptions = [];
|
||||
this.dataSource.data = [];
|
||||
this.selectedFlowVersion = null;
|
||||
}
|
||||
|
||||
flowChanged(flowId: string): void {
|
||||
|
@ -245,7 +250,7 @@ export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
loadBuckets(registryId: string, branch?: string): void {
|
||||
loadBuckets(registryId: string, branch?: string | null): void {
|
||||
this.bucketOptions = [];
|
||||
|
||||
this.getBuckets(registryId, branch)
|
||||
|
@ -271,7 +276,7 @@ export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
loadFlows(registryId: string, bucketId: string, branch?: string): void {
|
||||
loadFlows(registryId: string, bucketId: string, branch?: string | null): void {
|
||||
this.flowOptions = [];
|
||||
this.flowLookup.clear();
|
||||
|
||||
|
@ -298,8 +303,9 @@ export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
loadVersions(registryId: string, bucketId: string, flowId: string, branch?: string): void {
|
||||
loadVersions(registryId: string, bucketId: string, flowId: string, branch?: string | null): void {
|
||||
this.dataSource.data = [];
|
||||
this.selectedFlowVersion = null;
|
||||
this.selectedFlowDescription = this.flowLookup.get(flowId)?.description;
|
||||
|
||||
this.getFlowVersions(registryId, bucketId, flowId, branch)
|
||||
|
|
|
@ -67,7 +67,7 @@ import { ContextErrorBanner } from '../../../../../../../ui/common/context-error
|
|||
})
|
||||
export class SaveVersionDialog extends CloseOnEscapeDialog implements OnInit {
|
||||
@Input() getBranches: (registryId: string) => Observable<BranchEntity[]> = () => of([]);
|
||||
@Input() getBuckets: (registryId: string, branch?: string) => Observable<BucketEntity[]> = () => of([]);
|
||||
@Input() getBuckets: (registryId: string, branch?: string | null) => Observable<BucketEntity[]> = () => of([]);
|
||||
@Input({ required: true }) saving!: Signal<boolean>;
|
||||
|
||||
@Output() save: EventEmitter<SaveVersionRequest> = new EventEmitter<SaveVersionRequest>();
|
||||
|
@ -109,7 +109,7 @@ export class SaveVersionDialog extends CloseOnEscapeDialog implements OnInit {
|
|||
|
||||
this.saveVersionForm = formBuilder.group({
|
||||
registry: new FormControl(this.registryClientOptions[0].value, Validators.required),
|
||||
branch: new FormControl('default', Validators.required),
|
||||
branch: new FormControl(null),
|
||||
bucket: new FormControl(null, Validators.required),
|
||||
flowName: new FormControl(null, Validators.required),
|
||||
flowDescription: new FormControl(null),
|
||||
|
@ -137,57 +137,64 @@ export class SaveVersionDialog extends CloseOnEscapeDialog implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
loadBranches(registryId: string): void {
|
||||
if (registryId) {
|
||||
this.branchOptions = [];
|
||||
|
||||
this.getBranches(registryId)
|
||||
.pipe(take(1))
|
||||
.subscribe((branches: BranchEntity[]) => {
|
||||
if (branches.length > 0) {
|
||||
branches.forEach((entity: BranchEntity) => {
|
||||
this.branchOptions.push({
|
||||
text: entity.branch.name,
|
||||
value: entity.branch.name
|
||||
});
|
||||
});
|
||||
|
||||
const branchId = this.branchOptions[0].value;
|
||||
if (branchId) {
|
||||
this.saveVersionForm.get('branch')?.setValue(branchId);
|
||||
this.loadBuckets(registryId, branchId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
private clearBranches(): void {
|
||||
this.branchOptions = [];
|
||||
this.saveVersionForm.get('branch')?.setValue(null);
|
||||
this.clearBuckets();
|
||||
}
|
||||
|
||||
loadBuckets(registryId: string, branch?: string): void {
|
||||
if (registryId) {
|
||||
this.bucketOptions = [];
|
||||
loadBranches(registryId: string): void {
|
||||
this.clearBranches();
|
||||
|
||||
this.getBuckets(registryId, branch)
|
||||
.pipe(take(1))
|
||||
.subscribe((buckets: BucketEntity[]) => {
|
||||
if (buckets.length > 0) {
|
||||
buckets.forEach((entity: BucketEntity) => {
|
||||
// only allow buckets to be selectable if the user can read and write to them
|
||||
if (entity.permissions.canRead && entity.permissions.canWrite) {
|
||||
this.bucketOptions.push({
|
||||
text: entity.bucket.name,
|
||||
value: entity.id,
|
||||
description: entity.bucket.description
|
||||
});
|
||||
}
|
||||
this.getBranches(registryId)
|
||||
.pipe(take(1))
|
||||
.subscribe((branches: BranchEntity[]) => {
|
||||
if (branches.length > 0) {
|
||||
branches.forEach((entity: BranchEntity) => {
|
||||
this.branchOptions.push({
|
||||
text: entity.branch.name,
|
||||
value: entity.branch.name
|
||||
});
|
||||
});
|
||||
|
||||
const bucketId = this.bucketOptions[0].value;
|
||||
if (bucketId) {
|
||||
this.saveVersionForm.get('bucket')?.setValue(bucketId);
|
||||
}
|
||||
const branchId = this.branchOptions[0].value;
|
||||
if (branchId) {
|
||||
this.saveVersionForm.get('branch')?.setValue(branchId);
|
||||
this.loadBuckets(registryId, branchId);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private clearBuckets(): void {
|
||||
this.bucketOptions = [];
|
||||
this.saveVersionForm.get('bucket')?.setValue(null);
|
||||
}
|
||||
|
||||
loadBuckets(registryId: string, branch?: string | null): void {
|
||||
this.clearBuckets();
|
||||
|
||||
this.getBuckets(registryId, branch)
|
||||
.pipe(take(1))
|
||||
.subscribe((buckets: BucketEntity[]) => {
|
||||
if (buckets.length > 0) {
|
||||
buckets.forEach((entity: BucketEntity) => {
|
||||
// only allow buckets to be selectable if the user can read and write to them
|
||||
if (entity.permissions.canRead && entity.permissions.canWrite) {
|
||||
this.bucketOptions.push({
|
||||
text: entity.bucket.name,
|
||||
value: entity.id,
|
||||
description: entity.bucket.description
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const bucketId = this.bucketOptions[0].value;
|
||||
if (bucketId) {
|
||||
this.saveVersionForm.get('bucket')?.setValue(bucketId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
registryChanged(registryId: string): void {
|
||||
|
@ -200,8 +207,10 @@ export class SaveVersionDialog extends CloseOnEscapeDialog implements OnInit {
|
|||
}
|
||||
|
||||
branchChanged(branch: string): void {
|
||||
const registryId = this.saveVersionForm.get('registry')?.value;
|
||||
this.loadBuckets(registryId, branch);
|
||||
const selectedRegistryId: string | null = this.saveVersionForm.get('registry')?.value;
|
||||
if (selectedRegistryId) {
|
||||
this.loadBuckets(selectedRegistryId, branch);
|
||||
}
|
||||
}
|
||||
|
||||
submitForm() {
|
||||
|
|
Loading…
Reference in New Issue