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

CCDM: Adding a JsInit Handler for JS bootstrapper #6127

Merged
merged 5 commits into from Aug 6, 2019
Merged

Conversation

manolo
Copy link
Member

@manolo manolo commented Jul 30, 2019

Part of the #6133 this change adds a bootstrap-handler to be called from the flow-client javascript.

The handler creates the user session, and the flow UI, returning a JSON that is used in the browser to run the bootstrap script that configures the hosted page and loads the flow-client module.

This handler is required in CCDM projects because flow does not need to be initialized until the user actually navigates to a view provided by flow instead of a pure client view.

This change is Reviewable

@manolo manolo added the hilla Issues related to Hilla label Jul 30, 2019
@manolo manolo requested a review from qtdzz July 30, 2019 14:19
@project-bot project-bot bot added this to Review in progress in OLD Vaadin Flow ongoing work (Vaadin 10+) Jul 30, 2019
@manolo manolo changed the title CCDM: Adding a JsInit bootstrapper CCDM: Adding a JsInit Handler for JS bootstrapper Jul 30, 2019
@manolo manolo force-pushed the mcm/ccdm/jsinit branch 2 times, most recently from 435c017 to de6213d Compare August 1, 2019 09:58
@manolo manolo self-assigned this Aug 1, 2019
Copy link
Contributor

@qtdzz qtdzz left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 5 files at r1, 6 of 6 files at r2.
Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @manolo)


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 202 at r2 (raw file):

    @Override
    public boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException {
        if (session.getService().getDeploymentConfiguration().isCompatibilityMode()) {

Do you think we should also put this condition in canHandleRequest?


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 296 at r2 (raw file):

    }

    private JsonObject getInitialUidl(UI ui) {

This method and others around here are duplicated with those in com.vaadin.flow.server.BootstrapHandler.BootstrapPageBuilder because of the way they were implemented. Do you think that we should worry about it or just accept it for now and refactor them later?


flow-server/src/test/java/com/vaadin/flow/server/MockVaadinServletService.java, line 19 at r2 (raw file):

import javax.servlet.ServletException;

This change seems unrelated but it's up to you


flow-server/src/test/java/com/vaadin/flow/server/MockVaadinSession.java, line 21 at r2 (raw file):

import java.util.concurrent.locks.ReentrantLock;

import com.vaadin.flow.server.VaadinService;

This change seems unrelated but it's up to you

Copy link
Member Author

@manolo manolo left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @qtdzz)


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 202 at r2 (raw file):

Previously, qtdzz (Tien Nguyen) wrote…

Do you think we should also put this condition in canHandleRequest?

Done.


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 296 at r2 (raw file):

Previously, qtdzz (Tien Nguyen) wrote…

This method and others around here are duplicated with those in com.vaadin.flow.server.BootstrapHandler.BootstrapPageBuilder because of the way they were implemented. Do you think that we should worry about it or just accept it for now and refactor them later?

Refactored. There were not part of the public API.

@manolo manolo force-pushed the mcm/ccdm/jsinit branch 2 times, most recently from b1356d3 to 7caa295 Compare August 1, 2019 17:43
@vaadin-bot
Copy link
Collaborator

SonarQube analysis reported 1 issue

  • INFO 1 info

Watch the comments in this conversation to review them.

Copy link
Member Author

@manolo manolo left a comment

Choose a reason for hiding this comment

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

Dismissed @vaadin-bot from a discussion.
Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @manolo and @qtdzz)

@manolo manolo force-pushed the ccdm branch 2 times, most recently from 7d6b40c to ec2ca61 Compare August 5, 2019 06:26
Copy link
Contributor

@qtdzz qtdzz left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 4 files at r3, 2 of 2 files at r4.
Reviewable status: all discussions resolved, 0 of 1 LGTMs obtained (waiting on @caalador)


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 136 at r4 (raw file):

!VaadinSession.getCurrent().getService()

Minor: is it safer to use request.getService() instead ?

qtdzz
qtdzz previously approved these changes Aug 6, 2019
OLD Vaadin Flow ongoing work (Vaadin 10+) automation moved this from Review in progress to Reviewer approved Aug 6, 2019
qtdzz
qtdzz previously approved these changes Aug 6, 2019
Copy link
Contributor

@qtdzz qtdzz left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r5.
Reviewable status: all discussions resolved, 0 of 1 LGTMs obtained (waiting on @caalador)

OLD Vaadin Flow ongoing work (Vaadin 10+) automation moved this from Review in progress to Reviewer approved Aug 6, 2019
Copy link
Member Author

@manolo manolo left a comment

Choose a reason for hiding this comment

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

Dismissed @vaadin-bot from a discussion.
Reviewable status: all discussions resolved, 0 of 1 LGTMs obtained (waiting on @caalador)

Copy link
Contributor

@caalador caalador left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 5 files at r1, 2 of 6 files at r2, 3 of 4 files at r3, 1 of 2 files at r4, 2 of 2 files at r5.
Reviewable status: 5 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @manolo)


