Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add baseUrl variable #60

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/jaeger-ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
window.global = {};
</script>
<script>
window.baseUrl;
window.apiBaseUrl;
window.initialRoutePath;
window.embeddedMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,37 +71,41 @@ export default function AltViewOptions(props: Props) {
onTraceViewChange(item);
};

const menu = (
<Menu>
{MENU_ITEMS.filter(item => item.viewType !== viewType).map(item => (
<Menu.Item key={item.viewType}>
<a onClick={() => handleSelectView(item.viewType)} role="button">
{item.label}
const menu = () => {
const baseUrl = window.baseUrl ?? window.apiBaseUrl;

return (
<Menu>
{MENU_ITEMS.filter(item => item.viewType !== viewType).map(item => (
<Menu.Item key={item.viewType}>
<a onClick={() => handleSelectView(item.viewType)} role="button">
{item.label}
</a>
</Menu.Item>
))}
<Menu.Item>
<a
href={`${baseUrl}/api/traces/${traceID}?prettyPrint=true`}
rel="noopener noreferrer"
target="_blank"
onClick={trackJsonView}
>
Trace JSON
</a>
</Menu.Item>
))}
<Menu.Item>
<a
href={`${window.apiBaseUrl}/api/traces/${traceID}?prettyPrint=true`}
rel="noopener noreferrer"
target="_blank"
onClick={trackJsonView}
>
Trace JSON
</a>
</Menu.Item>
<Menu.Item>
<a
href={`${window.apiBaseUrl}/api/traces/${traceID}?raw=true&prettyPrint=true`}
rel="noopener noreferrer"
target="_blank"
onClick={trackRawJsonView}
>
Trace JSON (unadjusted)
</a>
</Menu.Item>
</Menu>
);
<Menu.Item>
<a
href={`${baseUrl}/api/traces/${traceID}?raw=true&prettyPrint=true`}
rel="noopener noreferrer"
target="_blank"
onClick={trackRawJsonView}
>
Trace JSON (unadjusted)
</a>
</Menu.Item>
</Menu>
);
};

const currentItem = MENU_ITEMS.find(item => item.viewType === viewType);
const dropdownText = currentItem ? currentItem.label : 'Alternate Views';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,12 @@ export function TracePageHeaderFn(props: TracePageHeaderEmbedProps & { forwarded
);

const handleStandaloneLinkClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
const baseUrl = window.baseUrl ?? window.apiBaseUrl;
e.preventDefault();
window.sendMessageToDigma<OpenURLInDefaultBrowserPayload>({
action: globalActions.OPEN_URL_IN_DEFAULT_BROWSER,
payload: {
url: `${window.apiBaseUrl}${window.location.pathname}${window.location.search}`,
url: `${baseUrl}${window.location.pathname}${window.location.search}`,
},
});
};
Expand Down
7 changes: 4 additions & 3 deletions packages/jaeger-ui/src/components/common/ErrorMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export default function ErrorMessage({
}

if (error.message.includes('Failed to fetch') || error.httpStatus === 502) {
const baseUrl = window.baseUrl ?? window.apiBaseUrl;
const isUserDefinedJaegerQueryURL = window.isUserDefinedJaegerQueryURL === true;
return (
<DigmaErrorMessage
Expand All @@ -173,16 +174,16 @@ export default function ErrorMessage({
isUserDefinedJaegerQueryURL ? (
<>
The Jaeger link
{isString(window.apiBaseUrl) && (
{isString(baseUrl) && (
<>
{' '}
<a
className="CustomErrorMessage--link"
href={window.apiBaseUrl}
href={baseUrl}
target="_blank"
rel="noopener noreferrer"
>
{window.apiBaseUrl}
{baseUrl}
</a>
</>
)}{' '}
Expand Down
1 change: 1 addition & 0 deletions packages/jaeger-ui/typings/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ declare interface Window {
) => string | undefined;
cancelMessageToDigma: (request_id: string) => void;
platform?: unknown;
baseUrl?: unknown
apiBaseUrl?: unknown;
initialRoutePath?: unknown;
embeddedMode?: unknown;
Expand Down