diff --git a/changelog/11119.txt b/changelog/11119.txt new file mode 100644 index 000000000..6ce5c6d4a --- /dev/null +++ b/changelog/11119.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Add role from database connection automatically populates the database for new role +``` diff --git a/ui/app/components/database-role-edit.js b/ui/app/components/database-role-edit.js index 992c712c7..b6820ea82 100644 --- a/ui/app/components/database-role-edit.js +++ b/ui/app/components/database-role-edit.js @@ -19,6 +19,9 @@ export default class DatabaseRoleEdit extends Component { ) { this.wizard.transitionFeatureMachine(this.wizard.featureState, 'CONTINUE', 'database'); } + if (this.args.initialKey) { + this.args.model.database = [this.args.initialKey]; + } } @tracked loading = false; diff --git a/ui/app/templates/components/database-connection.hbs b/ui/app/templates/components/database-connection.hbs index 0ecf92af4..b0b555cf5 100644 --- a/ui/app/templates/components/database-connection.hbs +++ b/ui/app/templates/components/database-connection.hbs @@ -60,7 +60,7 @@ @secret='' @mode="create" @type="add" - @queryParams={{query-params initialKey=(or filter baseKey.id) itemType="role"}} + @queryParams={{query-params initialKey=@model.name itemType="role"}} @data-test-secret-create=true > Add role diff --git a/ui/tests/acceptance/secrets/backend/database/secret-test.js b/ui/tests/acceptance/secrets/backend/database/secret-test.js index 947f565be..38b9ce3bd 100644 --- a/ui/tests/acceptance/secrets/backend/database/secret-test.js +++ b/ui/tests/acceptance/secrets/backend/database/secret-test.js @@ -139,6 +139,14 @@ module('Acceptance | secrets/database/*', function(hooks) { assert .dom(`[data-test-row-value="Write concern"]`) .hasText('{ "wtimeout": 5000 }', 'Write concern is now showing on the table'); + // click "Add Role" + await click('[data-test-secret-create="true"]'); + await settled(); + assert.equal( + searchSelectComponent.selectedOptions[0].text, + connectionDetails.id, + 'Database connection is pre-selected on the form' + ); }); test('buttons show up for managing connection', async function(assert) {