diff --git a/core/client.js b/core/client.js index 7398a155..acad4ae5 100644 --- a/core/client.js +++ b/core/client.js @@ -118,28 +118,6 @@ class TfNavigationElement extends LitElement { return this.spark_lines[key]; } - /** - * TODOC - * @returns - */ - render_login() { - if (this?.credentials?.session?.name) { - return html`logout ${this.credentials.session.name}`; - } else { - return html`login`; - } - } - set_active_identity(id) { send({action: 'setActiveIdentity', identity: id}); this.renderRoot.getElementById('id_dropdown').classList.remove('w3-show'); @@ -159,66 +137,102 @@ class TfNavigationElement extends LitElement { window.location.href = '/~core/ssb/#' + this.identity; } + logout() { + window.location.href = `/login/logout?return=${encodeURIComponent(url() + hash())}`; + } + render_identity() { let self = this; - if (this.identities?.length) { - return html` - -
- -
+ + if (this?.credentials?.session?.name) { + if (this.identities?.length) { + return html` + +
- - ${this.identities.map( - (x) => html` - - ` - )} + + + ${this.identities.map( + (x) => html` + + ` + )} + +
-
- `; - } else if ( - this.credentials?.session?.name && - this.credentials.session.name !== 'guest' - ) { - return html` - - - `; + `; + } else if ( + this.credentials?.session?.name && + this.credentials.session.name !== 'guest' + ) { + return html` + + + + `; + } else { + return html` + + `; + } + } else { + return html`login`; } } @@ -358,7 +372,7 @@ class TfNavigationElement extends LitElement { ${Object.keys(this.spark_lines) .sort() .map((x) => this.spark_lines[x])} - ${this.render_login()} ${this.render_identity()} + ${this.render_identity()} ${this.status?.is_error ? html` diff --git a/tools/autotest.py b/tools/autotest.py index fd67a2d4..a5f43fe3 100755 --- a/tools/autotest.py +++ b/tools/autotest.py @@ -125,7 +125,8 @@ try: driver.switch_to.default_content() driver.find_element(By.ID, 'allow').click() - driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.LINK_TEXT, 'logout testuser').click() + driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'identity').click() + driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'logout').click() driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'login_label').click() driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('testuser') driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('test_password') @@ -133,13 +134,8 @@ try: wait.until(expected_conditions.presence_of_element_located((By.ID, 'content'))) - # NoSuchElementException - while True: - try: - driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.LINK_TEXT, 'logout testuser').click() - break - except: - pass + driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'identity').click() + driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'logout').click() driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'guest_label').click() driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'guestButton').click() @@ -148,7 +144,7 @@ try: wait.until(expected_conditions.presence_of_element_located((By.TAG_NAME, 'tf-app'))).shadow_root driver.switch_to.default_content() - driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.LINK_TEXT, 'logout guest').click() + driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'logout').click() driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'login_label').click() driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('testuser') @@ -189,7 +185,8 @@ try: driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'confirm').send_keys('new_password') driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click() wait.until(expected_conditions.presence_of_element_located((By.ID, 'document'))) - driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.LINK_TEXT, 'logout testuser').click() + driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'identity').click() + driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'logout').click() driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'login_label').click() driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'name').send_keys('testuser') driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('test_password')