open-consul/ui-v2/app/components/oidc-select/index.hbs
John Cowen c96fd3778e ui: Misc SSO w/Namespace amends (#7851)
* ui: If an auth-method is in another namespace than default, make that clear

* Pass through the namespace of the auth method rather than use the current

* Make sure we refresh the application route, before redirecting

This ensure that the nspaces and are refreshed in the main nav menu
2020-05-12 17:14:53 +00:00

48 lines
1.7 KiB
Handlebars

<StateChart @src={{chart}} as |State Guard Action dispatch state|>
<Ref @target={{this}} @name="dispatch" @value={{dispatch}} />
<State @matches="loaded">
<div class="oidc-select" ...attributes>
{{#if (lt items.length 3)}}
<ul>
{{#each items as |item|}}
<li>
<button
disabled={{disabled}}
type="button" class={{concat item.Kind '-oidc-provider'}}
onclick={{action onchange item}}
>
Continue with {{or item.DisplayName item.Name}}{{#if (not-eq item.Namespace 'default')}} ({{item.Namespace}}){{/if}}
</button>
</li>
{{/each}}
</ul>
{{else}}
{{#let (or provider (object-at 0 items)) as |item|}}
<label>
<span>SSO Provider</span>
<PowerSelect
@disabled={{disabled}}
@onChange={{action (mut provider)}}
@selected={{item}}
@searchEnabled={{false}}
@options={{items}} as |item|>
<span class={{concat item.Kind '-oidc-provider'}}>
{{or item.DisplayName item.Name}}{{#if (not-eq item.Namespace 'default')}} ({{item.Namespace}}){{/if}}
</span>
</PowerSelect>
</label>
<button
disabled={{disabled}}
type="button"
onclick={{action onchange item}}
>
Log in
</button>
{{/let}}
{{/if}}
</div>
</State>
<State @matches="loading">
<div class="progress indeterminate"></div>
</State>
</StateChart>