Skip to content

Commit f440eb9

Browse files
authored
feat: Relative links (#1204)
- Notebooks work - Links between notebooks work - Deeplinking notebooks works in dev mode with proxy - Does not work in production - would need server to correctly proxy URLs and write the correct document base - Embed-grid works - Embed-chart works - Plugins work - Fixes #1070 - Unit tests and e2e tests pass - Tested in both a dev build, and production build - Tested following steps in #1070 - Tested in DnD, ensured the correct paths were being loaded
1 parent 769d753 commit f440eb9

35 files changed

Lines changed: 190 additions & 115 deletions

package-lock.json

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"@deephaven/jsapi-utils": "file:../jsapi-utils",
3737
"@deephaven/log": "file:../log",
3838
"@deephaven/react-hooks": "file:../react-hooks",
39+
"@deephaven/utils": "file:../utils",
3940
"@paciolan/remote-component": "2.13.0",
4041
"@paciolan/remote-module-loader": "^3.0.2",
4142
"fira": "mozilla/fira#4.202"

packages/app-utils/src/components/AppBootstrap.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function renderComponent(client: CoreClient) {
4545
});
4646
return render(
4747
<ApiContext.Provider value={api}>
48-
<AppBootstrap apiUrl={API_URL} pluginsUrl={PLUGINS_URL}>
48+
<AppBootstrap serverUrl={API_URL} pluginsUrl={PLUGINS_URL}>
4949
{mockChild}
5050
</AppBootstrap>
5151
</ApiContext.Provider>
@@ -59,7 +59,7 @@ beforeEach(() => {
5959
it('should throw if api has not been bootstrapped', () => {
6060
expect(() =>
6161
render(
62-
<AppBootstrap apiUrl={API_URL} pluginsUrl={PLUGINS_URL}>
62+
<AppBootstrap serverUrl={API_URL} pluginsUrl={PLUGINS_URL}>
6363
{mockChild}
6464
</AppBootstrap>
6565
)
@@ -91,7 +91,7 @@ it('should display an error if no login plugin matches the provided auth handler
9191
expect(mockLogin).not.toHaveBeenCalled();
9292
expect(
9393
screen.queryByText(
94-
'Error: No login plugins found, please register a login plugin for auth handlers: MockAuthHandler'
94+
'No login plugins found, please register a login plugin for auth handlers: MockAuthHandler'
9595
)
9696
).not.toBeNull();
9797
});

packages/app-utils/src/components/AppBootstrap.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import FontBootstrap from './FontBootstrap';
99
import PluginsBootstrap from './PluginsBootstrap';
1010
import AuthBootstrap from './AuthBootstrap';
1111
import ConnectionBootstrap from './ConnectionBootstrap';
12-
import { getBaseUrl, getConnectOptions } from '../utils';
12+
import { getConnectOptions } from '../utils';
1313
import FontsLoaded from './FontsLoaded';
1414

1515
export type AppBootstrapProps = {
16-
/** URL of the API to load. */
17-
apiUrl: string;
16+
/** URL of the server. */
17+
serverUrl: string;
1818

1919
/** URL of the plugins to load. */
2020
pluginsUrl: string;
@@ -33,12 +33,11 @@ export type AppBootstrapProps = {
3333
* Will display the children when everything is loaded and authenticated.
3434
*/
3535
export function AppBootstrap({
36-
apiUrl,
3736
fontClassNames,
3837
pluginsUrl,
38+
serverUrl,
3939
children,
4040
}: AppBootstrapProps) {
41-
const serverUrl = getBaseUrl(apiUrl).origin;
4241
const clientOptions = useMemo(() => getConnectOptions(), []);
4342

4443
// On logout, we reset the client and have user login again

packages/app-utils/src/components/AuthBootstrap.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '@deephaven/auth-plugins';
88
import { LoadingOverlay } from '@deephaven/components';
99
import { useClient } from '@deephaven/jsapi-bootstrap';
10+
import { getErrorMessage } from '@deephaven/utils';
1011
import { PluginsContext } from './PluginsBootstrap';
1112
import { getAuthPluginComponent } from '../plugins';
1213
import LoginNotifier from './LoginNotifier';
@@ -76,8 +77,8 @@ export function AuthBootstrap({ children }: AuthBootstrapProps) {
7677
if (isLoading || error != null) {
7778
return (
7879
<LoadingOverlay
79-
isLoading={isLoading}
80-
errorMessage={error != null ? `${error}` : undefined}
80+
isLoading={isLoading && error == null}
81+
errorMessage={getErrorMessage(error)}
8182
/>
8283
);
8384
}

packages/app-utils/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
{ "path": "../jsapi-types" },
1515
{ "path": "../jsapi-utils" },
1616
{ "path": "../log" },
17-
{ "path": "../react-hooks" }
17+
{ "path": "../react-hooks" },
18+
{ "path": "../utils" }
1819
]
1920
}

packages/auth-plugins/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
"@deephaven/jsapi-types": "file:../jsapi-types",
4040
"@deephaven/jsapi-utils": "file:../jsapi-utils",
4141
"@deephaven/log": "file:../log",
42-
"@deephaven/utils": "file:../utils",
4342
"@deephaven/redux": "file:../redux",
43+
"@deephaven/utils": "file:../utils",
4444
"classnames": "^2.3.1",
4545
"react-transition-group": "^4.4.2",
4646
"js-cookie": "^3.0.5"

packages/auth-plugins/src/Login.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ interface LoginProps {
66
/** What to show in the login input part of the login form. */
77
children: React.ReactNode;
88

9-
/** Path to the logo. Defaults to `/logo.png` */
9+
/** Path to the custom logo, relative to document base */
1010
logoPath?: string;
1111
}
1212

13-
export function Login({ children, logoPath = '/logo.png' }: LoginProps) {
13+
export function Login({ children, logoPath = './logo.png' }: LoginProps) {
1414
return (
1515
<div className="login-container">
1616
<RandomAreaPlotAnimation />

packages/babel-preset/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@ module.exports = api => ({
2222
plugins: [
2323
api.env('test')
2424
? [
25-
// This is needed to replace import.meta w/ process in Jest
25+
// This is needed to replace import.meta.env w/ process in Jest
2626
// Jest does not play nicely w/ ESM and Vite uses import.meta
2727
// import.meta is only avaialable in ESM
2828
path.resolve(__dirname, 'importMetaEnvPlugin'),
2929
]
30-
: // The add-import-extension plugin causes Jest to error, but is needed for proper ESM builds
31-
['babel-plugin-add-import-extension'],
30+
: false,
31+
api.env('test')
32+
? [
33+
// Also need to handle import.meta.url
34+
'babel-plugin-transform-import-meta',
35+
]
36+
: false,
37+
api.env('test')
38+
? false // The add-import-extension plugin causes Jest to error, but is needed for proper ESM builds
39+
: ['babel-plugin-add-import-extension'],
3240
[
3341
'transform-rename-import',
3442
{

packages/babel-preset/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@babel/preset-react": "^7.18.0",
1818
"@babel/preset-typescript": "^7.18.0",
1919
"babel-plugin-add-import-extension": "^1.6.0",
20+
"babel-plugin-transform-import-meta": "^2.2.0",
2021
"babel-plugin-transform-rename-import": "^2.3.0"
2122
},
2223
"publishConfig": {

0 commit comments

Comments
 (0)