Skip to content

Commit bbc09d0

Browse files
Fix initial route path to use base url (#69)
* Fix initial route path to use base url * Fix external links * Update trigger event name
1 parent e52370c commit bbc09d0

File tree

5 files changed

+52
-25
lines changed

5 files changed

+52
-25
lines changed

.github/workflows/digma-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
push: true
3636

3737
update-digma-ui:
38-
name: Update Jaeger dependencies in Digma UI
38+
name: Update dependencies in Digma UI
3939
needs: [build, attach-release-asset, build-push-docker-image]
4040
runs-on: ubuntu-latest
4141
steps:
@@ -48,7 +48,7 @@ jobs:
4848
with:
4949
token: ${{ secrets.RELEASE_PAT }}
5050
repository: digma-ai/digma-ui
51-
event-type: update-jaeger
51+
event-type: update-dependencies
5252
client-payload: |-
5353
{
5454
"jaegerUIVersion": "${{ needs.build.outputs.version }}",

packages/jaeger-ui/src/components/App/index.jsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,16 @@ export default class JaegerUIApp extends Component {
5656
processScripts();
5757
this.zoomManager = new ZoomManager();
5858
this._handleZoomKeyboardShortcuts = this._handleZoomKeyboardShortcuts.bind(this);
59+
this.state = { isRedirected: false };
5960
}
6061

6162
componentDidMount() {
63+
if (isString(window.initialRoutePath) && window.initialRoutePath) {
64+
const urlToNavigate = prefixUrl(window.initialRoutePath);
65+
history.push(urlToNavigate);
66+
}
67+
this.setState({ isRedirected: true });
68+
6269
document.addEventListener('keydown', this._handleZoomKeyboardShortcuts);
6370
}
6471

@@ -81,11 +88,8 @@ export default class JaegerUIApp extends Component {
8188
}
8289

8390
render() {
84-
// Navigate to URL provided on app start
85-
if (isString(window.initialRoutePath) && window.initialRoutePath) {
86-
const urlToNavigate = window.initialRoutePath;
87-
window.initialRoutePath = '';
88-
history.push(urlToNavigate);
91+
if (!this.state.isRedirected) {
92+
return null;
8993
}
9094

9195
return (

packages/jaeger-ui/src/components/TracePage/TracePageHeader/AltViewOptions.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import * as React from 'react';
1616
import { Dropdown, Icon, Menu, Button } from 'antd';
1717
import './AltViewOptions.css';
18-
import { Link } from 'react-router-dom';
1918
import {
2019
trackGanttView,
2120
trackGraphView,
@@ -26,6 +25,7 @@ import {
2625
} from './TracePageHeader.track';
2726
import prefixUrl from '../../../utils/prefix-url';
2827
import { ETraceViewType } from '../types';
28+
import isString from '../../../utils/ts/typeGuards/isString';
2929

3030
type Props = {
3131
onTraceViewChange: (viewType: ETraceViewType) => void;
@@ -72,7 +72,17 @@ export default function AltViewOptions(props: Props) {
7272
onTraceViewChange(item);
7373
};
7474

75-
const getMenuLinkUrl = (url: string) => window.baseUrl ?? window.apiBaseUrl ?? prefixUrl(url);
75+
const getMenuItemUrl = (path: string): string => {
76+
if (isString(window.baseUrl) && window.baseUrl) {
77+
return `${window.baseUrl}${path}`;
78+
}
79+
80+
if (isString(window.apiBaseUrl) && window.apiBaseUrl) {
81+
return `${window.apiBaseUrl}${path}`;
82+
}
83+
84+
return prefixUrl(path);
85+
};
7686

7787
const menu = (
7888
<Menu>
@@ -84,24 +94,24 @@ export default function AltViewOptions(props: Props) {
8494
</Menu.Item>
8595
))}
8696
<Menu.Item>
87-
<Link
88-
to={getMenuLinkUrl(`/api/traces/${traceID}?prettyPrint=true`)}
97+
<a
98+
href={getMenuItemUrl(`/api/traces/${traceID}?prettyPrint=true`)}
8999
rel="noopener noreferrer"
90100
target="_blank"
91101
onClick={trackJsonView}
92102
>
93103
Trace JSON
94-
</Link>
104+
</a>
95105
</Menu.Item>
96106
<Menu.Item>
97-
<Link
98-
to={getMenuLinkUrl(`/api/traces/${traceID}?raw=true&prettyPrint=true`)}
107+
<a
108+
href={getMenuItemUrl(`/api/traces/${traceID}?raw=true&prettyPrint=true`)}
99109
rel="noopener noreferrer"
100110
target="_blank"
101111
onClick={trackRawJsonView}
102112
>
103113
Trace JSON (unadjusted)
104-
</Link>
114+
</a>
105115
</Menu.Item>
106116
</Menu>
107117
);

packages/jaeger-ui/src/components/TracePage/TracePageHeader/TracePageHeader.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import ExternalLinks from '../../common/ExternalLinks';
4141
import ZoomControls from './ZoomControls';
4242
import { globalActions } from '../../../api/digma/actions';
4343
import { OpenURLInDefaultBrowserPayload } from '../../../api/digma/types';
44+
import isString from '../../../utils/ts/typeGuards/isString';
45+
import prefixUrl from '../../../utils/prefix-url';
4446

4547
type TracePageHeaderEmbedProps = {
4648
canCollapse: boolean;
@@ -161,12 +163,25 @@ export function TracePageHeaderFn(props: TracePageHeaderEmbedProps & { forwarded
161163
);
162164

163165
const handleStandaloneLinkClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
164-
const baseUrl = window.baseUrl ?? window.apiBaseUrl;
166+
const getBaseUrl = (): string => {
167+
if (isString(window.baseUrl) && window.baseUrl) {
168+
return window.baseUrl;
169+
}
170+
171+
if (isString(window.apiBaseUrl) && window.apiBaseUrl) {
172+
return window.apiBaseUrl;
173+
}
174+
175+
return prefixUrl('/');
176+
};
177+
178+
const baseUrl: string = getBaseUrl();
179+
165180
e.preventDefault();
166181
window.sendMessageToDigma<OpenURLInDefaultBrowserPayload>({
167182
action: globalActions.OPEN_URL_IN_DEFAULT_BROWSER,
168183
payload: {
169-
url: `${baseUrl}${window.location.pathname}${window.location.search}`,
184+
url: `${baseUrl}/trace/${trace.traceID}${window.location.search}`,
170185
},
171186
});
172187
};

packages/jaeger-ui/src/components/TracePage/TracePageHeader/__snapshots__/AltViewOptions.test.js.snap

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,24 @@ exports[`AltViewOptions renders correctly 1`] = `
3939
</a>
4040
</MenuItem>
4141
<MenuItem>
42-
<Link
42+
<a
43+
href="/api/traces/test trace ID?prettyPrint=true"
4344
onClick={[MockFunction]}
4445
rel="noopener noreferrer"
45-
replace={false}
4646
target="_blank"
47-
to="/api/traces/test trace ID?prettyPrint=true"
4847
>
4948
Trace JSON
50-
</Link>
49+
</a>
5150
</MenuItem>
5251
<MenuItem>
53-
<Link
52+
<a
53+
href="/api/traces/test trace ID?raw=true&prettyPrint=true"
5454
onClick={[MockFunction]}
5555
rel="noopener noreferrer"
56-
replace={false}
5756
target="_blank"
58-
to="/api/traces/test trace ID?raw=true&prettyPrint=true"
5957
>
6058
Trace JSON (unadjusted)
61-
</Link>
59+
</a>
6260
</MenuItem>
6361
</Menu>
6462
}

0 commit comments

Comments
 (0)