flow-server/src/main/java/com/vaadin/flow/server/BootstrapHandler.java, line 723 at r5 (raw file):

        }

        /**

Moving these around makes no sense for the actual ticket. Please revert this


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 54 at r5 (raw file):

given for

needed to


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 57 at r5 (raw file):

is thought for CCDM projects whose `index.html` response does not 
have any bootstrap code

is for client driven projects where index.html does not contain bootstrap data.


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 58 at r5 (raw file):

but it's responsability of the `@vaadin/flow` client

Bootstrapping is the responsibility of @vaadin/flow client code


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 63 at r5 (raw file):

JsInitHandler

Would be good to have the info about what this is in the name so JsInitBootstrapHandler or JavaScriptBootsrtapHandleras we have for WebComponentBootstrapHandler
Also if JsInit correct or should it be more like ClientJsonBootstrapHandler as from the server we don't handle JS in the handler, but do return json.

OLD Vaadin Flow ongoing work (Vaadin 10+) automation moved this from Reviewer approved to Review in progress Aug 6, 2019
Copy link
Member Author

@manolo manolo left a comment

Choose a reason for hiding this comment

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

Reviewable status: 5 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @manolo and @qtdzz)


flow-server/src/main/java/com/vaadin/flow/server/BootstrapHandler.java, line 723 at r5 (raw file):

Previously, caalador wrote…

Moving these around makes no sense for the actual ticket. Please revert this

Otherwise we need to copy this code in the other class, @qtdzz suggested not to repeat code which is a good practice.

This is private API and does not break anything

Copy link
Member Author

@manolo manolo left a comment

Choose a reason for hiding this comment

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

Reviewable status: 5 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @manolo and @qtdzz)


flow-server/src/main/java/com/vaadin/flow/server/BootstrapHandler.java, line 723 at r5 (raw file):

Previously, manolo (Manuel Carrasco Moñino) wrote…

Otherwise we need to copy this code in the other class, @qtdzz suggested not to repeat code which is a good practice.

This is private API and does not break anything

Take a look to first change in the PR, it was not modifiying this class, but repeated code

Copy link
Contributor

@caalador caalador left a comment

Choose a reason for hiding this comment

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

Reviewable status: 5 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @manolo and @qtdzz)


flow-server/src/main/java/com/vaadin/flow/server/BootstrapHandler.java, line 723 at r5 (raw file):

Previously, manolo (Manuel Carrasco Moñino) wrote…

Take a look to first change in the PR, it was not modifiying this class, but repeated code

I see only one change and that just moves the methods to another position.

Copy link
Member Author

@manolo manolo left a comment

Choose a reason for hiding this comment

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

Reviewable status: 5 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @manolo and @qtdzz)


flow-server/src/main/java/com/vaadin/flow/server/BootstrapHandler.java, line 723 at r5 (raw file):

Previously, caalador wrote…

I see only one change and that just moves the methods to another position.

It's moving from one class to another in the same file

Copy link
Member Author

@manolo manolo left a comment

Choose a reason for hiding this comment

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

Reviewable status: 5 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @manolo and @qtdzz)


flow-server/src/main/java/com/vaadin/flow/server/BootstrapHandler.java, line 723 at r5 (raw file):

Previously, manolo (Manuel Carrasco Moñino) wrote…

It's moving from one class to another in the same file

I meant BootstrapPageBuilder -> BootstrapHandler

Copy link
Contributor

@caalador caalador left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @manolo)


flow-server/src/main/java/com/vaadin/flow/server/BootstrapHandler.java, line 723 at r5 (raw file):

Previously, manolo (Manuel Carrasco Moñino) wrote…

I meant BootstrapPageBuilder -> BootstrapHandler

800 line internal class is not ok... The internal classes should really be broken out at some point for less sanity loss.

Copy link
Member Author

@manolo manolo left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 unresolved discussions, 0 of 1 LGTMs obtained (waiting on @caalador and @qtdzz)


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 54 at r5 (raw file):

Previously, caalador wrote…
given for

needed to

Done.


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 57 at r5 (raw file):

Previously, caalador wrote…
is thought for CCDM projects whose `index.html` response does not 
have any bootstrap code

is for client driven projects where index.html does not contain bootstrap data.

Done.


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 58 at r5 (raw file):

Previously, caalador wrote…
but it's responsability of the `@vaadin/flow` client

Bootstrapping is the responsibility of @vaadin/flow client code

Done.


flow-server/src/main/java/com/vaadin/flow/server/communication/JsInitHandler.java, line 63 at r5 (raw file):

Previously, caalador wrote…
JsInitHandler

Would be good to have the info about what this is in the name so JsInitBootstrapHandler or JavaScriptBootsrtapHandleras we have for WebComponentBootstrapHandler
Also if JsInit correct or should it be more like ClientJsonBootstrapHandler as from the server we don't handle JS in the handler, but do return json.

Done.

OLD Vaadin Flow ongoing work (Vaadin 10+) automation moved this from Review in progress to Reviewer approved Aug 6, 2019
Copy link
Contributor

@caalador caalador left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r6.
Reviewable status: :shipit: complete! all discussions resolved, 1 of 1 LGTMs obtained

Copy link
Contributor

@qtdzz qtdzz left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all discussions resolved, 2 of 1 LGTMs obtained


config.put(ApplicationConstants.SERVICE_URL, serviceUrl);

// TODO(manolo) this comment is left intentionally because we
Copy link
Collaborator

Choose a reason for hiding this comment

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

INFO Complete the task associated to this TODO comment. rule

Copy link
Member Author

@manolo manolo left a comment

Choose a reason for hiding this comment

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

Dismissed @vaadin-bot from a discussion.
Reviewable status: :shipit: complete! all discussions resolved, 2 of 1 LGTMs obtained

@manolo manolo merged commit 7950f3d into ccdm Aug 6, 2019
OLD Vaadin Flow ongoing work (Vaadin 10+) automation moved this from Reviewer approved to Done - pending release Aug 6, 2019
@manolo manolo deleted the mcm/ccdm/jsinit branch August 6, 2019 09:31
@ujoni ujoni added the +1.0.0 label Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hilla Issues related to Hilla +1.0.0
Projects
OLD Vaadin Flow ongoing work (Vaadin ...
  
Done - pending release
Development

Successfully merging this pull request may close these issues.

None yet

5 participants