Skip to content

Commit bfd2e54

Browse files
UI: Moving settings/mount-backend-form to secrets/mounts (#8975) (#8998)
* adding route and replacing old route usage * adding comments * updating secrets tests to new route Co-authored-by: Dan Rivera <dan.rivera@hashicorp.com>
1 parent 5f8575d commit bfd2e54

File tree

17 files changed

+104
-39
lines changed

17 files changed

+104
-39
lines changed

ui/app/components/dashboard/quick-actions-card.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
@icon="chevron-right"
9898
@iconPosition="trailing"
9999
@text="Enable a secrets engine"
100-
@route="vault.cluster.settings.mount-secret-backend"
100+
@route="vault.cluster.secrets.mounts"
101101
/>
102102
</EmptyState>
103103
{{/if}}

ui/app/components/dashboard/secrets-engines-card.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
@icon="chevron-right"
8888
@iconPosition="trailing"
8989
@text="Enable a secrets engine"
90-
@route="vault.cluster.settings.mount-secret-backend"
90+
@route="vault.cluster.secrets.mounts"
9191
/>
9292
</EmptyState>
9393
{{/if}}

ui/app/components/secret-engine/list.hbs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
}}
55

66
<div class="top-right-absolute has-top-margin-s">
7-
<Hds::Button
8-
@text="Enable new engine"
9-
@icon="plus"
10-
@route="vault.cluster.settings.mount-secret-backend"
11-
data-test-enable-engine
12-
/>
7+
<Hds::Button @text="Enable new engine" @icon="plus" @route="vault.cluster.secrets.mounts" data-test-enable-engine />
138
</div>
149
<Toolbar>
1510
<ToolbarFilters>

ui/app/components/sidebar/nav/cluster.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Nav.Link @route="vault.cluster.dashboard" @text="Dashboard" data-test-sidebar-nav-link="Dashboard" />
1010
<Nav.Link
1111
@route="vault.cluster.secrets"
12-
@current-when="vault.cluster.secrets vault.cluster.settings.mount-secret-backend vault.cluster.secrets.backend.configuration.edit"
12+
@current-when="vault.cluster.secrets vault.cluster.secrets.mounts vault.cluster.secrets.backend.configuration.edit"
1313
@text="Secrets Engines"
1414
data-test-sidebar-nav-link="Secrets Engines"
1515
/>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: BUSL-1.1
4+
*/
5+
6+
import { service } from '@ember/service';
7+
import Controller from '@ember/controller';
8+
import { action } from '@ember/object';
9+
import { supportedSecretBackends } from 'vault/helpers/supported-secret-backends';
10+
import engineDisplayData from 'vault/helpers/engines-display-data';
11+
12+
const SUPPORTED_BACKENDS = supportedSecretBackends();
13+
14+
export default class SecretMountsController extends Controller {
15+
@service router;
16+
17+
@action
18+
onMountSuccess(type, path, useEngineRoute = false) {
19+
let transition;
20+
if (SUPPORTED_BACKENDS.includes(type)) {
21+
const engineInfo = engineDisplayData(type);
22+
if (useEngineRoute) {
23+
transition = this.router.transitionTo(
24+
`vault.cluster.secrets.backend.${engineInfo.engineRoute}`,
25+
path
26+
);
27+
} else {
28+
// For keymgmt, we need to land on provider tab by default using query params
29+
const queryParams = engineInfo.type === 'keymgmt' ? { tab: 'provider' } : {};
30+
transition = this.router.transitionTo('vault.cluster.secrets.backend.index', path, { queryParams });
31+
}
32+
} else {
33+
transition = this.router.transitionTo('vault.cluster.secrets.backends');
34+
}
35+
return transition.followRedirects();
36+
}
37+
}

