open-nomad/ui/app/components/metadata-kv.hbs
Michael Schurter 35d65c7c7e
Dynamic Node Metadata (#15844)
Fixes #14617
Dynamic Node Metadata allows Nomad users, and their jobs, to update Node metadata through an API. Currently Node metadata is only reloaded when a Client agent is restarted.

Includes new UI for editing metadata as well.

---------

Co-authored-by: Phil Renaud <phil.renaud@hashicorp.com>
2023-02-07 14:42:25 -08:00

64 lines
1.8 KiB
Handlebars

<tr data-test-attributes-section>
{{#if this.editing}}
<td colspan="2">
<MetadataEditor
@kv={{hash key=this.prefixedKey value=this.value}}
@onEdit={{this.onEdit}}
@constantKey={{true}}
@autofocusValue={{true}}
>
<button
data-test-update-metadata
disabled={{or (not @key) (not @value)}}
type="submit"
class="button is-primary"
{{on "click" (queue
(action @onKVSave (hash key=this.prefixedKey value=this.value))
(action (mut this.editing) false)
)}}
>
Update {{this.prefixedKey}}
</button>
<button
data-test-delete-metadata
type="button"
class="button is-danger"
{{on "click" (queue
(action @onKVSave (hash key=this.prefixedKey value=null))
(action (mut this.editing) false)
)}}
>
Delete Property
</button>
<button
data-test-cancel-metadata
type="button"
class="button"
{{on "click"
(queue
(action (mut this.editing) false)
(action (mut this.value) @value)
)
}}
>
Cancel
</button>
</MetadataEditor>
</td>
{{else}}
<td data-test-key>
{{#if @prefix}}<span class="is-faded" data-test-prefix>{{@prefix}}.</span>{{/if}}
{{~@key}}
</td>
<td title="{{@value}}">
<span data-test-value>{{@value}}</span>
{{#if @editable}}
<button class="button is-light is-compact edit-existing-metadata-button" type="button"
{{on "click" (action (mut this.editing) true)}}
>Edit</button>
{{/if}}
</td>
{{/if}}
</tr>