From 7ed8a6eca860e521d06f144439ee782b342e7953 Mon Sep 17 00:00:00 2001 From: Bohdan Iakymets Date: Thu, 15 Nov 2018 16:01:06 +0100 Subject: [PATCH 1/9] (backport to 1.4) Add polyfills to support IE11 Added `babel-polyfill` and removed `promise` and `object-assign` packages. See: PR #869, Issue #869, [BZ1644970](https://bugzilla.redhat.com/1644970) --- config/polyfills.js | 15 ++------------- package.json | 3 +-- yarn.lock | 11 +++-------- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/config/polyfills.js b/config/polyfills.js index f24c797f3..2ba6446e5 100644 --- a/config/polyfills.js +++ b/config/polyfills.js @@ -1,19 +1,8 @@ // NOTE: These polyfills are most likely unnecessary for our supported browsers. If verified, // they may be removed and save the space in the bundle. -// TODO: Verify if these polyfills are still necessary. - -if (typeof Promise === 'undefined') { - // Rejection tracking prevents a common issue where React gets into an - // inconsistent state due to an error, but it gets swallowed by a Promise, - // and the user has no idea what causes React's erratic future behavior. - require('promise/lib/rejection-tracking').enable() - window.Promise = require('promise/lib/es6-extensions.js') -} - // fetch() polyfill for making API calls. require('whatwg-fetch') -// Object.assign() is commonly used with React. -// It will use the native implementation if it's present and isn't buggy. -Object.assign = require('object-assign') +// Babel-polyfills for using Array.prototype.includes, Object.assign and Promise +require('babel-polyfill') diff --git a/package.json b/package.json index 63983915a..24e4d425b 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,6 @@ "opn": "4.0.2", "path-exists": "3.0.0", "postcss-loader": "0.13.0", - "promise": "7.1.1", "readline-sync": "1.4.9", "recursive-readdir": "2.2.2", "request": "2.87.0", @@ -65,6 +64,7 @@ "whatwg-fetch": "1.0.0" }, "dependencies": { + "babel-polyfill": "6.26.0", "blob-util": "1.2.1", "bootstrap": "3.3.7", "bootstrap-select": "1.13.1", @@ -74,7 +74,6 @@ "immutable": "3.8.2", "intl-messageformat": "2.2.0", "jquery": "=3.2.1", - "object-assign": "4.1.1", "patternfly": "3.48.1", "patternfly-bootstrap-combobox": "1.1.7", "patternfly-react": "2.4.1", diff --git a/yarn.lock b/yarn.lock index 5d016f8d3..e34030246 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1083,9 +1083,10 @@ babel-plugin-transform-strict-mode@^6.24.1: babel-runtime "^6.22.0" babel-types "^6.24.1" -babel-polyfill@^6.26.0: +babel-polyfill@6.26.0, babel-polyfill@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" + integrity sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM= dependencies: babel-runtime "^6.26.0" core-js "^2.5.0" @@ -4923,7 +4924,7 @@ oauth-sign@~0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" -object-assign@4.1.1, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: +object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" @@ -5655,12 +5656,6 @@ progress@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" -promise@7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/promise/-/promise-7.1.1.tgz#489654c692616b8aa55b0724fa809bb7db49c5bf" - dependencies: - asap "~2.0.3" - promise@^7.1.1: version "7.3.1" resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf" From 6f936dfa289026492fe9c68b0d68bf28849f7319 Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Thu, 6 Dec 2018 09:46:41 -0500 Subject: [PATCH 2/9] refactor static index page processing The project has two distinct run modes, `yarn start` and `yarn build`. And they have different requirements for the static page that loads the app. Start mode uses webpack to inject the user SSO tokens at build time. Build mode uses a war based JSP to inject the SSO tokens on the server. The static index file creation has been simplified to a single handlebars template file with code to handle both run modes embedded. When webpack `HtmlWebpackPlugin` builds the static index file, the options are set as appropriate to generate the `.html` for `yarn start` or the `.jsp` for `yarn build`. --- Makefile.am | 11 +++-------- config/paths.js | 2 +- config/webpack.config.dev.js | 32 ++++++++++++++++++++++---------- config/webpack.config.prod.js | 12 ++++++++++-- index.html | 13 ------------- index.jsp | 3 --- index.jsp.template | 1 - package.json | 1 + scripts/start.js | 5 +++++ static/index.hbs | 33 +++++++++++++++++++++++++++++++++ yarn.lock | 21 ++++++++++++++++++++- 11 files changed, 95 insertions(+), 39 deletions(-) delete mode 100644 index.html delete mode 100644 index.jsp delete mode 100644 index.jsp.template create mode 100644 static/index.hbs diff --git a/Makefile.am b/Makefile.am index 083571eab..e529704f2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,7 +37,6 @@ EXTRA_DIST = \ index.jsp.template \ yarn.lock \ .flowconfig - DISTCLEANFILES = $(PACKAGE)-$(VERSION).tar.gz \ aclocal.m4 \ @@ -53,7 +52,7 @@ DISTCLEANDIRS = autom4te.cache \ dockerbuild TMPREPOS = tmp.repos -RPMBUILD_ARGS := +RPMBUILD_ARGS := RPMBUILD_ARGS += --define="_topdir `pwd`/$(TMPREPOS)" RPMBUILD_ARGS += $(if $(RELEASE_SUFFIX), --define="release_suffix $$RELEASE_SUFFIX") @@ -89,9 +88,6 @@ all: ovirt-web-ui ovirt-web-ui: $(YARN) run build cp -rpv packaging/* build/ - cp index.jsp build/ - awk 'BEGIN{getline l < "index.jsp.template"}/
<\/div>/{gsub("
",l)}1' build/index.html >> build/index.jsp - rm build/index.html mv build/static build/index.jsp build/ovirt-web-ui.config build/ovirt-web-ui.war/ install-data-local: @@ -101,11 +97,10 @@ install-data-local: cp -rpv build/ovirt-web-ui.war $(DESTDIR)$(USER_PORTAL_DIR) cp -rpvT build/branding $(DESTDIR)$(USER_PORTAL_DIR)/branding/ovirt cp -rpv build/etc/* $(DESTDIR)$(sysconfdir) - echo "ln -s" $(DESTDIR)$(USER_PORTAL_DIR)/ovirt-web-ui.war $(DESTDIR)$(OVIRT_ENGINE_DIR)/ovirt-web-ui.war - ln -sf ../ovirt-web-ui/ovirt-web-ui.war $(DESTDIR)$(OVIRT_ENGINE_DIR)/ovirt-web-ui.war + ln -sf $(DESTDIR)$(USER_PORTAL_DIR)/ovirt-web-ui.war $(DESTDIR)$(OVIRT_ENGINE_DIR)/ovirt-web-ui.war ln -sfr $(DESTDIR)$(USER_PORTAL_DIR)/branding/ovirt $(DESTDIR)$(sysconfdir)/ovirt-web-ui/branding/00-ovirt.brand -check-local: +check-local: $(YARN) test # vim: ts=2 diff --git a/config/paths.js b/config/paths.js index 0c60465ef..547bf9624 100644 --- a/config/paths.js +++ b/config/paths.js @@ -27,7 +27,7 @@ var nodePaths = (process.env.NODE_PATH || '') // config after eject: we're in ./config/ module.exports = { appBuild: resolveApp('build'), - appHtml: resolveApp('index.html'), + appHtml: resolveApp('static/index.hbs'), appIndexJs: resolveApp('src/index.js'), appPackageJson: resolveApp('package.json'), appSrc: resolveApp('src'), diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index 5ac6b9622..93b66a33d 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -196,27 +196,37 @@ module.exports = { ] }, plugins: [ - new CopyWebpackPlugin([{ - from: 'src/ovirt-web-ui.config', - }, { - from: 'branding', - to: 'branding', - toType: 'dir' - }]), + new CopyWebpackPlugin([ + { + from: 'src/ovirt-web-ui.config', + }, + { + from: 'branding', + to: 'branding', + toType: 'dir' + } + ]), + // Generates an `index.html` file with the diff --git a/package.json b/package.json index 24e4d425b..3f6147adf 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "flow-babel-webpack-plugin": "1.1.1", "fs-extra": "0.30.0", "gzip-size": "3.0.0", + "handlebars-loader": "^1.7.0", "html-loader": "0.4.3", "html-webpack-plugin": "2.22.0", "http-proxy-middleware": "0.17.1", diff --git a/scripts/start.js b/scripts/start.js index 5e90788dd..0ee041929 100644 --- a/scripts/start.js +++ b/scripts/start.js @@ -373,6 +373,11 @@ function getUserInfo (protocol, port) { }); } +/* + * Setup `env` with SSO userInfo so the `webpack.DefinePlugin` can push it to the + * webpack bundle to be read by the login code. In build/prod mode, the `index.jsp` + * will push the SSO info to the window on the server side. + */ function injectUserInfo (userInfo) { env['window.userInfo'] = JSON.stringify(userInfo); } diff --git a/static/index.hbs b/static/index.hbs new file mode 100644 index 000000000..9b016e483 --- /dev/null +++ b/static/index.hbs @@ -0,0 +1,33 @@ +{{#if htmlWebpackPlugin.options.jspSSO}} +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +{{/if}} + + + + + + + + VM Portal + + + {{#if htmlWebpackPlugin.options.jspSSO}} + + + {{else}} + + {{/if}} + + +
+ + diff --git a/yarn.lock b/yarn.lock index e34030246..996327d1c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -520,7 +520,7 @@ async@^2.1.4: dependencies: lodash "^4.17.10" -async@~0.2.6: +async@~0.2.10, async@~0.2.6: version "0.2.10" resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" @@ -3184,6 +3184,16 @@ gzip-size@3.0.0: dependencies: duplexer "^0.1.1" +handlebars-loader@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/handlebars-loader/-/handlebars-loader-1.7.0.tgz#4f750bc62c350fb922e52d8564d667887e909723" + integrity sha512-tfS3n+PrDB2gnDnrx0/DGvdb4wF4JqV7CEiVof3RymOIWYrcmD+ZiaXTlZ/f7fZ7+aQPEv6JRG0HS7nTlyvGlQ== + dependencies: + async "~0.2.10" + fastparse "^1.0.0" + loader-utils "1.0.x" + object-assign "^4.1.0" + handlebars@^4.0.3: version "4.0.11" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" @@ -4411,6 +4421,15 @@ loader-utils@0.2.x, loader-utils@^0.2.11, loader-utils@^0.2.15, loader-utils@^0. json5 "^0.5.0" object-assign "^4.0.1" +loader-utils@1.0.x: + version "1.0.4" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.0.4.tgz#13f56197f1523a305891248b4c7244540848426c" + integrity sha1-E/Vhl/FSOjBYkSSLTHJEVAhIQmw= + dependencies: + big.js "^3.1.3" + emojis-list "^2.0.0" + json5 "^0.5.0" + loader-utils@^1.0.2: version "1.1.0" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.1.0.tgz#c98aef488bcceda2ffb5e2de646d6a754429f5cd" From 63ea7edabc56896c7f409b7b09be296f129fcb7e Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Thu, 6 Dec 2018 16:19:01 -0500 Subject: [PATCH 3/9] add meta tag to keep IE11 off compatibility mode web-ui works ok on IE11 both in dev and prod mode, but if intranet settings get turned on and IE go to "compatibility mode", it doesn't work. Adding the meta tag to the static app loader page keeps IE out of that mode. If a company has "Enterprise Mode" turned on, web-ui will need to be white listed. No meta tags in HTML headers can coerce IE11 into working differently in that scenario. --- static/index.hbs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/static/index.hbs b/static/index.hbs index 9b016e483..28f6635e5 100644 --- a/static/index.hbs +++ b/static/index.hbs @@ -7,10 +7,11 @@ + - VM Portal + VM Portal {{#if htmlWebpackPlugin.options.jspSSO}} From 6e4e0e221e74f169ddcb998e1af7a406377b70a7 Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Thu, 6 Dec 2018 17:33:51 -0500 Subject: [PATCH 4/9] Fix fileDownload helper function for IE11 --- src/helpers.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/helpers.js b/src/helpers.js index 1b7e6593d..89e7c3897 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -1,4 +1,3 @@ -import { Blob } from 'blob-util' import { locale as appLocale } from './intl' // "payload":{"message":"Not Found","shortMessage":"LOGIN failed","type":404,"action":{"type":"LOGIN","payload":{"credentials":{"username":"admin@internal","password":"admi"}}}}} @@ -46,8 +45,9 @@ export function fileDownload ({ data, fileName = 'myFile.dat', mimeType = 'appli if (data) { const a = document.createElement('a') - if (navigator.msSaveBlob) { // IE10 - return navigator.msSaveBlob(new Blob([data], { mimeType }), fileName) + if (navigator.msSaveBlob) { // IE10 & IE11 + const saveBlob = new Blob([data], { type: mimeType }) + return navigator.msSaveBlob(saveBlob, fileName) } else if ('download' in a) { // html5 A[download] a.href = `data:${mimeType},${encodeURIComponent(data)}` a.setAttribute('download', fileName) From 5f4e81248069c748b6e9877b5bf16fb723d6745f Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Mon, 10 Dec 2018 11:03:13 -0500 Subject: [PATCH 5/9] Remove commented out webpack dev plugin --- config/webpack.config.dev.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index 93b66a33d..fe5f2bfc1 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -232,15 +232,6 @@ module.exports = { // makes the discovery automatic so you don't have to restart. // See https://github.com/facebookincubator/create-react-app/issues/186 new WatchMissingNodeModulesPlugin(paths.appNodeModules), - - //global jquery is provided to any webpack modules - /* - new webpack.ProvidePlugin({ - $: "jquery", - jQuery: "jquery", - "window.jQuery": "jquery" - }) - */ ], // Some libraries import Node modules but don't use them in the browser. // Tell Webpack to provide empty mocks for them so importing them works. From 1d28a8d7060a50ad312e6e3883733f38a7049a57 Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Tue, 11 Dec 2018 11:00:27 -0500 Subject: [PATCH 6/9] set semver on handlebars-loader devDep to "1.7.0" --- package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3f6147adf..2f61f5dc6 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "flow-babel-webpack-plugin": "1.1.1", "fs-extra": "0.30.0", "gzip-size": "3.0.0", - "handlebars-loader": "^1.7.0", + "handlebars-loader": "1.7.0", "html-loader": "0.4.3", "html-webpack-plugin": "2.22.0", "http-proxy-middleware": "0.17.1", diff --git a/yarn.lock b/yarn.lock index 996327d1c..ca2148f67 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3184,7 +3184,7 @@ gzip-size@3.0.0: dependencies: duplexer "^0.1.1" -handlebars-loader@^1.7.0: +handlebars-loader@1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/handlebars-loader/-/handlebars-loader-1.7.0.tgz#4f750bc62c350fb922e52d8564d667887e909723" integrity sha512-tfS3n+PrDB2gnDnrx0/DGvdb4wF4JqV7CEiVof3RymOIWYrcmD+ZiaXTlZ/f7fZ7+aQPEv6JRG0HS7nTlyvGlQ== From 5f679a8c249f617474216ac0536652728570b666 Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Tue, 18 Dec 2018 10:29:51 -0500 Subject: [PATCH 7/9] add mock_runner files to .gitignore --- .gitignore | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 01336dbf8..a64e66367 100644 --- a/.gitignore +++ b/.gitignore @@ -27,8 +27,14 @@ missing ovirt-web-ui.spec tmp.repos/ /ovirt-web-ui-*.tar.gz + # intl related /extra /.zanata-cache/ - +# mock_runner +.bash_history +.node-gyp/ +exported-artifacts/ +rpmbuild/ +mocker-*.cfg From d3bf78fa48dba3ff48f6b5b2ffcc7644fd68b10f Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Tue, 18 Dec 2018 10:30:45 -0500 Subject: [PATCH 8/9] update Makefile.am to package 'static/' in the source tarball --- Makefile.am | 4 +--- ovirt-web-ui.spec.in | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index e529704f2..d574b508e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,9 +32,7 @@ EXTRA_DIST = \ scripts \ packaging \ package.json \ - index.html \ - index.jsp \ - index.jsp.template \ + static \ yarn.lock \ .flowconfig diff --git a/ovirt-web-ui.spec.in b/ovirt-web-ui.spec.in index 6974ac235..58a8b5c69 100644 --- a/ovirt-web-ui.spec.in +++ b/ovirt-web-ui.spec.in @@ -65,7 +65,7 @@ make install DESTDIR=%{buildroot} - Fix use of VmNics in VmDetail such that Nic operations work again [BZ1631149](https://bugzilla.redhat.com/show_bug.cgi?id=1631149) - implement ErrorBoundary to prevent white screen crash [#729](https://github.com/oVirt/ovirt-web-ui/issues/729) -* Wed Sep 5 2018 Greg Sheremeta - 1.4.3-1 +* Tue Sep 5 2018 Greg Sheremeta - 1.4.3-1 Fixed issues: - ux-redesign: make old Normal View the default when clicking a VM [#751](https://github.com/oVirt/ovirt-web-ui/issues/751) From aaf88d1c8284edc5913cddf02e9b6afe24c05011 Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Wed, 19 Dec 2018 21:44:07 -0500 Subject: [PATCH 9/9] Fixed rpm build, update the spec.in file with current info --- Makefile.am | 2 +- ovirt-web-ui.spec.in | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index d574b508e..3dd04bc5b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -95,7 +95,7 @@ install-data-local: cp -rpv build/ovirt-web-ui.war $(DESTDIR)$(USER_PORTAL_DIR) cp -rpvT build/branding $(DESTDIR)$(USER_PORTAL_DIR)/branding/ovirt cp -rpv build/etc/* $(DESTDIR)$(sysconfdir) - ln -sf $(DESTDIR)$(USER_PORTAL_DIR)/ovirt-web-ui.war $(DESTDIR)$(OVIRT_ENGINE_DIR)/ovirt-web-ui.war + ln -sfr $(DESTDIR)$(USER_PORTAL_DIR)/ovirt-web-ui.war $(DESTDIR)$(OVIRT_ENGINE_DIR)/ovirt-web-ui.war ln -sfr $(DESTDIR)$(USER_PORTAL_DIR)/branding/ovirt $(DESTDIR)$(sysconfdir)/ovirt-web-ui/branding/00-ovirt.brand check-local: diff --git a/ovirt-web-ui.spec.in b/ovirt-web-ui.spec.in index 58a8b5c69..7e443164b 100644 --- a/ovirt-web-ui.spec.in +++ b/ovirt-web-ui.spec.in @@ -1,7 +1,4 @@ # Used for rpm-packaging of pre-bundled application with already resolved JS dependencies -%global _ovirtwebuidir %{_datarootdir}/ovirt-web-ui -%global _ovirt_engine_conf %{_datarootdir}/ovirt-engine/services/ovirt-engine/ovirt-engine.conf -%global _ovirt_engine_ear_application_xml %{_datarootdir}/ovirt-engine/engine.ear/META-INF/application.xml %global product oVirt %global use_rhev %( test -z @RHEV@ && echo 1 || echo 0) @@ -23,10 +20,10 @@ BuildArch: noarch BuildRequires: ovirt-engine-nodejs >= 8.0.0 BuildRequires: ovirt-engine-yarn >= 1.7.0 -BuildRequires: ovirt-engine-nodejs-modules >= 1.5.7 +BuildRequires: ovirt-engine-nodejs-modules >= 1.8.2 %description -This package provides new VM Portal for %{product}, so far as technical preview. +This package provides the VM Portal for %{product}. %prep # Use the ovirt-engine nodejs installation @@ -51,7 +48,7 @@ make install DESTDIR=%{buildroot} %files %doc README.md %license LICENSE -%{_ovirtwebuidir} +%{_datarootdir}/ovirt-web-ui %{_datarootdir}/ovirt-engine/ovirt-web-ui.war %{_sysconfdir}/ovirt-engine/engine.conf.d/50-ovirt-web-ui.conf %{_sysconfdir}/ovirt-web-ui/branding/00-ovirt.brand