Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidebranch: add new route on DR secondary #8640

Merged
Merged
Show file tree
Hide file tree
Changes from 6 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
7 changes: 7 additions & 0 deletions ui/app/mixins/cluster-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const CLUSTER = 'vault.cluster';
const CLUSTER_INDEX = 'vault.cluster.index';
const OIDC_CALLBACK = 'vault.cluster.oidc-callback';
const DR_REPLICATION_SECONDARY = 'vault.cluster.replication-dr-promote';
const DR_REPLICATION_SECONDARY_DETAILS = 'vault.cluster.replication-dr-promote.details';
const EXCLUDED_REDIRECT_URLS = ['/vault/logout'];

export { INIT, UNSEAL, AUTH, CLUSTER, CLUSTER_INDEX, DR_REPLICATION_SECONDARY };
Expand Down Expand Up @@ -70,6 +71,12 @@ export default Mixin.create({
return UNSEAL;
}
if (get(cluster, 'dr.isSecondary')) {
if (transition && transition.targetName === DR_REPLICATION_SECONDARY_DETAILS) {
return DR_REPLICATION_SECONDARY_DETAILS;
}
if (this.router.currentRouteName === DR_REPLICATION_SECONDARY_DETAILS) {
return DR_REPLICATION_SECONDARY_DETAILS;
}
return DR_REPLICATION_SECONDARY;
}
if (!isAuthed) {
Expand Down
4 changes: 3 additions & 1 deletion ui/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ Router.map(function() {
this.route('show', { path: '/:policy_name' });
this.route('edit', { path: '/:policy_name/edit' });
});
this.route('replication-dr-promote');
this.route('replication-dr-promote', function() {
this.route('details');
});
if (config.addRootMounts) {
config.addRootMounts.call(this);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { inject as service } from '@ember/service';
import Base from './cluster-route-base';
import Base from '../cluster-route-base';

export default Base.extend({
replicationMode: service(),
Expand Down
24 changes: 24 additions & 0 deletions ui/app/templates/partials/status/cluster.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,30 @@
</nav>
<hr/>
{{/if}}
{{else}}
{{#if (has-permission 'status' routeParams='replication')}}
<nav class="menu">
<p class="menu-label">Replication</p>
<ul>
{{#if cluster.anyReplicationEnabled}}
<li>
{{#link-to
"vault.cluster.replication-dr-promote.details"
disabled=(not currentToken)
invokeAction=(action onLinkClick)
}}
{{replication-mode-summary
mode="dr"
display='menu'
cluster=cluster
}}
{{/link-to}}
</li>
{{/if}}
</ul>
</nav>
<hr/>
{{/if}}
{{/if}}
{{/if}}
{{/unless}}
Expand Down
13 changes: 13 additions & 0 deletions ui/app/templates/vault/cluster/replication-dr-promote/details.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<SplashPage as |Page|>
<Page.header>
<h1 class="title is-4">
Disaster Recovery
</h1>
</Page.header>
<Page.content>
<LinkTo
@params={{array "vault.cluster.replication-dr-promote"}}
class="is-block">MEEP
</LinkTo>
</Page.content>
</SplashPage>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<h1 class="title is-4">
Disaster Recovery secondary is&nbsp;enabled
</h1>
<LinkTo
@params={{array "vault.cluster.replication-dr-promote.details"}}
class="is-block">MEEP
</LinkTo>
</Page.header>
<Page.content>
<nav class="tabs sub-nav is-marginless">
Expand Down
19 changes: 19 additions & 0 deletions ui/tests/acceptance/replication/dr/secondary-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { module, test } from 'qunit';
import { later } from '@ember/runloop';
import { setupApplicationTest } from 'ember-qunit';
import { currentURL, visit, pauseTest } from '@ember/test-helpers';

import authPage from 'vault/tests/pages/auth';

module('Acceptance | DR secondary details', function(hooks) {
setupApplicationTest(hooks);

hooks.beforeEach(function() {
return authPage.login();
});

test('visiting DR Recovery Details page', async function(assert) {
await visit('/vault/replication-dr-promote/details');
assert.equal(currentURL(), '/vault/replication-dr-promote/details');
});
});