2021-04-06 12:40:40 +00:00
<Route
@name= {{ routeName }}
as |route|>
2021-09-15 18:50:11 +00:00
{{ # let
'/'
as |separator|}}
{{ # let
(concat (join separator (slice 0 -1 (split route.params.key separator))) separator)
as |parentKey|}}
<DataLoader
@src= {{ uri '/${partition}/${nspace}/${dc}/kv/${key}'
(hash
partition=route.params.partition
nspace=route.params.nspace
dc=route.params.dc
key=(if (string-ends-with routeName 'create') parentKey route.params.key)
)
}}
as |loader|>
<BlockSlot @name="error">
<AppError
@error= {{ loader .error }}
@login= {{ route .model .app .login .open }}
/>
</BlockSlot>
<BlockSlot @name="loaded">
{{ # let
route.params.dc
route.params.partition
route.params.nspace
loader.data
as |dc partition nspace item|}}
2021-04-06 12:40:40 +00:00
<AppView>
2021-12-01 11:33:33 +00:00
2021-04-06 12:40:40 +00:00
<BlockSlot @name="breadcrumbs">
<ol>
2021-12-01 11:33:33 +00:00
<li>
<Action
data-test-back
@href= {{ href-to 'dc.kv.index' }}
>
Key / Values
</Action>
</li>
2021-09-15 18:50:11 +00:00
{{ # if ( not-eq parentKey separator ) }}
{{ # let
(split parentKey separator)
as |parts|}}
{{ # each parts as | breadcrumb in dex | }}
{{ # if ( gt breadcrumb .length 0 ) }}
{{! if breadcrumb isn't '' then slice of enough of the parentKey }}
{{! to make the correct href. 'Enough' is the current index plus 1.}}
{{! We push on a '' here so make sure we get a trailing slash/separator }}
<li>
2021-12-01 11:33:33 +00:00
<Action
@href= {{ href-to 'dc.kv.folder'
2021-09-15 18:50:11 +00:00
(join '/'
(append
(slice 0 (add index 1) parts) ''
)
)
}}
>
{{ breadcrumb }}
2021-12-01 11:33:33 +00:00
</Action>
2021-09-15 18:50:11 +00:00
</li>
{{ / if }}
2021-04-06 12:40:40 +00:00
{{ / each }}
2021-09-15 18:50:11 +00:00
{{ / let }}
{{ / if }}
2021-04-06 12:40:40 +00:00
</ol>
</BlockSlot>
2021-12-01 11:33:33 +00:00
2021-04-06 12:40:40 +00:00
<BlockSlot @name="header">
<h1>
2021-12-01 11:33:33 +00:00
{{ # if ( and item .Key ( not-eq item .Key parentKey ) ) }}
2021-09-15 18:50:11 +00:00
<route.Title @title="Edit Key / Value" @render= {{ false }} />
{{ left-trim item .Key parentKey }}
2021-12-01 11:33:33 +00:00
{{ else }}
2021-09-15 18:50:11 +00:00
<route.Title @title="New Key / Value" @render= {{ true }} />
2021-12-01 11:33:33 +00:00
{{ / if }}
2021-04-06 12:40:40 +00:00
</h1>
</BlockSlot>
2021-12-01 11:33:33 +00:00
2021-04-06 12:40:40 +00:00
<BlockSlot @name="content">
2021-12-01 11:33:33 +00:00
{{! if a KV has a session `Session` will always be populated despite any specific session permissions }}
2021-09-15 18:50:11 +00:00
{{ # if item .Session }}
2021-04-06 12:40:40 +00:00
<Notice
@type="warning"
data-test-session-warning
as |notice|>
<notice.Body>
<p>
<strong>Warning.</strong> This KV has a lock session. You can edit KV's with lock sessions, but we recommend doing so with care, or not doing so at all. It may negatively impact the active node it's associated with. See below for more details on the Lock Session and see <a href=" {{ env 'CONSUL_DOCS_URL' }} /internals/sessions.html" target="_blank" rel="noopener noreferrer">our documentation</a> for more information.
</p>
</notice.Body>
</Notice>
2021-09-15 18:50:11 +00:00
{{ / if }}
2021-12-01 11:33:33 +00:00
2021-04-06 12:40:40 +00:00
<Consul::Kv::Form
@item= {{ item }}
2021-09-15 18:50:11 +00:00
@dc= {{ route .params .dc }}
@nspace= {{ route .params .nspace }}
@partition= {{ route .params .partition }}
@onsubmit= {{ if ( eq parentKey separator ) ( transition-to 'dc.kv.index' ) ( transition-to 'dc.kv.folder' parentKey ) }}
@parent= {{ parentKey }}
2021-04-06 12:40:40 +00:00
/>
2021-09-15 18:50:11 +00:00
2021-12-01 11:33:33 +00:00
2021-12-01 11:06:44 +00:00
{{! `session` is slightly different to `item.Session` as we only have `session` }}
{{! if you have `session:read perms` whereas you can get the sessions ID from }}
{{! `item.Session` without any session perms }}
{{ # if ( and item .Session ) }}
2021-09-15 18:50:11 +00:00
<DataSource
@src= {{ uri '/${partition}/${nspace}/${dc}/sessions/for-key/${id}'
(hash
partition=route.params.partition
nspace=route.params.nspace
dc=route.params.dc
id=item.Session
)
}}
@onchange= {{ action ( mut session ) value = "data" }}
/>
2021-12-01 11:33:33 +00:00
<h2>
<Action
rel="help"
@href= {{ concat ( env 'CONSUL_DOCS_URL' ) '/internals/sessions.html#session-design' }}
@external= {{ true }}
>
Lock Session
</Action>
</h2>
{{ # if session .ID }}
2021-04-06 12:40:40 +00:00
<Consul::LockSession::Form
@item= {{ session }}
2021-12-01 11:33:33 +00:00
@ondelete= {{ loader .invalidate }}
2021-04-06 12:40:40 +00:00
/>
2021-09-15 18:50:11 +00:00
{{ / if }}
{{ / if }}
2021-04-06 12:40:40 +00:00
</BlockSlot>
</AppView>
2021-09-15 18:50:11 +00:00
{{ / let }}
</BlockSlot>
</DataLoader>
{{ / let }}
{{ / let }}
2021-04-06 12:40:40 +00:00
</Route>