Skip to content

Commit

Permalink
Implementing PR feedback from the UI team
Browse files Browse the repository at this point in the history
  • Loading branch information
stevendpclark committed Sep 25, 2024
1 parent 696b777 commit 642e5fc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 27 deletions.
17 changes: 7 additions & 10 deletions ui/app/models/pki/tidy.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ export default class PkiTidyModel extends Model {
hideToggle: true,
formatTtl: true,
})
minStartupBackoffDuration; // auto-tidy only
minStartupBackoffDuration; // auto-tidy only

@attr('string', {
label: 'Maximum startup backoff duration',
defaultValue: '15m'
label: 'Maximum startup backoff duration',
defaultValue: '15m',
editType: 'ttl',
helperTextEnabled:
'Sets the max_startup_backoff_duration field which forces the maximum delay after Vault startup auto-tidy can run',
Expand Down Expand Up @@ -154,18 +154,15 @@ export default class PkiTidyModel extends Model {

get allGroups() {
const groups = [
{ autoTidy: ['enabled', 'intervalDuration', 'minStartupBackoffDuration', 'maxStartupBackoffDuration'] },
{ autoTidy: ['enabled', 'intervalDuration', ...this.autoTidyConfigFields] },
...this.sharedFields,
];
return this._expandGroups(groups);
}

// fields that are specific to auto-tidy, which should only show up when enabled.
get autoTidyEnabledFields() {
const enabledFields = [
{ 'Auto Tidy Startup Backoff': ['minStartupBackoffDuration', 'maxStartupBackoffDuration'] },
];
return this._expandGroups(enabledFields);
// fields that are specific to auto-tidy
get autoTidyConfigFields() {
return ['minStartupBackoffDuration', 'maxStartupBackoffDuration'];
}

// shared between auto and manual tidy operations
Expand Down
20 changes: 7 additions & 13 deletions ui/lib/pki/addon/components/pki-tidy-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<MessageError @errorMessage={{this.errorBanner}} class="has-top-margin-s" />

<form class="has-bottom-margin-s" {{on "submit" (perform this.save)}} data-test-tidy-form={{@tidyType}}>
{{#if (and (eq @tidyType "auto") this.intervalDurationAttr)}}
{{#if (eq @tidyType "auto")}}
{{#let this.intervalDurationAttr as |attr|}}
<TtlPicker
data-test-input={{attr.name}}
Expand All @@ -26,19 +26,13 @@
@initialValue={{get @tidy attr.name}}
/>
{{/let}}

{{#if @tidy.enabled}}
{{#each @tidy.autoTidyConfigFields as |field|}}
<FormField @attr={{get @tidy.allByKey field}} @model={{@tidy}} />
{{/each}}
{{/if}}
{{/if}}
{{#each @tidy.autoTidyEnabledFields as |fieldGroup|}}
{{#each-in fieldGroup as |group fields|}}
{{#if (and (eq @tidyType "auto") @tidy.enabled)}}
<h2 class="title is-size-5 has-border-bottom-light page-header" data-test-tidy-header={{group}}>
{{group}}
</h2>
{{#each fields as |attr|}}
<FormField @attr={{attr}} @model={{@tidy}} />
{{/each}}
{{/if}}
{{/each-in}}
{{/each}}
{{#each @tidy.formFieldGroups as |fieldGroup|}}
{{#each-in fieldGroup as |group fields|}}
{{#if (or (eq @tidyType "manual") @tidy.enabled)}}
Expand Down
2 changes: 0 additions & 2 deletions ui/lib/pki/addon/components/pki-tidy-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ interface Args {

interface PkiTidyTtls {
intervalDuration: string;
minStartupBackoffDuration: string;
maxStartupBackoffDuration: string;
acmeAccountSafetyBuffer: string;
}
interface PkiTidyBooleans {
Expand Down
5 changes: 3 additions & 2 deletions ui/tests/integration/components/pki/pki-tidy-form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module('Integration | Component | pki tidy form', function (hooks) {
test('it hides or shows fields depending on auto-tidy toggle', async function (assert) {
assert.expect(47);
const sectionHeaders = [
'Auto Tidy Startup Backoff',
'Universal operations',
'ACME operations',
'Issuer operations',
Expand Down Expand Up @@ -183,7 +182,7 @@ module('Integration | Component | pki tidy form', function (hooks) {
});

test('it should change the attributes on the model', async function (assert) {
assert.expect(11);
assert.expect(12);
this.server.post('/pki-auto-tidy/config/auto-tidy', (schema, req) => {
assert.propEqual(
JSON.parse(req.requestBody),
Expand Down Expand Up @@ -249,6 +248,8 @@ module('Integration | Component | pki tidy form', function (hooks) {
pauseDuration: 30,
revocationQueueSafetyBuffer: 40,
safetyBuffer: 50,
minStartupBackoffDuration: 300,
maxStartupBackoffDuration: 900,
};
this.autoTidy.eachAttribute(async (attr, { type }) => {
const skipFields = ['enabled', 'tidyAcme', 'intervalDuration', 'acmeAccountSafetyBuffer']; // combined with duration ttl or asserted separately
Expand Down

0 comments on commit 642e5fc

Please sign in to comment.