open-consul/ui/packages/consul-ui/app/components/auth-dialog/index.hbs
John Cowen 86e885fc5b
ui: Upgrade AuthDialog (#11913)
- Move AuthDialog to use a Glimmer Component plus native named blocks/slots.
- Unravel the Auth* contextual components, there wasn't a lot of point having them as contextual components and now the AuthDialog (non-view-specific state machine component) can be used entirely separately from the view-specific components (AuthForm and AuthProfile).
- Move all the ACL related components that are in the main app chrome/navigation (our HashicorpConsul component) in our consul-acls sub package/module (which will eventually be loaded on demand only when ACLs are enabled)
2022-01-07 19:08:25 +00:00

47 lines
1.1 KiB
Handlebars

<StateChart
@src={{chart}}
as |State Guard Action dispatch state|>
<Guard
@name="hasToken"
@cond={{action 'hasToken'}}
/>
<Action
@name="login"
@exec={{action 'login'}}
/>
<Action
@name="logout"
@exec={{action 'logout'}}
/>
{{! This DataSource just permanently listens to any changes to the users }}
{{! token, whether thats a new token, a changed token or a deleted token }}
<DataSource
@src={{@src}}
@onchange={{queue (action (mut token) value="data") (action dispatch "CHANGE") (action (mut previousToken) value="data")}}
/>
{{! This DataSink is just used for logging in from the form, }}
{{! or logging out via the exposed logout function }}
<DataSink
@sink={{@sink}}
as |sink|
>
{{#let (hash
login=(action sink.open)
logout=(action sink.open null)
token=token
) as |api|}}
<State @matches="authorized">
{{yield api to="authorized"}}
</State>
<State @matches="unauthorized">
{{yield api to="unauthorized"}}
</State>
{{/let}}
</DataSink>
</StateChart>