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

Remove ModelWrap Component #15001

Merged
merged 4 commits into from
Apr 11, 2022
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
37 changes: 0 additions & 37 deletions ui/lib/core/addon/components/model-wrap.js

This file was deleted.

1 change: 0 additions & 1 deletion ui/lib/core/addon/templates/components/model-wrap.hbs

This file was deleted.

1 change: 0 additions & 1 deletion ui/lib/core/app/components/model-wrap.js

This file was deleted.

20 changes: 20 additions & 0 deletions ui/lib/kmip/addon/controllers/credentials/show.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';

export default class CredentialsShowController extends Controller {
@service flashMessages;
@service router;

@action
async revokeCredentials() {
try {
await this.model.destroyRecord();
this.flashMessages.success('Successfully revoked credentials');
this.router.transitionTo('vault.cluster.secrets.backend.kmip.credentials.index', this.scope, this.role);
} catch (e) {
this.flashMessages.danger(`There was an error revoking credentials: ${e.errors.join(' ')}`);
this.model.rollbackAttributes();
}
}
}
21 changes: 21 additions & 0 deletions ui/lib/kmip/addon/controllers/role.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';

export default class RoleController extends Controller {
@service flashMessages;
@service router;

@action
async deleteRole() {
const { id } = this.model;
try {
await this.model.destroyRecord();
this.flashMessages.success(`Successfully deleted role ${id}`);
this.router.transitionTo('vault.cluster.secrets.backend.kmip.scope.roles', this.scope);
} catch (e) {
this.flashMessages.danger(`There was an error deleting the role ${id}: ${e.errors.join(' ')}`);
this.model.rollbackAttributes();
}
}
}
31 changes: 10 additions & 21 deletions ui/lib/kmip/addon/templates/credentials/show.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,16 @@
<Toolbar>
<ToolbarActions>
{{#if this.model.deletePath.canDelete}}
<ModelWrap as |m|>
<ConfirmAction
@buttonClasses="toolbar-link"
@onConfirmAction={{action
(perform
m.callMethod
"destroyRecord"
this.model
"Successfully revoked credentials"
"There was an error revoking credentials"
(transition-to "vault.cluster.secrets.backend.kmip.credentials.index" this.scope this.role)
)
}}
@confirmTitle="Revoke this?"
@confirmMessage="Any client using these credentials will no longer be able to."
@cancelButtonText="Cancel"
@confirmButtonText="Revoke"
>
Revoke credentials
</ConfirmAction>
</ModelWrap>
<ConfirmAction
@buttonClasses="toolbar-link"
@onConfirmAction={{this.revokeCredentials}}
@confirmTitle="Revoke this?"
@confirmMessage="Any client using these credentials will no longer be able to."
@cancelButtonText="Cancel"
@confirmButtonText="Revoke"
>
Revoke credentials
</ConfirmAction>
<div class="toolbar-separator"></div>
{{/if}}
<ToolbarLink @params={{array "credentials.index" this.scope this.role}} data-test-kmip-link-back-to-role>
Expand Down
27 changes: 8 additions & 19 deletions ui/lib/kmip/addon/templates/role.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,14 @@
<Toolbar>
<ToolbarActions>
{{#if this.model.updatePath.canUpdate}}
<ModelWrap as |m|>
<ConfirmAction
@buttonClasses="toolbar-link"
@onConfirmAction={{action
(perform
m.callMethod
"destroyRecord"
this.model
(concat "Successfully deleted role " this.model.id)
(concat "There was an error deleting the role " this.model.id)
(transition-to "vault.cluster.secrets.backend.kmip.scope.roles" this.scope)
)
}}
@confirmMessage={{concat "Are you sure you want to delete " this.model.id "?"}}
@cancelButtonText="Cancel"
>
Delete role
</ConfirmAction>
</ModelWrap>
<ConfirmAction
@buttonClasses="toolbar-link"
@onConfirmAction={{this.deleteRole}}
@confirmMessage={{concat "Are you sure you want to delete " this.model.id "?"}}
@cancelButtonText="Cancel"
>
Delete role
</ConfirmAction>
<div class="toolbar-separator"></div>
{{/if}}
{{#if this.model.updatePath.canUpdate}}
Expand Down
10 changes: 5 additions & 5 deletions ui/tests/acceptance/enterprise-kmip-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { currentURL, currentRouteName, settled, fillIn } from '@ember/test-helpers';
import { module, test, skip } from 'qunit';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { create } from 'ember-cli-page-object';

Expand Down Expand Up @@ -126,8 +126,8 @@ module('Acceptance | Enterprise | KMIP secrets', function (hooks) {
);
assert.notOk(scopesPage.isEmpty, 'configuration page no longer renders empty state');
});
// JLR TODO: figure out concurrency issue after 3.28 upgrade
skip('it can revoke from the credentials show page', async function (assert) {

test('it can revoke from the credentials show page', async function (assert) {
let { path, scope, role, serial } = await generateCreds();
await settled();
await credentialsPage.visitDetail({ backend: path, scope, role, serial });
Expand Down Expand Up @@ -235,8 +235,8 @@ module('Acceptance | Enterprise | KMIP secrets', function (hooks) {
assert.equal(rolesPage.listItemLinks.length, 0, 'renders no roles');
assert.ok(rolesPage.isEmpty, 'renders empty');
});
// JLR TODO: figure out concurrency issue after 3.28 upgrade
skip('it can delete a role from the detail page', async function (assert) {

test('it can delete a role from the detail page', async function (assert) {
let { path, scope, role } = await createRole();
await settled();
await rolesPage.visitDetail({ backend: path, scope, role });
Expand Down