Skip to content

Commit

Permalink
address transit capabilities issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Monkeychip committed Oct 2, 2024
1 parent be3a183 commit fa0894e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ui/app/models/transit-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ export default class TransitKeyModel extends Model {
get canRead() {
return this.secretPath.get('canUpdate') !== false;
}
get canUpdate() {
return this.secretPath.get('canUpdate') !== false;
}
get canEdit() {
return this.secretPath.get('canUpdate') !== false;
}
Expand Down
2 changes: 0 additions & 2 deletions ui/app/templates/components/transit-edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@
@deleteKey={{action "deleteKey"}}
@key={{this.key}}
@requestInFlight={{this.requestInFlight}}
@capabilities={{this.capabilities}}
/>
{{else if (eq this.mode "show")}}
<TransitFormShow
@refresh={{action "refresh"}}
@tab={{this.tab}}
@key={{this.key}}
@capabilities={{this.capabilities}}
@mode={{this.mode}}
@model={{this.model}}
@backend={{this.backend}}
Expand Down
4 changes: 2 additions & 2 deletions ui/app/templates/components/transit-form-edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
</div>
<div class="field is-grouped is-grouped-split box is-fullwidth is-bottomless">
<div class="field is-grouped">
{{#if @capabilities.canUpdate}}
{{#if @key.canUpdate}}
<div class="control">
<Hds::Button
@text="Update transit key"
Expand All @@ -109,7 +109,7 @@
/>
</div>
</div>
{{#if (and @key.canDelete @capabilities.canDelete)}}
{{#if @model.canDelete}}
<ConfirmAction @buttonText="Delete transit key" @onConfirmAction={{@deleteKey}} />
{{/if}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/transit-form-show.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
/>
{{/if}}
{{#if (eq @mode "show")}}
{{#if (or @capabilities.canUpdate @capabilities.canDelete)}}
{{#if (or @model.canUpdate @model.canDelete)}}
<ToolbarSecretLink @secret={{@key.id}} @backend={{@key.backend}} @mode="edit" replace={{true}}>
Edit key
</ToolbarSecretLink>
Expand Down
6 changes: 6 additions & 0 deletions ui/tests/integration/components/transit-edit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { module, test } from 'qunit';
import { setupRenderingTest } from 'vault/tests/helpers';
import { click, fillIn, render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { capabilitiesStub } from 'vault/tests/helpers/stubs';

const SELECTORS = {
createForm: '[data-test-transit-create-form]',
Expand All @@ -16,9 +18,13 @@ const SELECTORS = {
};
module('Integration | Component | transit-edit', function (hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);

hooks.beforeEach(function () {
this.store = this.owner.lookup('service:store');
this.server.post('/sys/capabilities-self', () =>
capabilitiesStub('transit-backend/keys/some-key', ['sudo'])
);
this.model = this.store.createRecord('transit-key', { backend: 'transit-backend', id: 'some-key' });
this.backendCrumb = {
label: 'transit',
Expand Down

0 comments on commit fa0894e

Please sign in to comment.