From d90d0eb6fba4b2cf34aed1fde21b807458d1ea9d Mon Sep 17 00:00:00 2001 From: Hiromu Hota Date: Thu, 6 Feb 2020 10:54:38 -0800 Subject: [PATCH] Fix file-open-save-new-core to make it fully-functional --- .../java/org/pentaho/di/ui/spoon/WebSpoonTest.java | 10 ++++++++++ .../fileopensave/dialog/FileOpenSaveDialog.java | 6 ++++++ .../src/main/javascript/app/services/data.service.js | 6 ++++-- .../src/main/javascript/app/services/helper.service.js | 4 +++- .../OSGI-INF/blueprint/blueprint.xml | 1 + 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/integration/src/test/java/org/pentaho/di/ui/spoon/WebSpoonTest.java b/integration/src/test/java/org/pentaho/di/ui/spoon/WebSpoonTest.java index 9be65c4ff087..ed0c601a42ae 100644 --- a/integration/src/test/java/org/pentaho/di/ui/spoon/WebSpoonTest.java +++ b/integration/src/test/java/org/pentaho/di/ui/spoon/WebSpoonTest.java @@ -142,6 +142,16 @@ public void testOpenSaveMenus() { assertFalse( isMenuItemDisabled( "//div[text() = 'Save as (VFS)...']" ) ); } + @Test + public void testOpenSaveNewDialog() { + clickElement( "//div[text() = 'File']" ); + assertFalse( isMenuItemDisabled( "//div[text() = 'Open URL...']" ) ); + clickElement( "//div[text() = 'Open URL...']" ); // Open the new dialog + driver.switchTo().frame( driver.findElement( By.xpath(".//iframe[starts-with(@src, '/spoon/osgi/@pentaho/di-plugin-file-open-save-new@9.0.0.0-423/index.html')]") ) ); + wait.until( ExpectedConditions.presenceOfElementLocated( By.xpath( "//div[contains(text(),'Local')]" ) ) ); + assertEquals( 1, driver.findElements( By.xpath( "//div[contains(text(),'Local')]" ) ).size() ); + } + @Test public void testDatabaseConnectionDialog() throws Exception { // Create a new transformation diff --git a/plugins/file-open-save-new/core/src/main/java/org/pentaho/di/plugins/fileopensave/dialog/FileOpenSaveDialog.java b/plugins/file-open-save-new/core/src/main/java/org/pentaho/di/plugins/fileopensave/dialog/FileOpenSaveDialog.java index fa1e7b3d8c6b..2d85d61c7d4e 100644 --- a/plugins/file-open-save-new/core/src/main/java/org/pentaho/di/plugins/fileopensave/dialog/FileOpenSaveDialog.java +++ b/plugins/file-open-save-new/core/src/main/java/org/pentaho/di/plugins/fileopensave/dialog/FileOpenSaveDialog.java @@ -154,19 +154,25 @@ public void open( FileDialogOperation fileDialogOperation ) { new BrowserFunction( browser, "close" ) { @Override public Object function( Object[] arguments ) { + Runnable execute = () -> { closeBrowser( browser ); + }; + display.asyncExec( execute ); return true; } }; new BrowserFunction( browser, "select" ) { @Override public Object function( Object[] arguments ) { + Runnable execute = () -> { try { setProperties( arguments ); closeBrowser( browser ); } catch ( Exception e ) { log.logError( "Error in processing select() from file-open-save app: ", e ); } + }; + display.asyncExec( execute ); return true; } }; diff --git a/plugins/file-open-save-new/core/src/main/javascript/app/services/data.service.js b/plugins/file-open-save-new/core/src/main/javascript/app/services/data.service.js index d0e5e2242696..0ff486026eab 100644 --- a/plugins/file-open-save-new/core/src/main/javascript/app/services/data.service.js +++ b/plugins/file-open-save-new/core/src/main/javascript/app/services/data.service.js @@ -79,7 +79,7 @@ define( var options = { method: method, - url: _cacheBust(url), + url: CONTEXT_PATH + _cacheBust(url), headers: { Accept: "application/json" }, @@ -335,7 +335,7 @@ define( function _wrapHttp(method, url, data, timeout) { var options = { method: method, - url: _cacheBust(url), + url: CONTEXT_PATH + _cacheBust(url), headers: { Accept: "application/json" }, @@ -360,6 +360,8 @@ define( } else { url += "?v=" + value; } + var cid = getConnectionId(); + url += "&cid=" + cid; return url; } } diff --git a/plugins/file-open-save-new/core/src/main/javascript/app/services/helper.service.js b/plugins/file-open-save-new/core/src/main/javascript/app/services/helper.service.js index 128bc95ec5c8..091f063360ac 100644 --- a/plugins/file-open-save-new/core/src/main/javascript/app/services/helper.service.js +++ b/plugins/file-open-save-new/core/src/main/javascript/app/services/helper.service.js @@ -109,7 +109,7 @@ define( function _wrapHttp(method, url, data) { var options = { method: method, - url: _cacheBust(url), + url: CONTEXT_PATH + _cacheBust(url), headers: { Accept: "application/json" } @@ -133,6 +133,8 @@ define( } else { url += "?v=" + value; } + var cid = getConnectionId(); + url += "&cid=" + cid; return url; } } diff --git a/plugins/file-open-save-new/core/src/main/resources-filtered/OSGI-INF/blueprint/blueprint.xml b/plugins/file-open-save-new/core/src/main/resources-filtered/OSGI-INF/blueprint/blueprint.xml index 28f03570d918..05467c58f7b4 100644 --- a/plugins/file-open-save-new/core/src/main/resources-filtered/OSGI-INF/blueprint/blueprint.xml +++ b/plugins/file-open-save-new/core/src/main/resources-filtered/OSGI-INF/blueprint/blueprint.xml @@ -47,6 +47,7 @@ +