fix(client): hide Open site action when URL is not browser-openable
The Open site action in monitor row menus called `window.open(monitor.url)` unconditionally, which produced unresolvable navigation for monitors targeting internal services: - Hardware monitors always point at a Capture agent (e.g. http://capture:59232/api/v1/metrics) that the user's browser can't reach. - Port, ping, docker, game, grpc, and websocket monitors store hostnames or non-HTTP endpoints, which browsers can't load anyway. This change hides the action where it can't possibly work: - Removed entirely from the Infrastructure (hardware) monitors table. - In the Uptime monitors table, only shown for http and pagespeed monitor types whose URL starts with http:// or https://. A more comprehensive fix that adds a separate user-facing siteUrl field on the Monitor schema is left for a follow-up. Closes #3434
This commit is contained in:
1 parent
6ed0818bad
commit
50fb4f47fd
2 files changed
+14
-13
No files matched your search
@@ -80,14 +80,6 @@ export const InfraMonitorsTable = ({
|
||||
|
||||
const getActions = (monitor: Monitor): ActionMenuItem[] => {
|
||||
return [
|
||||
{
|
||||
id: 1,
|
||||
label: t("pages.common.monitors.actions.openSite"),
|
||||
action: () => {
|
||||
window.open(monitor.url, "_blank", "noreferrer");
|
||||
},
|
||||
closeMenu: true,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: t("pages.common.monitors.actions.details"),
|
||||
|
||||
@@ -71,16 +71,24 @@ export const MonitorTable = ({
|
||||
refetch();
|
||||
};
|
||||
|
||||
const isBrowserOpenable = (monitor: Monitor): boolean => {
|
||||
if (monitor.type !== "http" && monitor.type !== "pagespeed") return false;
|
||||
return /^https?:\/\//i.test(monitor.url ?? "");
|
||||
};
|
||||
|
||||
const getActions = (monitor: Monitor): ActionMenuItem[] => {
|
||||
return [
|
||||
{
|
||||
const actions: ActionMenuItem[] = [];
|
||||
if (isBrowserOpenable(monitor)) {
|
||||
actions.push({
|
||||
id: 1,
|
||||
label: t("pages.common.monitors.actions.openSite"),
|
||||
action: () => {
|
||||
window.open(monitor.url, "_blank", "noreferrer");
|
||||
},
|
||||
closeMenu: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
actions.push(
|
||||
{
|
||||
id: 2,
|
||||
label: t("pages.common.monitors.actions.details"),
|
||||
@@ -130,8 +138,9 @@ export const MonitorTable = ({
|
||||
),
|
||||
action: () => setSelectedMonitor(monitor),
|
||||
closeMenu: true,
|
||||
},
|
||||
];
|
||||
}
|
||||
);
|
||||
return actions;
|
||||
};
|
||||
|
||||
const getHeaders = (chartType: string) => {
|
||||
|
||||
Reference in new issue
Block a user