Enable storage bucket deletion (#2541)

* fix: 🐛 enable storage bucket deletion
This commit is contained in:
Dharini Jeeva authored and GitHub committed 2024-10-31 09:36:19 -07:00
1 parent 390f051e43
commit 5e208c4115
4 files changed
+28 -16

No files matched your search

+4 -6
View File
@@ -31,14 +31,12 @@ export default class OverrideStorageBucketAbility extends StorageBucketAbility {
}
/**
* TODO: Ensure that storage buckets may be deleted only if the
* This override ensures that storage buckets may be deleted only if the
* session-recording feature flag is enabled.
* For now a storage bucket cannot be deleted.
*/
get canDelete() {
return false;
// return this.features.isEnabled('ssh-session-recording')
// ? super.canDelete
// : false;
return this.features.isEnabled('ssh-session-recording')
? super.canDelete
: false;
}
}
@@ -47,6 +47,8 @@ export default class ScopesScopeStorageBucketsIndexController extends Controller
@notifySuccess('notifications.delete-success')
async delete(storageBucket) {
await storageBucket.destroyRecord();
await this.router.replaceWith('scopes.scope.storage-buckets');
await this.router.refresh();
}
/**
@@ -16,6 +16,19 @@
<Hds::Copy::Snippet @textToCopy={{@model.id}} @color='secondary' />
</page.header>
{{#if (can 'delete storage-bucket' @model)}}
<page.actions>
<Hds::Dropdown as |dd|>
<dd.ToggleButton @text={{t 'actions.manage'}} @color='secondary' />
<dd.Interactive
@text={{t 'actions.delete'}}
@color='critical'
{{on 'click' (fn this.storageBuckets.delete @model)}}
/>
</Hds::Dropdown>
</page.actions>
{{/if}}
<page.navigation>
<Rose::Nav::Tabs as |nav|>
<nav.link @route='scopes.scope.storage-buckets.storage-bucket.index'>
@@ -2,19 +2,18 @@
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
// TODO: Un-skip tests once delete storage bucket action is enabled.
import { module, skip } from 'qunit';
import { module, test } from 'qunit';
import { visit, click, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { Response } from 'miragejs';
import { authenticateSession } from 'ember-simple-auth/test-support';
import { setupIndexedDb } from 'api/test-support/helpers/indexed-db';
module('Acceptance | storage-buckets | delete', function (hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
setupIndexedDb(hooks);
let intl;
let features;
@@ -62,10 +61,10 @@ module('Acceptance | storage-buckets | delete', function (hooks) {
features.enable('ssh-session-recording');
});
skip('user can delete a storage bucket', async function (assert) {
test('user can delete a storage bucket', async function (assert) {
const storageBucketCount = getStorageBucketCount();
await visit(urls.globalScope);
assert.true(instances.storageBucket.authorized_actions.includes('delete'));
await click(`[href="${urls.storageBuckets}"]`);
await click(DROPDOWN_BUTTON_SELECTOR);
await click(DELETE_DROPDOWN_SELECTOR);
@@ -74,7 +73,7 @@ module('Acceptance | storage-buckets | delete', function (hooks) {
assert.strictEqual(getStorageBucketCount(), storageBucketCount - 1);
});
skip('user can accept delete storage bucket via dialog', async function (assert) {
test('user can accept delete storage bucket via dialog', async function (assert) {
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
const storageBucketCount = getStorageBucketCount();
@@ -95,7 +94,7 @@ module('Acceptance | storage-buckets | delete', function (hooks) {
assert.strictEqual(getStorageBucketCount(), storageBucketCount - 1);
});
skip('user can cancel delete storage bucket via dialog', async function (assert) {
test('user can cancel delete storage bucket via dialog', async function (assert) {
const confirmService = this.owner.lookup('service:confirm');
confirmService.enabled = true;
const storageBucketCount = getStorageBucketCount();
@@ -126,7 +125,7 @@ module('Acceptance | storage-buckets | delete', function (hooks) {
assert.strictEqual(getStorageBucketCount(), storageBucketCount);
});
skip('user cannot delete storage bucket without proper authorization', async function (assert) {
test('user cannot delete storage bucket without proper authorization', async function (assert) {
await visit(urls.globalScope);
instances.storageBucket.authorized_actions =
instances.storageBucket.authorized_actions.filter(
@@ -139,7 +138,7 @@ module('Acceptance | storage-buckets | delete', function (hooks) {
assert.dom(DELETE_DROPDOWN_SELECTOR).doesNotExist();
});
skip('deleting a storage bucket which errors displays error messages', async function (assert) {
test('deleting a storage bucket which errors displays error messages', async function (assert) {
await visit(urls.globalScope);
this.server.del('/storage-buckets/:id', () => {
return new Response(