Consolidate the acount/login navigation bar options to try to save some space on mobile.
This commit is contained in:
parent
0f3be229e6
commit
3630cdbfe0
@ -118,28 +118,6 @@ class TfNavigationElement extends LitElement {
|
|||||||
return this.spark_lines[key];
|
return this.spark_lines[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODOC
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
render_login() {
|
|
||||||
if (this?.credentials?.session?.name) {
|
|
||||||
return html`<a
|
|
||||||
class="w3-bar-item w3-right"
|
|
||||||
id="login"
|
|
||||||
href="/login/logout?return=${url() + hash()}"
|
|
||||||
>logout ${this.credentials.session.name}</a
|
|
||||||
>`;
|
|
||||||
} else {
|
|
||||||
return html`<a
|
|
||||||
class="w3-bar-item w3-right"
|
|
||||||
id="login"
|
|
||||||
href="/login?return=${url() + hash()}"
|
|
||||||
>login</a
|
|
||||||
>`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set_active_identity(id) {
|
set_active_identity(id) {
|
||||||
send({action: 'setActiveIdentity', identity: id});
|
send({action: 'setActiveIdentity', identity: id});
|
||||||
this.renderRoot.getElementById('id_dropdown').classList.remove('w3-show');
|
this.renderRoot.getElementById('id_dropdown').classList.remove('w3-show');
|
||||||
@ -159,8 +137,14 @@ class TfNavigationElement extends LitElement {
|
|||||||
window.location.href = '/~core/ssb/#' + this.identity;
|
window.location.href = '/~core/ssb/#' + this.identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logout() {
|
||||||
|
window.location.href = `/login/logout?return=${encodeURIComponent(url() + hash())}`;
|
||||||
|
}
|
||||||
|
|
||||||
render_identity() {
|
render_identity() {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
|
||||||
|
if (this?.credentials?.session?.name) {
|
||||||
if (this.identities?.length) {
|
if (this.identities?.length) {
|
||||||
return html`
|
return html`
|
||||||
<link type="text/css" rel="stylesheet" href="/static/w3.css" />
|
<link type="text/css" rel="stylesheet" href="/static/w3.css" />
|
||||||
@ -168,6 +152,7 @@ class TfNavigationElement extends LitElement {
|
|||||||
<button
|
<button
|
||||||
class="w3-button w3-rest w3-cyan"
|
class="w3-button w3-rest w3-cyan"
|
||||||
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap; max-width: 100%"
|
style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap; max-width: 100%"
|
||||||
|
id="identity"
|
||||||
@click=${self.toggle_id_dropdown}
|
@click=${self.toggle_id_dropdown}
|
||||||
>
|
>
|
||||||
${self.names[this.identity]}▾
|
${self.names[this.identity]}▾
|
||||||
@ -202,6 +187,12 @@ class TfNavigationElement extends LitElement {
|
|||||||
</button>
|
</button>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
|
<button
|
||||||
|
class="w3-bar-item w3-button w3-border"
|
||||||
|
id="logout"
|
||||||
|
@click=${self.logout}
|
||||||
|
>Logout ${this.credentials.session.name}</button
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@ -211,14 +202,37 @@ class TfNavigationElement extends LitElement {
|
|||||||
) {
|
) {
|
||||||
return html`
|
return html`
|
||||||
<link type="text/css" rel="stylesheet" href="/static/w3.css" />
|
<link type="text/css" rel="stylesheet" href="/static/w3.css" />
|
||||||
|
<button
|
||||||
|
class="w3-bar-item w3-right w3-cyan"
|
||||||
|
id="logout"
|
||||||
|
@click=${self.logout}
|
||||||
|
>Logout ${this.credentials.session.name}</button
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
id="create_identity"
|
id="create_identity"
|
||||||
@click=${this.create_identity}
|
@click=${this.create_identity}
|
||||||
class="w3-button w3-mobile w3-blue w3-right"
|
class="w3-button w3-mobile w3-cyan w3-right"
|
||||||
>
|
>
|
||||||
Create an Identity
|
Create an Identity
|
||||||
</button>
|
</button>
|
||||||
`;
|
`;
|
||||||
|
} else {
|
||||||
|
return html`
|
||||||
|
<button
|
||||||
|
class="w3-bar-item w3-button w3-right w3-cyan"
|
||||||
|
id="logout"
|
||||||
|
@click=${self.logout}
|
||||||
|
>Logout ${this.credentials.session.name}</button
|
||||||
|
>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return html`<a
|
||||||
|
class="w3-bar-item w3-cyan w3-right"
|
||||||
|
id="login"
|
||||||
|
href="/login?return=${url() + hash()}"
|
||||||
|
>login</a
|
||||||
|
>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +372,7 @@ class TfNavigationElement extends LitElement {
|
|||||||
${Object.keys(this.spark_lines)
|
${Object.keys(this.spark_lines)
|
||||||
.sort()
|
.sort()
|
||||||
.map((x) => this.spark_lines[x])}
|
.map((x) => this.spark_lines[x])}
|
||||||
${this.render_login()} ${this.render_identity()}
|
${this.render_identity()}
|
||||||
</div>
|
</div>
|
||||||
${this.status?.is_error
|
${this.status?.is_error
|
||||||
? html`
|
? html`
|
||||||
|
@ -125,7 +125,8 @@ try:
|
|||||||
driver.switch_to.default_content()
|
driver.switch_to.default_content()
|
||||||
driver.find_element(By.ID, 'allow').click()
|
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, '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, 'name').send_keys('testuser')
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('test_password')
|
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')))
|
wait.until(expected_conditions.presence_of_element_located((By.ID, 'content')))
|
||||||
|
|
||||||
# NoSuchElementException
|
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'identity').click()
|
||||||
while True:
|
driver.find_element(By.TAG_NAME, 'tf-navigation').shadow_root.find_element(By.ID, 'logout').click()
|
||||||
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-auth').shadow_root.find_element(By.ID, 'guest_label').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()
|
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
|
wait.until(expected_conditions.presence_of_element_located((By.TAG_NAME, 'tf-app'))).shadow_root
|
||||||
driver.switch_to.default_content()
|
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, '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, '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, 'confirm').send_keys('new_password')
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'loginButton').click()
|
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')))
|
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, '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, 'name').send_keys('testuser')
|
||||||
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('test_password')
|
driver.find_element(By.TAG_NAME, 'tf-auth').shadow_root.find_element(By.ID, 'password').send_keys('test_password')
|
||||||
|
Loading…
Reference in New Issue
Block a user