chore: 🤖 new routes for storage policy (#2056)

chore: 🤖 new routes for storage policy (#2056)
This commit is contained in:
Dharini Jeeva authored and GitHub committed 2024-01-03 12:05:23 -08:00
1 parent e3406d9a95
commit 01a986e08b
18 files changed
+214 -1

No files matched your search

@@ -915,3 +915,8 @@ worker:
label: Worker Auth Registration Request
help: The registration key provided by this worker when it started
registered: Registered
policy:
title: Storage Policy
title_plural: Storage Policies
titles:
new: New Storage Policy
+2
View File
@@ -21,6 +21,7 @@ export default class OverrideScopeAbility extends OverrideModelAbility {
get canCreate() {
switch (this.collection) {
case 'storage-buckets':
case 'policies':
return (
this.features.isEnabled('ssh-session-recording') && super.canCreate
);
@@ -38,6 +39,7 @@ export default class OverrideScopeAbility extends OverrideModelAbility {
switch (this.collection) {
case 'session-recordings':
case 'storage-buckets':
case 'policies':
return (
this.features.isEnabled('ssh-session-recording') && super.canList
);
+5
View File
@@ -159,6 +159,11 @@ Router.map(function () {
function () {},
);
});
this.route('policies', function () {
this.route('new');
this.route('policy', { path: ':policy_id' }, function () {});
});
});
});
@@ -0,0 +1,32 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default class ScopesScopePoliciesRoute extends Route {
// =services
@service store;
@service can;
// =methods
/**
* Load all policies under current scope
* @return {Promise<[PolicyModel]>}
*/
async model() {
const scope = this.modelFor('scopes.scope');
const { id: scope_id } = scope;
if (
this.can.can('list scope', scope, {
collection: 'policies',
})
) {
return this.store.query('policy', { scope_id });
}
}
}
@@ -0,0 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Route from '@ember/routing/route';
export default class ScopesScopePoliciesIndexRoute extends Route {}
@@ -0,0 +1,9 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Route from '@ember/routing/route';
export default class ScopesScopePoliciesNewRoute extends Route {
}
@@ -0,0 +1,8 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Route from '@ember/routing/route';
export default class ScopesScopePoliciesPolicyRoute extends Route {}
@@ -0,0 +1,10 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Route from '@ember/routing/route';
export default class ScopesScopePoliciesPolicyIndexRoute extends Route {
// =services
}
+20 -1
View File
@@ -60,7 +60,15 @@
{{t 'resources.storage-bucket.title_plural'}}
</nav.link>
{{/if}}
{{#if (can 'navigate scope' @model collection='policies')}}
<nav.link @route='scopes.scope.policies'>
<Rose::Icon
@name='flight-icons/svg/hourglass-16'
@size='medium'
/>
{{t 'resources.policy.title_plural'}}
</nav.link>
{{/if}}
{{#if
(and
(can 'navigate worker' @model collection='workers')
@@ -87,7 +95,18 @@
<Rose::Icon @name='flight-icons/svg/grid-16' @size='medium' />
{{t 'resources.project.title_plural'}}
</nav.link>
{{#if (can 'navigate scope' @model collection='policies')}}
<nav.link @route='scopes.scope.policies'>
<Rose::Icon
@name='flight-icons/svg/hourglass-16'
@size='medium'
/>
{{t 'resources.policy.title_plural'}}
</nav.link>
{{/if}}
</Rose::Nav::Sidebar>
{{/if}}
{{#if @model.isProject}}
@@ -0,0 +1,12 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
{{page-title (t 'resources.policy.title_plural')}}
<Breadcrumbs::Item
@text={{t 'resources.policy.title_plural'}}
@route='scopes.scope.policies'
/>
{{outlet}}
@@ -0,0 +1,16 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
<Rose::Layout::Page as |page|>
<page.breadcrumbs>
<Breadcrumbs::Container />
</page.breadcrumbs>
<page.header>
<h2>
{{t 'resources.policy.title_plural'}}
</h2>
<p>{{t 'resources.policy.description'}}</p>
</page.header>
</Rose::Layout::Page>
@@ -0,0 +1,10 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
{{page-title (t 'titles.new')}}
<Breadcrumbs::Item
@text={{t 'resources.policy.titles.new'}}
@route='scopes.scope.policies.new'
/>
@@ -0,0 +1,13 @@
{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
{{page-title @model.displayName}}
<Breadcrumbs::Item
@text={{@model.displayName}}
@route='scopes.scope.policies.policy'
@model={{@model}}
/>
{{outlet}}
Whitespace-only changes.
@@ -0,0 +1,16 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupTest } from 'admin/tests/helpers';
module('Unit | Route | scopes/scope/policies/index', function (hooks) {
setupTest(hooks);
test('it exists', function (assert) {
let route = this.owner.lookup('route:scopes/scope/policies/index');
assert.ok(route);
});
});
@@ -0,0 +1,16 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupTest } from 'admin/tests/helpers';
module('Unit | Route | scopes/scope/policies/new', function (hooks) {
setupTest(hooks);
test('it exists', function (assert) {
let route = this.owner.lookup('route:scopes/scope/policies/new');
assert.ok(route);
});
});
@@ -0,0 +1,16 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupTest } from 'admin/tests/helpers';
module('Unit | Route | scopes/scope/policies/policy', function (hooks) {
setupTest(hooks);
test('it exists', function (assert) {
let route = this.owner.lookup('route:scopes/scope/policies/policy');
assert.ok(route);
});
});
@@ -0,0 +1,16 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { setupTest } from 'admin/tests/helpers';
module('Unit | Route | scopes/scope/policies/policy/index', function (hooks) {
setupTest(hooks);
test('it exists', function (assert) {
let route = this.owner.lookup('route:scopes/scope/policies/policy/index');
assert.ok(route);
});
});