From 4cfd47d5fb775b0453390430ab49f965ef6a9ad0 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Fri, 30 Sep 2022 15:28:27 -0700 Subject: [PATCH] Fix small TtlPIcker2 bug (#17376) * fix * add changelog * wrong file name for changelog * update from what core responded with re: type duration --- changelog/17376.txt | 3 +++ ui/app/models/mfa-method.js | 1 + ui/app/models/pki/pki-role-engine.js | 1 + ui/lib/core/addon/components/ttl-picker2.js | 5 +++-- 4 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 changelog/17376.txt diff --git a/changelog/17376.txt b/changelog/17376.txt new file mode 100644 index 000000000..0b2f4e40d --- /dev/null +++ b/changelog/17376.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Remove default value of 30 to TtlPicker2 if no value is passed in. +``` diff --git a/ui/app/models/mfa-method.js b/ui/app/models/mfa-method.js index c6be20108..473ed6837 100644 --- a/ui/app/models/mfa-method.js +++ b/ui/app/models/mfa-method.js @@ -123,6 +123,7 @@ export default class MfaMethod extends Model { editType: 'ttl', helperTextEnabled: 'How long each generated TOTP is valid.', hideToggle: true, + defaultValue: 30, // API accepts both an integer as seconds and sting with unit e.g 30 || '30s' }) period; @attr('number', { diff --git a/ui/app/models/pki/pki-role-engine.js b/ui/app/models/pki/pki-role-engine.js index 46cd52df3..a3747414c 100644 --- a/ui/app/models/pki/pki-role-engine.js +++ b/ui/app/models/pki/pki-role-engine.js @@ -41,6 +41,7 @@ export default class PkiRoleEngineModel extends Model { 'Also called the not_before_duration property. Allows certificates to be valid for a certain time period before now. This is useful to correct clock misalignment on various systems when setting up your CA.', editType: 'ttl', hideToggle: true, + defaultValue: '30s', // type in API is duration which accepts both an integer and string e.g. 30 || '30s' }) notBeforeDuration; diff --git a/ui/lib/core/addon/components/ttl-picker2.js b/ui/lib/core/addon/components/ttl-picker2.js index b06747ed0..d7b17c275 100644 --- a/ui/lib/core/addon/components/ttl-picker2.js +++ b/ui/lib/core/addon/components/ttl-picker2.js @@ -13,7 +13,7 @@ * @param helperTextDisabled="Allow tokens to be used indefinitely" {String} - This helper text is shown under the label when the toggle is switched off * @param helperTextEnabled="Disable the use of the token after" {String} - This helper text is shown under the label when the toggle is switched on * @param description="Longer description about this value, what it does, and why it is useful. Shows up in tooltip next to helpertext" - * @param time=30 {Number} - The time (in the default units) which will be adjustable by the user of the form + * @param time='' {Number} - The time (in the default units) which will be adjustable by the user of the form * @param unit="s" {String} - This is the unit key which will show by default on the form. Can be one of `s` (seconds), `m` (minutes), `h` (hours), `d` (days) * @param recalculationTimeout=5000 {Number} - This is the time, in milliseconds, that `recalculateSeconds` will be be true after time is updated * @param initialValue=null {String} - This is the value set initially (particularly from a string like '30h') @@ -50,7 +50,7 @@ export default TtlForm.extend({ helperTextDisabled: 'Allow tokens to be used indefinitely', helperTextEnabled: 'Disable the use of the token after', description: '', - time: 30, + time: '', // if defaultValue is NOT set, then do not display a defaultValue. unit: 's', initialValue: null, changeOnInit: false, @@ -62,6 +62,7 @@ export default TtlForm.extend({ const enable = this.initialEnabled; const changeOnInit = this.changeOnInit; // if initial value is unset use params passed in as defaults + // and if no defaultValue is passed in display no time if (!value && value !== 0) { return; }