Skip to content

Commit

Permalink
chore!: Rename dev mode gizmo to dev tools (vaadin#13679)
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur- authored May 11, 2022
1 parent 4d9150e commit b182ea8
Show file tree
Hide file tree
Showing 38 changed files with 354 additions and 360 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ApplicationConfiguration {
private String atmosphereJSVersion;
private String[] exportedWebComponents;

private boolean devmodeGizmoEnabled;
private boolean devToolsEnabled;
private String liveReloadUrl;
private String liveReloadBackend;
private String springBootLiveReloadPort;
Expand Down Expand Up @@ -360,23 +360,23 @@ public String[] getExportedWebComponents() {
}

/**
* Gets if development mode gizmo should be added to the page.
* Gets if development tools should be added to the page.
*
* @return whether development mode gizmo should be added
* @return whether development tools should be added
*/
public boolean isDevmodeGizmoEnabled() {
return devmodeGizmoEnabled;
public boolean isDevToolsEnabled() {
return devToolsEnabled;
}

/**
*
* Sets if development mode gizmo should be added to the page.
* Sets if development tools should be added to the page.
*
* @param devmodeGizmoEnabled
* whether development mode gizmo should be added
* @param devToolsEnabled
* whether development tools should be added
*/
public void setDevmodeGizmoEnabled(boolean devmodeGizmoEnabled) {
this.devmodeGizmoEnabled = devmodeGizmoEnabled;
public void setDevToolsEnabled(boolean devToolsEnabled) {
this.devToolsEnabled = devToolsEnabled;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,23 @@ public ApplicationConnection(
Console.log(
"Vaadin application servlet version: " + servletVersion);

if (applicationConfiguration.isDevmodeGizmoEnabled()
if (applicationConfiguration.isDevToolsEnabled()
&& applicationConfiguration.getLiveReloadUrl() != null) {
Element devmodeGizmo = Browser.getDocument()
.createElement("vaadin-devmode-gizmo");
DomApi.wrap(devmodeGizmo).setAttribute("url",
Element devTools = Browser.getDocument()
.createElement("vaadin-dev-tools");
DomApi.wrap(devTools).setAttribute("url",
applicationConfiguration.getLiveReloadUrl());
if (applicationConfiguration.getLiveReloadBackend() != null) {
DomApi.wrap(devmodeGizmo).setAttribute("backend",
DomApi.wrap(devTools).setAttribute("backend",
applicationConfiguration.getLiveReloadBackend());
}
if (applicationConfiguration
.getSpringBootLiveReloadPort() != null) {
DomApi.wrap(devmodeGizmo).setAttribute(
DomApi.wrap(devTools).setAttribute(
"springbootlivereloadport", applicationConfiguration
.getSpringBootLiveReloadPort());
}
DomApi.wrap(body).appendChild(devmodeGizmo);
DomApi.wrap(body).appendChild(devTools);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ private static void populateApplicationConfiguration(
conf.setExportedWebComponents(
jsoConfiguration.getConfigStringArray("webcomponents"));

conf.setDevmodeGizmoEnabled(jsoConfiguration
.getConfigBoolean(ApplicationConstants.DEVMODE_GIZMO_ENABLED));
conf.setDevToolsEnabled(jsoConfiguration
.getConfigBoolean(ApplicationConstants.DEV_TOOLS_ENABLED));
conf.setLiveReloadUrl(
jsoConfiguration.getConfigString("liveReloadUrl"));
conf.setLiveReloadBackend(
Expand Down
42 changes: 0 additions & 42 deletions flow-client/src/test/frontend/VaadinDevmodeGizmoTests.js

This file was deleted.

42 changes: 42 additions & 0 deletions flow-client/src/test/frontend/vaadin-dev-tools-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { describe, it } = intern.getPlugin('interface.bdd');
const { assert } = intern.getPlugin("chai");

import { DevTools } from "../../main/frontend/vaadin-dev-tools";

describe('vaadin-dev-tools', () => {

it('should connect to port-hostname.gitpod.io with Spring Boot Devtools', () => {
const devTools = document.createElement('vaadin-dev-tools');
devTools.setAttribute('url', '');
devTools.setAttribute('backend', 'SPRING_BOOT_DEVTOOLS');
devTools.setAttribute('springBootLiveReloadPort', '35729');
let location = {
'protocol': 'https',
'hostname': 'abc-12345678-1234-1234-1234-1234567890ab.ws-eu01.gitpod.io'
};
assert.equal(devTools.getSpringBootWebSocketUrl(location),
'ws://35729-12345678-1234-1234-1234-1234567890ab.ws-eu01.gitpod.io');
});

it('should use base URI', () => {
const devTools = document.createElement('vaadin-dev-tools');
devTools.setAttribute('url', 'http://localhost:8080/context/vaadinServlet');
devTools.setAttribute('backend', 'HOTSWAP_AGENT');

assert.equal(devTools.getDedicatedWebSocketUrl(),
'ws://localhost:8080/context/vaadinServlet?v-r=push&debug_window');
});

it('should have a new message on tray when error occurs', () => {
const devTools = document.createElement('vaadin-dev-tools');
devTools.setAttribute('url', '');
devTools.setAttribute('backend', 'HOTSWAP_AGENT');
devTools.openWebSocketConnection();
devTools.javaConnection.handleError('TEST');
assert.equal(devTools.javaStatus, 'error');
assert.equal(devTools.messages.length, 1);
assert.equal(devTools.messages[0].type, 'error');
assert.equal(devTools.messages[0].message, 'TEST');

});
});
2 changes: 1 addition & 1 deletion flow-client/webpack.tests.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
mode: "development",
entry: {
flow: "./src/test/frontend/FlowTests.ts",
gizmo: "./src/test/frontend/VaadinDevmodeGizmoTests.js",
devtools: "./src/test/frontend/vaadin-dev-tools-tests.js",
},
output: {
filename: "[name].spec.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,23 +299,20 @@ default boolean isEagerServerLoad() {
/**
* Checks if dev mode live reload is enabled or not.
* <p>
* Note that if the dev mode gizmo is disabled
* ({@link #isDevModeGizmoEnabled()} returns {@code false}), the live reload
* will be disabled as well.
* Note that if the dev tools are disabled ({@link #isDevToolsEnabled()}
* returns {@code false}), the live reload will be disabled as well.
*
* @return {@code true} if dev mode live reload is enabled, {@code false}
* otherwise
*/
boolean isDevModeLiveReloadEnabled();

/**
* Checks if dev mode gizmo (debug window) is enabled or not. It is always
* disabled in production mode. In development mode, it is enabled by
* default.
* Checks if dev tools are enabled or not. They is always disabled in
* production mode. In development mode, it is enabled by default.
*
* @return {@code true} if dev mode gizmo is enabled, {@code false}
* otherwise
* @return {@code true} if dev tools are enabled, {@code false} otherwise
*/
boolean isDevModeGizmoEnabled();
boolean isDevToolsEnabled();

}
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ private static void warnAboutPreserveOnRefreshAndLiveReloadCombo(UI ui) {
if (!configuration.isProductionMode()
&& configuration.isDevModeLiveReloadEnabled()) {
ui.getPage().executeJs(
"Vaadin.devModeGizmo.showNotification('warning', '@PreserveOnRefresh enabled', 'When refreshing the page in the browser, the server-side Java view instance is reused rather than being recreated.', null, 'preserveOnRefreshWarning')");
"Vaadin.devTools.showNotification('warning', '@PreserveOnRefresh enabled', 'When refreshing the page in the browser, the server-side Java view instance is reused rather than being recreated.', null, 'preserveOnRefreshWarning')");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1386,14 +1386,15 @@ public JsonObject getApplicationParameters(BootstrapContext context) {
versionInfo.put("atmosphereVersion", atmosphereVersion);
}
appConfig.put("versionInfo", versionInfo);
appConfig.put(ApplicationConstants.DEVMODE_GIZMO_ENABLED,
deploymentConfiguration.isDevModeGizmoEnabled());
appConfig.put(ApplicationConstants.DEV_TOOLS_ENABLED,
deploymentConfiguration.isDevToolsEnabled());

VaadinService service = session.getService();
Optional<BrowserLiveReload> liveReload = BrowserLiveReloadAccessor
.getLiveReloadFromService(service);

// With V15+ bootstrap, gizmo is added to generated index.html
// With V15+ bootstrap, dev tools is added to generated
// index.html
if (liveReload.isPresent()
&& deploymentConfiguration.useV14Bootstrap()) {
appConfig.put("liveReloadUrl", BootstrapHandlerHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,20 @@ public class InitParameters implements Serializable {
/**
* Configuration parameter name for enabling live reload.
* <p>
* Note that if the dev mode gizmo is disabled
* ({@link #SERVLET_PARAMETER_DEVMODE_ENABLE_GIZMO} is set to {@code
* Note that if the dev tools are disabled
* ({@link #SERVLET_PARAMETER_DEVMODE_ENABLE_DEV_TOOLS} is set to {@code
* false}), the live reload will be disabled as well.
*
* @since
*/
public static final String SERVLET_PARAMETER_DEVMODE_ENABLE_LIVE_RELOAD = "devmode.liveReload.enabled";

/**
* Configuration parameter name for enabling dev mode gizmo (debug window).
* Configuration parameter name for enabling dev tools.
*
* @since 9.0
*/
public static final String SERVLET_PARAMETER_DEVMODE_ENABLE_GIZMO = "devmode.gizmo.enabled";
public static final String SERVLET_PARAMETER_DEVMODE_ENABLE_DEV_TOOLS = "devmode.devTools.enabled";

/**
* Configuration parameter name for enabling session serialization in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import static com.vaadin.flow.server.InitParameters.BUILD_FOLDER;
import static com.vaadin.flow.server.InitParameters.SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS;
import static com.vaadin.flow.server.InitParameters.SERVLET_PARAMETER_DEVMODE_ENABLE_GIZMO;
import static com.vaadin.flow.server.InitParameters.SERVLET_PARAMETER_DEVMODE_ENABLE_DEV_TOOLS;
import static com.vaadin.flow.server.InitParameters.SERVLET_PARAMETER_DEVMODE_ENABLE_LIVE_RELOAD;
import static com.vaadin.flow.server.InitParameters.SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION;
import static com.vaadin.flow.server.InitParameters.SERVLET_PARAMETER_PRODUCTION_MODE;
Expand Down Expand Up @@ -273,16 +273,16 @@ public Properties getInitParameters() {

@Override
public boolean isDevModeLiveReloadEnabled() {
return isDevModeGizmoEnabled() && getBooleanProperty(
return isDevToolsEnabled() && getBooleanProperty(
SERVLET_PARAMETER_DEVMODE_ENABLE_LIVE_RELOAD, true);
}

@Override
public boolean isDevModeGizmoEnabled() {
public boolean isDevToolsEnabled() {
return !isProductionMode()
&& getBooleanProperty(SERVLET_PARAMETER_DEVMODE_ENABLE_GIZMO,
true)
&& enableDevServer(); // gizmo excluded from prod bundle
&& getBooleanProperty(
SERVLET_PARAMETER_DEVMODE_ENABLE_DEV_TOOLS, true)
&& enableDevServer(); // dev tools excluded from prod bundle
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public boolean synchronizedHandleRequest(VaadinSession session,
// modify the page based on registered IndexHtmlRequestListener:s
service.modifyIndexHtmlResponse(indexHtmlResponse);

if (config.isDevModeGizmoEnabled()) {
addDevmodeGizmo(indexDocument, config, session, request);
if (config.isDevToolsEnabled()) {
addDevTools(indexDocument, config, session, request);
catchErrorsInDevMode(indexDocument);

if (getFeatureFlags(service)
Expand Down Expand Up @@ -180,7 +180,7 @@ private void addLicenseChecker(Document indexDocument) {
"window.Vaadin = window.Vaadin || {};" + //
"window.Vaadin.VaadinLicenseChecker = {" + //
" maybeCheck: (productInfo) => {" + //
" window.Vaadin.devModeGizmo.checkLicense(productInfo);" + //
" window.Vaadin.devTools.checkLicense(productInfo);" + //
" }" + //
"};");
}
Expand All @@ -203,27 +203,27 @@ private void storeAppShellTitleToUI(Document indexDocument) {
}
}

private void addDevmodeGizmo(Document indexDocument,
private void addDevTools(Document indexDocument,
DeploymentConfiguration config, VaadinSession session,
VaadinRequest request) {
VaadinService service = session.getService();
Optional<BrowserLiveReload> liveReload = BrowserLiveReloadAccessor
.getLiveReloadFromService(service);

if (liveReload.isPresent()) {
Element devmodeGizmo = new Element("vaadin-devmode-gizmo");
Element devTools = new Element("vaadin-dev-tools");
if (!config.isDevModeLiveReloadEnabled()) {
devmodeGizmo.attr("liveReloadDisabled", "");
devTools.attr("liveReloadDisabled", "");
}
devmodeGizmo.attr("url",
devTools.attr("url",
BootstrapHandlerHelper.getPushURL(session, request));
BrowserLiveReload.Backend backend = liveReload.get().getBackend();
if (backend != null) {
devmodeGizmo.attr("backend", backend.toString());
devTools.attr("backend", backend.toString());
}
devmodeGizmo.attr("springbootlivereloadport", Integer
devTools.attr("springbootlivereloadport", Integer
.toString(Constants.SPRING_BOOT_DEFAULT_LIVE_RELOAD_PORT));
indexDocument.body().appendChild(devmodeGizmo);
indexDocument.body().appendChild(devTools);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ protected BootstrapContext createAndInitUI(Class<? extends UI> uiClass,
.collect(JsonUtils.asArray());
config.put("webcomponents", tags);

config.put(ApplicationConstants.DEVMODE_GIZMO_ENABLED, false);
config.put(ApplicationConstants.DEV_TOOLS_ENABLED, false);

return context;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void run() {
lines.addAll(getCssLines());
if (!productionMode && useLegacyV14Bootstrap) {
// This is only needed for v14bootstrap mode
lines.add(TaskGenerateBootstrap.DEVMODE_GIZMO_IMPORT);
lines.add(TaskGenerateBootstrap.DEV_TOOLS_IMPORT);
}
collectModules(lines);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
*/
public class TaskGenerateBootstrap extends AbstractTaskClientGenerator {

static final String DEVMODE_GIZMO_IMPORT = String
.format("import '@vaadin/flow-frontend/VaadinDevmodeGizmo.js';%n");
static final String DEV_TOOLS_IMPORT = String
.format("import '@vaadin/flow-frontend/vaadin-dev-tools.js';%n");
private final FrontendDependenciesScanner frontDeps;
private final File frontendGeneratedDirectory;
private final File frontendDirectory;
Expand All @@ -61,7 +61,7 @@ protected String getFileContent() {
lines.add(String.format("import './%s';%n", FEATURE_FLAGS_FILE_NAME));
lines.add(String.format("import '%s';%n", getIndexTsEntryPath()));
if (!productionMode) {
lines.add(DEVMODE_GIZMO_IMPORT);
lines.add(DEV_TOOLS_IMPORT);
}
lines.addAll(getThemeLines());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,8 @@ public class ApplicationConstants implements Serializable {
public static final String DEBUG_WINDOW_CONNECTION = "debug_window";

/**
* Boolean client configuration parameter enabling the development mode
* gizmo.
* Boolean client configuration parameter enabling the development tools.
*/
public static final String DEVMODE_GIZMO_ENABLED = "devmodeGizmoEnabled";
public static final String DEV_TOOLS_ENABLED = "devToolsEnabled";

}
Loading

0 comments on commit b182ea8

Please sign in to comment.