diff --git a/changelog/30119.txt b/changelog/30119.txt
new file mode 100644
index 0000000000..259c8414ca
--- /dev/null
+++ b/changelog/30119.txt
@@ -0,0 +1,3 @@
+```release-note:improvement
+ui/database: Adding warning modal pop up when creating a static role that will be rotated immediately
+```
\ No newline at end of file
diff --git a/ui/app/templates/components/database-role-edit.hbs b/ui/app/components/database-role-edit.hbs
similarity index 90%
rename from ui/app/templates/components/database-role-edit.hbs
rename to ui/app/components/database-role-edit.hbs
index dfd99c7308..076eab4933 100644
--- a/ui/app/templates/components/database-role-edit.hbs
+++ b/ui/app/components/database-role-edit.hbs
@@ -108,7 +108,7 @@
{{else}}
{{! Edit or Create }}
-
+{{/if}}
+
+{{#if this.saveIssuerWarning}}
+
+
+ Are you sure?
+
+
+
+ {{this.saveIssuerWarning}}
+
+
+
+
+
+
+
+
+
{{/if}}
\ No newline at end of file
diff --git a/ui/app/components/database-role-edit.js b/ui/app/components/database-role-edit.js
index 6429c5c2db..ac92c019fe 100644
--- a/ui/app/components/database-role-edit.js
+++ b/ui/app/components/database-role-edit.js
@@ -35,6 +35,7 @@ export default class DatabaseRoleEdit extends Component {
@tracked modelValidations;
@tracked invalidFormAlert;
@tracked errorMessage = '';
+ @tracked saveIssuerWarning = '';
constructor() {
super(...arguments);
@@ -83,6 +84,11 @@ export default class DatabaseRoleEdit extends Component {
.catch(() => null);
}
+ @action continueSubmitForm() {
+ this.saveIssuerWarning = '';
+ this.saveRole.perform();
+ }
+
@action
generateCreds(roleId, roleType = '') {
this.router.transitionTo('vault.cluster.secrets.backend.credentials', roleId, {
@@ -108,12 +114,25 @@ export default class DatabaseRoleEdit extends Component {
});
}
- handleCreateEditRole = task(
- waitFor(async (evt) => {
- evt.preventDefault();
- this.resetErrors();
+ @action
+ async handleCreateEditRole(evt) {
+ evt.preventDefault();
+ this.resetErrors();
+ const { mode, model } = this.args;
+ if (!this.isValid()) return;
+
+ // if we're creating and rotating a static role immediately, warn user
+ if (!model.skip_import_rotation && model.type === 'static' && mode === 'create') {
+ this.saveIssuerWarning =
+ "You have enabled 'Rotate immediately' for this static role. Vault will update the password immediately after you save. NOTE: This will disrupt any active use of this role outside of Vault.";
+ return;
+ }
+ await this.saveRole.perform();
+ }
+
+ saveRole = task(
+ waitFor(async () => {
const { mode, model } = this.args;
- if (!this.isValid()) return;
if (mode === 'create') {
model.id = model.name;
diff --git a/ui/tests/integration/components/database-role-edit-test.js b/ui/tests/integration/components/database-role-edit-test.js
index 05e14f6091..b88ab3f01b 100644
--- a/ui/tests/integration/components/database-role-edit-test.js
+++ b/ui/tests/integration/components/database-role-edit-test.js
@@ -104,13 +104,16 @@ module('Integration | Component | database-role-edit', function (hooks) {
assert.dom('[data-test-value-div="Rotate immediately"]').containsText('No');
});
- test('enterprise: it should successfully create user that does rotate immediately', async function (assert) {
+ test('enterprise: it should successfully create user that does rotate immediately & verify warning modal pops up', async function (assert) {
this.version.type = 'enterprise';
this.server.post('/sys/capabilities-self', capabilitiesStub('database/static-creds/my-role', ['create']));
await render(hbs``);
await click('[data-test-secret-save]');
+ assert.dom('[data-test-issuer-warning]').exists(); // check if warning modal shows after clicking save
+ await click('[data-test-issuer-save]'); // click continue button on modal
+
await render(hbs``);
assert.dom('[data-test-value-div="Rotate immediately"]').containsText('Yes');
});