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

Refactor navigation open at App.html #2435

Closed
stanleychh opened this issue Dec 16, 2021 · 0 comments · Fixed by #2441
Closed

Refactor navigation open at App.html #2435

stanleychh opened this issue Dec 16, 2021 · 0 comments · Fixed by #2441
Assignees
Labels
refactoring Something needs to be refactored in a separate task
Milestone

Comments

@stanleychh
Copy link
Contributor

A follow-up issue of #2393.
(Can start this task when #2393 be merged)

Purpose: Reduce repetition in codebase

luigi/core/src/App.html

Lines 1349 to 1417 in 8ba179d

if ('luigi.navigation.open' === e.data.msg) {
isNavigateBack = false;
const srcNode = isSpecialIframe ? iframe.luigi.currentNode : undefined;
const srcPathParams = isSpecialIframe ? iframe.luigi.pathParams : undefined;
const params = e.data.params;
const { intent, newTab, modal, splitView, drawer, withoutSync } = params;
if (e.source !== window && !intent && params.link) {
params.link = params.link.split('?')[0];
}
if (newTab) {
let path = buildPath(params, srcNode, srcPathParams);
path = GenericHelpers.addLeadingSlash(path);
openViewInNewTab(path);
} else if (modal !== undefined) {
let path = buildPath(params, srcNode, srcPathParams);
path = GenericHelpers.addLeadingSlash(path);
const pathExist = await pathExists(path);
path = await RoutingHelpers.handlePageNotFoundAndRetrieveRedirectPath(
getComponentWrapper(),
path,
pathExist
);
if (!path) {
return;
}
contentNode = node;
resetMicrofrontendModalData();
openViewInModal(path, modal === true ? {} : modal);
} else if (splitView !== undefined) {
let path = buildPath(params, srcNode, srcPathParams);
path = GenericHelpers.addLeadingSlash(path);
const pathExist = await pathExists(path);
path = await RoutingHelpers.handlePageNotFoundAndRetrieveRedirectPath(
getComponentWrapper(),
path,
pathExist
);
if (!path) {
return;
}
contentNode = node;
openSplitView(path, splitView);
} else if (drawer !== undefined) {
let path = buildPath(params, srcNode, srcPathParams);
path = GenericHelpers.addLeadingSlash(path);
const pathExist = await pathExists(path);
path = await RoutingHelpers.handlePageNotFoundAndRetrieveRedirectPath(
getComponentWrapper(),
path,
pathExist
);
if (!path) {
return;
}
contentNode = node;
resetMicrofrontendDrawerData();
drawer.isDrawer = true;
openViewInDrawer(path, drawer);
} else {
getUnsavedChangesModalPromise().then(() => {
isNavigationSyncEnabled = !withoutSync;
handleNavigation(e.data, config, srcNode, srcPathParams);
closeModal();
closeSplitView();
closeDrawer();
isNavigationSyncEnabled = true;
});
}
}

@stanleychh stanleychh added the refactoring Something needs to be refactored in a separate task label Dec 16, 2021
@stanleychh stanleychh added this to the Sprint 22 milestone Dec 16, 2021
@stanleychh stanleychh self-assigned this Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Something needs to be refactored in a separate task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant