mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
* An option to select, and column etc. to view, sentinel policy scope * Flake potential: Seed(1) had a couple jobs with the same ModifyIndex * More de-flaking
84 lines
1.7 KiB
JavaScript
84 lines
1.7 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Controller from '@ember/controller';
|
|
import { action } from '@ember/object';
|
|
import { inject as service } from '@ember/service';
|
|
import { task } from 'ember-concurrency';
|
|
|
|
export default class SentinelPoliciesIndexController extends Controller {
|
|
@service router;
|
|
@service notifications;
|
|
|
|
@action openPolicy(policy) {
|
|
this.router.transitionTo(
|
|
'administration.sentinel-policies.policy',
|
|
policy.name
|
|
);
|
|
}
|
|
|
|
@action goToNewPolicy() {
|
|
this.router.transitionTo('administration.sentinel-policies.new');
|
|
}
|
|
|
|
@action goToTemplateGallery() {
|
|
this.router.transitionTo('administration.sentinel-policies.gallery');
|
|
}
|
|
|
|
get columns() {
|
|
return [
|
|
{
|
|
key: 'name',
|
|
label: 'Name',
|
|
isSortable: true,
|
|
},
|
|
{
|
|
key: 'description',
|
|
label: 'Description',
|
|
},
|
|
{
|
|
key: 'enforcementLevel',
|
|
label: 'Enforcement Level',
|
|
isSortable: true,
|
|
},
|
|
{
|
|
key: 'scope',
|
|
label: 'Scope',
|
|
isSortable: true,
|
|
},
|
|
{
|
|
key: 'delete',
|
|
label: 'Delete',
|
|
},
|
|
];
|
|
}
|
|
|
|
@task(function* (policy) {
|
|
try {
|
|
yield policy.deleteRecord();
|
|
yield policy.save();
|
|
|
|
if (this.store.peekRecord('policy', policy.id)) {
|
|
this.store.unloadRecord(policy);
|
|
}
|
|
|
|
this.notifications.add({
|
|
title: `Sentinel policy ${policy.name} successfully deleted`,
|
|
color: 'success',
|
|
});
|
|
} catch (err) {
|
|
this.notifications.add({
|
|
title: 'Error deleting policy',
|
|
color: 'critical',
|
|
sticky: true,
|
|
message: err,
|
|
});
|
|
|
|
throw err;
|
|
}
|
|
})
|
|
deletePolicy;
|
|
}
|