diff --git a/addons/core/translations/resources/en-us.yaml b/addons/core/translations/resources/en-us.yaml index 2e0495965..46ea6b1a5 100644 --- a/addons/core/translations/resources/en-us.yaml +++ b/addons/core/translations/resources/en-us.yaml @@ -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 diff --git a/ui/admin/app/abilities/scope.js b/ui/admin/app/abilities/scope.js index 736a72cf0..62d03adf1 100644 --- a/ui/admin/app/abilities/scope.js +++ b/ui/admin/app/abilities/scope.js @@ -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 ); diff --git a/ui/admin/app/router.js b/ui/admin/app/router.js index 1e77b806c..1977959ff 100644 --- a/ui/admin/app/router.js +++ b/ui/admin/app/router.js @@ -159,6 +159,11 @@ Router.map(function () { function () {}, ); }); + + this.route('policies', function () { + this.route('new'); + this.route('policy', { path: ':policy_id' }, function () {}); + }); }); }); diff --git a/ui/admin/app/routes/scopes/scope/policies.js b/ui/admin/app/routes/scopes/scope/policies.js new file mode 100644 index 000000000..dd6416002 --- /dev/null +++ b/ui/admin/app/routes/scopes/scope/policies.js @@ -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 }); + } + } +} diff --git a/ui/admin/app/routes/scopes/scope/policies/index.js b/ui/admin/app/routes/scopes/scope/policies/index.js new file mode 100644 index 000000000..1d8d75223 --- /dev/null +++ b/ui/admin/app/routes/scopes/scope/policies/index.js @@ -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 {} diff --git a/ui/admin/app/routes/scopes/scope/policies/new.js b/ui/admin/app/routes/scopes/scope/policies/new.js new file mode 100644 index 000000000..949ff3e2d --- /dev/null +++ b/ui/admin/app/routes/scopes/scope/policies/new.js @@ -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 { +} diff --git a/ui/admin/app/routes/scopes/scope/policies/policy.js b/ui/admin/app/routes/scopes/scope/policies/policy.js new file mode 100644 index 000000000..178b8b188 --- /dev/null +++ b/ui/admin/app/routes/scopes/scope/policies/policy.js @@ -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 {} diff --git a/ui/admin/app/routes/scopes/scope/policies/policy/index.js b/ui/admin/app/routes/scopes/scope/policies/policy/index.js new file mode 100644 index 000000000..f92f6bf6b --- /dev/null +++ b/ui/admin/app/routes/scopes/scope/policies/policy/index.js @@ -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 +} diff --git a/ui/admin/app/templates/scopes/scope.hbs b/ui/admin/app/templates/scopes/scope.hbs index 9d981c47c..c31b9319e 100644 --- a/ui/admin/app/templates/scopes/scope.hbs +++ b/ui/admin/app/templates/scopes/scope.hbs @@ -60,7 +60,15 @@ {{t 'resources.storage-bucket.title_plural'}} {{/if}} - + {{#if (can 'navigate scope' @model collection='policies')}} + + + {{t 'resources.policy.title_plural'}} + + {{/if}} {{#if (and (can 'navigate worker' @model collection='workers') @@ -87,7 +95,18 @@ {{t 'resources.project.title_plural'}} + + {{#if (can 'navigate scope' @model collection='policies')}} + + + {{t 'resources.policy.title_plural'}} + + {{/if}} + {{/if}} {{#if @model.isProject}} diff --git a/ui/admin/app/templates/scopes/scope/policies.hbs b/ui/admin/app/templates/scopes/scope/policies.hbs new file mode 100644 index 000000000..dc7ab62de --- /dev/null +++ b/ui/admin/app/templates/scopes/scope/policies.hbs @@ -0,0 +1,12 @@ +{{! + Copyright (c) HashiCorp, Inc. + SPDX-License-Identifier: MPL-2.0 +}} + +{{page-title (t 'resources.policy.title_plural')}} + + +{{outlet}} \ No newline at end of file diff --git a/ui/admin/app/templates/scopes/scope/policies/index.hbs b/ui/admin/app/templates/scopes/scope/policies/index.hbs new file mode 100644 index 000000000..84db34bfe --- /dev/null +++ b/ui/admin/app/templates/scopes/scope/policies/index.hbs @@ -0,0 +1,16 @@ +{{! + Copyright (c) HashiCorp, Inc. + SPDX-License-Identifier: MPL-2.0 +}} + + + + + + +

+ {{t 'resources.policy.title_plural'}} +

+

{{t 'resources.policy.description'}}

+
+
\ No newline at end of file diff --git a/ui/admin/app/templates/scopes/scope/policies/new.hbs b/ui/admin/app/templates/scopes/scope/policies/new.hbs new file mode 100644 index 000000000..03eb23195 --- /dev/null +++ b/ui/admin/app/templates/scopes/scope/policies/new.hbs @@ -0,0 +1,10 @@ +{{! + Copyright (c) HashiCorp, Inc. + SPDX-License-Identifier: MPL-2.0 +}} + +{{page-title (t 'titles.new')}} + \ No newline at end of file diff --git a/ui/admin/app/templates/scopes/scope/policies/policy.hbs b/ui/admin/app/templates/scopes/scope/policies/policy.hbs new file mode 100644 index 000000000..1e5065627 --- /dev/null +++ b/ui/admin/app/templates/scopes/scope/policies/policy.hbs @@ -0,0 +1,13 @@ +{{! + Copyright (c) HashiCorp, Inc. + SPDX-License-Identifier: MPL-2.0 +}} + +{{page-title @model.displayName}} + + +{{outlet}} \ No newline at end of file diff --git a/ui/admin/app/templates/scopes/scope/policies/policy/index.hbs b/ui/admin/app/templates/scopes/scope/policies/policy/index.hbs new file mode 100644 index 000000000..e69de29bb diff --git a/ui/admin/tests/unit/routes/scopes/scope/policies/index-test.js b/ui/admin/tests/unit/routes/scopes/scope/policies/index-test.js new file mode 100644 index 000000000..7563bf42f --- /dev/null +++ b/ui/admin/tests/unit/routes/scopes/scope/policies/index-test.js @@ -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); + }); +}); diff --git a/ui/admin/tests/unit/routes/scopes/scope/policies/new-test.js b/ui/admin/tests/unit/routes/scopes/scope/policies/new-test.js new file mode 100644 index 000000000..be73d8755 --- /dev/null +++ b/ui/admin/tests/unit/routes/scopes/scope/policies/new-test.js @@ -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); + }); +}); diff --git a/ui/admin/tests/unit/routes/scopes/scope/policies/policy-test.js b/ui/admin/tests/unit/routes/scopes/scope/policies/policy-test.js new file mode 100644 index 000000000..a9a8ad60c --- /dev/null +++ b/ui/admin/tests/unit/routes/scopes/scope/policies/policy-test.js @@ -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); + }); +}); diff --git a/ui/admin/tests/unit/routes/scopes/scope/policies/policy/index-test.js b/ui/admin/tests/unit/routes/scopes/scope/policies/policy/index-test.js new file mode 100644 index 000000000..c06136924 --- /dev/null +++ b/ui/admin/tests/unit/routes/scopes/scope/policies/policy/index-test.js @@ -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); + }); +});