ui/app/router.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ Router.map(function () {
174174
});
175175
});
176176
this.route('secrets', function () {
177+
this.route('mounts', function () {
178+
// TODO: Revisit path on create once components are separated - should we specify selected type or just keep it generic as /create?
179+
this.route('create', { path: '/:mount_type/create' });
180+
});
177181
this.route('backends', { path: '/' });
178182
this.route('backend', { path: '/:backend' }, function () {
179183
this.mount('kmip');
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) HashiCorp, Inc.
3+
* SPDX-License-Identifier: BUSL-1.1
4+
*/
5+
6+
import Route from '@ember/routing/route';
7+
import { service } from '@ember/service';
8+
import SecretsEngineForm from 'vault/forms/secrets/engine';
9+
import Router from 'vault/router';
10+
11+
import type { ModelFrom } from 'vault/vault/route';
12+
13+
export type MountSecretBackendModel = ModelFrom<VaultClusterSecretsMountsIndexRouter>;
14+
15+
export default class VaultClusterSecretsMountsIndexRouter extends Route {
16+
@service declare router: Router;
17+
18+
model() {
19+
const defaults = {
20+
config: { listing_visibility: false },
21+
kv_config: {
22+
max_versions: 0,
23+
cas_required: false,
24+
delete_version_after: undefined,
25+
},
26+
options: { version: 2 },
27+
};
28+
return new SecretsEngineForm(defaults, { isNew: true });
29+
}
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{!
2+
Copyright (c) HashiCorp, Inc.
3+
SPDX-License-Identifier: BUSL-1.1
4+
}}
5+
6+
{{! TODO: Copied from existing component, to be replaced by new parent component in separate ticket - VAULT-37522 }}
7+
<MountBackendForm @mountModel={{this.model}} @mountCategory="secret" @onMountSuccess={{action "onMountSuccess"}} />

ui/tests/acceptance/enterprise-transform-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
100100
});
101101

102102
test('it can create a transformation and add itself to the role attached', async function (assert) {
103-
await visit('/vault/settings/mount-secret-backend');
103+
await visit('/vault/secrets/mounts');
104104
const backend = `transform-${uuidv4()}`;
105105
await click('[data-test-mount-type="transform"]');
106106
await fillIn(GENERAL.inputByAttr('path'), backend);
@@ -152,7 +152,7 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
152152

153153
test('it can create a role and add itself to the transformation attached', async function (assert) {
154154
const roleName = 'my-role';
155-
await visit('/vault/settings/mount-secret-backend');
155+
await visit('/vault/secrets/mounts');
156156
const backend = `transform-${uuidv4()}`;
157157
await mountBackend('transform', backend);
158158
// create transformation without role
@@ -192,7 +192,7 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
192192

193193
test('it adds a role to a transformation when added to a role', async function (assert) {
194194
const roleName = 'role-test';
195-
await visit('/vault/settings/mount-secret-backend');
195+
await visit('/vault/secrets/mounts');
196196
const backend = `transform-${uuidv4()}`;
197197
await mountBackend('transform', backend);
198198
const transformation = await newTransformation(backend, 'b-transformation', true);
@@ -204,7 +204,7 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
204204

205205
test('it shows a message if an update fails after save', async function (assert) {
206206
const roleName = 'role-remove';
207-
await visit('/vault/settings/mount-secret-backend');
207+
await visit('/vault/secrets/mounts');
208208
const backend = `transform-${uuidv4()}`;
209209
await mountBackend('transform', backend);
210210
// Create transformation
@@ -242,7 +242,7 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
242242

243243
test('it allows creation and edit of a template', async function (assert) {
244244
const templateName = 'my-template';
245-
await visit('/vault/settings/mount-secret-backend');
245+
await visit('/vault/secrets/mounts');
246246
const backend = `transform-${uuidv4()}`;
247247
await mountBackend('transform', backend);
248248
await click('[data-test-secret-list-tab="Templates"]');
@@ -284,7 +284,7 @@ module('Acceptance | Enterprise | Transform secrets', function (hooks) {
284284

285285
test('it allows creation and edit of an alphabet', async function (assert) {
286286
const alphabetName = 'vowels-only';
287-
await visit('/vault/settings/mount-secret-backend');
287+
await visit('/vault/secrets/mounts');
288288
const backend = `transform-${uuidv4()}`;
289289
await mountBackend('transform', backend);
290290
await click('[data-test-secret-list-tab="Alphabets"]');

ui/tests/acceptance/secrets/backend/aws/aws-configuration-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module('Acceptance | aws | configuration', function (hooks) {
5555
test('it should prompt configuration after mounting the aws engine', async function (assert) {
5656
const path = `aws-${this.uid}`;
5757
// in this test go through the full mount process. Bypass this step in later tests.
58-
await visit('/vault/settings/mount-secret-backend');
58+
await visit('/vault/secrets/mounts');
5959
await mountBackend('aws', path);
6060
await click(SES.configTab);
6161
assert.dom(GENERAL.emptyStateTitle).hasText('AWS not configured');

0 commit comments

Comments
 (0)