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.
Sentinel Policies allow operators to express rules as code and have those rules automatically enforced when jobs are planned.
+