Openstatus www.openstatus.dev

chore: override monitor url if hidden (#1343)

authored by

Maximilian Kaske and committed by
GitHub
ed7f2630 192efbd8

+28 -20
+20 -9
apps/web/src/app/(pages)/public/monitors/[id]/page.tsx
··· 24 24 searchParamsCache, 25 25 } from "./search-params"; 26 26 27 + /** 28 + * Workspace slugs that should have the URL hidden 29 + */ 30 + const WORKSPACES_HIDE_URL = 31 + process.env.WORKSPACES_HIDE_URL?.split(",").map(Number) || []; 32 + 27 33 export default async function Page(props: { 28 34 params: Promise<{ workspaceSlug: string; id: string }>; 29 35 searchParams: Promise<{ [key: string]: string | string[] | undefined }>; ··· 50 56 const isQuantileDisabled = intervalMinutes <= periodicityMinutes; 51 57 const minutes = isQuantileDisabled ? periodicityMinutes : intervalMinutes; 52 58 59 + const hideURL = 60 + monitor.workspaceId && WORKSPACES_HIDE_URL.includes(monitor.workspaceId); 61 + 53 62 const [metrics, data, metricsByRegion] = await Promise.all([ 54 63 prepareMetricsByPeriod(period, type).getData({ 55 64 monitorId: id, ··· 76 85 <Shell className="sticky top-2 z-10 flex items-center justify-between gap-2 bg-background/80 backdrop-blur-xs"> 77 86 <div className="min-w-0"> 78 87 <p className="font-semibold text-sm">{monitor.name}</p> 79 - <a 80 - href={monitor.url} 81 - target="_blank" 82 - rel="noreferrer" 83 - className="truncate text-base text-muted-foreground" 84 - > 85 - {monitor.url} 86 - </a> 88 + {hideURL ? null : ( 89 + <a 90 + href={monitor.url} 91 + target="_blank" 92 + rel="noreferrer" 93 + className="truncate text-base text-muted-foreground" 94 + > 95 + {monitor.url} 96 + </a> 97 + )} 87 98 </div> 88 99 <div className="flex items-center gap-2"> 89 100 {isDirty ? <ButtonReset /> : null} ··· 99 110 quantile={quantile} 100 111 interval={interval} 101 112 regions={regions.length ? (regions as Region[]) : monitor.regions} // FIXME: not properly reseted after filtered 102 - monitor={monitor} 113 + monitor={{ ...monitor, url: hideURL ? "" : monitor.url }} 103 114 isQuantileDisabled={isQuantileDisabled} 104 115 metricsByRegion={metricsByRegion.data} 105 116 preferredSettings={preferredSettings}
+5 -7
apps/web/src/app/status-page/[domain]/monitors/[id]/page.tsx
··· 74 74 const isQuantileDisabled = intervalMinutes <= periodicityMinutes; 75 75 const minutes = isQuantileDisabled ? periodicityMinutes : intervalMinutes; 76 76 77 + const hideURL = 78 + monitor.workspaceId && WORKSPACES_HIDE_URL.includes(monitor.workspaceId); 79 + 77 80 const [metrics, data, metricsByRegion] = await Promise.all([ 78 81 prepareMetricsByPeriod(period, type).getData({ 79 82 monitorId: id, ··· 102 105 <div className="relative flex w-full flex-col gap-6"> 103 106 <Header 104 107 title={monitor.name} 105 - description={ 106 - monitor.workspaceId && 107 - WORKSPACES_HIDE_URL.includes(monitor.workspaceId) 108 - ? undefined 109 - : monitor.url 110 - } 108 + description={hideURL ? undefined : monitor.url} 111 109 /> 112 110 <div className="flex items-center justify-between gap-2"> 113 111 <DatePickerPreset defaultValue={period} values={periods} /> ··· 121 119 quantile={quantile} 122 120 interval={interval} 123 121 regions={regions.length ? (regions as Region[]) : monitor.regions} // FIXME: not properly reseted after filtered 124 - monitor={monitor} 122 + monitor={{ ...monitor, url: hideURL ? "" : monitor.url }} 125 123 isQuantileDisabled={isQuantileDisabled} 126 124 metricsByRegion={metricsByRegion.data} 127 125 preferredSettings={preferredSettings}
+3 -4
apps/web/src/app/status-page/[domain]/monitors/page.tsx
··· 41 41 // filter monitor by public or not 42 42 43 43 const publicMonitors = page.monitors.filter((monitor) => monitor.public); 44 + const hideURL = 45 + page.workspaceId && WORKSPACES_HIDE_URL.includes(page.workspaceId); 44 46 45 47 const monitorsWithData = 46 48 publicMonitors.length > 0 ··· 88 90 <div className="flex w-full min-w-0 items-center justify-between gap-3"> 89 91 <div className="w-full min-w-0"> 90 92 <p className="font-semibold text-sm">{monitor.name}</p> 91 - {monitor.workspaceId && 92 - WORKSPACES_HIDE_URL.includes( 93 - monitor.workspaceId, 94 - ) ? null : ( 93 + {hideURL ? null : ( 95 94 <p className="truncate text-muted-foreground text-sm"> 96 95 {monitor.url} 97 96 </p>