diff --git a/ui/packages/consul-acls/app/components/consul/token/selector/index.hbs b/ui/packages/consul-acls/app/components/consul/token/selector/index.hbs index dd372e95c8..599aeae6cb 100644 --- a/ui/packages/consul-acls/app/components/consul/token/selector/index.hbs +++ b/ui/packages/consul-acls/app/components/consul/token/selector/index.hbs @@ -53,6 +53,7 @@ -{{#let - (hash - State=State - Guard=Guard - Action=ChartAction - dispatch=dispatch - state=state - ) -as |chart|}} -{{#let - (hash - reset=(action dispatch "RESET") - focus=this.focus - disabled=(state-matches state "loading") - error=(queue - (action dispatch "ERROR") - (action (mut this.error) value="error.errors.firstObject") - ) - submit=(queue - (action (mut this.value)) - (action dispatch "SUBMIT") - ) - ) -as |exported|}} - - {{!TODO: Call this reset or similar }} - -
- -{{#if (can 'use SSO')}} - + {{#let + (hash State=State Guard=Guard Action=ChartAction dispatch=dispatch state=state) + as |chart| + }} + {{#let + (hash + reset=(action dispatch 'RESET') + focus=this.focus + disabled=(state-matches state 'loading') + error=(queue + (action dispatch 'ERROR') (action (mut this.error) value='error.errors.firstObject') ) - (hash - label='SSO' - selected=(state-matches tabState 'sso') - ) - }} - @onclick={{queue (action tabDispatch) (action dispatch "RESET")}} - /> -{{/if}} - - {{#if this.error.status}} - - -

- {{#if this.value.Name}} - {{#if (eq this.error.status '403')}} - Consul login failed
- We received a token from your OIDC provider but could not log in to Consul with it. - {{else if (eq this.error.status '401')}} - Could not log in to provider
- The OIDC provider has rejected this access token. Please have an administrator check your auth method configuration. - {{else if (eq this.error.status '499')}} - SSO log in window closed
- The OIDC provider window was closed. Please try again. - {{else}} - Error
- {{this.error.detail}} - {{/if}} - {{else}} - {{#if (eq this.error.status '403')}} - Invalid token
- The token entered does not exist. Please enter a valid token to log in. - {{else if (eq this.error.status '404')}} - No providers
- No SSO providers are configured for that Partition. - {{else}} - Error
- {{this.error.detail}} - {{/if}} - {{/if}} -

-
-
- {{/if}} -
- -
-
-
- - Log in - -
-
+ +
+
+ +
+ + Log in + +
+
- - Contact your administrator for login credentials. - + {{yield (assign exported (hash Method=TabState))}} + + + Contact your administrator for login credentials. + +
+ +
+ + + + {{/let}} + {{/let}} - - - - - - -{{/let}} -{{/let}} - \ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/oidc-select/index.hbs b/ui/packages/consul-ui/app/components/oidc-select/index.hbs index 1a3ef815c2..3c9d4cb876 100644 --- a/ui/packages/consul-ui/app/components/oidc-select/index.hbs +++ b/ui/packages/consul-ui/app/components/oidc-select/index.hbs @@ -1,134 +1,117 @@ - -{{#let - (hash - State=State - Guard=Guard - Action=ChartAction - dispatch=dispatch - state=state - ) -as |chart|}} + + {{#let + (hash State=State Guard=Guard Action=ChartAction dispatch=dispatch state=state) + as |chart| + }} -
- - - - - - - Choose different Partition - - - - - - - {{! this belongs to the outer StateChart but we need }} - {{! to understand validation state }} - - - Choose provider - - - - - - - - - - - {{#if (lt this.items.length 3)}} - -
    - {{#each this.items as |item|}} -
  • - - Continue with {{or item.DisplayName item.Name}}{{#if (not-eq item.Namespace 'default')}} ({{item.Namespace}}){{/if}} - -
  • - {{/each}} -
- - {{else}} - - {{#let (or this.provider (object-at 0 this.items)) as |item|}} - - - <:option as |option|> - - {{or option.item.DisplayName option.item.Name}}{{#if (not-eq option.item.Namespace 'default')}} ({{option.item.Namespace}}){{/if}} - - - +
+ + + + - Log in + Choose different Partition + - {{/let}} - {{/if}} - + + + + {{! this belongs to the outer StateChart but we need }} + {{! to understand validation state }} + + + Choose provider + + + + + + + + + + + {{#if (lt this.items.length 3)}} + +
    + {{#each this.items as |item|}} +
  • + + Continue with + {{or item.DisplayName item.Name}}{{#if (not-eq item.Namespace 'default')}} + ({{item.Namespace}}){{/if}} + +
  • + {{/each}} +
+ + {{else}} + + {{#let (or this.provider (object-at 0 this.items)) as |item|}} + + + <:option as |option|> + + {{or option.item.DisplayName option.item.Name}}{{#if + (not-eq option.item.Namespace 'default') + }} ({{option.item.Namespace}}){{/if}} + + + + + + Log in + + + {{/let}} + {{/if}} +
-{{/let}} - \ No newline at end of file + {{/let}} + diff --git a/ui/packages/consul-ui/app/components/oidc-select/index.js b/ui/packages/consul-ui/app/components/oidc-select/index.js index 03e24ba7de..4fb78062d4 100644 --- a/ui/packages/consul-ui/app/components/oidc-select/index.js +++ b/ui/packages/consul-ui/app/components/oidc-select/index.js @@ -4,9 +4,14 @@ import { tracked } from '@glimmer/tracking'; import chart from './chart.xstate'; export default class OidcSelect extends Component { - @tracked partition = ''; + @tracked partition = 'default'; + constructor() { super(...arguments); this.chart = chart; + + if (this.args.partition) { + this.partition = this.args.partition; + } } } diff --git a/ui/packages/consul-ui/tests/acceptance/login.feature b/ui/packages/consul-ui/tests/acceptance/login.feature index 17a4ab82b5..9af0bbfeee 100644 --- a/ui/packages/consul-ui/tests/acceptance/login.feature +++ b/ui/packages/consul-ui/tests/acceptance/login.feature @@ -41,6 +41,7 @@ Feature: login --- And I click login on the navigation And I click "[data-test-tab=tab_sso] button" + Then the "[name='partition']" input should have the value "default" And I type "partition" into "[name=partition]" And I click ".oidc-select button" Then a GET request was made to "/v1/internal/ui/oidc-auth-methods?dc=dc-1&ns=@namespace&partition=partition" diff --git a/ui/packages/consul-ui/tests/steps/assertions/dom.js b/ui/packages/consul-ui/tests/steps/assertions/dom.js index b4727055c6..d508911e66 100644 --- a/ui/packages/consul-ui/tests/steps/assertions/dom.js +++ b/ui/packages/consul-ui/tests/steps/assertions/dom.js @@ -85,5 +85,13 @@ export default function (scenario, assert, pauseUntil, find, currentURL, clipboa }) .then(['the title should be "$title"'], function (title) { assert.equal(document.title, title, `Expected the document.title to equal "${title}"`); + }) + .then(['the "$selector" input should have the value "$value"'], function (selector, value) { + const $el = find(selector); + assert.equal( + $el.value, + value, + `Expected the input at ${selector} to have value ${value}, but it had ${$el.value}` + ); }); }