github.com/hernad/nomad@v1.6.112/ui/app/components/variable-form.hbs (about) 1 {{! 2 Copyright (c) HashiCorp, Inc. 3 SPDX-License-Identifier: MPL-2.0 4 ~}} 5 6 {{did-update this.onViewChange @view}} 7 {{did-insert this.establishKeyValues}} 8 <form class="new-variables" autocomplete="off" {{on "submit" this.save}}> 9 10 {{#if @model.isNew}} 11 {{#unless this.isJobTemplateVariable}} 12 <div class="related-entities related-entities-hint"> 13 <p>Prefix your path with <code>nomad/jobs</code> to automatically make your variable accessible to all jobs. <br /> 14 Adding job name, group name, or task name will make your variable available to that specific job, group, or task. <br /> 15 Format: <code>nomad/jobs/<jobname></code>, <code>nomad/jobs/<jobname>/<groupname></code>, <code>nomad/jobs/<jobname>/<groupname>/<taskname></code></p> 16 </div> 17 {{/unless}} 18 19 {{#if this.shouldShowLinkedEntities}} 20 <VariableForm::RelatedEntities 21 @new={{true}} 22 @job={{@model.pathLinkedEntities.job}} 23 @group={{@model.pathLinkedEntities.group}} 24 @task={{@model.pathLinkedEntities.task}} 25 @namespace={{this.variableNamespace}} 26 /> 27 {{/if}} 28 29 {{/if}} 30 31 {{#if this.hasConflict}} 32 <div class="notification conflict is-danger"> 33 <h3 class="title is-4">Heads up! Your variable has a conflict.</h3> 34 <p>This might be because someone else tried saving in the time since you've had it open.</p> 35 {{#if this.conflictingVariable.modifyTime}} 36 <span class="tooltip" aria-label="{{format-ts this.conflictingVariable.modifyTime}}"> 37 {{moment-from-now this.conflictingVariable.modifyTime}} 38 </span> 39 {{/if}} 40 {{#if this.conflictingVariable.items}} 41 <pre><code>{{stringify-object this.conflictingVariable.items whitespace=2}}</code></pre> 42 {{else}} 43 <p>Your ACL token limits your ability to see further details about the conflicting variable.</p> 44 {{/if}} 45 <div class="options"> 46 <button data-test-refresh-button type="button" class="button" {{on "click" this.refresh}}>Refresh your browser</button> 47 <button data-test-overwrite-button type="button" class="button is-danger" {{on "click" this.saveWithOverwrite}}>Overwrite anyway</button> 48 </div> 49 </div> 50 {{/if}} 51 52 <div class={{if this.namespaceOptions "path-namespace"}}> 53 <label> 54 <span> 55 Path 56 </span> 57 <Input 58 @type="text" 59 @value={{this.path}} 60 placeholder="nomad/jobs/my-job/my-group/my-task" 61 class="input path-input {{if this.duplicatePathWarning "error"}}" 62 {{on "input" this.setModelPath}} 63 disabled={{not @model.isNew}} 64 {{autofocus}} 65 data-test-path-input 66 /> 67 {{#if this.duplicatePathWarning}} 68 <p class="duplicate-path-error help is-danger"> 69 There is already a variable located at 70 {{this.path}} 71 . 72 <br /> 73 Please choose a different path, or 74 <LinkTo 75 @route="variables.variable.edit" 76 @model={{this.duplicatePathWarning.path}} 77 > 78 edit the existing variable 79 </LinkTo> 80 . 81 </p> 82 {{/if}} 83 {{#if this.isJobTemplateVariable}} 84 <p class="help job-template-hint"> 85 Use this variable to generate job templates with 86 <code>nomad job init -template={{this.jobTemplateName}} 87 <CopyButton 88 @clipboardText="nomad job init -template={{this.jobTemplateName}}" 89 /> 90 </code> 91 </p> 92 {{/if}} 93 </label> 94 <VariableForm::NamespaceFilter 95 @data={{hash 96 disabled=(not @model.isNew) 97 selection=this.variableNamespace 98 namespaceOptions=this.namespaceOptions 99 }} 100 @fns={{hash 101 onSelect=this.setNamespace 102 setNamespaceOptions=this.setNamespaceOptions 103 }} 104 /> 105 </div> 106 {{#if this.isJobTemplateVariable}} 107 <VariableForm::JobTemplateEditor 108 @keyValues={{this.keyValues}} 109 @updateKeyValue={{this.updateKeyValue}} 110 /> 111 {{else}} 112 {{#if (eq this.view "json")}} 113 <div 114 class="editor-wrapper boxed-section-body is-full-bleed 115 {{if this.JSONError 'error'}}" 116 > 117 <div 118 data-test-json-editor 119 {{code-mirror 120 content=this.JSONItems 121 onUpdate=this.updateCode 122 extraKeys=(hash Cmd-Enter=(action "save")) 123 }} 124 ></div> 125 {{#if this.JSONError}} 126 <p class="help is-danger"> 127 {{this.JSONError}} 128 </p> 129 {{/if}} 130 </div> 131 {{else}} 132 {{#each this.keyValues as |entry iter|}} 133 <div class="key-value"> 134 <label> 135 <span> 136 Key 137 </span> 138 <Input 139 data-test-var-key 140 @type="text" 141 @value={{entry.key}} 142 class="input" 143 {{autofocus ignore=(eq iter 0)}} 144 {{on "input" (fn this.validateKey entry)}} 145 /> 146 </label> 147 <VariableForm::InputGroup @entry={{entry}} /> 148 <button 149 class="delete-row button is-danger is-inverted" 150 type="button" 151 {{on "click" (action this.deleteRow entry)}} 152 disabled={{eq this.keyValues.length 1}} 153 > 154 Delete 155 </button> 156 {{#each-in entry.warnings as |k v|}} 157 <span class="key-value-error help is-danger"> 158 {{v}} 159 </span> 160 {{/each-in}} 161 </div> 162 {{/each}} 163 {{/if}} 164 {{/if}} 165 166 <footer> 167 {{#unless this.isJSONView}} 168 {{#unless this.isJobTemplateVariable}} 169 <button 170 class="add-more button is-info is-inverted" 171 type="button" 172 disabled={{not (and this.keyValues.lastObject.key this.keyValues.lastObject.value)}} 173 {{on "click" this.appendRow}} 174 data-test-add-kv 175 > 176 Add More 177 </button> 178 {{/unless}} 179 {{/unless}} 180 <button 181 disabled={{this.shouldDisableSave}} 182 class="button is-primary save" 183 type="submit" 184 data-test-submit-var 185 > 186 Save 187 {{pluralize "Variable" @this.keyValues.length}} 188 </button> 189 </footer> 190 </form>