feat: Enable metric alerts on dev (#140)

* Allow to set alerts for metric charts on development env
* Validation improvements for webhook alerts form (HDX-213)
This commit is contained in:
Shorpo 2023-12-05 17:41:34 -07:00 committed by GitHub
parent 141fce003a
commit a40faf1741
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 22 deletions

View file

@ -0,0 +1,5 @@
---
'@hyperdx/app': patch
---
Allow to set alerts for metric charts on development env

View file

@ -55,28 +55,28 @@ export const SlackChannelForm = ({
return (
<>
{hasSlackWebhooks && (
<div className="mt-3">
<Form.Label className="text-muted">Slack Webhook</Form.Label>
<Form.Select
className="bg-black border-0 mb-1 px-3"
required
id="webhookId"
size="sm"
{...webhookSelectProps}
>
{/* Ensure user selects a slack webhook before submitting form */}
<option value="" disabled>
Select a Slack Webhook
<div className="mt-3">
<Form.Label className="text-muted">Slack Webhook</Form.Label>
<Form.Select
className="bg-black border-0 mb-1 px-3"
required
id="webhookId"
size="sm"
{...webhookSelectProps}
>
{/* Ensure user selects a slack webhook before submitting form */}
<option value="" disabled selected>
{hasSlackWebhooks
? 'Select a Slack Webhook'
: 'No Slack Webhooks available'}
</option>
{slackWebhooks?.data.map((sw: any) => (
<option key={sw._id} value={sw._id}>
{sw.name}
</option>
{slackWebhooks.data.map((sw: any) => (
<option key={sw._id} value={sw._id}>
{sw.name}
</option>
))}
</Form.Select>
</div>
)}
))}
</Form.Select>
</div>
<div className="mb-2">
<a

View file

@ -21,6 +21,7 @@ import EditChartFormAlerts from './EditChartFormAlerts';
import HDXNumberChart from './HDXNumberChart';
import HDXTableChart from './HDXTableChart';
import { intervalToGranularity } from './Alert';
import { METRIC_ALERTS_ENABLED } from './config';
export type Chart = {
id: string;
@ -867,6 +868,9 @@ export const EditLineChartForm = ({
return null;
}
const isChartAlertsFeatureEnabled =
editedChart.series[0].table === 'logs' || METRIC_ALERTS_ENABLED;
return (
<form
onSubmit={e => {
@ -970,7 +974,7 @@ export const EditLineChartForm = ({
}}
/>
{editedChart.series[0].table === 'logs' && (
{isChartAlertsFeatureEnabled && (
<div className="mt-4 border-top border-bottom border-grey p-2 py-3">
{isLocalDashboard ? (
<span className="text-gray-600 fs-8">

View file

@ -341,6 +341,7 @@ export default function TeamPage() {
name="name"
placeholder="My Slack Webhook"
className="border-0 mb-4 px-3"
required
/>
<Form.Label className="text-start text-muted fs-7 mb-2 mt-2">
Webhook URL
@ -351,6 +352,7 @@ export default function TeamPage() {
name="url"
placeholder="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
className="border-0 mb-4 px-3"
required
/>
<Button
variant="brand-primary"

View file

@ -9,3 +9,6 @@ export const HDX_COLLECTOR_URL =
'http://localhost:4318';
export const IS_OSS = process.env.NEXT_PUBLIC_IS_OSS ?? 'true' === 'true';
// Features in development
export const METRIC_ALERTS_ENABLED = process.env.NODE_ENV === 'development';