mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 21:35:52 +00:00
f2accb0bd1
* Add uri identifiers to all data source things and make them the same 1. Add uri identitifer to data-source service 2. Make <EventSource /> and <DataSource /> as close as possible 3. Add extra `.closed` method to get a list of inactive/closed/closing data-sources from elsewhere * Make the connections cleanup the least worst connection when required * Pass the uri/request id through all the things * Better user erroring * Make event sources close on error * Allow <DataLoader /> data slot to be configurable * Allow the <DataWriter /> removed state to be configurable * Don't error if meta is undefined * Stitch together all the repositories into the data-source/sink * Use data.source over repositories * Add missing <EventSource /> components * Fix up the views/templates * Disable all the old route based blocking query things * We still need the repo for the mixin for the moment * Don't default to default, default != ''
80 lines
2.4 KiB
Handlebars
80 lines
2.4 KiB
Handlebars
<StateChart @src={{chart}} as |State Guard Action dispatch state|>
|
|
|
|
<Ref @target={{this}} @name="dispatch" @value={{dispatch}} />
|
|
|
|
{{#let (hash
|
|
data=data
|
|
error=error
|
|
persist=(action "persist")
|
|
delete=(queue (action (mut data)) (action dispatch "REMOVE"))
|
|
inflight=(state-matches state (array "persisting" "removing"))
|
|
) as |api|}}
|
|
|
|
{{yield api}}
|
|
|
|
<State @matches="removing">
|
|
<DataSink
|
|
@sink={{sink}}
|
|
@item={{data}}
|
|
@data={{null}}
|
|
@onchange={{action dispatch "SUCCESS"}}
|
|
@onerror={{queue (action (mut error) value="error.errors.firstObject") (action dispatch "ERROR")}}
|
|
/>
|
|
</State>
|
|
|
|
<State @matches="persisting">
|
|
<DataSink
|
|
@sink={{sink}}
|
|
@item={{data}}
|
|
@onchange={{action dispatch "SUCCESS"}}
|
|
@onerror={{queue (action (mut error) value="error.errors.firstObject") (action dispatch "ERROR")}}
|
|
/>
|
|
</State>
|
|
|
|
<State @matches="removed">
|
|
{{#yield-slot name="removed" params=(block-params (component 'notification' after=(queue (action dispatch "RESET") (action ondelete))))}}
|
|
{{yield api}}
|
|
{{else}}
|
|
<Notification @after={{queue (action dispatch "RESET") (action ondelete)}}>
|
|
<p data-notification role="alert" class="success notification-delete">
|
|
<strong>Success!</strong>
|
|
Your {{type}} has been deleted.
|
|
</p>
|
|
</Notification>
|
|
{{/yield-slot}}
|
|
</State>
|
|
|
|
<State @matches="persisted">
|
|
<Notification @after={{action onchange}}>
|
|
{{#yield-slot name="persisted"}}
|
|
{{yield api}}
|
|
{{else}}
|
|
<p data-notification role="alert" class="success notification-update">
|
|
<strong>Success!</strong>
|
|
Your {{type}} has been saved.
|
|
</p>
|
|
{{/yield-slot}}
|
|
</Notification>
|
|
</State>
|
|
|
|
<State @matches="error">
|
|
{{#yield-slot name="error" params=(block-params (component 'notification' after=(action dispatch "RESET")))}}
|
|
{{yield api}}
|
|
{{else}}
|
|
<Notification @after={{action dispatch "RESET"}}>
|
|
<p data-notification role="alert" class="error notification-update">
|
|
<strong>Error!</strong>
|
|
There was an error saving your {{type}}.
|
|
{{#if (and api.error.status api.error.detail)}}
|
|
<br />{{api.error.status}}: {{api.error.detail}}
|
|
{{/if}}
|
|
</p>
|
|
</Notification>
|
|
{{/yield-slot}}
|
|
</State>
|
|
<YieldSlot @name="content">
|
|
{{yield api}}
|
|
</YieldSlot>
|
|
|
|
{{/let}}
|
|
</StateChart> |