mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
* Gallery allows picking stuff * Small fixes * added sentinel templates * Can set enforcement level on policies * Working on the interactive sentinel dev mode * Very rough development flow on FE * Changed position in gutter menu * More sentinel stuff * PR cleanup: removed testmode, removed unneeded mixins and deps * Heliosification * Index-level sentinel policy deletion and page title fixes * Makes the Canaries sentinel policy real and then comments out the unfinished ones * rename Access Control to Administration in prep for moving Sentinel Policies and Node Pool admin there * Sentinel policies moved within the Administration section * Mirage fixture for sentinel policy endpoints * Description length check and 500 prevention * Sync review PR feedback addressed, implied butons on radio cards * Cull un-used sentinel policies --------- Co-authored-by: Mike Nomitch <mail@mikenomitch.com>
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Route from '@ember/routing/route';
|
|
import { inject as service } from '@ember/service';
|
|
import TEMPLATES from 'nomad-ui/utils/default-sentinel-policy-templates';
|
|
|
|
export default class NewRoute extends Route {
|
|
@service store;
|
|
|
|
queryParams = {
|
|
template: {
|
|
refreshModel: true,
|
|
},
|
|
};
|
|
|
|
model({ template }) {
|
|
let policy = '#I always pass\nmain = rule { true }\n';
|
|
let name = '';
|
|
let description = '';
|
|
|
|
if (template) {
|
|
let matchingTemplate = TEMPLATES.find((t) => t.name == template);
|
|
if (matchingTemplate) {
|
|
policy = matchingTemplate.policy;
|
|
name = matchingTemplate.name;
|
|
description = matchingTemplate.description;
|
|
}
|
|
}
|
|
|
|
return this.store.createRecord('sentinel-policy', {
|
|
name,
|
|
policy,
|
|
description,
|
|
enforcementLevel: 'advisory',
|
|
scope: 'submit-job',
|
|
});
|
|
}
|
|
|
|
resetController(controller, isExiting) {
|
|
if (isExiting) {
|
|
// If user didn't save, delete the freshly created model
|
|
if (controller.model.isNew) {
|
|
controller.model.destroyRecord();
|
|
controller.set('template', null);
|
|
}
|
|
}
|
|
}
|
|
}
|