mirror of
https://github.com/status-im/consul.git
synced 2025-01-26 21:51:39 +00:00
5fb9df1640
* Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at <Blog URL>, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
90 lines
2.5 KiB
Handlebars
90 lines
2.5 KiB
Handlebars
{{!
|
|
Copyright (c) HashiCorp, Inc.
|
|
SPDX-License-Identifier: BUSL-1.1
|
|
}}
|
|
|
|
{{yield}}
|
|
<StateChart @src={{chart}} as |State Guard Action dispatch state|>
|
|
<Ref @target={{this}} @name="dispatch" @value={{dispatch}} />
|
|
<Guard @name="loaded" @cond={{action "isLoaded"}} />
|
|
|
|
|
|
{{#let (hash
|
|
data=data
|
|
error=error
|
|
invalidate=this.invalidate
|
|
dispatchError=(queue (action (mut error) value="error.errors.firstObject") (action dispatch "ERROR"))
|
|
) as |api|}}
|
|
|
|
{{#yield-slot name="data"}}
|
|
{{yield api}}
|
|
{{else}}
|
|
{{! if we didn't specify any data}}
|
|
{{#if (not items)}}
|
|
{{! try and load the data if we aren't in an error state}}
|
|
<State @notMatches={{array "error" "disconnected"}}>
|
|
{{! but only if we only asked for a single load and we are in loading state}}
|
|
{{#if (and src (or (not once) (state-matches state "loading")))}}
|
|
<DataSource
|
|
@open={{open}}
|
|
@src={{src}}
|
|
@onchange={{queue (action "change" value="data") (action dispatch "SUCCESS")}}
|
|
@onerror={{api.dispatchError}}
|
|
as |source|>
|
|
{{did-insert (set this 'invalidate' source.invalidate)}}
|
|
</DataSource>
|
|
{{/if}}
|
|
</State>
|
|
{{/if}}
|
|
{{/yield-slot}}
|
|
|
|
<State @matches="loading">
|
|
{{#yield-slot name="loading"}}
|
|
{{yield api}}
|
|
{{else}}
|
|
<Consul::Loader />
|
|
{{/yield-slot}}
|
|
</State>
|
|
|
|
<State @matches="error">
|
|
{{#yield-slot name="error"}}
|
|
{{yield api}}
|
|
{{else}}
|
|
<ErrorState @error={{error}} />
|
|
{{/yield-slot}}
|
|
</State>
|
|
|
|
<State @matches={{array "idle" "disconnected"}}>
|
|
|
|
<State @matches="disconnected">
|
|
{{#if (not (eq error.status '401'))}}
|
|
{{#yield-slot name="disconnected" params=(block-params (action dispatch "RESET"))}}
|
|
{{yield api}}
|
|
{{else}}
|
|
<Hds::Toast @color='warning'
|
|
{{notification
|
|
sticky=true
|
|
}} as |T|>
|
|
<T.Title>Warning!</T.Title>
|
|
<T.Description>An error was returned whilst loading this data, refresh to try again.</T.Description>
|
|
</Hds::Toast>
|
|
{{/yield-slot}}
|
|
{{/if}}
|
|
</State>
|
|
{{#if (eq error.status "403")}}
|
|
{{#yield-slot name="error"}}
|
|
{{yield api}}
|
|
{{else}}
|
|
<ErrorState @error={{error}} />
|
|
{{/yield-slot}}
|
|
{{else}}
|
|
<YieldSlot @name="loaded">
|
|
{{yield api}}
|
|
</YieldSlot>
|
|
{{/if}}
|
|
|
|
</State>
|
|
|
|
{{/let}}
|
|
{{did-update (fn dispatch "LOAD") src=src}}
|
|
</StateChart> |