</div>
</ng-template>
+<ng-template #deleteTpl></ng-template>
+
<router-outlet name="modal"></router-outlet>
itemNames: [subsystem.nqn],
actionDescription: 'delete',
bodyContext: {
- deletionMessage: $localize`Deleting <strong>${subsystem.nqn}</strong> will remove all associated configurations and resources. Dependent services may stop working. This action cannot be undone.`
+ deletionMessage: $localize`Deleting <strong>${subsystem.nqn}</strong> will remove all associated configurations and resources. Dependent services may stop working. This action cannot be undone.`,
+ forceDeleteAcknowledgementMessage: $localize`I understand this may remove resources still attached to this subsystem.`
},
submitActionObservable: () =>
this.taskWrapper.wrapTaskAroundCall({
it('should call deleteSubsystem', () => {
service.deleteSubsystem(mockNQN, mockGroupName).subscribe();
- const req = httpTesting.expectOne(
- `${API_PATH}/subsystem/${mockNQN}?gw_group=${mockGroupName}`
- );
+ const req = httpTesting.expectOne((request) => {
+ return (
+ request.url === `${API_PATH}/subsystem/${mockNQN}` &&
+ request.params.get('gw_group') === mockGroupName &&
+ request.params.get('force') === 'true'
+ );
+ });
expect(req.request.method).toBe('DELETE');
});
it('should call isSubsystemPresent', () => {
}
deleteSubsystem(subsystemNQN: string, group: string) {
- return this.http.delete(`${API_PATH}/subsystem/${subsystemNQN}?gw_group=${group}`, {
- observe: 'response'
+ return this.http.delete(`${API_PATH}/subsystem/${subsystemNQN}`, {
+ observe: 'response',
+ params: {
+ gw_group: group,
+ force: 'true'
+ }
});
}
<ng-container i18n>Enter the correct resource name.</ng-container>
</span>
</ng-template>
+ @if (bodyContext?.forceDeleteAcknowledgementMessage) {
+ <div class="form-item cds-mt-3">
+ <cds-checkbox id="force_delete_ack"
+ formControlName="forceDeleteAck"
+ [required]="true"
+ ariaLabel="Forced delete acknowledgement">
+ {{ bodyContext.forceDeleteAcknowledgementMessage }}
+ </cds-checkbox>
+ </div>
+ }
</ng-template>
</div>
</div>
[form]="deletionForm"
[submitText]="(actionDescription | titlecase) + ' ' + itemDescription"
[modalForm]="true"
- [disabled]="(submitDisabled$ | async) || deletionForm.disabled || (impact === impactEnum.high ? !deletionForm.controls.confirmInput.value : !deletionForm.controls.confirmation.value)"
+ [disabled]="(submitDisabled$ | async) || deletionForm.disabled || (impact === impactEnum.high ? (!deletionForm.controls.confirmInput.value || !forceDeleteAckSatisfied) : !deletionForm.controls.confirmation.value)"
[submitBtnType]="(actionDescription === 'delete' || actionDescription === 'remove') ? 'danger' : 'primary'"></cd-form-button-panel>
</cds-modal>
}
ngOnInit() {
- const controls = {
+ const controls: Record<string, AbstractControl> = {
impact: new UntypedFormControl(this.impact),
confirmation: new UntypedFormControl(false, {
validators: [
})
};
+ if (
+ this.impact === this.impactEnum.high &&
+ this.bodyContext?.forceDeleteAcknowledgementMessage
+ ) {
+ controls.forceDeleteAck = new UntypedFormControl(false, [Validators.requiredTrue]);
+ }
+
if (this.childFormGroup) {
controls['child'] = this.childFormGroup;
}
}
}
+ get forceDeleteAckSatisfied(): boolean {
+ if (
+ !(this.impact === this.impactEnum.high && this.bodyContext?.forceDeleteAcknowledgementMessage)
+ ) {
+ return true;
+ }
+ const c = this.deletionForm?.get('forceDeleteAck');
+ return c ? !!c.value : true;
+ }
+
matchResourceName(control: AbstractControl): ValidationErrors | null {
if (!control.value) {
return null;
inputLabel?: string;
inputPlaceholder?: string;
deletionMessage?: string;
+ /** When set on a high-impact delete, user must check an extra acknowledgement before submit. */
+ forceDeleteAcknowledgementMessage?: string;
}