Skip to content

Commit 2a9239f

Browse files
authored
Show an error message if the API is not found (#133)
- Check if window.dh exists when starting up, show an error message if it does not
1 parent 79e8a2b commit 2a9239f

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

packages/code-studio/public/index.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@
3737
src="%REACT_APP_CORE_API_URL%/%REACT_APP_CORE_API_NAME%"
3838
type="text/javascript"
3939
></script>
40+
<script>
41+
(function () {
42+
document.addEventListener('DOMContentLoaded', function() {
43+
// If for some reason the API doesn't load, our app will not work. Write out a message to help the user.
44+
if (!window.dh) {
45+
document.getElementById('root').insertAdjacentHTML(
46+
'afterbegin',
47+
`<div class="modal d-block">
48+
<div class="modal-dialog modal-dialog-centered theme-bg-light">
49+
<div class="modal-content">
50+
<div class="modal-body">
51+
<h5 class="modal-title">Error: Unable to load API</h5>
52+
<p class="text-break">Ensure the server is running and you are able to reach %REACT_APP_CORE_API_URL%/%REACT_APP_CORE_API_NAME%, then refresh the page.</p>
53+
</div>
54+
</div>
55+
</div>
56+
</div>`
57+
);
58+
}
59+
});
60+
})();
61+
</script>
4062
<title>Deephaven</title>
4163
</head>
4264
<body>

packages/components/scss/new_variables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ $spacer-3: map-get($spacers, 3);
66
$spacer-4: map-get($spacers, 4);
77
$spacer-5: map-get($spacers, 5);
88

9-
/* Marching Ants for golden layout dropzone and drag and drop */
9+
//Marching Ants for golden layout dropzone and drag and drop
1010
//top bottom, left right.
1111
//create 4 background images that are 50% color 1, 50% color 2 using graidents, two veritical, two horizontal
1212
//size them to ant-size and thickness

packages/iris-grid/src/AdvancedFilterCreatorSelectValueList.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React, { PureComponent } from 'react';
33
import PropTypes from 'prop-types';
44
import { CSSTransition } from 'react-transition-group';
5-
import dh from '@deephaven/jsapi-shim';
5+
import dh, { PropTypes as APIPropTypes } from '@deephaven/jsapi-shim';
66
import { LoadingSpinner, SelectValueList } from '@deephaven/components';
77
import Log from '@deephaven/log';
88
import Formatter from './Formatter';
@@ -271,8 +271,7 @@ AdvancedFilterCreatorSelectValueList.propTypes = {
271271
invertSelection: PropTypes.bool,
272272
selectedValues: PropTypes.arrayOf(PropTypes.any),
273273
onChange: PropTypes.func,
274-
filters: PropTypes.arrayOf(PropTypes.instanceOf(dh.FilterCondition))
275-
.isRequired,
274+
filters: PropTypes.arrayOf(APIPropTypes.FilterCondition).isRequired,
276275
formatter: PropTypes.instanceOf(Formatter).isRequired,
277276
};
278277

0 commit comments

Comments
 (0)