From 133959ea7c73f700b69e139ee21b1091e512e2a3 Mon Sep 17 00:00:00 2001
From: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
Date: Wed, 31 May 2023 15:44:22 -0700
Subject: [PATCH 1/6] cherry-pick changes from pr
---
changelog/20907.txt | 3 +
ui/app/models/pki/role.js | 2 +-
ui/lib/core/addon/components/form-field.hbs | 2 +-
ui/lib/core/addon/helpers/loose-equal.js | 22 +++++++
ui/lib/core/app/helpers/loose-equal.js | 6 ++
.../addon/components/pki-key-parameters.hbs | 2 +-
.../components/pki/pki-role-form-test.js | 66 +++++++++++++++++++
.../integration/helpers/loose-equal-test.js | 34 ++++++++++
8 files changed, 134 insertions(+), 3 deletions(-)
create mode 100644 changelog/20907.txt
create mode 100644 ui/lib/core/addon/helpers/loose-equal.js
create mode 100644 ui/lib/core/app/helpers/loose-equal.js
create mode 100644 ui/tests/integration/helpers/loose-equal-test.js
diff --git a/changelog/20907.txt b/changelog/20907.txt
new file mode 100644
index 000000000000..3f13a659de2b
--- /dev/null
+++ b/changelog/20907.txt
@@ -0,0 +1,3 @@
+```release-note:bug
+ui: fixes key_bits and signature_bits reverting to default values when editing a pki role
+```
\ No newline at end of file
diff --git a/ui/app/models/pki/role.js b/ui/app/models/pki/role.js
index bb3d45478aab..621b3f20ced5 100644
--- a/ui/app/models/pki/role.js
+++ b/ui/app/models/pki/role.js
@@ -179,7 +179,7 @@ export default class PkiRoleModel extends Model {
})
keyBits; // no possibleValues because options are dependent on selected key type
- @attr('number', {
+ @attr('string', {
label: 'Signature bits',
subText: `Only applicable for key_type 'RSA'. Ignore for other key types.`,
defaultValue: '0',
diff --git a/ui/lib/core/addon/components/form-field.hbs b/ui/lib/core/addon/components/form-field.hbs
index b3a405fa8bd5..8074a03d55ae 100644
--- a/ui/lib/core/addon/components/form-field.hbs
+++ b/ui/lib/core/addon/components/form-field.hbs
@@ -46,7 +46,7 @@
{{/if}}
{{#each (path-or-array @attr.options.possibleValues @model) as |val|}}
-
{{/each}}
diff --git a/ui/lib/core/addon/helpers/loose-equal.js b/ui/lib/core/addon/helpers/loose-equal.js
new file mode 100644
index 000000000000..78767fe552eb
--- /dev/null
+++ b/ui/lib/core/addon/helpers/loose-equal.js
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) HashiCorp, Inc.
+ * SPDX-License-Identifier: MPL-2.0
+ */
+
+import { helper } from '@ember/component/helper';
+
+/*
+ * use sparingly *
+ ex: logic for an HTML element's selected boolean because