Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tooltipText param to TopNav and LeftNav #2242

Merged
merged 32 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2085f8d
Add tooltipText param to TopNav and LeftNav
rafalgamon Aug 31, 2021
7d7b884
Add tooltipText param to TopNav and LeftNav
rafalgamon Aug 31, 2021
fc55dab
Add tooltipText param to TopNav and LeftNav
rafalgamon Aug 31, 2021
bb7b32e
Merge branch 'master' into 2160-tooltiptext-for-navigation
ndricimrr Sep 1, 2021
73babc5
Add defaults.tooltipText param to TopNav and LeftNav
rafalgamon Sep 3, 2021
0b7b219
Merge branch 'master' into 2160-tooltiptext-for-navigation
ndricimrr Sep 6, 2021
7500837
Merge branch 'master' into 2160-tooltiptext-for-navigation
ndricimrr Sep 8, 2021
59441c7
2160 | Implemented changed in logic after Code Review
rafalgamon Sep 9, 2021
829977b
Merge branch 'master' into 2160-tooltiptext-for-navigation
ndricimrr Sep 13, 2021
9cfb610
Merge branch 'master' into 2160-tooltiptext-for-navigation
ndricimrr Sep 15, 2021
ae7f47d
Merge branch 'master' into 2160-tooltiptext-for-navigation
ndricimrr Sep 15, 2021
0d4741a
2160 | Move resolveTooltipText() to navigation-helpers.js
rafalgamon Sep 16, 2021
d5320c6
Update docs/navigation-parameters-reference.md
rafalgamon Sep 17, 2021
e8bcb97
Update docs/navigation-parameters-reference.md
rafalgamon Sep 17, 2021
3870b5c
Merge branch 'master' into 2160-tooltiptext-for-navigation
UlianaMunich Sep 22, 2021
bb9f887
Merge branch 'master' into 2160-tooltiptext-for-navigation
ndricimrr Sep 22, 2021
55cf104
2160 | Fixed tooltipText for <a> in TopNav section
rafalgamon Sep 23, 2021
cc3bc34
2160 | Fixed defaults.tooltipText in docu
rafalgamon Sep 24, 2021
606cae9
Update docs/navigation-parameters-reference.md
rafalgamon Sep 29, 2021
2fa9131
Merge branch 'master' into 2160-tooltiptext-for-navigation
ndricimrr Sep 29, 2021
d45d340
Merge branch 'master' into 2160-tooltiptext-for-navigation
JohannesDoberer Oct 11, 2021
e4c2006
2160 | Changed logic of tooltipText
rafalgamon Oct 12, 2021
f2d6150
Merge branch '2160-tooltiptext-for-navigation' of ssh://github.com/ra…
rafalgamon Oct 12, 2021
256ed6a
2160 | Fixed burgerTooltip
rafalgamon Oct 12, 2021
50d1e46
Merge branch 'master' into 2160-tooltiptext-for-navigation
JohannesDoberer Oct 14, 2021
91d06cf
Merge branch 'master' into 2160-tooltiptext-for-navigation
rafalgamon Oct 18, 2021
fbc9562
Merge branch 'master' into 2160-tooltiptext-for-navigation
hardl Oct 19, 2021
eb954a9
2160 | Changed tooltipText docu
rafalgamon Oct 19, 2021
cb024d6
Merge branch '2160-tooltiptext-for-navigation' of ssh://github.com/ra…
rafalgamon Oct 19, 2021
74621fc
Merge branch 'master' into 2160-tooltiptext-for-navigation
hardl Oct 21, 2021
a44f545
Merge branch 'master' into 2160-tooltiptext-for-navigation
JohannesDoberer Oct 22, 2021
7ccef82
Merge branch 'master' into 2160-tooltiptext-for-navigation
JohannesDoberer Oct 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions core/src/AuthorizationSimpleProfileMenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,18 @@
</li>
{/each} {#if hasUserSettings}
<li
tabindex="-1"
tabindex="-1"
class="fd-menu__item lui-anchor-node"
on:click|preventDefault="{onUserSettingsClick}"
on:keyup="{(event) => handleKeyUp(event)}"
data-testid="{getTestId(profileNav.settings)}"
>
<a tabindex="0" title="User Settings" class="fd-menu__link" data-testid="settings-link">
<a
tabindex="0"
title="User Settings"
class="fd-menu__link"
data-testid="settings-link"
>
{#if profileNav.settings.icon} {#if hasOpenUIicon(profileNav.settings)}
<i class="fd-top-nav__icon sap-icon--{profileNav.settings.icon}"></i>
{:else}
Expand Down Expand Up @@ -296,10 +301,10 @@
}

li > button.fd-menu__link {
background-color: var(--sapList_Background,#fff);
background-color: var(--sapList_Background, #fff);

&:hover {
background-color: var(--sapList_Hover_Background,#f5f5f5);
background-color: var(--sapList_Hover_Background, #f5f5f5);
}
}
</style>
33 changes: 20 additions & 13 deletions core/src/UserSettingsEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,14 @@

export function handleKeyListItem(event, index) {
if (event.keyCode === KEYCODE_ENTER || event.keyCode === KEYCODE_SPACE) {
document.querySelectorAll('.lui-usersettings-content li.fd-list__item')[index].click();
document
.querySelectorAll('.lui-usersettings-content li.fd-list__item')
[index].click();
}
}

/*to display a language on forst load of the User Settings dialog*/
/*to display a language on forst load of the User Settings dialog*/

getLabelForValue();
</script>

Expand Down Expand Up @@ -192,25 +195,29 @@
aria-expanded="false"
aria-haspopup="true"
on:click|stopPropagation="{()=>toggleOptions(event,schemaItem.isEditable)}"
>
>
<div class="fd-select">
<div
<div
tabindex="0"
aria-expanded="false"
aria-haspopup="listbox"
aria-expanded="false"
aria-haspopup="listbox"
aria-label="Language"
class="fd-select__control lui-anchor-node"
class="fd-select__control lui-anchor-node"
on:keyup="{(event) => handleKeyUp(event)}"
data-testid="lui-us-language-dropdown">
<span
data-testid="lui-us-language-dropdown"
>
<span
class="fd-select__text-content"
data-testid="lui-us-input{i}"
disabled="{schemaItem.isEditable===undefined || schemaItem.isEditable?false:true}"
>{getLabelForValue(storedUserSettingData[userSettingGroup[0]][key], schemaItem.options)}
>{getLabelForValue(storedUserSettingData[userSettingGroup[0]][key],
schemaItem.options)}
</span>
<span
class="fd-button fd-button--transparent fd-select__button lui-activate-language-dropdown"
>
<i class="sap-icon--slim-arrow-down"></i>
</span>
<span class="fd-button fd-button--transparent fd-select__button lui-activate-language-dropdown">
<i class="sap-icon--slim-arrow-down"></i>
</span>
</div>
</div>
</div>
Expand Down
21 changes: 14 additions & 7 deletions core/src/navigation/LeftNav.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
<div class="lui-nav-title">
<ul class="fd-nested-list">
<li class="fd-nested-list__item">
<a class="fd-nested-list__link" title="{$getTranslation(navHeader.label)}">
<a
class="fd-nested-list__link"
title="{resolveTooltipText(navHeader, $getTranslation(navHeader.label))}"
>
{#if navHeader.icon} {#if isOpenUIiconName(navHeader.icon)}
<i
class="lui-header-icon fd-nested-list__icon sap-icon sap-icon--{navHeader.icon}"
Expand Down Expand Up @@ -56,7 +59,7 @@
<li class="fd-nested-list__item">
<a
href="{getRouteLink(node)}"
title="{$getTranslation(node.label)}"
title="{resolveTooltipText(node, $getTranslation(node.label))}"
class="fd-nested-list__link {node === selectedNode ? 'is-selected' : ''}"
on:click|preventDefault="{() => handleClick(node)}"
data-testid="{getTestId(node)}"
Expand Down Expand Up @@ -98,7 +101,7 @@
<div class="fd-nested-list__content has-child">
<a
href="javascript:void(null)"
title="{$getTranslation(key)}"
title="{resolveTooltipText(nodes, $getTranslation(key))}"
class="fd-nested-list__link {isExpanded(nodes, expandedCategories) ? 'is-expanded' : ''}"
tabindex="-1"
id="collapsible_listnode_{index}"
Expand Down Expand Up @@ -150,7 +153,7 @@
class="fd-nested-list__link {node === selectedNode ? 'is-selected' : ''}"
on:click|preventDefault="{() => handleClick(node)}"
data-testid="{getTestId(node)}"
title="{$getTranslation(node.label)}"
title="{resolveTooltipText(node, $getTranslation(node.label))}"
>
<span class="fd-nested-list__title">{$getTranslation(node.label)}</span>
{#if node.externalLink && node.externalLink.url}
Expand Down Expand Up @@ -179,7 +182,7 @@
class="fd-nested-list__link {node === selectedNode ? 'is-selected' : ''}"
on:click|preventDefault="{() => handleClick(node)}"
data-testid="{getTestId(node)}"
title="{$getTranslation(node.label)}"
title="{resolveTooltipText(node, $getTranslation(node.label))}"
>
<span class="fd-nested-list__title"
>{$getTranslation(node.label)}</span
Expand All @@ -201,7 +204,7 @@
<!-- Category nodes -->
<li
class="fd-nested-list__group-header lui-category"
title="{$getTranslation(key)}"
title="{resolveTooltipText(nodes, $getTranslation(key))}"
data-testid="{getTestIdForCat(nodes.metaInfo, key)}"
id="category_list_level1_{index}"
>
Expand All @@ -223,7 +226,7 @@
{#each nodes as node} {#if !node.hideFromNav} {#if node.label}
<li
class="fd-nested-list__item"
title="{$getTranslation(node.label)}"
title="{resolveTooltipText(node, $getTranslation(node.label))}"
aria-labelledby="category_list_level1_{index}"
>
<a
Expand Down Expand Up @@ -552,6 +555,10 @@
: NavigationHelpers.prepareForTests(key || metaInfo.label);
}

function resolveTooltipText(node, translation) {
return NavigationHelpers.generateTooltipText(node, translation);
}

// [svelte-upgrade suggestion]
// review these functions and remove unnecessary 'export' keywords
export function handleClick(node) {
Expand Down
11 changes: 8 additions & 3 deletions core/src/navigation/TopNav.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<div class="fd-popover fd-popover--right">
<div class="fd-popover__control" on:click|stopPropagation="{() => {}}">
<button
title="{getNodeLabel(node)}"
title="{resolveTooltipText(node, getNodeLabel(node))}"
class="fd-shellbar__button fd-button {node === selectedNode ? 'is-selected' : ''}"
aria-controls="dropDownPopover-{i}"
aria-expanded="{dropDownStates[`dropDownPopover-${i}`] || false}"
Expand Down Expand Up @@ -78,6 +78,7 @@
<a
href="{addNavHrefForAnchor ? getRouteLink(node) : undefined}"
class="fd-shellbar__button fd-button {node === selectedNode ? 'is-selected' : ''}"
title="{resolveTooltipText(node, getNodeLabel(node))}"
aria-expanded="false"
aria-haspopup="true"
on:click|preventDefault="{() => handleClick(node)}"
Expand All @@ -88,7 +89,7 @@
</a>
{:else}
<button
title="{getNodeLabel(node)}"
title="{resolveTooltipText(node, getNodeLabel(node))}"
class="fd-shellbar__button fd-button {node === selectedNode ? 'is-selected' : ''}"
aria-expanded="false"
aria-haspopup="true"
Expand Down Expand Up @@ -191,7 +192,7 @@
<li class="fd-menu__item">
<a
href="{getRouteLink(node)}"
title="{getNodeLabel(node)}"
title="{resolveTooltipText(node, getNodeLabel(node))}"
class="fd-menu__link"
on:click|preventDefault="{() => openMobileTopNavDropDown(node)}"
data-e2e="mobile-topnav-dropdown-category"
Expand Down Expand Up @@ -529,6 +530,10 @@
return RoutingHelpers.getNodeHref(node, pathParams);
}

function resolveTooltipText(node, translation) {
return NavigationHelpers.generateTooltipText(node, translation);
}

export function openMobileProductSwitcher() {
toggleDropdownState('productSwitcherPopover');
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class RoutingClass {

let cNode2 = currentNode;
let hideSideNavInherited = nodeObject.hideSideNav;
if(hideSideNavInherited === undefined) {
if (hideSideNavInherited === undefined) {
while (cNode2) {
if (cNode2.tabNav && cNode2.hideSideNav === true) {
hideSideNavInherited = true;
Expand Down
17 changes: 16 additions & 1 deletion core/src/utilities/helpers/navigation-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class NavigationHelpersClass {
}
return false;
}

/**
* Returns a nested property value defined by a chain string
* @param {*} obj the object
Expand Down Expand Up @@ -416,6 +416,21 @@ class NavigationHelpersClass {
reject(error);
});
}

generateTooltipText(node, translation) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic should be like follows:

let tt_text = node.tooltipText;
if(tt_text === undefined) {
   tt_text = LuigiConfig.getConfigValue('navigation.defaults.tooltipText');
}

if(tt_text === undefined) {
   return translation;
} else if(tt_text === false) {
   return '';
} else {
  return LuigiI18N.getTranslation(tt_text);
}

let ttText = node.tooltipText;
if (ttText === undefined) {
ttText = LuigiConfig.getConfigValue('navigation.defaults.tooltipText');
}

if (ttText === undefined) {
return translation;
} else if (ttText === false) {
return '';
} else {
return LuigiI18N.getTranslation(ttText);
}
}
}

export const NavigationHelpers = new NavigationHelpersClass();
2 changes: 1 addition & 1 deletion core/test/services/web-components.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('WebComponentService', function() {
window.Luigi = {
navigation: 'mock1',
ux: 'mock2',
i18n: ()=> LuigiI18N
i18n: () => LuigiI18N
};
});

Expand Down
18 changes: 17 additions & 1 deletion docs/navigation-parameters-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,20 @@ The navigation parameters allow you to configure **global** navigation settings

### nodeChangeHook
- **type**: function
- **description**: allows you to invoke and execute a specific function on the global level when a request to navigate to the node occurs. The function receives two node objects as input parameters: the previous node and current node, as described in the configuration.
- **description**: allows you to invoke and execute a specific function on the global level when a request to navigate to the node occurs. The function receives two node objects as input parameters: the previous node and current node, as described in the configuration.

### defaults.isolateView
- **type**: boolean
- **description**: renders all views in new frames. This setting overrides the same-domain frame reuse.
- **default**: the parameter **defaults.isolateView** is `false` by default, and you can overwrite it using the **isolateView** value on a single node level.
rafalgamon marked this conversation as resolved.
Show resolved Hide resolved


### defaults.tooltipText
- **type**: boolean | string
- **description**: applies the [tooltipText](navigation-parameters-reference.md#tooltiptext) property to all navigation nodes where it is not set explicitly. If it is `false` all tooltips will hide. If it is `Some string text` all tooltips will have value `Some string text`.
- **default**: the parameter **defaults.tooltipText** is `undefined` by default.


### defaults.pageErrorHandler
<!-- add-attribute:class:warning -->
> **NOTE**: The **pageErrorHandler** only works if the [loading indicator](#loadingindicatorenabled) is not disabled.
Expand Down Expand Up @@ -157,6 +164,15 @@ Node parameters are all the parameters that can be added to an individual naviga
- A static **pathSegment** of value `settings` results in `example.com/settings`.
- A dynamic **pathSegment** is prefixed with a colon and can load any value. Find out more about dynamic paths in Luigi [here](navigation-advanced.md#dynamically-changeable-paths).

### tooltipText
- **type**: string
- **description**: Allows to set a custom tooltip text for this node or to disable the tooltip by setting the value to `false`.
- **default**: it is `undefined` by default, and it can be overwrite by using the **tooltipText** value on a single node level.
- **example**:
```javascript
tooltipText: 'Useful links'
```

### link
- **type**: string
- **description**: refers to an absolute path in the navigation structure or a relative path to a grandchild of the current path. If this parameter is defined, **pathSegment** is ignored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ describe('Fiddle', () => {

cy.get('[data-testid="lui-us-language-dropdown"]')
.eq(0)
.click();
.click();
cy.get('[data-testid="lui-us-option0_0"]').click();
cy.get('[data-testid="lui-us-input0"]')
.should('exist')
Expand Down
Loading