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