Files
nomad/ui/app/routes/administration/policies/new.js
Phil Renaud 1976202cd6 Feature: Dynamic Host Volumes in the UI (#25224)
* DHV UI init

* /csi routes to /storage routes and a routeRedirector util (#25163)

* /csi routes to /storage routes and a routeRedirector util

* Tests and routes move csi/ to storage/

* Changelog added

* [ui] Storage UI overhaul + Dynamic Host Volumes UI (#25226)

* Storage index page and DHV model properties

* Naive version of a storage overview page

* Experimental fetch of alloc data dirs

* Fetch ephemeral disks and static host volumes as an ember concurrency task and nice table stylings

* Playing nice with section header labels to make eslint happy even though wcag was already cool with it

* inlined the storage type explainers and reordered things, plus tooltips and keynav

* Bones of a dynamic host volume individual page

* Woooo dynamic host volume model, adapter, and serializer with embedded alloc relationships

* Couple test fixes

* async:false relationship for dhv.hasMany('alloc') to prevent a ton of xhr requests

* DHV request type at index routemodel and better serialization

* Pagination and searching and query params oh my

* Test retrofits for csi volumes

* Really fantastic flake gets fixed

* DHV detail page acceptance test and a bunch of mirage hooks

* Seed so that the actions test has a guaranteed task

* removed ephemeral disk and static host volume manual scanning

* CapacityBytes and capabilities table added to DHV detail page

* Debugging actions flyout test

* was becoming clear that faker.seed editing was causing havoc elsewhere so might as well not boil the ocean and just tell this test to do what I want it to

* Post-create job gets taskCount instead of count

* CSI volumes now get /csi route prefix at detail level

* lazyclick method for unused keynav removed

* keyboard nav and table-watcher for DHV added

* Addressed PR comments, changed up capabilities table and id references, etc.

* Capabilities table for DHV and ID in details header

* Testfixes for pluginID and capabilities table on DHV page
2025-03-10 14:46:02 -04:00

118 lines
2.1 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';
const INITIAL_POLICY_RULES = `# See https://developer.hashicorp.com/nomad/tutorials/access-control/access-control-policies for ACL Policy details
# Example policy structure:
namespace "default" {
policy = "deny"
capabilities = []
}
namespace "example-ns" {
policy = "deny"
capabilities = ["list-jobs", "read-job"]
variables {
# list access to variables in all paths, full access in nested/variables/*
path "*" {
capabilities = ["list"]
}
path "nested/variables/*" {
capabilities = ["write", "read", "destroy", "list"]
}
}
}
host_volume "example-volume" {
policy = "deny"
}
agent {
policy = "deny"
}
node {
policy = "deny"
}
quota {
policy = "deny"
}
operator {
policy = "deny"
}
# Possible Namespace Policies:
# * deny
# * read
# * write
# * scale
# Possible Namespace Capabilities:
# * list-jobs
# * parse-job
# * read-job
# * submit-job
# * dispatch-job
# * read-logs
# * read-fs
# * alloc-exec
# * alloc-lifecycle
# * csi-write-volume
# * csi-mount-volume
# * host-volume-create
# * host-volume-register
# * host-volume-read
# * host-volume-write
# * host-volume-delete
# * list-scaling-policies
# * read-scaling-policy
# * read-job-scaling
# * scale-job
# Possible Variables capabilities
# * write
# * read
# * destroy
# * list
# Possible Policies for "agent", "node", "quota", "operator", and "host_volume":
# * deny
# * read
# * write
`;
export default class AccessControlPoliciesNewRoute extends Route {
@service can;
@service router;
beforeModel() {
if (this.can.cannot('write policy')) {
this.router.transitionTo('/administration/policies');
}
}
model() {
return this.store.createRecord('policy', {
name: '',
rules: INITIAL_POLICY_RULES,
});
}
resetController(controller, isExiting) {
if (isExiting) {
// If user didn't save, delete the freshly created model
if (controller.model.isNew) {
controller.model.destroyRecord();
}
}
}
}