From aef0424a012dbc5801afd931b80d486cb629941a Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Thu, 20 Jul 2023 19:18:05 +1000 Subject: [PATCH] Dev UI: Change page title to indicate sub page Signed-off-by: Phillip Kruger --- .../dev-ui/controller/router-controller.js | 16 ++++++++-- .../main/resources/dev-ui/qwc/qwc-header.js | 22 ++++++++++++- .../src/main/resources/dev-ui/qwc/qwc-menu.js | 31 +++++++++++++++---- 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/router-controller.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/router-controller.js index 25497656d93cf..fefced2e6236e 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/router-controller.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/controller/router-controller.js @@ -41,7 +41,6 @@ export class RouterController { } getCurrentTitle(){ - let dot = "\u00B7"; let p = this.getCurrentPage(); if(p){ if(p.namespaceLabel){ @@ -49,7 +48,7 @@ export class RouterController { }else { let md = this.getCurrentMetaData(); if(md && md.extensionName){ - return md.extensionName + " " + dot + " " + p.title; + return md.extensionName; }else { return p.title; } @@ -58,6 +57,19 @@ export class RouterController { return null; } + getCurrentSubTitle(){ + let p = this.getCurrentPage(); + if(p){ + if(!p.namespaceLabel){ + let md = this.getCurrentMetaData(); + if(md && md.extensionName){ + return p.title; + } + } + } + return null; + } + getCurrentNamespace(){ let p = this.getCurrentPage(); if(p){ diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-header.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-header.js index f2eb0235d4877..40e2f9d2dd766 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-header.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-header.js @@ -67,6 +67,14 @@ export class QwcHeader extends observeState(LitElement) { color: var(--lumo-contrast-90pct); } + .subtitle { + display: flex; + align-items:center; + font-size: var(--lumo-font-size-xl); + padding-left: 8px; + color: var(--lumo-contrast-50pct); + } + .logo-text { padding-top: 10px; font-size: xx-large; @@ -89,6 +97,7 @@ export class QwcHeader extends observeState(LitElement) { static properties = { _title: {state: true}, + _subTitle: {state: true}, _rightSideNav: {state: true}, _selectedTheme: {state: true}, _themeOptions: {state: true}, @@ -98,6 +107,7 @@ export class QwcHeader extends observeState(LitElement) { constructor() { super(); this._title = "Extensions"; + this._subTitle = null; this._rightSideNav = ""; this._createThemeItems(); @@ -149,7 +159,7 @@ export class QwcHeader extends observeState(LitElement) { Quarkus Dev UI - ${this._title} + ${this._renderTitle()}
${this._rightSideNav} @@ -159,6 +169,15 @@ export class QwcHeader extends observeState(LitElement) { `; } + _renderTitle(){ + let dot = "\u00B7"; + if(this._subTitle){ + return html`${this._title}${dot} ${this._subTitle}`; + }else{ + return html`${this._title}`; + } + } + _renderThemeOptions(){ return html` diff --git a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-menu.js b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-menu.js index 1050f1e5da2df..9dbfb970f49a4 100644 --- a/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-menu.js +++ b/extensions/vertx-http/dev-ui-resources/src/main/resources/dev-ui/qwc/qwc-menu.js @@ -180,12 +180,8 @@ export class QwcMenu extends observeState(LitElement) { } let pageRef = this.routerController.getPageUrlFor(page); - const selected = this._selectedPage == page.namespace; - let classnames = "item"; - if(selected){ - classnames = "item selected"; - } - + + let classnames = this._getClassNames(page, index); return html` @@ -195,6 +191,29 @@ export class QwcMenu extends observeState(LitElement) { } } + _getClassNames(page, index){ + + const selected = this._selectedPage == page.namespace; + if(selected){ + return "item selected"; + } + + // Else check for default + let pages = devuiState.menu; + let hasMenuItem = false; + for (let i = 0; i < pages.length; i++) { + if(this._selectedPage === pages[i].namespace){ + hasMenuItem = true; + } + } + + if(!hasMenuItem && index === 0){ + return "item selected"; + } + + return "item"; + } + _renderIcon(icon, action){ if((action == "smaller" && this._show) || (action == "larger" && !this._show)){ return html`