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

Context Switcher in top navigation #190

Merged
merged 60 commits into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
d8cffc8
tets
maxmarkus Oct 15, 2018
3794c6e
Merge remote-tracking branch 'upstream/master'
maxmarkus Oct 22, 2018
49e2946
Merge remote-tracking branch 'upstream/master'
maxmarkus Oct 26, 2018
a5d34ad
Merge remote-tracking branch 'upstream/master'
maxmarkus Oct 29, 2018
e8e0405
initial
maxmarkus Oct 30, 2018
c4e4d57
refactored route change listener to a external function that can be u…
maxmarkus Oct 30, 2018
35be633
context switcher, reading options from config, setting proper paths f…
maxmarkus Oct 31, 2018
e25b3fe
added dynamic top + bottom actions, lazy loading for context switcher
maxmarkus Nov 2, 2018
be143f3
lazyloadOptions defaults to true, added documentation
maxmarkus Nov 2, 2018
119cac2
added e2e tets
maxmarkus Nov 2, 2018
0a83dd7
changes based on comments, fixed e2e tests
maxmarkus Nov 5, 2018
b14f8bb
copying only fundamental stuff that we need
maxmarkus Nov 5, 2018
4ca4667
docu update
maxmarkus Nov 6, 2018
bc8a934
docu update
maxmarkus Nov 6, 2018
f39cd4c
Merge remote-tracking branch 'upstream/master' into feature/context-s…
maxmarkus Nov 6, 2018
c0e1682
removed docu that is not part of the ticket
maxmarkus Nov 6, 2018
f1414a7
Unit tests
maxmarkus Nov 6, 2018
065ae8f
latest changes
maxmarkus Nov 6, 2018
3bd455d
Add missing line and improve wording (#199)
bszwarc Nov 7, 2018
cd56d94
Describe get path params and get node params better (#155)
pekura Nov 7, 2018
c4cfbd2
Remove unnecessary import
jesusreal Nov 7, 2018
e524ded
Bring back external link example in angular app and add small text im…
jesusreal Nov 7, 2018
02135b5
Remove unnecessary code from extended configuration
jesusreal Nov 7, 2018
3811923
Merge branch 'master' into feature/context-switcher
jesusreal Nov 7, 2018
22ce442
Merge remote-tracking branch 'upstream/master' into markus-feature/co…
jesusreal Nov 9, 2018
b9278e3
Merge remote-tracking branch 'upstream/master' into feature/context-s…
jesusreal Nov 9, 2018
4c92bfd
Do not consider context switcher when a path segment contains parentN…
jesusreal Nov 12, 2018
714a701
Improvement on "Do not consider context switcher when a path segment …
jesusreal Nov 12, 2018
cf4a7ca
Use proper configuration to avoid runtime errors on environments and …
jesusreal Nov 12, 2018
c11acf2
Load options only once and based on lazyloadOptions value from config
jesusreal Nov 12, 2018
d91e8a9
Add unit tests for new function in context switcher helpers
jesusreal Nov 12, 2018
4146380
better documentation for `addTrailingSlash` method
jesusreal Nov 13, 2018
eed353c
Merge remote-tracking branch 'upstream/master' into feature/context-s…
jesusreal Nov 13, 2018
8f44440
Avoid runtime error for pop state event handler (path routing) when n…
jesusreal Nov 13, 2018
3bb30e2
bundle fundamental-ui.min.css in luigi.css
jesusreal Nov 14, 2018
24778fc
increment bundle size for luigi.js and luigi.css
jesusreal Nov 14, 2018
fe12527
cleanup public folder on each webpack build
jesusreal Nov 14, 2018
3f78c84
update gitignore files
jesusreal Nov 14, 2018
9a964e3
cleanup static.css as svelte is not using SAP-icons font anymore
jesusreal Nov 14, 2018
2fb3152
Merge branch 'feature/context-switcher' of github.com:maxmarkus/luigi…
maxmarkus Nov 15, 2018
ef3d82a
automatic label for dynamic component if not defined
maxmarkus Nov 15, 2018
86ba769
Remove flickering on left nav
jesusreal Nov 15, 2018
b0e0ff5
Small refactoring
jesusreal Nov 15, 2018
64f50eb
Merge remote-tracking branch 'upstream/master' into feature/context-s…
jesusreal Nov 15, 2018
c56f1df
Small refactoring well done
jesusreal Nov 15, 2018
a1eab3c
Revert "Remove flickering on left nav"
jesusreal Nov 15, 2018
c1505f4
bundle order in luigi.css to be first fundamental
jesusreal Nov 15, 2018
a919848
remove dependency for extract-text-webpack-plugin
jesusreal Nov 15, 2018
ff364cb
Update docs/navigation-configuration.md
dariadomagala-sap Nov 16, 2018
6509c2e
Fix opening context switcher dropdown
dariadomagala-sap Nov 16, 2018
eba3353
Merge branch 'feature/context-switcher' of https://github.com/maxmark…
dariadomagala-sap Nov 16, 2018
28627c9
Set max width for context switcher and hide part of the word if is to…
dariadomagala-sap Nov 16, 2018
01c6c75
Merge branch 'feature/context-switcher' of github.com:maxmarkus/luigi…
maxmarkus Nov 16, 2018
b752d42
Added title attribute to context switcher options. Fixes #193
maxmarkus Nov 16, 2018
dcce6ef
updated docu
maxmarkus Nov 16, 2018
91bb21c
Change labels
dariadomagala-sap Nov 16, 2018
aced0dd
Merge branch 'feature/context-switcher' of github.com:maxmarkus/luigi…
maxmarkus Nov 20, 2018
84a0672
label are only lazy loaded on click, refactored function names
maxmarkus Nov 20, 2018
4a96631
Merge branch 'master' into feature/context-switcher
maxmarkus Nov 21, 2018
6ed4a1e
Merge branch 'master' into feature/context-switcher
maxmarkus Nov 21, 2018
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ node_modules

# Lerna
lerna-debug.log
oidc-client.min.js

.changelog
10 changes: 6 additions & 4 deletions core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ yarn-debug.log*
yarn-error.log*

.vscode/
public/luigi.css
public/luigi.js
public/luigi.vendor.js
public/SAP-icons.woff
/public/luigi.css
/public/luigi.js
/public/*.woff
/public/*.woff2
/public/*.ttf
/public/auth

# maps
*.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
describe('Context switcher', () => {
beforeEach(() => {
cy.visit('http://localhost:4200');
cy.login('tets@email.com', 'tets');
});

it('Clicking around the context switcher', () => {
// default label
cy.get('.context-switcher')
.contains('Select Environment ...')
.click();

// click an action
cy.get('.context-switcher .fd-popover__body')
.contains('New Environment (bottom)')
.click();

cy.location().should(loc => {
expect(loc.hash).to.eq('#/create-environment');
});

// default label
cy.get('.context-switcher')
.contains('Select Environment ...')
.click();

// click an action
cy.get('.context-switcher .fd-popover__body')
.contains('Environment 1')
.click();

cy.location().should(loc => {
expect(loc.hash).to.eq('#/environments/env1');
});

// check label
cy.get('.context-switcher .fd-popover__control button').should(
'contain',
'Environment 1'
);

// Overview
cy.goToOverviewPage();

// check label
cy.get('.context-switcher .fd-popover__control button').should(
'contain',
'Select Environment ...'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ describe('Luigi client features', () => {
.contains('External Page')
.click();

cy.get('.fd-spinner').should('exist');
cy.get('.spinnerContainer .fd-spinner').should('exist');

cy.get('.fd-spinner').should('not.exist');
cy.get('.spinnerContainer .fd-spinner').should('not.exist');

cy.wait(250);
cy.get('iframe').then($iframe => {
Expand All @@ -188,10 +188,11 @@ describe('Luigi client features', () => {
cy.wrap($iframeBody)
.contains('Show loading indicator')
.click();
cy.get('.fd-spinner').should('exist');

cy.get('.spinnerContainer .fd-spinner').should('exist');

// wait for programmatic hide of loading indicator
cy.get('.fd-spinner').should('not.exist');
cy.get('.spinnerContainer .fd-spinner').should('not.exist');
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ const routes: Routes = [
{
path: 'projects/:projectId/dynamic/:dynamicValue',
component: DynamicComponent
},
{
path: 'create/:dynamicValue',
component: DynamicComponent
},
{
path: 'environments',
component: DynamicComponent
},
{
path: 'environments/:dynamicValue',
component: DynamicComponent
},
{
path: 'environments/:ignoredDynamicValue/:dynamicValue',
component: DynamicComponent
}
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ export class DynamicComponent implements OnInit, OnDestroy {
return;
}

const lastPathParam = Object.values(
LuigiClient.getPathParams() || {}
).pop();

// We can directly access our specified context values here
this.nodeLabel = toTitleCase(ctx.context.label);
this.nodeLabel = toTitleCase(ctx.context.label || lastPathParam);
this.links = ctx.context.links;
if (!this.cdr['destroyed']) {
this.cdr.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,22 @@ Luigi.setConfig({
},
{
hideFromNav: true,
pathSegment: 'hidden-sample',
label: 'Hidden',
viewUrl: '/sampleapp.html#/projects/overview'
pathSegment: 'create-environment',
viewUrl: '/sampleapp.html#/create/environment',
context: {
label: 'Create Environment'
}
},
{
hideFromNav: true,
pathSegment: 'environments',
viewUrl: '/sampleapp.html#/environments',
children: [
{
pathSegment: ':environmentId',
viewUrl: '/sampleapp.html#/environments/:environmentId'
}
]
},
{
pathSegment: 'forbidden-sample',
Expand Down Expand Up @@ -470,9 +483,46 @@ Luigi.setConfig({
]
}
];
},
// The following configuration will be used to render the context switcher component
contextSwitcher: {
defaultLabel: 'Select Environment ...',
parentNodePath: '/environments', // absolute path
lazyloadOptions: true, // load options on click instead on page load
options: () => {
return [...Array(10).keys()].filter(n => n !== 0).map(n => ({
label: 'Environment ' + n, // (i.e mapping between what the user sees and what is taken to replace the dynamic part for the dynamic node)
pathValue: 'env' + n // will be used to replace dynamic part
}));
},
actions: [
{
label: '+ New Environment (top)',
link: '/create-environment'
},
{
label: '+ New Environment (bottom)',
link: '/create-environment',
position: 'bottom', // top or bottom
clickHandler: node => {
// called BEFORE route change
return true; // route change will be done using link value (if defined)
// return false // route change will not be done even if link attribute is defined
}
}
],

/**
* fallbackLabelResolver
* Resolve what do display in the context switcher (Label) in case the activated
* context (option) is not listed in available options (eg kyma-system namespace),
* or if options have not been fetched yet
*/
fallbackLabelResolver: id => {
return id.replace(/\b\w/g, l => l.toUpperCase());
}
}
},

