Skip to content

Commit

Permalink
NAS-125438 / 24.04 / Fix step checking (by RehanY147) (#9282)
Browse files Browse the repository at this point in the history
* Empty commit to create PR on github.

You should reset it

* NAS-125438: Hide layout step for existing metadata vdevs

* NAS-125438: Fixed test

* NAS-125438: Show readonly layout input when editing

---------

Co-authored-by: Vladimir Vinogradenko <[email protected]>
Co-authored-by: RehanY147 <[email protected]>
  • Loading branch information
3 people authored Dec 7, 2023
1 parent eaafa9f commit 9ed6dd6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
<ng-template #showLayoutInfo>
<ix-input
*ngIf="isDataVdev"
*ngIf="isDataVdev || isMetadataVdev"
[formControl]="layoutControl"
[label]="'Layout' | translate"
[readonly]="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export class AutomatedDiskSelectionComponent implements OnChanges {
return isDraidLayout(this.layoutControl.value);
}

get isMetadataVdev(): boolean {
return this.type === VdevType.Special;
}

private updateStoreOnChanges(): void {
this.store.isLoading$.pipe(filter((isLoading) => !isLoading), take(1), untilDestroyed(this)).subscribe({
next: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { of } from 'rxjs';
import { CreateVdevLayout, VdevType } from 'app/enums/v-dev-type.enum';
import helptext from 'app/helptext/storage/volumes/manager/manager';
import { IxFormsModule } from 'app/modules/ix-forms/ix-forms.module';
import { AddVdevsStore } from 'app/pages/storage/modules/pool-manager/components/add-vdevs/store/add-vdevs-store.service';
import { LayoutStepComponent } from 'app/pages/storage/modules/pool-manager/components/pool-manager-wizard/components/layout-step/layout-step.component';
import { MetadataWizardStepComponent } from 'app/pages/storage/modules/pool-manager/components/pool-manager-wizard/steps/7-metadata-wizard-step/metadata-wizard-step.component';
import { PoolManagerStore, PoolManagerTopology } from 'app/pages/storage/modules/pool-manager/store/pool-manager.store';
Expand Down Expand Up @@ -39,6 +40,10 @@ describe('DataWizardStepComponent', () => {
MockComponent(LayoutStepComponent),
],
providers: [
mockProvider(AddVdevsStore, {
pool$: of(null),
isLoading$: of(false),
}),
mockProvider(PoolManagerStore, {
topology$: of({
[VdevType.Data]: { layout: CreateVdevLayout.Raidz1 },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {
ChangeDetectionStrategy, Component, EventEmitter, Input, Output,
ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output,
} from '@angular/core';
import { UntilDestroy } from '@ngneat/until-destroy';
import { CreateVdevLayout, VdevType } from 'app/enums/v-dev-type.enum';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { map } from 'rxjs';
import { CreateVdevLayout, TopologyItemType, VdevType } from 'app/enums/v-dev-type.enum';
import helptext from 'app/helptext/storage/volumes/manager/manager';
import { AddVdevsStore } from 'app/pages/storage/modules/pool-manager/components/add-vdevs/store/add-vdevs-store.service';
import { PoolManagerStore } from 'app/pages/storage/modules/pool-manager/store/pool-manager.store';

@UntilDestroy()
Expand All @@ -12,7 +14,7 @@ import { PoolManagerStore } from 'app/pages/storage/modules/pool-manager/store/p
templateUrl: './metadata-wizard-step.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MetadataWizardStepComponent {
export class MetadataWizardStepComponent implements OnInit {
@Input() isStepActive: boolean;
@Input() stepWarning: string | null;
@Output() goToLastStep = new EventEmitter<void>();
Expand All @@ -26,7 +28,9 @@ export class MetadataWizardStepComponent {
protected allowedLayouts = [CreateVdevLayout.Mirror, CreateVdevLayout.Stripe];

constructor(
private addVdevsStore: AddVdevsStore,
private store: PoolManagerStore,
private cdr: ChangeDetectorRef,
) {}

goToReviewStep(): void {
Expand All @@ -36,4 +40,23 @@ export class MetadataWizardStepComponent {
resetStep(): void {
this.store.resetStep(VdevType.Special);
}

ngOnInit(): void {
this.addVdevsStore.pool$.pipe(
map((pool) => pool?.topology[VdevType.Special]),
untilDestroyed(this),
).subscribe((metadataTopology) => {
if (!metadataTopology?.length) {
return;
}
// TODO: Similar code in poolTopologyToStoreTopology
let type = metadataTopology[0].type;
if (type === TopologyItemType.Disk && !metadataTopology[0].children.length) {
type = TopologyItemType.Stripe;
}
this.allowedLayouts = [type] as unknown as CreateVdevLayout[];
this.canChangeLayout = false;
this.cdr.markForCheck();
});
}
}

0 comments on commit 9ed6dd6

Please sign in to comment.