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

Product Switcher documentation and configurable label and icon #703

Merged
merged 18 commits into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b670a99
added product switcher configurable icon and label, documentation
maxmarkus Jul 30, 2019
495c8b9
docu update, similar to profile
maxmarkus Jul 30, 2019
4af3e36
productSwitcher demo config object
maxmarkus Jul 30, 2019
ccb3e59
Apply suggestions from code review
maxmarkus Jul 31, 2019
ee3be3d
Merge branch '698-configurable-my-products' of github.com:maxmarkus/l…
maxmarkus Jul 31, 2019
d7a83a0
Merge branch 'master' into 698-configurable-my-products
maxmarkus Jul 31, 2019
0408656
Merge branch '698-configurable-my-products' of github.com:maxmarkus/l…
maxmarkus Jul 31, 2019
e376df7
Merge branch 'master' into 698-configurable-my-products
maxmarkus Jul 31, 2019
7e7f662
Merge branch '698-configurable-my-products' of github.com:maxmarkus/l…
maxmarkus Jul 31, 2019
5f3ed4e
defaults for productswitcher
maxmarkus Jul 31, 2019
fb927aa
Merge branch 'master' into 698-configurable-my-products
maxmarkus Jul 31, 2019
b105a22
Merge branch '698-configurable-my-products' of github.com:maxmarkus/l…
maxmarkus Jul 31, 2019
1be30cb
applied defaults to second place, refactored to have defaults in a he…
maxmarkus Aug 1, 2019
7c140f3
Merge branch 'master' into 698-configurable-my-products
maxmarkus Aug 1, 2019
fac3567
Merge branch 'master' into 698-configurable-my-products
maxmarkus Aug 2, 2019
41842ad
Merge branch 'master' into 698-configurable-my-products
jesusreal Aug 2, 2019
e5d1c80
Merge branch 'master' into 698-configurable-my-products
jesusreal Aug 2, 2019
a6b2d3e
Merge branch 'master' into 698-configurable-my-products
maxmarkus Aug 6, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,11 @@ class Navigation {
return items;
};

// The following configuration will be used to render a product switcher component
// The following configuration will be used to render a product switcher at the end of the top navigation
productSwitcher = {
label: 'My Products',
Copy link
Contributor

@JohannesDoberer JohannesDoberer Jul 31, 2019

Choose a reason for hiding this comment

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

If there is a empty object productSwitcher ={} we get the following view on mobile.
Bildschirmfoto 2019-07-31 um 16 58 57

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I have added the default label My Products. Is also required for backwards compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

icon: 'grid',
// icon: '/assets/favicon-sap.ico',
items: this.getProductSwitcherItems
};

