Skip to content

Commit

Permalink
UI: Connection "Add Role" automatically populates database in form (#…
Browse files Browse the repository at this point in the history
…11119)

* Database role create form sets url param itemKey as database on init

* add test for new functionality

* Add changelog
  • Loading branch information
chelshaw authored Mar 17, 2021
1 parent ed19750 commit 4733d7f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog/11119.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Add role from database connection automatically populates the database for new role
```
3 changes: 3 additions & 0 deletions ui/app/components/database-role-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/database-connection.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions ui/tests/acceptance/secrets/backend/database/secret-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4733d7f

Please sign in to comment.