Skip to content

Commit

Permalink
Global prettying (SAP#1952)
Browse files Browse the repository at this point in the history
Runs prettier for all core and client source code
  • Loading branch information
ndricimrr authored Mar 25, 2021
1 parent 48f7f1f commit 294b73c
Show file tree
Hide file tree
Showing 69 changed files with 1,459 additions and 2,274 deletions.
8 changes: 2 additions & 6 deletions client/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ class Helpers {
* @param {string} id listenerId
*/
removeEventListener(id) {
const listenerExists = Boolean(
this.listeners.find(l => l.listenerId === id)
);
const listenerExists = Boolean(this.listeners.find(l => l.listenerId === id));
if (listenerExists) {
this.listeners = this.listeners.filter(l => l.listenerId !== id);
return true;
Expand All @@ -83,9 +81,7 @@ class Helpers {
*/
getRandomId() {
// window.msCrypto for IE 11
return (window.crypto || window.msCrypto).getRandomValues(
new Uint32Array(1)
)[0];
return (window.crypto || window.msCrypto).getRandomValues(new Uint32Array(1))[0];
}

/**
Expand Down
40 changes: 11 additions & 29 deletions client/src/lifecycleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ class LifecycleManager extends LuigiClientBase {
constructor() {
super();
this.luigiInitialized = false;
this.defaultContextKeys = [
'context',
'internal',
'nodeParams',
'pathParams'
];
this.defaultContextKeys = ['context', 'internal', 'nodeParams', 'pathParams'];
this.setCurrentContext(
this.defaultContextKeys.reduce(function(acc, key) {
acc[key] = {};
Expand Down Expand Up @@ -50,20 +45,20 @@ class LifecycleManager extends LuigiClientBase {
* @example
* const init = LuigiClient.isLuigiClientInitialized()
*/
isLuigiClientInitialized(){
isLuigiClientInitialized() {
return this.luigiInitialized;
}

/**
* Starts the handshake with Luigi Core and thereafter resulting in initialization of Luigi Client. It is always ran by default when importing luigi-client package in your micro frontend. Note that when using 'defer-luigi-init' to defer default initialization you will need to initialize the handshake using this function manually wherever needed.
* Starts the handshake with Luigi Core and thereafter resulting in initialization of Luigi Client. It is always ran by default when importing luigi-client package in your micro frontend. Note that when using 'defer-luigi-init' to defer default initialization you will need to initialize the handshake using this function manually wherever needed.
* @since 1.12.0
* @memberof Lifecycle
* @example
* LuigiClient.luigiClientInit()
*/
luigiClientInit() {
if (this.luigiInitialized) {
console.warn("Luigi Client has been already initialized")
console.warn('Luigi Client has been already initialized');
return;
}
/**
Expand All @@ -78,12 +73,7 @@ class LifecycleManager extends LuigiClientBase {
rawData[key] = JSON.parse(rawData[key]);
}
} catch (e) {
console.info(
'unable to parse luigi context data for',
key,
rawData[key],
e
);
console.info('unable to parse luigi context data for', key, rawData[key], e);
}
}
this.setCurrentContext(rawData);
Expand Down Expand Up @@ -116,9 +106,7 @@ class LifecycleManager extends LuigiClientBase {
setContext(e.data);
if (!this.currentContext.internal.isNavigateBack) {
history.replaceState({ luigiInduced: true }, '', e.data.viewUrl);
window.dispatchEvent(
new PopStateEvent('popstate', { state: 'luiginavigation' })
);
window.dispatchEvent(new PopStateEvent('popstate', { state: 'luiginavigation' }));
}
// execute the context change listener if set by the micro frontend
this._notifyUpdate();
Expand All @@ -137,8 +125,7 @@ class LifecycleManager extends LuigiClientBase {
'*'
);
this._tpcCheck();
};

}

_tpcCheck() {
let tpc = 'enabled';
Expand Down Expand Up @@ -335,12 +322,9 @@ class LifecycleManager extends LuigiClientBase {
* const customMsgId = LuigiClient.addCustomMessageListener('myapp.project-updated', (data) => doSomething(data))
*/
addCustomMessageListener(customMessageId, customMessageListener) {
return helpers.addEventListener(
customMessageId,
(customMessage, listenerId) => {
return customMessageListener(customMessage, listenerId);
}
);
return helpers.addEventListener(customMessageId, (customMessage, listenerId) => {
return customMessageListener(customMessage, listenerId);
});
}

/**
Expand Down Expand Up @@ -467,9 +451,7 @@ class LifecycleManager extends LuigiClientBase {
* @since 0.6.2
*/
sendCustomMessage(message) {
const customMessageInternal = helpers.convertCustomMessageUserToInternal(
message
);
const customMessageInternal = helpers.convertCustomMessageUserToInternal(message);
helpers.sendPostMessageToLuigiCore(customMessageInternal);
}

Expand Down
31 changes: 6 additions & 25 deletions client/src/linkManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,7 @@ export class linkManager extends LuigiClientBase {
* LuigiClient.linkManager().navigate('/settings', null, true) // preserve view
* LuigiClient.linkManager().navigate('#?Intent=Sales-order?id=13') // intent navigation
*/
navigate(
path,
sessionId,
preserveView,
modalSettings,
splitViewSettings,
drawerSettings
) {
navigate(path, sessionId, preserveView, modalSettings, splitViewSettings, drawerSettings) {
if (this.options.errorSkipNavigation) {
this.options.errorSkipNavigation = false;
return;
Expand Down Expand Up @@ -150,18 +143,12 @@ export class linkManager extends LuigiClientBase {
fromContext(navigationContext) {
const navigationContextInParent =
this.currentContext.context.parentNavigationContexts &&
this.currentContext.context.parentNavigationContexts.indexOf(
navigationContext
) !== -1;
this.currentContext.context.parentNavigationContexts.indexOf(navigationContext) !== -1;
if (navigationContextInParent) {
this.options.fromContext = navigationContext;
} else {
this.options.errorSkipNavigation = true;
console.error(
'Navigation not possible, navigationContext ' +
navigationContext +
' not found.'
);
console.error('Navigation not possible, navigationContext ' + navigationContext + ' not found.');
}
return this;
}
Expand All @@ -175,15 +162,12 @@ export class linkManager extends LuigiClientBase {
*/
fromClosestContext() {
const hasParentNavigationContext =
this.currentContext &&
this.currentContext.context.parentNavigationContexts.length > 0;
this.currentContext && this.currentContext.context.parentNavigationContexts.length > 0;
if (hasParentNavigationContext) {
this.options.fromContext = null;
this.options.fromClosestContext = true;
} else {
console.error(
'Navigation not possible, no parent navigationContext found.'
);
console.error('Navigation not possible, no parent navigationContext found.');
}
return this;
}
Expand Down Expand Up @@ -292,10 +276,7 @@ export class linkManager extends LuigiClientBase {
* @returns {boolean} indicating if there is a preserved view you can return to
*/
hasBack() {
return (
!!this.currentContext.internal.modal ||
this.currentContext.internal.viewStackSize !== 0
);
return !!this.currentContext.internal.modal || this.currentContext.internal.viewStackSize !== 0;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions client/src/luigi-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import { storageManager } from './storageManager';
*/
class LuigiClient {
constructor() {
if (
window !== window.top &&
window.document.head.getAttribute('disable-luigi-history-handling') !=
'true'
) {
if (window !== window.top && window.document.head.getAttribute('disable-luigi-history-handling') != 'true') {
history.pushState = history.replaceState.bind(history);
}
}
Expand Down
12 changes: 2 additions & 10 deletions client/src/luigi-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ export class LuigiElement extends HTMLElement {
this.afterInit(ctx);
this.__initialized = true;
};
if (
this.luigiConfig &&
this.luigiConfig.styleSources &&
this.luigiConfig.styleSources.length > 0
) {
if (this.luigiConfig && this.luigiConfig.styleSources && this.luigiConfig.styleSources.length > 0) {
let nr_styles = this.luigiConfig.styleSources.length;
const loadStylesSync = this.luigiConfig.loadStylesSync;
const afterLoadOrError = () => {
Expand Down Expand Up @@ -150,11 +146,7 @@ export function html(literal, ...keys) {
let html = '';
literal.forEach((el, index) => {
html += el;
if (
index < keys.length &&
keys[index] !== undefined &&
keys[index] !== null
) {
if (index < keys.length && keys[index] !== undefined && keys[index] !== null) {
html += keys[index];
}
});
Expand Down
5 changes: 1 addition & 4 deletions client/src/splitViewHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ export class splitViewHandle extends LuigiClientBase {
console.warn(name + ' is not a valid split view event');
return false;
}
const id = helpers.addEventListener(
`luigi.navigation.splitview.${name}.ok`,
e => callback(e.data.data)
);
const id = helpers.addEventListener(`luigi.navigation.splitview.${name}.ok`, e => callback(e.data.data));
this.splitView.listeners.push(id);
return id;
}
Expand Down
4 changes: 1 addition & 3 deletions client/src/storageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class StorageManager extends LuigiClientBase {
constructor() {
super();
this.storageEventProcessor = new StorageEventProcessor();
helpers.addEventListener('storage', (evt, listenerId) =>
this.storageEventProcessor.processEvent(evt, listenerId)
);
helpers.addEventListener('storage', (evt, listenerId) => this.storageEventProcessor.processEvent(evt, listenerId));
}

/**
Expand Down
18 changes: 6 additions & 12 deletions client/src/uxManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class UxManager extends LuigiClientBase {
super();
helpers.addEventListener('luigi.current-locale-changed', e => {
if (e.data.currentLocale && lifecycleManager.currentContext?.internal) {
lifecycleManager.currentContext.internal.currentLocale =
e.data.currentLocale;
lifecycleManager.currentContext.internal.currentLocale = e.data.currentLocale;
lifecycleManager._notifyUpdate();
}
});
Expand Down Expand Up @@ -95,13 +94,10 @@ class UxManager extends LuigiClientBase {
* });
*/
showConfirmationModal(settings) {
helpers.addEventListener(
'luigi.ux.confirmationModal.hide',
(e, listenerId) => {
this.hideConfirmationModal(e.data.data);
helpers.removeEventListener(listenerId);
}
);
helpers.addEventListener('luigi.ux.confirmationModal.hide', (e, listenerId) => {
this.hideConfirmationModal(e.data.data);
helpers.removeEventListener(listenerId);
});
helpers.sendPostMessageToLuigiCore({
msg: 'luigi.ux.confirmationModal.show',
data: { settings }
Expand Down Expand Up @@ -169,9 +165,7 @@ class UxManager extends LuigiClientBase {
//generate random ID
settings.id = helpers.getRandomId();
if (settings?.closeAfter < 100) {
console.warn(
`Message with id='${settings.id}' has too small 'closeAfter' value. It needs to be at least 100ms.`
);
console.warn(`Message with id='${settings.id}' has too small 'closeAfter' value. It needs to be at least 100ms.`);
settings.closeAfter = undefined;
}
helpers.sendPostMessageToLuigiCore({
Expand Down
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
{
"path": "./public/luigi.css",
"maxSize": "460 kB",
"maxSize": "461 kB",
"compression": "none"
},
{
Expand Down
30 changes: 15 additions & 15 deletions core/src/Alerts.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
id="j2ALl423"
data-testid="luigi-alert"
>
<p
class="fd-message-strip__text"
>{@html al.dataSanitized ? al.settings.text: ''}</p>
<p class="fd-message-strip__text">
{@html al.dataSanitized ? al.settings.text: ''}
</p>
<button
class="fd-button fd-button--transparent fd-message"
on:click="{() => dispatch('alertDismiss',{id: al.settings.id})}"
Expand All @@ -28,27 +28,27 @@
createEventDispatcher,
onMount,
getContext
} from 'svelte';
} from "svelte";

const dispatch = createEventDispatcher();

import { EscapingHelpers } from './utilities/helpers';
import { EscapingHelpers } from "./utilities/helpers";

export let alertQueue;
export let alertTypeMap = {
info: 'information',
success: 'success',
warning: 'warning',
error: 'error'
info: "information",
success: "success",
warning: "warning",
error: "error"
};
const getUnsavedChangesModalPromise = getContext(
'getUnsavedChangesModalPromise'
"getUnsavedChangesModalPromise"
);
const handleNavigation = getContext('handleNavigation');
const handleNavigation = getContext("handleNavigation");

beforeUpdate(() => {
if (!alertQueue || !alertQueue.length) {
console.warn('There are no alerts to display');
console.warn("There are no alerts to display");
return;
}

Expand Down Expand Up @@ -87,8 +87,8 @@
// review these functions and remove unnecessary 'export' keywords
export function addClickListener(url, elemId) {
try {
document.getElementById(elemId).addEventListener('click', event => {
const isRelative = !url.startsWith('/');
document.getElementById(elemId).addEventListener("click", event => {
const isRelative = !url.startsWith("/");
event.stopPropagation();
getUnsavedChangesModalPromise().then(() => {
const data = {
Expand All @@ -101,7 +101,7 @@
});
});
} catch (e) {
console.error('Error on Alert::addClickListener', e);
console.error("Error on Alert::addClickListener", e);
}
}
</script>
Expand Down
Loading

0 comments on commit 294b73c

Please sign in to comment.