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 automatic loading indicator to show processing #129

Merged
merged 33 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
41bb5f8
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Jul 31, 2018
4349a3e
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 1, 2018
7cafa4b
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 7, 2018
f8a6a28
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 8, 2018
0ab8b3a
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 8, 2018
9e4e1f0
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 14, 2018
0d886e5
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 22, 2018
c0edce7
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 28, 2018
21fa6a4
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 30, 2018
63c3a61
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 31, 2018
c0d06bc
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Sep 4, 2018
282ddcc
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Sep 5, 2018
7623ae3
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Sep 6, 2018
db5803f
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Sep 10, 2018
ab060d9
Merge remote-tracking branch 'upstream/master'
maxmarkus Sep 11, 2018
a8be44f
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Sep 18, 2018
f7b37bc
Merge remote-tracking branch 'upstream/master'
maxmarkus Sep 21, 2018
dbd6180
Merge remote-tracking branch 'upstream/master'
maxmarkus Sep 26, 2018
5833ec5
Merge remote-tracking branch 'upstream/master'
maxmarkus Oct 1, 2018
5363724
Merge remote-tracking branch 'upstream/master'
maxmarkus Oct 4, 2018
f2c3709
Implemented loading indicator to automatically show and hide triggere…
maxmarkus Oct 5, 2018
17d35bc
added e2e tests for loading indicator
maxmarkus Oct 5, 2018
016506f
added unit tests to check showLoadingIndicator value, added documenta…
maxmarkus Oct 5, 2018
2a74f7e
Merge branch 'master' into feature/loading-indicator
maxmarkus Oct 5, 2018
2ce0ef5
manually applied prettier
maxmarkus Oct 8, 2018
71381c8
Merge branch 'feature/loading-indicator' of github.com:maxmarkus/luig…
maxmarkus Oct 8, 2018
a71a8c5
Merge remote-tracking branch 'upstream/master' into feature/loading-i…
maxmarkus Oct 8, 2018
3dfadac
docu rephrasing
maxmarkus Oct 8, 2018
8d6eea6
docu updates
maxmarkus Oct 8, 2018
60478fb
refactoring based on PR comments
maxmarkus Oct 9, 2018
c507fce
added wait timeout again to prevent iframe selection failure
maxmarkus Oct 9, 2018
919d9b2
extended loading indicator documentation
maxmarkus Oct 9, 2018
bae4ac2
small docu update
maxmarkus Oct 10, 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
49 changes: 29 additions & 20 deletions client/luigi-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,13 @@
currentContext = rawData;

Luigi.token = currentContext.context.idToken;
// Luigi.linkManagerData = currentContext.context.linkManagerData;
// Luigi.currentEnvironmentId = currentContext.context.currentEnvironmentId;
// Luigi.sessionId = currentContext.context.sessionId;
}

function hasHash(string) {
return string.indexOf('#') !== -1;
}

