52 lines
2.4 KiB
Handlebars
52 lines
2.4 KiB
Handlebars
<form>
|
|
<fieldset
|
|
disabled={{if (not (can "write acl" item=item)) "disabled"}}
|
|
>
|
|
<label class="type-text{{if item.error.Name ' has-error'}}">
|
|
<span>Name</span>
|
|
<Input @value={{item.Name}} @name="name" @autofocus="autofocus" />
|
|
</label>
|
|
<div role="radiogroup" class={{if item.error.Type ' has-error'}}>
|
|
{{#each types as |type|}}
|
|
<label>
|
|
<span>{{capitalize type}}</span>
|
|
<input type="radio" name="Type" value="{{type}}" checked={{if (eq item.Type type) 'checked'}} onchange={{ action 'change' }}/>
|
|
</label>
|
|
{{/each}}
|
|
</div>
|
|
<label class="type-text">
|
|
<span>Policy <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a></span>
|
|
<CodeEditor @class={{if item.error.Rules "error"}} @name="Rules" @value={{item.Rules}} @syntax="hcl" @onkeyup={{action "change" "Rules"}} />
|
|
</label>
|
|
{{#if create }}
|
|
<label class="type-text">
|
|
<span>ID</span>
|
|
<Input @value={{item.ID}} />
|
|
<em>We'll generate a UUID if this field is left empty.</em>
|
|
</label>
|
|
{{/if}}
|
|
</fieldset>
|
|
<div>
|
|
{{#if (and create (can "create acls")) }}
|
|
{{! we only need to check for an empty name here as ember munges autofocus, once we have autofocus back revisit this}}
|
|
<button type="submit" {{ action "create" item}} disabled={{if (or item.isPristine item.isInvalid (eq item.Name '')) 'disabled'}}>Save</button>
|
|
{{else}}
|
|
{{#if (can "write acl" item=item)}}
|
|
<button type="submit" {{ action "update" item}} disabled={{if item.isInvalid 'disabled'}}>Save</button>
|
|
{{/if}}
|
|
{{/if}}
|
|
<button type="reset" {{ action "cancel" item}}>Cancel</button>
|
|
{{# if (and (not create) (can "delete acl" item=item) ) }}
|
|
<ConfirmationDialog @message="Are you sure you want to delete this ACL token?">
|
|
<BlockSlot @name="action" as |confirm|>
|
|
<button type="button" data-test-delete class="type-delete" {{action confirm 'delete' item parent}}>Delete</button>
|
|
</BlockSlot>
|
|
<BlockSlot @name="dialog" as |execute cancel message|>
|
|
<DeleteConfirmation @message={{message}} @execute={{execute}} @cancel={{cancel}} />
|
|
</BlockSlot>
|
|
</ConfirmationDialog>
|
|
{{/if}}
|
|
</div>
|
|
</form>
|
|
|