2020-08-26 15:44:50 -07:00
|
|
|
{{#if this.handleAsyncStateOnly}}
|
2019-08-31 20:51:14 -07:00
|
|
|
{{#if @task.isRunning}}
|
2019-09-18 10:07:04 -07:00
|
|
|
<div class="concurrency-task-state-handler">
|
2020-11-09 12:17:51 -08:00
|
|
|
<NachoAnimation::PendulumEllipsis />
|
2019-09-18 10:07:04 -07:00
|
|
|
</div>
|
2019-08-31 20:51:14 -07:00
|
|
|
{{else}}
|
|
|
|
{{yield}}
|
|
|
|
{{/if}}
|
2020-08-26 15:44:50 -07:00
|
|
|
{{else}}
|
|
|
|
{{#if @task.last.isError}}
|
|
|
|
{{#let (or @errorHeading "An error occurred. Please try again shortly.") as |errorMessage|}}
|
|
|
|
{{! Show entity lockup if toggled on, otherwise yield error. This allows this component to be used in interfaces
|
|
|
|
where rendering the lockup is not suitable, for example in a button
|
|
|
|
<ConcurrencyTaskStateHandler @task=task @showLockup=false>
|
|
|
|
<button>
|
|
|
|
Click Me!
|
|
|
|
</button>
|
|
|
|
</ConcurrencyTaskStateHandler>
|
|
|
|
}}
|
|
|
|
{{#if this.showLockup}}
|
|
|
|
<EmptyState
|
|
|
|
@heading={{errorMessage}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<div class="concurrency-task-state-handler__button-container">
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="nacho-button nacho-button--large-inverse"
|
|
|
|
onclick={{action this.performTask this.taskArgs}}
|
|
|
|
>
|
|
|
|
Retry
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
{{else}}
|
|
|
|
{{! If the callee requires more flexibility, a custom component to handle rendering the error can be provided
|
|
|
|
and will take precedence over the basic message rendering
|
|
|
|
}}
|
|
|
|
{{#if @customErrorComponent}}
|
|
|
|
{{component @customErrorComponent error=@task.last.error message=@errorHeading}}
|
|
|
|
{{else}}
|
|
|
|
{{errorMessage}}
|
|
|
|
{{/if}}
|
|
|
|
{{/if}}
|
|
|
|
{{/let}}
|
|
|
|
|
|
|
|
{{else}}
|
|
|
|
{{#if @task.isRunning}}
|
|
|
|
<div class="concurrency-task-state-handler">
|
2020-11-09 12:17:51 -08:00
|
|
|
<NachoAnimation::PendulumEllipsis />
|
2020-08-26 15:44:50 -07:00
|
|
|
</div>
|
|
|
|
{{else}}
|
|
|
|
{{yield}}
|
|
|
|
{{/if}}
|
|
|
|
{{/if}}
|
2019-08-31 20:51:14 -07:00
|
|
|
{{/if}}
|