Expand Down
29 changes: 20 additions & 9 deletions core/src/navigation/ProductSwitcher.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,28 @@
<div class="fd-product-switcher">
<div class="fd-popover fd-popover--right">
<div class="fd-popover__control" on:click="event.stopPropagation()">
<!-- default: sap-icon--grid -->
{#if hasOpenUIicon(config)}
<button
class="fd-button--shell sap-icon--grid"
class="fd-button--shell sap-icon--{config.icon}"
aria-expanded="{dropDownStates.productSwitcherPopover || false}"
aria-haspopup="true"
on:click="toggleDropdownState()"
data-cy="desktop-product-switcher"
title="{config.label}"
></button>
{:else}
<button
class="fd-button--shell"
aria-expanded="{dropDownStates.productSwitcherPopover || false}"
aria-haspopup="true"
on:click="toggleDropdownState()"
data-cy="desktop-product-switcher"
title="{config.label}"
>
<img src="{config.icon}">
</button>
{/if}
</div>
<div
class="fd-popover__body fd-popover__body--right"
Expand Down Expand Up @@ -68,7 +83,7 @@
></button>
</div>
<div class="fd-action-bar__header">
<h5 class="fd-action-bar__title fd-has-type-1">My Products</h5>
<h5 class="fd-action-bar__title fd-has-type-1">{config.label}</h5>
</div>
</div>
<div class="fd-modal__body">
Expand Down Expand Up @@ -112,13 +127,9 @@ <h5 class="fd-action-bar__title fd-has-type-1">My Products</h5>
export default {
async oncreate() {
StateHelpers.doOnStoreChange(this.store, async () => {
const productSwitcherConfig = LuigiConfig.getConfigValue(
'navigation.productSwitcher'
);
this.set({
config: productSwitcherConfig
});
if (productSwitcherConfig) {
const config = NavigationHelpers.getProductSwitcherConfig();
this.set({ config });
if (config) {
const productSwitcherItems = await LuigiConfig.getConfigValueAsync(
'navigation.productSwitcher.items'
);
Expand Down
16 changes: 13 additions & 3 deletions core/src/navigation/TopNav.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,17 @@
on:click="openMobileProductSwitcher(event)"
data-cy="mobile-product-switcher"
>
<span class="fd-top-nav__icon sap-icon--grid sap-icon--m"></span>
My Products
{#if hasOpenUIicon(productSwitcherConfig) || !productSwitcherConfig.icon}
<span
class="fd-top-nav__icon sap-icon--{productSwitcherConfig.icon || 'grid'} sap-icon--m"
></span>
{:else}
<img
class="fd-top-nav__icon nav-icon"
src="{productSwitcherConfig.icon}"
>
{/if}
{productSwitcherConfig.label}
</a>
</li>
{/if}
Expand Down Expand Up @@ -336,7 +345,8 @@
),
responsiveNavSetting: LuigiConfig.getConfigValue(
'settings.responsiveNavigation'
)
),
productSwitcherConfig: NavigationHelpers.getProductSwitcherConfig()
});
});
this.set({
Expand Down
5 changes: 5 additions & 0 deletions core/src/utilities/helpers/navigation-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ class NavigationHelpersClass {
this.virtualGroupPrefix = '___';
}

getProductSwitcherConfig() {
const userConfig = LuigiConfig.getConfigValue('navigation.productSwitcher');
return Object.assign({ icon: 'grid', label: 'My Products' }, userConfig);
}

isNodeAccessPermitted(nodeToCheckPermissionFor, parentNode, currentContext) {
if (LuigiAuth.isAuthorizationEnabled()) {
const loggedIn = AuthHelpers.isLoggedIn();
Expand Down
36 changes: 34 additions & 2 deletions docs/navigation-parameters-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,26 @@ Luigi.setConfig({
link: '/projects/pr1'
}
]
}
},
productSwitcher: {
label: 'My Products',
icon: 'grid',
items: [
{
icon: '',
label: 'Luigi in Github',
externalLink: {
url: 'https://github.com/SAP/luigi',
sameWindow: false
}
},
{
icon: '',
label: 'Project 1',
link: '/projects/pr1'
}
]
},
}
});
```
Expand Down Expand Up @@ -199,7 +218,7 @@ The node parameters are as follows:

## Context switcher

The context switcher is a drop-down list available in the top navigation bar. It allows you to switch between a curated list of navigation elements such as Environments.
The context switcher is a drop-down list available in the top navigation bar. It allows you to switch between a curated list of navigation elements such as Environments. To do so, add the **contextSwitcher** property to the **navigation** object using the following optional properties:

- **defaultLabel** specifies the default label that is shown if no context is selected.
- **parentNodePath** specifies the base path, that is prepended to **options[].pathValue**. It must be an absolute path.
Expand Down Expand Up @@ -231,3 +250,16 @@ The profile section is a configurable drop-down list available in the top naviga
- **url** is the external URL that the link leads to.


## Product switcher

The product switcher is a pop-up window available in the top navigation bar. It allows you to switch between the navigation elements displayed in the pop-up. To do so, add the **productSwitcher** property to the **navigation** object using the following optional properties:

- **label** defines the label of the product switcher. It is displayed as a title attribute on hover in the top navigation and as a headline in the mobile pop-up.
- **icon** is the name of an icon, without the `sap-icon--` prefix. Its source may be [OpenUI](https://openui5.hana.ondemand.com/1.40.10/iconExplorer.html) or a custom link (relative or absolute) to an image. The icon is displayed without label in the top navigation.
- **items** is an array of objects, each one being a link to a Luigi navigation node or an external URL. An item can have the following parameters:
- **label** defines the text for the link.
- **icon** is the name of an icon from the [OpenUI](https://openui5.hana.ondemand.com/1.40.10/iconExplorer.html) or a custom link (relative or absolute) to an image displayed next to the label or instead of it.
- **link** defines an absolute link to a **node**.
- **externalLink** is an object which indicates that the node links to an external URL. If this parameter is defined, the **link** parameter is ignored. It has the following properties:
- **sameWindow** defines if the external URL is opened in the current tab or in a new one. The default value for this parameter is `false`.
- **url** is the external URL that the link leads to.