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`);
|
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();
|
let params: HttpParams = new HttpParams();
|
||||||
if (branch) {
|
if (branch) {
|
||||||
params = params.set('branch', branch);
|
params = params.set('branch', branch);
|
||||||
|
@ -42,7 +42,7 @@ export class RegistryService {
|
||||||
return this.httpClient.get(`${RegistryService.API}/flow/registries/${registryId}/buckets`, { params });
|
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();
|
let params: HttpParams = new HttpParams();
|
||||||
if (branch) {
|
if (branch) {
|
||||||
params = params.set('branch', 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();
|
let params: HttpParams = new HttpParams();
|
||||||
if (branch) {
|
if (branch) {
|
||||||
params = params.set('branch', branch);
|
params = params.set('branch', branch);
|
||||||
|
|
|
@ -888,7 +888,7 @@ export class FlowEffects {
|
||||||
|
|
||||||
dialogReference.componentInstance.getBuckets = (
|
dialogReference.componentInstance.getBuckets = (
|
||||||
registryId: string,
|
registryId: string,
|
||||||
branch?: string
|
branch?: string | null
|
||||||
): Observable<BucketEntity[]> => {
|
): Observable<BucketEntity[]> => {
|
||||||
return this.registryService.getBuckets(registryId, branch).pipe(
|
return this.registryService.getBuckets(registryId, branch).pipe(
|
||||||
take(1),
|
take(1),
|
||||||
|
@ -911,7 +911,7 @@ export class FlowEffects {
|
||||||
dialogReference.componentInstance.getFlows = (
|
dialogReference.componentInstance.getFlows = (
|
||||||
registryId: string,
|
registryId: string,
|
||||||
bucketId: string,
|
bucketId: string,
|
||||||
branch?: string
|
branch?: string | null
|
||||||
): Observable<VersionedFlowEntity[]> => {
|
): Observable<VersionedFlowEntity[]> => {
|
||||||
return this.registryService.getFlows(registryId, bucketId, branch).pipe(
|
return this.registryService.getFlows(registryId, bucketId, branch).pipe(
|
||||||
take(1),
|
take(1),
|
||||||
|
@ -935,7 +935,7 @@ export class FlowEffects {
|
||||||
registryId: string,
|
registryId: string,
|
||||||
bucketId: string,
|
bucketId: string,
|
||||||
flowId: string,
|
flowId: string,
|
||||||
branch?: string
|
branch?: string | null
|
||||||
): Observable<VersionedFlowSnapshotMetadataEntity[]> => {
|
): Observable<VersionedFlowSnapshotMetadataEntity[]> => {
|
||||||
return this.registryService.getFlowVersions(registryId, bucketId, flowId, branch).pipe(
|
return this.registryService.getFlowVersions(registryId, bucketId, flowId, branch).pipe(
|
||||||
take(1),
|
take(1),
|
||||||
|
@ -3500,7 +3500,7 @@ export class FlowEffects {
|
||||||
|
|
||||||
dialogReference.componentInstance.getBuckets = (
|
dialogReference.componentInstance.getBuckets = (
|
||||||
registryId: string,
|
registryId: string,
|
||||||
branch?: string
|
branch?: string | null
|
||||||
): Observable<BucketEntity[]> => {
|
): Observable<BucketEntity[]> => {
|
||||||
return this.registryService.getBuckets(registryId, branch).pipe(
|
return this.registryService.getBuckets(registryId, branch).pipe(
|
||||||
take(1),
|
take(1),
|
||||||
|
|
|
@ -84,13 +84,17 @@ import { ContextErrorBanner } from '../../../../../../../ui/common/context-error
|
||||||
})
|
})
|
||||||
export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
|
export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
|
||||||
@Input() getBranches: (registryId: string) => Observable<BranchEntity[]> = () => of([]);
|
@Input() getBranches: (registryId: string) => Observable<BranchEntity[]> = () => of([]);
|
||||||
@Input() getBuckets!: (registryId: string, branch?: string) => Observable<BucketEntity[]>;
|
@Input() getBuckets!: (registryId: string, branch?: string | null) => Observable<BucketEntity[]>;
|
||||||
@Input() getFlows!: (registryId: string, bucketId: string, branch?: string) => Observable<VersionedFlowEntity[]>;
|
@Input() getFlows!: (
|
||||||
|
registryId: string,
|
||||||
|
bucketId: string,
|
||||||
|
branch?: string | null
|
||||||
|
) => Observable<VersionedFlowEntity[]>;
|
||||||
@Input() getFlowVersions!: (
|
@Input() getFlowVersions!: (
|
||||||
registryId: string,
|
registryId: string,
|
||||||
bucketId: string,
|
bucketId: string,
|
||||||
flowId: string,
|
flowId: string,
|
||||||
branch?: string
|
branch?: string | null
|
||||||
) => Observable<VersionedFlowSnapshotMetadataEntity[]>;
|
) => Observable<VersionedFlowSnapshotMetadataEntity[]>;
|
||||||
|
|
||||||
saving$ = this.store.select(selectSaving);
|
saving$ = this.store.select(selectSaving);
|
||||||
|
@ -151,7 +155,7 @@ export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
|
||||||
|
|
||||||
this.importFromRegistryForm = this.formBuilder.group({
|
this.importFromRegistryForm = this.formBuilder.group({
|
||||||
registry: new FormControl(this.registryClientOptions[0].value, Validators.required),
|
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),
|
bucket: new FormControl(null, Validators.required),
|
||||||
flow: new FormControl(null, Validators.required),
|
flow: new FormControl(null, Validators.required),
|
||||||
keepParameterContexts: new FormControl(true, Validators.required)
|
keepParameterContexts: new FormControl(true, Validators.required)
|
||||||
|
@ -184,7 +188,7 @@ export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
|
||||||
|
|
||||||
private clearBranches(): void {
|
private clearBranches(): void {
|
||||||
this.branchOptions = [];
|
this.branchOptions = [];
|
||||||
this.importFromRegistryForm.get('branch')?.setValue('default');
|
this.importFromRegistryForm.get('branch')?.setValue(null);
|
||||||
this.clearBuckets();
|
this.clearBuckets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,6 +215,7 @@ export class ImportFromRegistry extends CloseOnEscapeDialog implements OnInit {
|
||||||
this.importFromRegistryForm.get('flow')?.setValue(null);
|
this.importFromRegistryForm.get('flow')?.setValue(null);
|
||||||
this.flowOptions = [];
|
this.flowOptions = [];
|
||||||
this.dataSource.data = [];
|
this.dataSource.data = [];
|
||||||
|
this.selectedFlowVersion = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
flowChanged(flowId: string): void {
|
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.bucketOptions = [];
|
||||||
|
|
||||||
this.getBuckets(registryId, branch)
|
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.flowOptions = [];
|
||||||
this.flowLookup.clear();
|
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.dataSource.data = [];
|
||||||
|
this.selectedFlowVersion = null;
|
||||||
this.selectedFlowDescription = this.flowLookup.get(flowId)?.description;
|
this.selectedFlowDescription = this.flowLookup.get(flowId)?.description;
|
||||||
|
|
||||||
this.getFlowVersions(registryId, bucketId, flowId, branch)
|
this.getFlowVersions(registryId, bucketId, flowId, branch)
|
||||||
|
|
|
@ -67,7 +67,7 @@ import { ContextErrorBanner } from '../../../../../../../ui/common/context-error
|
||||||
})
|
})
|
||||||
export class SaveVersionDialog extends CloseOnEscapeDialog implements OnInit {
|
export class SaveVersionDialog extends CloseOnEscapeDialog implements OnInit {
|
||||||
@Input() getBranches: (registryId: string) => Observable<BranchEntity[]> = () => of([]);
|
@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>;
|
@Input({ required: true }) saving!: Signal<boolean>;
|
||||||
|
|
||||||
@Output() save: EventEmitter<SaveVersionRequest> = new EventEmitter<SaveVersionRequest>();
|
@Output() save: EventEmitter<SaveVersionRequest> = new EventEmitter<SaveVersionRequest>();
|
||||||
|
@ -109,7 +109,7 @@ export class SaveVersionDialog extends CloseOnEscapeDialog implements OnInit {
|
||||||
|
|
||||||
this.saveVersionForm = formBuilder.group({
|
this.saveVersionForm = formBuilder.group({
|
||||||
registry: new FormControl(this.registryClientOptions[0].value, Validators.required),
|
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),
|
bucket: new FormControl(null, Validators.required),
|
||||||
flowName: new FormControl(null, Validators.required),
|
flowName: new FormControl(null, Validators.required),
|
||||||
flowDescription: new FormControl(null),
|
flowDescription: new FormControl(null),
|
||||||
|
@ -137,57 +137,64 @@ export class SaveVersionDialog extends CloseOnEscapeDialog implements OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBranches(registryId: string): void {
|
private clearBranches(): void {
|
||||||
if (registryId) {
|
this.branchOptions = [];
|
||||||
this.branchOptions = [];
|
this.saveVersionForm.get('branch')?.setValue(null);
|
||||||
|
this.clearBuckets();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBuckets(registryId: string, branch?: string): void {
|
loadBranches(registryId: string): void {
|
||||||
if (registryId) {
|
this.clearBranches();
|
||||||
this.bucketOptions = [];
|
|
||||||
|
|
||||||
this.getBuckets(registryId, branch)
|
this.getBranches(registryId)
|
||||||
.pipe(take(1))
|
.pipe(take(1))
|
||||||
.subscribe((buckets: BucketEntity[]) => {
|
.subscribe((branches: BranchEntity[]) => {
|
||||||
if (buckets.length > 0) {
|
if (branches.length > 0) {
|
||||||
buckets.forEach((entity: BucketEntity) => {
|
branches.forEach((entity: BranchEntity) => {
|
||||||
// only allow buckets to be selectable if the user can read and write to them
|
this.branchOptions.push({
|
||||||
if (entity.permissions.canRead && entity.permissions.canWrite) {
|
text: entity.branch.name,
|
||||||
this.bucketOptions.push({
|
value: entity.branch.name
|
||||||
text: entity.bucket.name,
|
|
||||||
value: entity.id,
|
|
||||||
description: entity.bucket.description
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const bucketId = this.bucketOptions[0].value;
|
const branchId = this.branchOptions[0].value;
|
||||||
if (bucketId) {
|
if (branchId) {
|
||||||
this.saveVersionForm.get('bucket')?.setValue(bucketId);
|
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 {
|
registryChanged(registryId: string): void {
|
||||||
|
@ -200,8 +207,10 @@ export class SaveVersionDialog extends CloseOnEscapeDialog implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
branchChanged(branch: string): void {
|
branchChanged(branch: string): void {
|
||||||
const registryId = this.saveVersionForm.get('registry')?.value;
|
const selectedRegistryId: string | null = this.saveVersionForm.get('registry')?.value;
|
||||||
this.loadBuckets(registryId, branch);
|
if (selectedRegistryId) {
|
||||||
|
this.loadBuckets(selectedRegistryId, branch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
submitForm() {
|
submitForm() {
|
||||||
|
|
Loading…
Reference in New Issue