Merge pull request #3574 from bluewave-labs/fix/open-site-action-internal-url
fix(client): hide Open site action when URL is not browser-openable
This commit is contained in:
2 files changed
+14
-13
No files matched your search
@@ -80,14 +80,6 @@ export const InfraMonitorsTable = ({
|
|||||||
|
|
||||||
const getActions = (monitor: Monitor): ActionMenuItem[] => {
|
const getActions = (monitor: Monitor): ActionMenuItem[] => {
|
||||||
return [
|
return [
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
label: t("pages.common.monitors.actions.openSite"),
|
|
||||||
action: () => {
|
|
||||||
window.open(monitor.url, "_blank", "noreferrer");
|
|
||||||
},
|
|
||||||
closeMenu: true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
label: t("pages.common.monitors.actions.details"),
|
label: t("pages.common.monitors.actions.details"),
|
||||||
|
|||||||
@@ -71,16 +71,24 @@ export const MonitorTable = ({
|
|||||||
refetch();
|
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[] => {
|
const getActions = (monitor: Monitor): ActionMenuItem[] => {
|
||||||
return [
|
const actions: ActionMenuItem[] = [];
|
||||||
{
|
if (isBrowserOpenable(monitor)) {
|
||||||
|
actions.push({
|
||||||
id: 1,
|
id: 1,
|
||||||
label: t("pages.common.monitors.actions.openSite"),
|
label: t("pages.common.monitors.actions.openSite"),
|
||||||
action: () => {
|
action: () => {
|
||||||
window.open(monitor.url, "_blank", "noreferrer");
|
window.open(monitor.url, "_blank", "noreferrer");
|
||||||
},
|
},
|
||||||
closeMenu: true,
|
closeMenu: true,
|
||||||
},
|
});
|
||||||
|
}
|
||||||
|
actions.push(
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
label: t("pages.common.monitors.actions.details"),
|
label: t("pages.common.monitors.actions.details"),
|
||||||
@@ -130,8 +138,9 @@ export const MonitorTable = ({
|
|||||||
),
|
),
|
||||||
action: () => setSelectedMonitor(monitor),
|
action: () => setSelectedMonitor(monitor),
|
||||||
closeMenu: true,
|
closeMenu: true,
|
||||||
},
|
}
|
||||||
];
|
);
|
||||||
|
return actions;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getHeaders = (chartType: string) => {
|
const getHeaders = (chartType: string) => {
|
||||||
|
|||||||
Reference in new issue
Block a user