Skip to content

Commit

Permalink
Merge branch 'master' into handle-init-in-luigi-client
Browse files Browse the repository at this point in the history
* master:
  Update Luigi core npm to 6.13.1 (SAP#990)
  Update INTERNAL-README.md (SAP#987)
  Edge browser back (SAP#992)
  • Loading branch information
JohannesDoberer committed Nov 29, 2019
2 parents 60fd5d3 + f8c0b19 commit c80b7b6
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('Luigi client linkManager', () => {
cy.wrap($iframeBody).should('contain', 'Called with params:');
cy.wrap($iframeBody).should('contain', '"foo": "bar"');

cy.expectSearchToBe('?~foo=bar&');
cy.expectSearchToBe('?~foo=bar');

cy.wrap($iframeBody)
.contains('Click here')
Expand Down
20 changes: 10 additions & 10 deletions core/package-lock.json

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

4 changes: 2 additions & 2 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"bundle-ie11": "webpack --mode=production --display-error-details --config webpack-ie11.config.js",
"bundle-develop": "npm run bundle-develop-evergreen",
"bundle-develop-evergreen": "npm run bundle-evergreen -- -d --watch",
"bundle-develop-ie11": "webpack --display-error-details --config webpack-ie11.config.js --debug --devtool cheap-source-map --output-pathinfo --watch",
"bundle-develop-ie11": "MINIFY=false webpack --display-error-details --config webpack-ie11.config.js --debug --devtool cheap-source-map --output-pathinfo --watch",
"test": "babel-node ./node_modules/nyc/bin/nyc.js mocha -- --recursive test",
"test:watch": "npm run test -- --watch",
"bundlesize": "npm run bundle && bundlesize",
Expand Down Expand Up @@ -126,7 +126,7 @@
"url": "ssh://github.com/SAP/luigi.git"
},
"dependencies": {
"npm": "^6.13.0",
"npm": "^6.13.1",
"test": "^0.6.0",
"diff": ">=3.5.0"
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/App.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,14 @@

if (params.nodeParams && Object.keys(params.nodeParams).length) {
path += '?';
Object.entries(params.nodeParams).forEach(entry => {
Object.entries(params.nodeParams).forEach((entry, index) => {
path +=
encodeURIComponent(
RoutingHelpers.getContentViewParamPrefix() + entry[0]
) +
'=' +
encodeURIComponent(entry[1]) +
'&';
(index < Object.keys(params.nodeParams).length - 1 ? '&' : '');
});
}
return path;
Expand Down
8 changes: 4 additions & 4 deletions core/src/services/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ class RoutingClass {
}

getModifiedPathname() {
if (!window.history.state) {
return '';
}
const path =
(window.history.state && window.history.state.path) ||
window.location.pathname;

return window.history.state.path
return path
.split('/')
.slice(1)
.join('/');
Expand Down
11 changes: 7 additions & 4 deletions core/src/utilities/helpers/routing-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ class RoutingHelpersClass {
}

getContentViewParamPrefix() {
return (
LuigiConfig.getConfigValue('routing.nodeParamPrefix') ||
this.defaultContentViewParamPrefix
);
let prefix = LuigiConfig.getConfigValue('routing.nodeParamPrefix');
if (prefix === false) {
prefix = '';
} else if (!prefix) {
prefix = this.defaultContentViewParamPrefix;
}
return prefix;
}

addRouteChangeListener(callback) {
Expand Down
8 changes: 6 additions & 2 deletions core/test/services/routing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,13 @@ describe('Routing', function() {
});

describe('getModifiedPathname()', () => {
it('without state', () => {
it('without state, falls back to location', () => {
const mockPathName = 'projects';
sinon.stub(window.history, 'state').returns(null);
assert.equal(Routing.getModifiedPathname(), '');
sinon.stub(window, 'location').value({
pathname: '/' + mockPathName
});
assert.equal(Routing.getModifiedPathname(), mockPathName);
});

it('with state path', () => {
Expand Down
3 changes: 2 additions & 1 deletion core/webpack-ie11.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class PatchLuigiPlugin {
if (compiler.hooks) {
compiler.hooks.afterEmit.tap('Luigi Patch', () =>
exec(
'babel public/luigi-ie11.js --out-file public/luigi-ie11.js --presets=@babel/preset-env --root . --root-mode upward --minified',
'babel public/luigi-ie11.js --out-file public/luigi-ie11.js --presets=@babel/preset-env --root . --root-mode upward' +
(process.env.MINIFY === 'false' ? '' : ' --minified'),
PatchLuigiPlugin.execHandler
)
);
Expand Down
2 changes: 1 addition & 1 deletion docs/application-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The examples on this page demonstrate commands that perform each of the necessar
<a name="noframework"></a>
### Application setup for an application not using a framework

<!-- add-attribute:class:success -->
<!-- add-attribute:class:warning -->
> **NOTE:** You need a development server capable of hosting Single Page Applications. The recommended server is Live Server.
1. If you do not have Live Server installed, use this command to install it.
Expand Down
1 change: 1 addition & 0 deletions website/docs/INTERNAL-README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Development:

Open [http://localhost:4000](http://localhost:4000), micro frontend is hosted on port 4001 and defined dynamically in configuration and sapper serve.


Production build:

`npm run export`
Expand Down
8 changes: 4 additions & 4 deletions website/docs/src/client-js/internal-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class InternalLinksHandler {
if(this.initDone) { return; }
this.initDone = true;

// modify internal links to be valid links for users and still make sapper happy
// modify internal links to be valid links for users and still make sapper happy
// since leaving them "wrong" (as local iframe links) in the first place
let intvCount = 0;
const intv = setInterval(() => {
Expand All @@ -19,21 +19,21 @@ export class InternalLinksHandler {
clearInterval(intv);
}
}, 150);


// register click handler
window.navigateInternal = (evt, elem) => {
evt.preventDefault();
evt.stopPropagation();
let url;
try {
url = new URL(elem.getAttribute('href'));
url = new URL(elem.getAttribute('href'), window.location.origin);
} catch (error) {
console.debug('navigateInternal URL parse error', elem, elem.getAttribute('href'), error);
}
const urlWithPath = url.pathname.replace(ctx.coreBaseUrl, '').replace('.md', '').replace('/docu-microfrontend', '');
if (url.hash) {
LuigiClient.linkManager().withParams({hash: url.hash.toLowerCase()}).navigate(urlWithPath);
LuigiClient.linkManager().withParams({'section': url.hash.substring(1).toLowerCase()}).navigate(urlWithPath);
} else {
LuigiClient.linkManager().navigate(urlWithPath);
}
Expand Down
24 changes: 16 additions & 8 deletions website/docs/src/client-js/smooth-scroll-anchors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@ export class ScrollAnchorsHandler {
init() {
// scroll if navigate param found
LuigiClient.addInitListener((ctx) => {
if(this.initDone) { return; }
if (this.initDone) { return; }
this.initDone = true;
if (LuigiClient.getNodeParams().hash) {
this.scrollAnchor(null, LuigiClient.getNodeParams().hash);
if (LuigiClient.getNodeParams().section) {
this.scrollAnchor(null, LuigiClient.getNodeParams().section);
}
window.scrollAnchor = this.scrollAnchor;
});

LuigiClient.addContextUpdateListener((ctx) => {
if (LuigiClient.getNodeParams().section) {
setTimeout(() => {
this.scrollAnchor(null, LuigiClient.getNodeParams().section);
});
}
});
}

// Vanilla JavaScript Scroll to Anchor
// @ https://perishablepress.com/vanilla-javascript-scroll-anchor/
// modified so respond could be also just a string with the #hash
Expand All @@ -24,13 +32,13 @@ export class ScrollAnchorsHandler {
targetID = (respond) ? respond.getAttribute('href') : this.getAttribute('href');
targetID = `#${targetID.split('#').pop()}`;
} else {
targetID = respond;
targetID = '#' + respond;
}

const targetAnchor = document.querySelector(targetID);
if (!targetAnchor) return;
targetAnchor.scrollIntoView({
behavior: 'smooth'
targetAnchor.scrollIntoView({
behavior: 'smooth'
});
}
}
}
2 changes: 1 addition & 1 deletion website/docs/src/luigi-config/extended/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Routing {
/**
* Prefix for reflecting params in the url, which is used when navigating .withParams() function.
*/
nodeParamPrefix = '~';
nodeParamPrefix = false;

/**
* skipRoutingForUrlPatterns
Expand Down
8 changes: 4 additions & 4 deletions website/docs/src/unified-plugins/rehype-luigi-linkparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ export default function luigiLinkParser(options) {
var parsed = url.parse(node.properties[prop]);
if (
parsed.href.startsWith(githubMaster + 'docs') && parsed.pathname && parsed.pathname.endsWith('.md') ||
parsed.pathname && parsed.pathname.endsWith('.md')
parsed.pathname && parsed.pathname.endsWith('.md')
) {
// internal link
// sample links: https://..., file.md, should not start with /file.md or ../file.md
node.properties['onclick'] = 'navigateInternal(event, this)';
node.properties['data-linktype'] = 'internal';

let newHref = parsed.href.replace(githubMaster + 'docs/', '').replace('.md', '');

// clean ./ from beginning of the link
Expand All @@ -50,7 +50,7 @@ export default function luigiLinkParser(options) {
} else if (parsed.hash && !parsed.pathname && !parsed.hostname) {
// current page anchor link
node.properties['href'] = prependForExport() + '/docs/' + settings.shortName + parsed.hash.toLowerCase();
node.properties['onclick'] = 'scrollAnchor(event, event.target)';
node.properties['onclick'] = 'navigateInternal(event, this)';
} else if (parsed.pathname && (
parsed.pathname.startsWith('../') || parsed.pathname.startsWith('/')
)) {
Expand All @@ -77,4 +77,4 @@ export default function luigiLinkParser(options) {
// add logic here
}
}
}
}

0 comments on commit c80b7b6

Please sign in to comment.