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

fix: resolve route parameters when rerouting and forwarding with query parameters (#20210) (CP: 23.5) (#20222) #20266

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions flow-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flow-client/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@vaadin/flow-deps",
"name": "@vaadin/flow-client",
"description": "Flow client package",
"version": "0.0.1",
"main": "src/main/resources/META-INF/frontend/Flow",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@

public enum Country {

FINLAND("Finland"), SWEDEN("Sweden"), USA("USA"), RUSSIA(
"Russia"), NETHERLANDS("Netherlands"), SOUTH_AFRICA("South Africa");
FINLAND("Finland"),
SWEDEN("Sweden"),
USA("USA"),
RUSSIA("Russia"),
NETHERLANDS("Netherlands"),
SOUTH_AFRICA("South Africa");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,21 @@ private static Optional<ImportanceType> fromAttributeValue(
* Sandbox types.
*/
public enum SandboxType {
RESTRICT_ALL(""), ALLOW_FORMS("allow-forms"), ALLOW_MODALS(
"allow-modals"), ALLOW_ORIENTATION_LOCK(
"allow-orientation-lock"), ALLOW_POINTER_LOCK(
"allow-pointer-lock"), ALLOW_POPUPS(
"allow-popups"), ALLOW_POPUPS_TO_ESCAPE_SANDBOX(
"allow-popups-to-escape-sandbox"), ALLOW_PRESENTATION(
"allow-presentation"), ALLOW_SAME_ORIGIN(
"allow-same-origin"), ALLOW_SCRIPTS(
"allow-scripts"), ALLOW_STORAGE_ACCESS_BY_USER_ACTIVATION(
"allow-storage-access-by-user-activation"), ALLOW_TOP_NAVIGATION(
"allow-top-navigation"), ALLOW_TOP_NAVIGATION_BY_USER_ACTIVATION(
"allow-top-navigation-by-user-activation");
RESTRICT_ALL(""),
ALLOW_FORMS("allow-forms"),
ALLOW_MODALS("allow-modals"),
ALLOW_ORIENTATION_LOCK("allow-orientation-lock"),
ALLOW_POINTER_LOCK("allow-pointer-lock"),
ALLOW_POPUPS("allow-popups"),
ALLOW_POPUPS_TO_ESCAPE_SANDBOX("allow-popups-to-escape-sandbox"),
ALLOW_PRESENTATION("allow-presentation"),
ALLOW_SAME_ORIGIN("allow-same-origin"),
ALLOW_SCRIPTS("allow-scripts"),
ALLOW_STORAGE_ACCESS_BY_USER_ACTIVATION(
"allow-storage-access-by-user-activation"),
ALLOW_TOP_NAVIGATION("allow-top-navigation"),
ALLOW_TOP_NAVIGATION_BY_USER_ACTIVATION(
"allow-top-navigation-by-user-activation");

private final String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public final class StringUtil {
* Comment parser state enumeration.
*/
private enum State {
NORMAL, IN_LINE_COMMENT, IN_BLOCK_COMMENT, IN_STRING, IN_STRING_APOSTROPHE
NORMAL,
IN_LINE_COMMENT,
IN_BLOCK_COMMENT,
IN_STRING,
IN_STRING_APOSTROPHE
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,11 @@ public <T> void forwardTo(String location, List<T> locationParams) {
*/
public void forwardTo(String locationString,
QueryParameters queryParameters) {
final Optional<Class<? extends Component>> target = getSource()
.getRegistry().getNavigationTarget(locationString);
final Optional<NavigationState> navigationState = getSource()
.resolveNavigationTarget(new Location(locationString));
this.redirectQueryParameters = queryParameters;
if (target.isPresent()) {
forwardTo(getNavigationState(locationString, List.of()));
if (navigationState.isPresent()) {
forwardTo(navigationState.get());
} else {
// Inform that forward target location is not known.
unknownForward = PathUtil.trimPath(locationString);
Expand Down Expand Up @@ -878,12 +878,11 @@ public <T> void rerouteTo(String route, List<T> routeParams) {
* query parameters for the target
*/
public void rerouteTo(String route, QueryParameters queryParameters) {
final Optional<Class<? extends Component>> target = getSource()
.getRegistry().getNavigationTarget(route);

final Optional<NavigationState> navigationState = getSource()
.resolveNavigationTarget(new Location(route));
this.redirectQueryParameters = queryParameters;
if (target.isPresent()) {
rerouteTo(getNavigationState(route, List.of()));
if (navigationState.isPresent()) {
rerouteTo(navigationState.get());
} else {
// Inform that reroute target location is not known.
unknownReroute = PathUtil.trimPath(route);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"name": "flow-default-dependencies",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Artur Signell",
"license": "Apache-2.0",
"private": true,
"description": "A list of default Flow dependencies",
"dependencies": {
"@polymer/polymer": "3.5.1",
"@vaadin/common-frontend": "0.0.18",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "flow-vite-dependencies",
"version": "1.0.0",
"description": "",
"private": true,
"description": "A ",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "no-name",
"private": true,
"license": "UNLICENSED",
"dependencies": {
"@polymer/iron-list": "3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion flow-server/src/test/resources/versions/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "no-name",
"private": true,
"license": "UNLICENSED",
"vaadin": {
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion flow-server/src/test/resources/versions/user_package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "no-name",
"private": true,
"license": "UNLICENSED",
"vaadin": {
"dependencies": {
Expand Down

This file was deleted.

20 changes: 10 additions & 10 deletions flow-tests/test-frontend/vite-basics/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "no-name",
"private": true,
"license": "UNLICENSED",
"scripts": {
"postinstall": "node -e \"fs.writeFileSync('target/classes/main.postinstall', 'hello')\""
},
"dependencies": {
"@polymer/polymer": "3.5.1",
"@testscope/all": "../vite-test-assets/packages/@testscope/all",
"@testscope/button": "../vite-test-assets/packages/@testscope/button",
"@testscope/map": "../vite-test-assets/packages/@testscope/map",
"@vaadin/testscope-all": "../vite-test-assets/packages/@vaadin/testscope-all",
"@vaadin/testscope-button": "../vite-test-assets/packages/@vaadin/testscope-button",
"@vaadin/testscope-map": "../vite-test-assets/packages/@vaadin/testscope-map",
"@vaadin/bundles": "../vite-test-assets/packages/@vaadin/bundles",
"@vaadin/common-frontend": "0.0.18",
"@vaadin/polymer-legacy-adapter": "23.3.0-alpha2",
Expand All @@ -19,8 +19,8 @@
"construct-style-sheets-polyfill": "3.1.0",
"copy-to-clipboard": "^3.3.1",
"lit": "2.6.1",
"package-outside-npm": "file:package-outside-npm",
"package2-outside-npm": "./package2-outside-npm"
"@vaadin/test-package-outside-npm": "file:../vite-test-assets/packages/@vaadin/test-package-outside-npm",
"@vaadin/test-package2-outside-npm": "../vite-test-assets/packages/@vaadin/test-package2-outside-npm"
},
"devDependencies": {
"@rollup/plugin-replace": "3.1.0",
Expand All @@ -39,12 +39,12 @@
"workbox-precaching": "6.5.4"
},
"overrides": {
"@testscope/all": "$@testscope/all",
"@testscope/button": "$@testscope/button",
"@vaadin/testscope-all": "$@vaadin/testscope-all",
"@vaadin/testscope-button": "$@vaadin/testscope-button",
"@vaadin/bundles": "$@vaadin/bundles",
"copy-to-clipboard": "$copy-to-clipboard",
"package-outside-npm": "$package-outside-npm",
"package2-outside-npm": "$package2-outside-npm",
"@vaadin/test-package-outside-npm": "$@vaadin/test-package-outside-npm",
"@vaadin/test-package2-outside-npm": "$@vaadin/test-package2-outside-npm",
"glob": "$glob",
"mkdirp": "$mkdirp",
"rollup-plugin-brotli": "$rollup-plugin-brotli",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

@Route("")
@JsModule("./jsonloader.js")
@JsModule("package-outside-npm/index.js")
@JsModule("package2-outside-npm/index.js")
@JsModule("@vaadin/test-package-outside-npm/index.js")
@JsModule("@vaadin/test-package2-outside-npm/index.js")
@JsModule("./testscopebuttonloader.js")
@JsModule("./testscopemaploader.js")
@JsModule("./importdir.js")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public void optimizeDepsExcludesBundles() {

@Test
public void optimizeDepsExcludeBundleContents() {
Assert.assertTrue(isExcluded("@testscope/all"));
Assert.assertTrue(isExcluded("@testscope/button"));
Assert.assertTrue(isExcluded("@testscope/map"));
Assert.assertTrue(isExcluded("@vaadin/testscope-all"));
Assert.assertTrue(isExcluded("@vaadin/testscope-button"));
Assert.assertTrue(isExcluded("@vaadin/testscope-map"));
}

private boolean isExcluded(String dependency) {
Expand Down
8 changes: 4 additions & 4 deletions flow-tests/test-frontend/vite-context-path/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "no-name",
"private": true,
"license": "UNLICENSED",
"dependencies": {
"@polymer/polymer": "3.5.1",
"@testscope/all": "../vite-test-assets/packages/@testscope/all",
"@testscope/button": "../vite-test-assets/packages/@testscope/button",
"@testscope/map": "../vite-test-assets/packages/@testscope/map",
"@vaadin/testscope-all": "../vite-test-assets/packages/@vaadin/testscope-all",
"@vaadin/testscope-button": "../vite-test-assets/packages/@vaadin/testscope-button",
"@vaadin/testscope-map": "../vite-test-assets/packages/@vaadin/testscope-map",
"@vaadin/bundles": "../vite-test-assets/packages/@vaadin/bundles-old",
"@vaadin/common-frontend": "0.0.18",
"@vaadin/polymer-legacy-adapter": "23.3.0-alpha2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.vaadin.flow.router.Route;

@Route("")
@JsModule("@testscope/all")
@JsModule("@vaadin/testscope-all")
public class MainView extends Div {
public MainView() {
add(new H2("Hello world!"), new HtmlComponent("testscope-button"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public void bundlesIsNotUsedWhenHasVersionMismatch() {

@Test
public void optimizeDepsNotExcludeBundleContents() {
Assert.assertFalse(isExcluded("@testscope/all"));
Assert.assertFalse(isExcluded("@testscope/button"));
Assert.assertFalse(isExcluded("@vaadin/testscope-all"));
Assert.assertFalse(isExcluded("@vaadin/testscope-button"));
}

private boolean isExcluded(String dependency) {
Expand Down
8 changes: 4 additions & 4 deletions flow-tests/test-frontend/vite-production/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "no-name",
"private": true,
"license": "UNLICENSED",
"dependencies": {
"@polymer/polymer": "3.5.1",
"@testscope/all": "../vite-test-assets/packages/@testscope/all",
"@testscope/button": "../vite-test-assets/packages/@testscope/button",
"@testscope/map": "../vite-test-assets/packages/@testscope/map",
"@vaadin/testscope-all": "../vite-test-assets/packages/@vaadin/testscope-all",
"@vaadin/testscope-button": "../vite-test-assets/packages/@vaadin/testscope-button",
"@vaadin/testscope-map": "../vite-test-assets/packages/@vaadin/testscope-map",
"@vaadin/bundles": "../vite-test-assets/packages/@vaadin/bundles",
"@vaadin/common-frontend": "0.0.18",
"@vaadin/polymer-legacy-adapter": "23.3.0-alpha2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* Copyright (C) 2000-2024 Vaadin Ltd
*
* This program is available under Vaadin Commercial License and Service Terms.
*
* See <https://vaadin.com/commercial-license-and-service-terms> for the full
* license.
*/
package com.vaadin.viteapp.views.empty;

import com.vaadin.flow.component.HtmlComponent;
Expand All @@ -19,8 +11,8 @@
import com.vaadin.flow.router.Route;

@Route("")
@JsModule("@testscope/button")
@JsModule("@testscope/map")
@JsModule("@vaadin/testscope-button")
@JsModule("@vaadin/testscope-map")
@JsModule("./lit-invalid-imports.ts")
@CssImport("./image.css")
public class MainView extends Div {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@test/bundles",
"name": "@vaadin/bundles-old",
"version": "0.1.0",
"description": "",
"type": "module",
Expand Down
Loading
Loading