routing: {
/**
* Development:
Expand Down
71 changes: 58 additions & 13 deletions core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
"babel-register": "^6.26.0",
"bundlesize": "^0.17.0",
"chai": "^4.1.2",
"clean-webpack-plugin": "^1.0.0",
"copy-webpack-plugin": "^4.5.2",
"css-loader": "^0.28.11",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"file-loader": "^2.0.0",
"fundamental-ui": "^1.2.2",
"jsdom": "11.12.0",
"jsdom-global": "3.0.2",
"mini-css-extract-plugin": "^0.4.4",
"mocha": "^5.2.0",
"mock-browser": "^0.92.14",
"node-sass": "^4.9.0",
Expand All @@ -38,18 +39,19 @@
"bundle": "webpack --display-error-details",
"bundle-develop": "webpack -d --watch",
"test": "./node_modules/mocha/bin/mocha --require babel-register --require babel-polyfill --require jsdom-global/register",
"test:watch": "npm run test -- --watch",
"bundlesize": "bundlesize",
"prepush": "npm run bundle && npm run bundlesize"
},
"bundlesize": [
{
"path": "./public/luigi.js",
"maxSize": "50 kB",
"maxSize": "100 kB",
"compression": "none"
},
{
"path": "./public/luigi.css",
"maxSize": "150 kB",
"maxSize": "300 kB",
"compression": "none"
}
],
Expand Down
5 changes: 0 additions & 5 deletions core/public/package-lock.json

This file was deleted.

Loading