diff --git a/.changelog/20483.txt b/.changelog/20483.txt new file mode 100644 index 00000000000..ebe6ee298dc --- /dev/null +++ b/.changelog/20483.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: Added a UI for creating, editing and deleting Sentinel Policies +``` diff --git a/ui/app/adapters/sentinel-policy.js b/ui/app/adapters/sentinel-policy.js index d319ce578fd..72bab4b5a9e 100644 --- a/ui/app/adapters/sentinel-policy.js +++ b/ui/app/adapters/sentinel-policy.js @@ -6,7 +6,6 @@ import { default as ApplicationAdapter } from './application'; import classic from 'ember-classic-decorator'; -// TODO: Nomitch - Update this @classic export default class SentinelPolicyAdapter extends ApplicationAdapter { pathForType = () => 'sentinel/policies'; diff --git a/ui/app/components/sentinel-policy-editor.js b/ui/app/components/sentinel-policy-editor.js index 35ed0c95c02..0c530a63896 100644 --- a/ui/app/components/sentinel-policy-editor.js +++ b/ui/app/components/sentinel-policy-editor.js @@ -65,8 +65,10 @@ export default class SentinelPolicyEditorComponent extends Component { }); if (shouldRedirectAfterSave) { - // TODO: GO TO THE SHOW PAGE INSTEAD - this.router.transitionTo('sentinel-policies.policy', this.policy.name); + this.router.transitionTo( + 'administration.sentinel-policies.policy', + this.policy.name + ); } } catch (err) { let message = err.errors?.length diff --git a/ui/app/controllers/sentinel-policies.js b/ui/app/controllers/administration/sentinel-policies.js similarity index 59% rename from ui/app/controllers/sentinel-policies.js rename to ui/app/controllers/administration/sentinel-policies.js index 7867dcb6d87..5a020ae857a 100644 --- a/ui/app/controllers/sentinel-policies.js +++ b/ui/app/controllers/administration/sentinel-policies.js @@ -5,4 +5,4 @@ import Controller from '@ember/controller'; -export default class SentinelPoliciesController extends Controller {} +export default class AdministrationSentinelPoliciesController extends Controller {} diff --git a/ui/app/controllers/sentinel-policies/gallery.js b/ui/app/controllers/administration/sentinel-policies/gallery.js similarity index 100% rename from ui/app/controllers/sentinel-policies/gallery.js rename to ui/app/controllers/administration/sentinel-policies/gallery.js diff --git a/ui/app/controllers/sentinel-policies/index.js b/ui/app/controllers/administration/sentinel-policies/index.js similarity index 88% rename from ui/app/controllers/sentinel-policies/index.js rename to ui/app/controllers/administration/sentinel-policies/index.js index 4c22faef999..269666e0b69 100644 --- a/ui/app/controllers/sentinel-policies/index.js +++ b/ui/app/controllers/administration/sentinel-policies/index.js @@ -13,11 +13,14 @@ export default class SentinelPoliciesIndexController extends Controller { @service notifications; @action openPolicy(policy) { - this.router.transitionTo('sentinel-policies.policy', policy.name); + this.router.transitionTo( + 'administration.sentinel-policies.policy', + policy.name + ); } @action goToNewPolicy() { - this.router.transitionTo('sentinel-policies.new'); + this.router.transitionTo('administration.sentinel-policies.new'); } get columns() { diff --git a/ui/app/controllers/sentinel-policies/new.js b/ui/app/controllers/administration/sentinel-policies/new.js similarity index 100% rename from ui/app/controllers/sentinel-policies/new.js rename to ui/app/controllers/administration/sentinel-policies/new.js diff --git a/ui/app/controllers/sentinel-policies/policy.js b/ui/app/controllers/administration/sentinel-policies/policy.js similarity index 94% rename from ui/app/controllers/sentinel-policies/policy.js rename to ui/app/controllers/administration/sentinel-policies/policy.js index be1f77accbc..9c4c32f3750 100644 --- a/ui/app/controllers/sentinel-policies/policy.js +++ b/ui/app/controllers/administration/sentinel-policies/policy.js @@ -23,7 +23,7 @@ export default class SentinelPoliciesPolicyController extends Controller { type: `success`, destroyOnClick: false, }); - this.router.transitionTo('sentinel-policies.index'); + this.router.transitionTo('administration.sentinel-policies.index'); } catch (err) { // A failed delete resulted in errors when you then navigated away and back // to the show page rollbackWithoutChangedAttrs fixes it, but there might diff --git a/ui/app/router.js b/ui/app/router.js index 454b458eb07..174c5c3c4e8 100644 --- a/ui/app/router.js +++ b/ui/app/router.js @@ -46,12 +46,6 @@ Router.map(function () { this.route('summary', { path: '*slug' }); }); - this.route('sentinel-policies', function () { - this.route('new'); - this.route('gallery'); - this.route('policy', { path: '/:id' }); - }); - this.route('clients', function () { this.route('client', { path: '/:node_id' }, function () { this.route('monitor'); @@ -145,6 +139,11 @@ Router.map(function () { path: '/:name', }); }); + this.route('sentinel-policies', function () { + this.route('new'); + this.route('gallery'); + this.route('policy', { path: '/:id' }); + }); }); // Mirage-only route for testing OIDC flow if (config['ember-cli-mirage']) { diff --git a/ui/app/routes/administration.js b/ui/app/routes/administration.js index 9c9a9fb1be2..da6664d08a3 100644 --- a/ui/app/routes/administration.js +++ b/ui/app/routes/administration.js @@ -22,7 +22,8 @@ export default class AdministrationRoute extends Route.extend( this.can.cannot('list policies') || this.can.cannot('list roles') || this.can.cannot('list tokens') || - this.can.cannot('list namespaces') + this.can.cannot('list namespaces') || + this.can.cannot('list sentinel-policies') ) { this.router.transitionTo('/jobs'); } @@ -35,6 +36,7 @@ export default class AdministrationRoute extends Route.extend( roles: this.store.findAll('role', { reload: true }), tokens: this.store.findAll('token', { reload: true }), namespaces: this.store.findAll('namespace', { reload: true }), + sentinelPolicies: this.store.findAll('sentinel-policy', { reload: true }), }); } diff --git a/ui/app/routes/sentinel-policies.js b/ui/app/routes/administration/sentinel-policies.js similarity index 82% rename from ui/app/routes/sentinel-policies.js rename to ui/app/routes/administration/sentinel-policies.js index 6fdc88f4337..a3f1cb2724b 100644 --- a/ui/app/routes/sentinel-policies.js +++ b/ui/app/routes/administration/sentinel-policies.js @@ -8,7 +8,7 @@ import Route from '@ember/routing/route'; import classic from 'ember-classic-decorator'; @classic -export default class ClientsRoute extends Route { +export default class AdministrationSentinelPoliciesRoute extends Route { @service store; model() { diff --git a/ui/app/routes/sentinel-policies/new.js b/ui/app/routes/administration/sentinel-policies/new.js similarity index 100% rename from ui/app/routes/sentinel-policies/new.js rename to ui/app/routes/administration/sentinel-policies/new.js diff --git a/ui/app/routes/sentinel-policies/policy.js b/ui/app/routes/administration/sentinel-policies/policy.js similarity index 100% rename from ui/app/routes/sentinel-policies/policy.js rename to ui/app/routes/administration/sentinel-policies/policy.js diff --git a/ui/app/styles/components/access-control.scss b/ui/app/styles/components/access-control.scss index 06061811449..561d7d46104 100644 --- a/ui/app/styles/components/access-control.scss +++ b/ui/app/styles/components/access-control.scss @@ -17,7 +17,7 @@ .section-cards { display: grid; - grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; & > div { padding: 1rem; diff --git a/ui/app/templates/administration/index.hbs b/ui/app/templates/administration/index.hbs index 6624fa405d3..fbf158af114 100644 --- a/ui/app/templates/administration/index.hbs +++ b/ui/app/templates/administration/index.hbs @@ -48,6 +48,17 @@

Namespaces allow jobs and other objects to be segmented from each other.

+ {{#if (can "read sentinel-policy")}} + + + {{this.model.sentinelPolicies.length}} {{pluralize "Sentinel Policy" this.model.sentinelPolicies.length}} + +

Sentinel Policies allow operators to express rules as code and have those rules automatically enforced when jobs are planned.

+ +
+ {{/if}} {{outlet}} \ No newline at end of file diff --git a/ui/app/templates/sentinel-policies.hbs b/ui/app/templates/administration/sentinel-policies.hbs similarity index 71% rename from ui/app/templates/sentinel-policies.hbs rename to ui/app/templates/administration/sentinel-policies.hbs index d6254b5ef30..1dc81ec3d2d 100644 --- a/ui/app/templates/sentinel-policies.hbs +++ b/ui/app/templates/administration/sentinel-policies.hbs @@ -3,8 +3,6 @@ SPDX-License-Identifier: BUSL-1.1 ~}} - + {{page-title "Sentinel Policies"}} - - {{outlet}} - \ No newline at end of file +{{outlet}} diff --git a/ui/app/templates/sentinel-policies/gallery.hbs b/ui/app/templates/administration/sentinel-policies/gallery.hbs similarity index 78% rename from ui/app/templates/sentinel-policies/gallery.hbs rename to ui/app/templates/administration/sentinel-policies/gallery.hbs index bfd4e41b0b0..e6545210a6b 100644 --- a/ui/app/templates/sentinel-policies/gallery.hbs +++ b/ui/app/templates/administration/sentinel-policies/gallery.hbs @@ -3,7 +3,7 @@ SPDX-License-Identifier: BUSL-1.1 ~}} - + {{page-title "Sentinel Policy Gallery"}}
@@ -27,9 +27,9 @@
- - +
\ No newline at end of file diff --git a/ui/app/templates/sentinel-policies/index.hbs b/ui/app/templates/administration/sentinel-policies/index.hbs similarity index 82% rename from ui/app/templates/sentinel-policies/index.hbs rename to ui/app/templates/administration/sentinel-policies/index.hbs index 3e8983e0e41..2bd0c24f2b9 100644 --- a/ui/app/templates/sentinel-policies/index.hbs +++ b/ui/app/templates/administration/sentinel-policies/index.hbs @@ -18,8 +18,9 @@ SPDX-License-Identifier: BUSL-1.1 label="Create Policy" }} > - + + {{else}} {{/if}} @@ -32,7 +33,7 @@ SPDX-License-Identifier: BUSL-1.1 <:body as |B|> - {{B.data.name}} {{B.data.description}} @@ -61,8 +62,8 @@ SPDX-License-Identifier: BUSL-1.1 No Sentinel Policies

- Get started by creating a policy from scratch or - by creating one from the policy gallery. + Get started by creating a policy from scratch or + by creating one from the policy gallery.

{{/if}} diff --git a/ui/app/templates/sentinel-policies/new.hbs b/ui/app/templates/administration/sentinel-policies/new.hbs similarity index 85% rename from ui/app/templates/sentinel-policies/new.hbs rename to ui/app/templates/administration/sentinel-policies/new.hbs index 1733b09a452..5a5d935226b 100644 --- a/ui/app/templates/sentinel-policies/new.hbs +++ b/ui/app/templates/administration/sentinel-policies/new.hbs @@ -3,7 +3,7 @@ SPDX-License-Identifier: BUSL-1.1 ~}} - + {{page-title "Create a Policy"}}
@@ -15,7 +15,7 @@ diff --git a/ui/app/templates/sentinel-policies/policy.hbs b/ui/app/templates/administration/sentinel-policies/policy.hbs similarity index 87% rename from ui/app/templates/sentinel-policies/policy.hbs rename to ui/app/templates/administration/sentinel-policies/policy.hbs index a5f84c92e7d..45a445902c8 100644 --- a/ui/app/templates/sentinel-policies/policy.hbs +++ b/ui/app/templates/administration/sentinel-policies/policy.hbs @@ -3,7 +3,7 @@ SPDX-License-Identifier: BUSL-1.1 ~}} - + {{page-title (concat "Sentinel Policy: " this.model.name)}}
diff --git a/ui/app/templates/components/administration-subnav.hbs b/ui/app/templates/components/administration-subnav.hbs index c75981061e6..174c99f98ea 100644 --- a/ui/app/templates/components/administration-subnav.hbs +++ b/ui/app/templates/components/administration-subnav.hbs @@ -10,5 +10,8 @@
  • Roles
  • Policies
  • Namespaces
  • + {{#if (can "list sentinel policies")}} +
  • Sentinel Policies
  • + {{/if}} diff --git a/ui/app/templates/components/gutter-menu.hbs b/ui/app/templates/components/gutter-menu.hbs index db7b8a07b1f..8dc68113030 100644 --- a/ui/app/templates/components/gutter-menu.hbs +++ b/ui/app/templates/components/gutter-menu.hbs @@ -85,23 +85,6 @@ {{/if}} - {{#if (can "read sentinel-policy")}} -
  • - - Sentinel - -
  • - {{/if}}