window.addEventListener('message', function (e) {
window.addEventListener('message', function messageListener(e) {
if ('luigi.init' === e.data.msg) {
setContext(e.data);
Luigi.initialized = true;
Expand Down Expand Up @@ -105,7 +102,7 @@
* Adds a listener that will react once Luigi is initialized.
* @param {function} initFn - a function that will be called once Luigi is initialized
*/
addInitListener: function (initFn) {
addInitListener: function addInitListener(initFn) {
window._init = initFn;
if (Luigi.initialized && window._init) {
window._init(currentContext.context);
Expand All @@ -115,7 +112,7 @@
* Use it to get Luigi context changes
* @param contextUpdatedFn a function that will be called every time Luigi context was changed
*/
addContextUpdateListener: function (contextUpdatedFn) {
addContextUpdateListener: function addContextUpdateListener(contextUpdatedFn) {
_contextUpdated = contextUpdatedFn;
if (Luigi.initialized && _contextUpdated) {
_contextUpdated(currentContext.context);
Expand All @@ -127,26 +124,26 @@
* sessionId
* currentEnvironmentId
*/
getEventData: function () {
getEventData: function getEventData() {
return currentContext.context;
},
/**
* Fetch node parameters
*/
getNodeParams: function () {
getNodeParams: function getNodeParams() {
return currentContext.nodeParams;
},
/**
* Fetch node parameters
*/
getPathParams: function () {
getPathParams: function getPathParams() {
return currentContext.pathParams;
},
/**
* Navigate to another route.
* Lets you navigate to another route.
*/
linkManager: function () {
linkManager: function linkManager() {
var options = {
preserveView: false,
nodeParams: {}
Expand All @@ -158,7 +155,7 @@
* @param {string} path path to be navigated to
* @param {string} sessionId current Luigi sessionId
*/
var _navigate = function (sessionId, path) {
var _navigate = function _navigate(sessionId, path) {
var relativePath = path[0] !== '/';
var navigation = {
msg: 'luigi.navigation.open',
Expand All @@ -179,7 +176,7 @@
* @param {string} sessionId current Luigi sessionId
* @param {boolean} preserveView open route in a new view window to goBack to last state afterwards
*/
navigate: function (path, sessionId, preserveView) {
navigate: function navigate(path, sessionId, preserveView) {
if (options.errorSkipNavigation) {
options.errorSkipNavigation = undefined;
return;
Expand All @@ -193,7 +190,7 @@
* Usage: linkManager.fromContext("currentTeam").navigate("path")
* @param {object} navigationContext
* */
fromContext: function (navigationContext) {
fromContext: function fromContext(navigationContext) {
if (!currentContext.context.parentNavigationContexts.includes(navigationContext)) {
options.errorSkipNavigation = true;
console.error(
Expand All @@ -212,7 +209,7 @@
* This has to be a parent navigation context, it is not possible to go to child navigation contexts
* Usage: linkManager.fromClosestContext().navigate("path")
*/
fromClosestContext: function () {
fromClosestContext: function fromClosestContext() {
if (currentContext.context.parentNavigationContexts.length === 0) {
console.error(
'Navigation not possible, no parent navigationContext found.'
Expand All @@ -230,7 +227,7 @@
* Can be chained with context settings functions like this: linkManager.fromContext("currentTeam").withParams({foo: "bar"}).navigate("path")
* @param {object} nodeParams
* */
withParams: function (nodeParams) {
withParams: function withParams(nodeParams) {
if (nodeParams) {
Object.assign(options.nodeParams, nodeParams);
}
Expand All @@ -242,7 +239,7 @@
* returns truthy. Can be used to show a back button
* @return boolean
*/
hasBack: function () {
hasBack: function hasBack() {
return Boolean(
currentContext.internal.viewStackSize !== 0
);
Expand All @@ -257,7 +254,7 @@
* @param {mixed} goBackValue data that is handed over as goBackContext after going back
* @return void
*/
goBack: function (goBackValue) {
goBack: function goBack(goBackValue) {
if (this.hasBack()) {
window.parent.postMessage(
{
Expand All @@ -273,18 +270,30 @@
/**
* Manage UX specific options.
*/
uxManager: function () {
uxManager: function uxManager() {
return {
/**
* Shows a spinner with backdrop to block the micro front-end frame
*/
showLoadingIndicator: function showLoadingIndicator() {
window.parent.postMessage({ msg: 'luigi.show-loading-indicator' }, '*');
},
/**
* Hides the spinner
*/
hideLoadingIndicator: function hideLoadingIndicator() {
window.parent.postMessage({ msg: 'luigi.hide-loading-indicator' }, '*');
},
/**
* Adds a backdrop for Core to block the UI
*/
addBackdrop: function () {
addBackdrop: function addBackdrop() {
window.parent.postMessage({ msg: 'luigi.add-backdrop' }, '*');
},
/**
* Removes the backdrop
*/
removeBackdrop: function () {
removeBackdrop: function removeBackdrop() {
window.parent.postMessage({ msg: 'luigi.remove-backdrop' }, '*');
}
};
Expand Down
5 changes: 5 additions & 0 deletions core/examples/luigi-sample-angular/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
"glob": "**",
"input": "node_modules/@kyma-project/luigi-core",
"output": "/luigi-core"
},
{
"glob": "luigi-client.js",
"input": "node_modules/@kyma-project/luigi-client",
"output": "/luigi-client"
}
],
"styles": ["src/styles.css"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
describe('Luigi client features', () => {
jesusreal marked this conversation as resolved.
Show resolved Hide resolved
beforeEach(() => {
cy.visit('http://localhost:4200');
});

it('linkManager features', () => {
cy.login('tets', 'tets');

//wait for the iFrame to be loaded
cy.wait(3000);
cy.wait(1000);
});

it('linkManager features', () => {
cy.get('iframe').then($iframe => {
const $iframeBody = $iframe.contents().find('body');
cy.goToFeaturesPage($iframeBody);
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('Luigi client features', () => {
});

//wait for the second iFrame to be loaded
cy.wait(1000);
cy.wait(500);
cy.get('iframe')
.first()
.then($preserveViewiFrame => {
Expand All @@ -110,30 +110,54 @@ describe('Luigi client features', () => {
});
});

it('uxManager features', () => {
cy.login('tets', 'tets');

//wait for the iFrame to be loaded
cy.wait(3000);
cy.get('iframe').then($iframe => {
const $iframeBody = $iframe.contents().find('body');
cy.goToFeaturesPage($iframeBody);
cy.wrap($iframeBody).should('not.contain', 'Lorem tipsum dolor sit amet');
cy.get('.fd-ui__overlay').should('not.exist');
describe('uxManager', () => {
it('backdrop', () => {
cy.wait(500);
cy.get('iframe').then($iframe => {
const $iframeBody = $iframe.contents().find('body');
cy.goToFeaturesPage($iframeBody);
cy.wrap($iframeBody).should('not.contain', 'Lorem tipsum dolor sit amet');
cy.get('.fd-ui__overlay').should('not.exist');

//open modal with backdrop
cy.wrap($iframeBody)
.contains('Add backdrop')
.click();
cy.wrap($iframeBody).should('contain', 'Lorem tipsum dolor sit amet');
cy.get('.fd-ui__overlay').should('exist');
//open modal with backdrop
cy.wrap($iframeBody)
.contains('Add backdrop')
.click();
cy.wrap($iframeBody).should('contain', 'Lorem tipsum dolor sit amet');
cy.get('.fd-ui__overlay').should('exist');

//close modal
cy.wrap($iframeBody)
.contains('Confirm')
//close modal
cy.wrap($iframeBody)
.contains('Confirm')
.click();
cy.wrap($iframeBody).should('not.contain', 'Lorem tipsum dolor sit amet');
cy.get('.fd-ui__overlay').should('not.exist');
});
});

it('loading indicator', () => {
cy.get('.fd-ui__header')
.contains('External Page')
.click();
cy.wrap($iframeBody).should('not.contain', 'Lorem tipsum dolor sit amet');
cy.get('.fd-ui__overlay').should('not.exist');

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

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

cy.wait(250);
cy.get('iframe').then($iframe => {
const $iframeBody = $iframe.contents().find('body');

// show loading indicator
cy.wrap($iframeBody)
.contains('Show loading indicator')
.click();
cy.get('.fd-spinner').should('exist');

// wait for programmatic hide of loading indicator
cy.get('.fd-spinner').should('not.exist');
});
});
});
});
Loading