Skip to content

Commit

Permalink
Merge pull request #886 from sjd78/1.4_ie11
Browse files Browse the repository at this point in the history
(backport to 1.4) Add additional IE11 support to load the App, Edge support to download console.vv files
  • Loading branch information
sjd78 authored Jan 8, 2019
2 parents 6d95b5d + aaf88d1 commit d637ebe
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 81 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 4 additions & 11 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ EXTRA_DIST = \
scripts \
packaging \
package.json \
index.html \
index.jsp \
index.jsp.template \
static \
yarn.lock \
.flowconfig


DISTCLEANFILES = $(PACKAGE)-$(VERSION).tar.gz \
aclocal.m4 \
Expand All @@ -53,7 +50,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")

Expand Down Expand Up @@ -89,9 +86,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 id="replace_with_index_jsp_template"><\/div>/{gsub("<div id=\"replace_with_index_jsp_template\"></div>",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:
Expand All @@ -101,11 +95,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 -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:
check-local:
$(YARN) test

# vim: ts=2
2 changes: 1 addition & 1 deletion config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
15 changes: 2 additions & 13 deletions config/polyfills.js
Original file line number Diff line number Diff line change
@@ -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')
33 changes: 18 additions & 15 deletions config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,39 +196,42 @@ 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 <script> injected.
new HtmlWebpackPlugin({
filename: 'index.html',
inject: true,
template: paths.appHtml,
template: `!!handlebars!${paths.appHtml}`,
jspSSO: false,
}),

// Makes some environment variables available to the JS code, for example:
// if (process.env.NODE_ENV === 'development') { ... }. See `env.js`.
new webpack.DefinePlugin(env),

// This is necessary to emit hot updates (currently CSS only):
new webpack.HotModuleReplacementPlugin(),

// Watcher doesn't work well if you mistype casing in a path so we use
// a plugin that prints an error when you attempt to do this.
// See https://github.com/facebookincubator/create-react-app/issues/240
new CaseSensitivePathsPlugin(),

// If you require a missing module and then `npm install` it, you still have
// to restart the development server for Webpack to discover it. This plugin
// 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.
Expand Down
12 changes: 10 additions & 2 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,16 @@ module.exports = {
to: 'branding',
toType: 'dir'
}]),

// Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin({
filename: 'index.jsp',
inject: true,
template: paths.appHtml,
template: `!!handlebars!${paths.appHtml}`,
jspSSO: true,
minify: {
removeComments: true,
collapseWhitespace: true,
collapseWhitespace: false,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
Expand All @@ -220,15 +223,19 @@ module.exports = {
minifyURLs: true,
},
}),

// Makes some environment variables available to the JS code, for example:
// if (process.env.NODE_ENV === 'production') { ... }. See `env.js`.
// It is absolutely essential that NODE_ENV was set to production here.
// Otherwise React will be compiled in the very slow development mode.
new webpack.DefinePlugin(env),

// This helps ensure the builds are consistent if source hasn't changed:
new webpack.optimize.OccurrenceOrderPlugin(),

// Try to dedupe duplicated modules, if any:
new webpack.optimize.DedupePlugin(),

// Minify the code.
new webpack.optimize.UglifyJsPlugin({
compress: {
Expand All @@ -243,6 +250,7 @@ module.exports = {
screw_ie8: true,
},
}),

// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
new ExtractTextPlugin('static/css/[name].[contenthash:8].css'),
],
Expand Down
13 changes: 0 additions & 13 deletions index.html

This file was deleted.

3 changes: 0 additions & 3 deletions index.jsp

This file was deleted.

1 change: 0 additions & 1 deletion index.jsp.template

This file was deleted.

11 changes: 4 additions & 7 deletions ovirt-web-ui.spec.in
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -65,7 +62,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 <[email protected]> - 1.4.3-1
* Tue Sep 5 2018 Greg Sheremeta <[email protected]> - 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)

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -51,7 +52,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",
Expand All @@ -65,6 +65,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",
Expand All @@ -74,7 +75,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",
Expand Down
5 changes: 5 additions & 0 deletions scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
6 changes: 3 additions & 3 deletions src/helpers.js
Original file line number Diff line number Diff line change
@@ -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"}}}}}
Expand Down Expand Up @@ -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)
Expand Down
34 changes: 34 additions & 0 deletions static/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{#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}}

<!-- App container page -->
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<title>VM Portal</title>

{{#if htmlWebpackPlugin.options.jspSSO}}
<!-- In prod mode, JSP code will inject SSO tokens on the server side. -->
<script type="text/javascript">
<c:if test="${sessionScope['userInfo'] != null}">
var userInfo = {
<c:forEach items="${sessionScope['userInfo']}" var="entry" varStatus="loop">
"${entry.key}": "${entry.value}"${loop.last ? '' : ','}
</c:forEach>
};
</c:if>
</script>
{{else}}
<!-- In dev mode, webpack will inject SSO tokens to the js bundle. -->
{{/if}}
</head>
<body>
<div id="root"></div>
</body>
</html>
Loading

0 comments on commit d637ebe

Please sign in to comment.