Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-15979] restore min max attributes #12763

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ <h6 bitTypography="h6">{{ "options" | i18n }}</h6>
formControlName="numWords"
id="num-words"
type="number"
[min]="numWordsMin"
[max]="numWordsMax"
(change)="save('numWords')"
/>
<bit-hint>{{ numWordsBoundariesHint$ | async }}</bit-hint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ export class PassphraseSettingsComponent implements OnInit, OnDestroy {
this.wordSeparatorMaxLength = constraints.wordSeparator.maxLength;
this.policyInEffect = constraints.policyInEffect;

this.numWordsMin = constraints.numWords.min;
this.numWordsMax = constraints.numWords.max;

this.toggleEnabled(Controls.capitalize, !constraints.capitalize?.readonly);
this.toggleEnabled(Controls.includeNumber, !constraints.includeNumber?.readonly);
});
Expand All @@ -128,6 +131,12 @@ export class PassphraseSettingsComponent implements OnInit, OnDestroy {
.subscribe(settings);
}

/** attribute binding for numWords[min] */
protected numWordsMin: number;

/** attribute binding for numWords[max] */
protected numWordsMax: number;

/** attribute binding for wordSeparator[maxlength] */
protected wordSeparatorMaxLength: number;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ <h2 bitTypography="h6">{{ "options" | i18n }}</h2>
<bit-card>
<bit-form-field disableMargin>
<bit-label>{{ "length" | i18n }}</bit-label>
<input bitInput formControlName="length" type="number" (change)="save('length')" />
<input
bitInput
formControlName="length"
type="number"
[min]="lengthMin"
[max]="lengthMax"
(change)="save('length')"
/>
<bit-hint>{{ lengthBoundariesHint$ | async }}</bit-hint>
</bit-form-field>
</bit-card>
Expand Down Expand Up @@ -71,7 +78,9 @@ <h2 bitTypography="h6">{{ "options" | i18n }}</h2>
bitInput
type="number"
formControlName="minNumber"
(change)="save('minNumbers')"
[min]="minNumberMin"
[max]="minNumberMax"
(change)="save('minNumber')"
/>
</bit-form-field>
<bit-form-field class="tw-w-full tw-basis-1/2">
Expand All @@ -80,6 +89,8 @@ <h2 bitTypography="h6">{{ "options" | i18n }}</h2>
bitInput
type="number"
formControlName="minSpecial"
[min]="minSpecialMin"
[max]="minSpecialMax"
(change)="save('minSpecial')"
/>
</bit-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ export class PasswordSettingsComponent implements OnInit, OnDestroy {
.subscribe(({ constraints }) => {
this.policyInEffect = constraints.policyInEffect;

this.lengthMin = constraints.length.min;
this.lengthMax = constraints.length.max;
this.minNumberMin = constraints.minNumber.min;
this.minNumberMax = constraints.minNumber.max;
this.minSpecialMin = constraints.minSpecial.min;
this.minSpecialMax = constraints.minSpecial.max;

const toggles = [
[Controls.length, constraints.length.min < constraints.length.max],
[Controls.uppercase, !constraints.uppercase?.readonly],
Expand Down Expand Up @@ -227,6 +234,24 @@ export class PasswordSettingsComponent implements OnInit, OnDestroy {
this.saveSettings.next(site);
}

/** attribute binding for length[min] */
protected lengthMin: number;

/** attribute binding for length[max] */
protected lengthMax: number;

/** attribute binding for minNumber[min] */
protected minNumberMin: number;

/** attribute binding for minNumber[max] */
protected minNumberMax: number;

/** attribute binding for minSpecial[min] */
protected minSpecialMin: number;

/** attribute binding for minSpecial[max] */
protected minSpecialMax: number;

/** display binding for enterprise policy notice */
protected policyInEffect: boolean;

Expand Down
Loading