Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ui/app/components/recovery/page/snapshots/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}

{{! TODO: This is an empty skeleton component which will be completed as part of 1.21 feature work on single item recovery }}
6 changes: 6 additions & 0 deletions ui/app/components/recovery/page/snapshots/load.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}

{{! TODO: This is an empty skeleton component which will be completed as part of 1.21 feature work on single item recovery }}
6 changes: 6 additions & 0 deletions ui/app/components/recovery/page/snapshots/snapshot.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}

{{! TODO: This is an empty skeleton component which will be completed as part of 1.21 feature work on single item recovery }}
7 changes: 7 additions & 0 deletions ui/app/components/sidebar/nav/cluster.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
data-test-sidebar-nav-link="Secrets Sync"
/>
{{/if}}
{{#if this.isNotProduction}}
<Nav.Link
@route="vault.cluster.recovery.snapshots"
@text="Secrets Recovery"
data-test-sidebar-nav-link="Secrets Recovery"
/>
{{/if}}
{{#if (has-permission "access")}}
<Nav.Link
@route={{get (route-params-for "access") "route"}}
Expand Down
6 changes: 6 additions & 0 deletions ui/app/components/sidebar/nav/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import Component from '@glimmer/component';
import { service } from '@ember/service';
import config from 'vault/config/environment';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh cool, so this acts as a sort of development feature flag. Good idea!

(This can be in a separate PR) but this could be formalized a bit and drawn into a helper so you don't need the getter every time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is definitely a new pattern to use the environment state like this. But with the new release cycle, I foresee us developing more iteratively instead of relying on sidebranches so it would make sense to make an app-wide helper!


export default class SidebarNavClusterComponent extends Component {
@service currentCluster;
Expand Down Expand Up @@ -57,4 +58,9 @@ export default class SidebarNavClusterComponent extends Component {
// otherwise we show the link depending on whether or not the feature exists
return this.version.hasSecretsSync;
}

// TODO remove conditional once further feature work for single item recovery for release 1.21 is completed
get isNotProduction() {
return config.environment !== 'production';
}
}
9 changes: 9 additions & 0 deletions ui/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ Router.map(function () {
this.route('dashboard');
this.mount('config-ui');
this.mount('sync');
// TODO remove conditional once further feature work for single item recovery for release 1.21 is completed
if (config.environment !== 'production') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The router is a special place in ember land. You might want to double check that nothing weird happens once you build this for prod.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how we've been rendering the docfy docs, so far nothing weird has been reported 🙃

this.route('recovery', function () {
this.route('snapshots', function () {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Optional] - It's 100% superflous, but I think it's nice to explicitly call out the index route in the router. I know it'd be diverent pattern in this file, but it's nice to see that there's something there at the default /

Suggested change
this.route('snapshots', function () {
this.route('snapshots', function () {
this.route('index', { path: '/' });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol yeah I definitely advised against this since ember docs callout it's not necessary so feels overly verbose. Plus if we explicitly defined an index route for every index that would make our router file huge and it's already a challenge to parse

this.route('load');
this.route('snapshot', { path: '/:snapshot_id' });
});
});
}
this.route('oidc-provider-ns', { path: '/*namespace/identity/oidc/provider/:provider_name/authorize' });
this.route('oidc-provider', { path: '/identity/oidc/provider/:provider_name/authorize' });
this.route('oidc-callback', { path: '/auth/*auth_path/oidc/callback' });
Expand Down
8 changes: 8 additions & 0 deletions ui/app/routes/vault/cluster/recovery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

import Route from '@ember/routing/route';

export default class RecoveryRoute extends Route {}
8 changes: 8 additions & 0 deletions ui/app/routes/vault/cluster/recovery/snapshots.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

import Route from '@ember/routing/route';

export default class RecoverySnapshotsRoute extends Route {}
8 changes: 8 additions & 0 deletions ui/app/routes/vault/cluster/recovery/snapshots/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

import Route from '@ember/routing/route';

export default class RecoverySnapshotsIndexRoute extends Route {}
8 changes: 8 additions & 0 deletions ui/app/routes/vault/cluster/recovery/snapshots/load.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

import Route from '@ember/routing/route';

export default class RecoverySnapshotsLoadRoute extends Route {}
12 changes: 12 additions & 0 deletions ui/app/routes/vault/cluster/recovery/snapshots/snapshot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/

import Route from '@ember/routing/route';

export default class RecoverySnapshotsSnapshotRoute extends Route {
model(params) {
return params.snapshot_id;
}
}
6 changes: 6 additions & 0 deletions ui/app/templates/vault/cluster/recovery/snapshots/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}

<Recovery::Page::Snapshots />
6 changes: 6 additions & 0 deletions ui/app/templates/vault/cluster/recovery/snapshots/load.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}

<Recovery::Page::Snapshots::Load />
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}
<Recovery::Page::Snapshots::Snapshot />
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module('Integration | Component | sidebar-nav-access', function (hooks) {
});
});

test('it should hide links and headings user does not have access too', async function (assert) {
test('it should hide links and headings user does not have access to', async function (assert) {
await renderComponent();
assert
.dom('[data-test-sidebar-nav-link]')
Expand Down
5 changes: 3 additions & 2 deletions ui/tests/integration/components/sidebar/nav/cluster-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ module('Integration | Component | sidebar-nav-cluster', function (hooks) {
});
});

test('it should hide links and headings user does not have access too', async function (assert) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

test('it should hide links and headings user does not have access to', async function (assert) {
await renderComponent();

assert
.dom('[data-test-sidebar-nav-link]')
.exists({ count: 2 }, 'Nav links are hidden other than secrets and dashboard');
.exists({ count: 3 }, 'Nav links are hidden other than secrets, recovery and dashboard');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a todo since this will change, we'll want to gate these in the has-permission helper? Or we could update the helper api path map with the relevant routes and wrap the sidenav link now - up to you :)

assert
.dom('[data-test-sidebar-nav-heading]')
.exists({ count: 1 }, 'Headings are hidden other than Vault');
Expand All @@ -65,6 +65,7 @@ module('Integration | Component | sidebar-nav-cluster', function (hooks) {
'Dashboard',
'Secrets Engines',
'Secrets Sync',
'Secrets Recovery',
'Access',
'Policies',
'Tools',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module('Integration | Component | sidebar-nav-policies', function (hooks) {
});
});

test('it should hide links user does not have access too', async function (assert) {
test('it should hide links user does not have access to', async function (assert) {
await renderComponent();
assert
.dom('[data-test-sidebar-nav-link]')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module('Integration | Component | sidebar-nav-tools', function (hooks) {
});
});

test('it should hide links user does not have access too', async function (assert) {
test('it should hide links user does not have access to', async function (assert) {
await renderComponent();
assert
.dom('[data-test-sidebar-nav-link]')
Expand Down
Loading