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

Bookmarkable modals #1841

Merged
merged 29 commits into from
Mar 24, 2021
Merged

Conversation

maxmarkus
Copy link
Contributor

@maxmarkus maxmarkus commented Jan 25, 2021

Changes proposed in this pull request:

  • Persistence of modal path and parameters in the url
  • Configurable parameter name: routing.showModalPathInUrl and routing.modalPathParam
  • nodeParams are working

TODO in this draft:

  • unit tests

How to reproduce:

  • run npm run simpledev in core
  • run npm start in test/e2e-testapplication
  • copy luigi-config:
core/dev-tools/simple-app/luigi-config.js
Luigi.setConfig({
  navigation: {
    nodes: [{
      pathSegment: 'home',
      hideFromNav: true,
      // hideSideNav: true,
      loadingIndicator: {
        enabled: false
      },
      viewUrl: '/microfrontend.html',
      children: [
        {
          label: 'Child 1',
          pathSegment: 'child',
          loadingIndicator: {
            enabled: false
          },
          viewUrl: 'http://127.0.0.1:8090/#child-1'
        },
        {
          label: 'Child 2',
          pathSegment: 'child-2',
          loadingIndicator: {
            enabled: false
          },
          viewUrl: '/microfrontend.html',
          // openNodeInModal: {
          //   title: 'Real Child'
          // }
        }
      ]
    }]
  },
  routing: {
    showModalPathInUrl: true,
    modalPathParam: 'modal'
  },
  settings: {
    responsiveNavigation: 'Fiori3',
    header: {
      title: 'Luigi Simple Dev'
    },
    theming: {
      themes: [
        { id: 1, name: 'light' },
        { id: 2, name: 'dark' },
      ],
      defaultTheme: 'dark'
    }
  }
});

http://localhost:4100/home/child-2?modal=%252Fhome%252Fchild%253F~foo%253Dbar&modalParams=%257B%2522title%2522%253A%2522Hello%2520Luigi%2522%257D

Related issue(s)
Resolves #1772

@maxmarkus maxmarkus added the enhancement New feature or request label Jan 25, 2021
@maxmarkus maxmarkus changed the title openAsModal should be bookmarkable Make modals bookmarkable Jan 25, 2021
@maxmarkus maxmarkus changed the title Make modals bookmarkable Bookmarkable modals Jan 26, 2021
@JohannesDoberer JohannesDoberer added this to the Sprint 16 milestone Jan 26, 2021
@JohannesDoberer
Copy link
Contributor

Missing test should not covered by the review

@legteodav legteodav self-assigned this Feb 9, 2021
const params = location.search
? RoutingHelpers.parseParams(location.search.slice(1))
: {};
const prevModalPath = params[modalParamName];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you check if the param is present in location.search? like...

if (!prevModalPath){
    return;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case there can or cannot be an existing modal. If we would return here, we would never append to the url.

Comment on lines 204 to 205
// handle bookmarkable modal path
const additionalModalPath = RoutingHelpers.getModalPathFromPath();
if (additionalModalPath) {
const modalParams = RoutingHelpers.getModalParamsFromPath();
const { nodeObject } = await Navigation.extractDataFromPath(additionalModalPath);
LuigiNavigation.openAsModal(additionalModalPath, nodeObject.openNodeInModal || modalParams);
}

Copy link
Contributor

@legteodav legteodav Feb 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async handleRouteChange(path, component, iframeElement, config, withoutSync) function is getting pretty long and complex (it would be nice to refactor).
Could you create a new function:

async handleBookmarkableModalPath(){
    const additionalModalPath = RoutingHelpers.getModalPathFromPath();
    if (additionalModalPath) {
      const modalParams = RoutingHelpers.getModalParamsFromPath();
      const { nodeObject } = await Navigation.extractDataFromPath(additionalModalPath);
      LuigiNavigation.openAsModal(additionalModalPath, nodeObject.openNodeInModal || modalParams);
    }
  }
Suggested change
// handle bookmarkable modal path
const additionalModalPath = RoutingHelpers.getModalPathFromPath();
if (additionalModalPath) {
const modalParams = RoutingHelpers.getModalParamsFromPath();
const { nodeObject } = await Navigation.extractDataFromPath(additionalModalPath);
LuigiNavigation.openAsModal(additionalModalPath, nodeObject.openNodeInModal || modalParams);
}
await this.handleBookmarkableModalPath();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I have not taken time to refactor yet, wanted to get the things working first. I appreciate your thoughts 👍

@JohannesDoberer JohannesDoberer self-assigned this Feb 14, 2021
@maxmarkus
Copy link
Contributor Author

maxmarkus commented Feb 17, 2021

I have updated the e2e test cases and fixed the implementation. One thing to mention: I have implemented a flexible "getQueryParam" and "getQueryParams" method in RoutingHelpers, since GenericHelpers.getUrlParams did not work properly. It might be an opportunity to consolidate other occurrences if this fits the same use case. Happy to have a talk about it too.

Added showModalPathInUrl: true, to the example above.

Unit tests will come in the next days.

@JohannesDoberer
Copy link
Contributor

Summery of the call with Markus:
Code looks good from my side.
Markus will provide the missing unit tests.

There is one tiny issue. When you open a modal from the left nav the url will not be generated. Markus will take a look and either it is a quick fix he will fix it in this PR or if not we will create a follow up ticket for that.

@JohannesDoberer JohannesDoberer modified the milestones: Sprint 16, Sprint 17 Mar 1, 2021
Copy link
Contributor

@JohannesDoberer JohannesDoberer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!!Looks good to me

@JohannesDoberer JohannesDoberer modified the milestones: Sprint 17, Sprint 18 Mar 15, 2021
…gi into 1772-bookmarkable-modal-mf

* '1772-bookmarkable-modal-mf' of github.com:maxmarkus/luigi:
  Add warning if both virtualTree and children nodes are defined (SAP#1935)
  Documentation for luigi client angular support library (SAP#1845)
  Fix withoutSync behavior under hashrouting enabled SAP#1787 (SAP#1893)
@ndricimrr ndricimrr self-assigned this Mar 19, 2021
…gi into 1772-bookmarkable-modal-mf

* '1772-bookmarkable-modal-mf' of github.com:maxmarkus/luigi:
  SemiCollapse tooltip bug (SAP#1929)
Copy link
Contributor

@ndricimrr ndricimrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see an error when attempting with the following configuration:

showModalPathInUrl = true;
 modalPathParam = 'modal';

and then for a particular node:
openNodeInModal: true,

Screenshot:
Screen Shot 2021-03-23 at 03 26 26

It works well with:
openNodeInModal: {title: "test"}

It just seems that for true value it still expects to find a title.

Copy link
Contributor

@ndricimrr ndricimrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@JohannesDoberer JohannesDoberer merged commit b43a9ef into SAP:master Mar 24, 2021
@JohannesDoberer JohannesDoberer deleted the 1772-bookmarkable-modal-mf branch March 24, 2021 09:38
@JohannesDoberer JohannesDoberer mentioned this pull request Mar 24, 2021
stanleychh pushed a commit to stanleychh/luigi that referenced this pull request Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"bookmarkable" modal micro frontend
4 participants