mirror of https://github.com/apache/nifi.git
NIFI-13960: Using the ExtensionCreation component when adding a Registry Client to better handle different bundles. (#9494)
This closes #9494
This commit is contained in:
parent
0bbf3cd233
commit
4198880879
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { DocumentedType, RegistryClientEntity, Revision } from '../../../../state/shared';
|
import { Bundle, DocumentedType, RegistryClientEntity, Revision } from '../../../../state/shared';
|
||||||
|
|
||||||
export const registryClientsFeatureKey = 'registryClients';
|
export const registryClientsFeatureKey = 'registryClients';
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ export interface CreateRegistryClientRequest {
|
||||||
component: {
|
component: {
|
||||||
name: string;
|
name: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
bundle: Bundle;
|
||||||
description?: string;
|
description?: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import { PropertyTableHelperService } from '../../../../service/property-table-h
|
||||||
import * as ErrorActions from '../../../../state/error/error.actions';
|
import * as ErrorActions from '../../../../state/error/error.actions';
|
||||||
import { ErrorHelper } from '../../../../service/error-helper.service';
|
import { ErrorHelper } from '../../../../service/error-helper.service';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { LARGE_DIALOG, MEDIUM_DIALOG, SMALL_DIALOG } from 'libs/shared/src';
|
import { LARGE_DIALOG, SMALL_DIALOG } from 'libs/shared/src';
|
||||||
import { BackNavigation } from '../../../../state/navigation';
|
import { BackNavigation } from '../../../../state/navigation';
|
||||||
import { ErrorContextKey } from '../../../../state/error';
|
import { ErrorContextKey } from '../../../../state/error';
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ export class RegistryClientsEffects {
|
||||||
concatLatestFrom(() => this.store.select(selectRegistryClientTypes)),
|
concatLatestFrom(() => this.store.select(selectRegistryClientTypes)),
|
||||||
tap(([, registryClientTypes]) => {
|
tap(([, registryClientTypes]) => {
|
||||||
const dialogReference = this.dialog.open(CreateRegistryClient, {
|
const dialogReference = this.dialog.open(CreateRegistryClient, {
|
||||||
...MEDIUM_DIALOG,
|
...LARGE_DIALOG,
|
||||||
data: {
|
data: {
|
||||||
registryClientTypes
|
registryClientTypes
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,55 +15,8 @@
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<h2 mat-dialog-title>Add Registry Client</h2>
|
<extension-creation
|
||||||
<form class="create-registry-client-form" [formGroup]="createRegistryClientForm">
|
[componentType]="'Registry Client'"
|
||||||
<mat-dialog-content>
|
[documentedTypes]="registryClientTypes"
|
||||||
<div>
|
[saving]="(saving$ | async)!"
|
||||||
<mat-form-field>
|
(extensionTypeSelected)="registryClientTypeSelected($event)"></extension-creation>
|
||||||
<mat-label>Name</mat-label>
|
|
||||||
<input matInput formControlName="name" type="text" />
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<mat-form-field>
|
|
||||||
<mat-label>Type</mat-label>
|
|
||||||
<mat-select formControlName="type">
|
|
||||||
@for (option of request.registryClientTypes; track option) {
|
|
||||||
@if (option.description) {
|
|
||||||
<mat-option
|
|
||||||
[value]="option.type"
|
|
||||||
nifiTooltip
|
|
||||||
[tooltipComponentType]="TextTip"
|
|
||||||
[tooltipInputData]="option.description"
|
|
||||||
[delayClose]="false">
|
|
||||||
{{ formatType(option) }}
|
|
||||||
</mat-option>
|
|
||||||
} @else {
|
|
||||||
<mat-option [value]="option.type">
|
|
||||||
{{ formatType(option) }}
|
|
||||||
</mat-option>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</mat-select>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<mat-form-field>
|
|
||||||
<mat-label>Description</mat-label>
|
|
||||||
<textarea matInput formControlName="description" type="text"></textarea>
|
|
||||||
</mat-form-field>
|
|
||||||
</div>
|
|
||||||
</mat-dialog-content>
|
|
||||||
@if ({ value: (saving$ | async)! }; as saving) {
|
|
||||||
<mat-dialog-actions align="end">
|
|
||||||
<button mat-button mat-dialog-close>Cancel</button>
|
|
||||||
<button
|
|
||||||
[disabled]="!createRegistryClientForm.dirty || createRegistryClientForm.invalid || saving.value"
|
|
||||||
type="button"
|
|
||||||
(click)="createRegistryClientClicked()"
|
|
||||||
mat-flat-button>
|
|
||||||
<span *nifiSpinner="saving.value">Apply</span>
|
|
||||||
</button>
|
|
||||||
</mat-dialog-actions>
|
|
||||||
}
|
|
||||||
</form>
|
|
||||||
|
|
|
@ -14,13 +14,3 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@use '@angular/material' as mat;
|
|
||||||
|
|
||||||
.create-registry-client-form {
|
|
||||||
@include mat.button-density(-1);
|
|
||||||
|
|
||||||
.mat-mdc-form-field {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
import { Component, EventEmitter, Inject, Input, Output } from '@angular/core';
|
import { Component, EventEmitter, Inject, Input, Output } from '@angular/core';
|
||||||
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
|
||||||
import { FormBuilder, FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
import { ReactiveFormsModule } from '@angular/forms';
|
||||||
import { MatInputModule } from '@angular/material/input';
|
import { MatInputModule } from '@angular/material/input';
|
||||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
|
@ -30,7 +30,7 @@ import { Client } from '../../../../../service/client.service';
|
||||||
import { MatSelectModule } from '@angular/material/select';
|
import { MatSelectModule } from '@angular/material/select';
|
||||||
import { NiFiCommon, TextTip, NifiTooltipDirective } from '@nifi/shared';
|
import { NiFiCommon, TextTip, NifiTooltipDirective } from '@nifi/shared';
|
||||||
import { ClusterConnectionService } from '../../../../../service/cluster-connection.service';
|
import { ClusterConnectionService } from '../../../../../service/cluster-connection.service';
|
||||||
import { CloseOnEscapeDialog } from '@nifi/shared';
|
import { ExtensionCreation } from '../../../../../ui/common/extension-creation/extension-creation.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'create-registry-client',
|
selector: 'create-registry-client',
|
||||||
|
@ -45,45 +45,30 @@ import { CloseOnEscapeDialog } from '@nifi/shared';
|
||||||
AsyncPipe,
|
AsyncPipe,
|
||||||
NifiSpinnerDirective,
|
NifiSpinnerDirective,
|
||||||
MatSelectModule,
|
MatSelectModule,
|
||||||
NifiTooltipDirective
|
NifiTooltipDirective,
|
||||||
|
ExtensionCreation
|
||||||
],
|
],
|
||||||
styleUrls: ['./create-registry-client.component.scss']
|
styleUrls: ['./create-registry-client.component.scss']
|
||||||
})
|
})
|
||||||
export class CreateRegistryClient extends CloseOnEscapeDialog {
|
export class CreateRegistryClient {
|
||||||
@Input() saving$!: Observable<boolean>;
|
@Input() saving$!: Observable<boolean>;
|
||||||
@Output() createRegistryClient: EventEmitter<CreateRegistryClientRequest> =
|
@Output() createRegistryClient: EventEmitter<CreateRegistryClientRequest> =
|
||||||
new EventEmitter<CreateRegistryClientRequest>();
|
new EventEmitter<CreateRegistryClientRequest>();
|
||||||
|
|
||||||
protected readonly TextTip = TextTip;
|
protected readonly TextTip = TextTip;
|
||||||
|
|
||||||
createRegistryClientForm: FormGroup;
|
registryClientTypes: DocumentedType[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(MAT_DIALOG_DATA) public request: CreateRegistryClientDialogRequest,
|
@Inject(MAT_DIALOG_DATA) public request: CreateRegistryClientDialogRequest,
|
||||||
private formBuilder: FormBuilder,
|
|
||||||
private nifiCommon: NiFiCommon,
|
private nifiCommon: NiFiCommon,
|
||||||
private client: Client,
|
private client: Client,
|
||||||
private clusterConnectionService: ClusterConnectionService
|
private clusterConnectionService: ClusterConnectionService
|
||||||
) {
|
) {
|
||||||
super();
|
this.registryClientTypes = request.registryClientTypes;
|
||||||
let type: string | null = null;
|
|
||||||
if (request.registryClientTypes.length > 0) {
|
|
||||||
type = request.registryClientTypes[0].type;
|
|
||||||
}
|
|
||||||
|
|
||||||
// build the form
|
|
||||||
this.createRegistryClientForm = this.formBuilder.group({
|
|
||||||
name: new FormControl('', Validators.required),
|
|
||||||
type: new FormControl(type, Validators.required),
|
|
||||||
description: new FormControl('')
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
formatType(option: DocumentedType): string {
|
registryClientTypeSelected(registryClientType: DocumentedType) {
|
||||||
return this.nifiCommon.getComponentTypeLabel(option.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
createRegistryClientClicked() {
|
|
||||||
const request: CreateRegistryClientRequest = {
|
const request: CreateRegistryClientRequest = {
|
||||||
revision: {
|
revision: {
|
||||||
clientId: this.client.getClientId(),
|
clientId: this.client.getClientId(),
|
||||||
|
@ -91,16 +76,12 @@ export class CreateRegistryClient extends CloseOnEscapeDialog {
|
||||||
},
|
},
|
||||||
disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
|
disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged(),
|
||||||
component: {
|
component: {
|
||||||
name: this.createRegistryClientForm.get('name')?.value,
|
name: this.nifiCommon.getComponentTypeLabel(registryClientType.type),
|
||||||
type: this.createRegistryClientForm.get('type')?.value,
|
type: registryClientType.type,
|
||||||
description: this.createRegistryClientForm.get('description')?.value
|
bundle: registryClientType.bundle
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.createRegistryClient.next(request);
|
this.createRegistryClient.next(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
override isDirty(): boolean {
|
|
||||||
return this.createRegistryClientForm.dirty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue