Skip to content

Commit

Permalink
Merge pull request #7988 from vaadin/cp/3.0
Browse files Browse the repository at this point in the history
Cherry-picks for 3.0
  • Loading branch information
haijian-vaadin committed Apr 3, 2020
2 parents e62ae0b + 10fd534 commit 7b10b69
Show file tree
Hide file tree
Showing 44 changed files with 1,070 additions and 6,045 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected void handleUnrecoverableError(String details,
* {@code null} to refresh on click
*/
public void handleUnrecoverableError(String caption, String message,
String details, String url) {
String details, String url) {
handleUnrecoverableError(caption, message, details, url, null);
}

Expand Down Expand Up @@ -118,14 +118,15 @@ public void handleUnrecoverableError(String caption, String message,
return;
}

Element systemErrorContainer =
handleError(caption, message, details, querySelector);
Element systemErrorContainer = handleError(caption, message, details,
querySelector);
systemErrorContainer.addEventListener("click",
e -> WidgetUtil.redirect(url), false);

Browser.getDocument().addEventListener(Event.KEYDOWN, e -> {
int keyCode = ((KeyboardEvent) e).getKeyCode();
if (keyCode == KeyCode.ESC) {
e.preventDefault();
WidgetUtil.redirect(url);
}
}, false);
Expand Down Expand Up @@ -167,8 +168,8 @@ public void handleError(Throwable throwable) {
}
}

private Element handleError(String caption, String message,
String details, String querySelector) {
private Element handleError(String caption, String message, String details,
String querySelector) {
Document document = Browser.getDocument();
Element systemErrorContainer = document.createDivElement();
systemErrorContainer.setClassName("v-system-error");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.vaadin.flow.component.ComponentUtil;
import com.vaadin.flow.component.HasElement;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.dependency.JavaScript;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.dnd.internal.DndUtil;
import com.vaadin.flow.dom.Element;
Expand All @@ -47,7 +46,6 @@
* @author Vaadin Ltd
* @since 2.0
*/
@JavaScript(DndUtil.DND_CONNECTOR_COMPATIBILITY)
@JsModule(DndUtil.DND_CONNECTOR)
public interface DragSource<T extends Component> extends HasElement {

Expand Down Expand Up @@ -170,7 +168,8 @@ default Element getDraggableElement() {
/**
* Sets this component as draggable. By default it is not.
*
* @param draggable {@code true} for enable dragging, {@code false} to prevent
* @param draggable
* {@code true} for enable dragging, {@code false} to prevent
*/
default void setDraggable(boolean draggable) {
if (draggable == isDraggable()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.ComponentUtil;
import com.vaadin.flow.component.HasElement;
import com.vaadin.flow.component.dependency.JavaScript;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.dnd.internal.DndUtil;
import com.vaadin.flow.dom.Element;
Expand All @@ -41,7 +40,6 @@
* @author Vaadin Ltd
* @since 2.0
*/
@JavaScript(DndUtil.DND_CONNECTOR_COMPATIBILITY)
@JsModule(DndUtil.DND_CONNECTOR)
public interface DropTarget<T extends Component> extends HasElement {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@
*/
public class DndUtil {

/**
* Resource path for importing dnd connector for compatibility mode.
*/
public static final String DND_CONNECTOR_COMPATIBILITY = "frontend://dndConnector.js";

/**
* Resource path for importing dnd connector.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,9 @@ public class BuildFrontendMojo extends FlowModeAbstractMojo {
* Whether to use byte code scanner strategy to discover frontend
* components.
*/
@Parameter(defaultValue = "true")
@Parameter(property = Constants.SERVLET_PARAMETER_DEVMODE_OPTIMIZE_BUNDLE, defaultValue = "true")
private boolean optimizeBundle;

@Parameter(property = Constants.SERVLET_PARAMETER_ENABLE_PNPM, defaultValue = "false")
private boolean pnpmEnable;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
updateBuildFile();
Expand Down Expand Up @@ -191,7 +188,7 @@ private void runWebpack() {
.directory(project.getBasedir()).inheritIO();
getLog().info("Running webpack ...");
FrontendUtils.console(FrontendUtils.YELLOW,
FrontendUtils.commandToString(npmFolder.getAbsolutePath(),
FrontendUtils.commandToString(npmFolder.getAbsolutePath(),
command));

Process webpackLaunch = null;
Expand Down Expand Up @@ -250,6 +247,9 @@ private void updateBuildFile() {
buildInfo.remove(NPM_TOKEN);
buildInfo.remove(GENERATED_TOKEN);
buildInfo.remove(FRONTEND_TOKEN);
buildInfo.remove(Constants.SERVLET_PARAMETER_ENABLE_PNPM);
buildInfo.remove(Constants.SERVLET_PARAMETER_DEVMODE_OPTIMIZE_BUNDLE);


buildInfo.put(SERVLET_PARAMETER_ENABLE_DEV_SERVER, false);
FileUtils.write(tokenFile, JsonUtil.stringify(buildInfo, 2) + "\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public abstract class FlowModeAbstractMojo extends AbstractMojo {
public boolean productionMode;

/**
* Whether or not we are running in legacy V14 bootstrap mode.
* True if defined or if it's set to true.
* Whether or not we are running in legacy V14 bootstrap mode. True if
* defined or if it's set to true.
*/
@Parameter(defaultValue = "${vaadin.useDeprecatedV14Bootstrapping}")
private String useDeprecatedV14Bootstrapping;
Expand Down Expand Up @@ -112,7 +112,14 @@ public abstract class FlowModeAbstractMojo extends AbstractMojo {
protected File generatedTsFolder;

/**
* Check if the plugin is running in legacy V14 bootstrap mode or not. Default: false.
* Instructs to use pnpm for installing npm frontend resources.
*/
@Parameter(property = Constants.SERVLET_PARAMETER_ENABLE_PNPM, defaultValue = "false")
protected boolean pnpmEnable;

/**
* Check if the plugin is running in legacy V14 bootstrap mode or not.
* Default: false.
*
* @return true if the `useDeprecatedV14Bootstrapping` is empty or true.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.maven.project.MavenProject;
import org.sonatype.plexus.build.incremental.BuildContext;

import com.vaadin.flow.server.Constants;
import com.vaadin.flow.server.ExecutionFailedException;
import com.vaadin.flow.server.frontend.FrontendUtils;
import com.vaadin.flow.server.frontend.NodeTasks;
Expand All @@ -51,9 +52,9 @@
import static com.vaadin.flow.server.Constants.FRONTEND_TOKEN;
import static com.vaadin.flow.server.Constants.GENERATED_TOKEN;
import static com.vaadin.flow.server.Constants.NPM_TOKEN;
import static com.vaadin.flow.server.Constants.SERVLET_PARAMETER_USE_V14_BOOTSTRAP;
import static com.vaadin.flow.server.Constants.SERVLET_PARAMETER_INITIAL_UIDL;
import static com.vaadin.flow.server.Constants.SERVLET_PARAMETER_PRODUCTION_MODE;
import static com.vaadin.flow.server.Constants.SERVLET_PARAMETER_USE_V14_BOOTSTRAP;
import static com.vaadin.flow.server.frontend.FrontendUtils.TOKEN_FILE;

/**
Expand Down Expand Up @@ -141,7 +142,8 @@ private void propagateBuildInfo() {
File token = new File(webpackOutputDirectory, TOKEN_FILE);
JsonObject buildInfo = Json.createObject();
buildInfo.put(SERVLET_PARAMETER_PRODUCTION_MODE, productionMode);
buildInfo.put(SERVLET_PARAMETER_USE_V14_BOOTSTRAP, useDeprecatedV14Bootstrapping());
buildInfo.put(SERVLET_PARAMETER_USE_V14_BOOTSTRAP,
useDeprecatedV14Bootstrapping());
buildInfo.put(SERVLET_PARAMETER_INITIAL_UIDL, eagerServerLoad);
buildInfo.put(NPM_TOKEN, npmFolder.getAbsolutePath());
buildInfo.put(GENERATED_TOKEN, generatedFolder.getAbsolutePath());
Expand All @@ -155,6 +157,8 @@ private void propagateBuildInfo() {
buildInfo.put(CONNECT_GENERATED_TS_DIR_TOKEN,
generatedTsFolder.getAbsolutePath());

buildInfo.put(Constants.SERVLET_PARAMETER_ENABLE_PNPM, pnpmEnable);

try {
FileUtils.forceMkdir(token.getParentFile());
FileUtils.write(token, JsonUtil.stringify(buildInfo, 2) + "\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
<pluginExecution>
<pluginExecutionFilter>
<goals>
<goal>copy-frontend-files</goal>
<goal>copy-production-files</goal>
<goal>package-for-production</goal>
<goal>prepare-frontend</goal>
<goal>validate</goal>
<goal>build-frontend</goal>
</goals>
Expand Down

0 comments on commit 7b10b69

Please sign in to comment.