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

feat(ui): TE-2363 allow user to opt in to be notified for historical anomalies when creating a subscription #1476

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
CardContent,
CardHeader,
Grid,
Switch,
TextField,
} from "@material-ui/core";
import React, { FunctionComponent } from "react";
Expand All @@ -28,7 +29,7 @@ import { PropertiesFormProps } from "./properties-form.interfaces";

// Refer: SubscriptionGroupPropertiesForm
export const PropertiesForm: FunctionComponent<PropertiesFormProps> = ({
values: { name, cron },
values: { name, cron, notifyHistoricalAnomalies },
onChange,
customHeader,
}) => {
Expand All @@ -42,6 +43,12 @@ export const PropertiesForm: FunctionComponent<PropertiesFormProps> = ({
onChange((stateProp) => ({ ...stateProp, name }));
};

const handleUpdateNotifyHistoricAnomalies = (
notifyHistoricalAnomalies: boolean
): void => {
onChange((stateProp) => ({ ...stateProp, notifyHistoricalAnomalies }));
};

return (
<Grid item xs={12}>
<Card>
Expand Down Expand Up @@ -77,6 +84,19 @@ export const PropertiesForm: FunctionComponent<PropertiesFormProps> = ({
cron={cron}
handleUpdateCron={handleUpdateCron}
/>
<InputSection
inputComponent={
<Switch
defaultChecked={!!notifyHistoricalAnomalies}
onChange={(e) => {
handleUpdateNotifyHistoricAnomalies(
e.target.checked
);
}}
/>
}
label={t("label.notifyHistoricalAnomalies")}
/>
</CardContent>
</Card>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { SubscriptionGroup } from "../../../../rest/dto/subscription-group.inter
interface FormValues {
name: string;
cron: string;
notifyHistoricalAnomalies?: boolean;
}

export interface PropertiesFormProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const SubscriptionGroupDetails: FunctionComponent<SubscriptionGroupDetail
const propertiesFormValues = {
cron: subscriptionGroup.cron,
name: subscriptionGroup.name,
notifyHistoricalAnomalies:
!!subscriptionGroup.notifyHistoricalAnomalies,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for better readability

Suggested change
notifyHistoricalAnomalies:
!!subscriptionGroup.notifyHistoricalAnomalies,
notifyHistoricalAnomalies:
Boolean(subscriptionGroup.notifyHistoricalAnomalies),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

};

return (
Expand Down
1 change: 1 addition & 0 deletions thirdeye-ui/src/app/locale/languages/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@
"none": "None",
"not-saved": "not saved",
"notifications": "notifications",
"notifyHistoricalAnomalies": "Notify Historical Anomalies",
"num-dimensions": "{{num}} dimensions",
"ok": "Ok",
"onboard": "Onboard",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface SubscriptionGroup {
owner: User;
notificationSchemes?: NotificationSchemes;
specs: NotificationSpec[];
notifyHistoricalAnomalies?: boolean; // optional as its only coming when this property is set
}

export enum SpecType {
Expand Down
Loading