-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): TE-2216 create alert page (#1480)
- Loading branch information
1 parent
910d43a
commit 443f1a8
Showing
98 changed files
with
6,507 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
...e-ui/src/app/components/additional-filters-drawer/additional-filters-drawer.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
/* | ||
* Copyright 2023 StarTree Inc | ||
* | ||
* Licensed under the StarTree Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at http://www.startree.ai/legal/startree-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND, | ||
* either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
import { Icon } from "@iconify/react"; | ||
import { Box, Button, Drawer, Typography } from "@material-ui/core"; | ||
import React, { FunctionComponent, useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { | ||
PropertyConfigValueTypes, | ||
TemplatePropertiesObject, | ||
} from "../../rest/dto/alert.interfaces"; | ||
import { AdditonalFiltersDrawerProps } from "./additional-filters-drawer.interfaces"; | ||
import { useAdditonalFiltersDrawerStyles } from "./additional-filters-drawer.styles"; | ||
import { FormComponentForTemplateField } from "../alert-wizard-v2/alert-template/alert-template-form-field/form-component-for-template-field/form-component-for-template-field.component"; | ||
import { LabelForTemplateFieldV2 } from "../alert-wizard-v2/alert-template/alert-template-form-field/label-for-template-field-v2/label-for-template-field-v2.component"; | ||
|
||
/** | ||
* Convenience wrapper on top of HelpDrawerCoreV1 so consumers do not have | ||
* to maintain isOpen state | ||
*/ | ||
export const AdditonalFiltersDrawer: FunctionComponent<AdditonalFiltersDrawerProps> = | ||
({ defaultValues, onApply, isOpen, onClose, availableConfigurations }) => { | ||
const classes = useAdditonalFiltersDrawerStyles(); | ||
const { t } = useTranslation(); | ||
const [localCopyOfProperties, setLocalCopyOfProperties] = | ||
useState<TemplatePropertiesObject>({ | ||
...defaultValues, | ||
}); | ||
|
||
const handleOnChange = ( | ||
key: string, | ||
value: PropertyConfigValueTypes | ||
): void => { | ||
setLocalCopyOfProperties((prev) => ({ | ||
...prev, | ||
[key]: value, | ||
})); | ||
}; | ||
|
||
const onSubmit = (): void => { | ||
onApply(localCopyOfProperties); | ||
}; | ||
|
||
return ( | ||
<Drawer | ||
PaperProps={{ | ||
className: classes.drawerPaper, | ||
}} | ||
anchor="right" | ||
open={isOpen} | ||
onClose={onClose} | ||
> | ||
<form onSubmit={onSubmit}> | ||
<Box | ||
alignItems="center" | ||
className={classes.header} | ||
display="flex" | ||
justifyContent="space-between" | ||
> | ||
<Typography variant="h6"> | ||
{t("label.advanced-options")} | ||
</Typography> | ||
<Icon | ||
cursor="pointer" | ||
fontSize={24} | ||
icon="ic:round-close" | ||
onClick={onClose} | ||
/> | ||
</Box> | ||
<Box className={classes.content} flex={1}> | ||
<Box> | ||
{availableConfigurations.map((config) => ( | ||
<Box | ||
className={classes.configItem} | ||
key={config.name} | ||
mb={3} | ||
width="100%" | ||
> | ||
<Typography color="inherit" variant="h6"> | ||
{config.name} | ||
</Typography> | ||
<Box className={classes.configItemFields}> | ||
{config.requiredPropertiesWithMetadata.map( | ||
(propertyMetadata) => ( | ||
<Box | ||
key={propertyMetadata.name} | ||
> | ||
<LabelForTemplateFieldV2 | ||
className={ | ||
classes.formLabel | ||
} | ||
name={ | ||
propertyMetadata.name | ||
} | ||
tooltipText={ | ||
propertyMetadata.description | ||
} | ||
/> | ||
<FormComponentForTemplateField | ||
propertyKey={ | ||
propertyMetadata.name | ||
} | ||
templateFieldProperty={ | ||
propertyMetadata | ||
} | ||
value={ | ||
localCopyOfProperties[ | ||
propertyMetadata | ||
.name | ||
] | ||
} | ||
onChange={( | ||
newValue | ||
) => { | ||
handleOnChange( | ||
propertyMetadata.name, | ||
newValue | ||
); | ||
}} | ||
/> | ||
</Box> | ||
) | ||
)} | ||
</Box> | ||
</Box> | ||
))} | ||
</Box> | ||
</Box> | ||
<Box | ||
className={classes.footer} | ||
display="flex" | ||
justifyContent="space-between" | ||
> | ||
<Button | ||
className={classes.actionSecondary} | ||
size="medium" | ||
variant="contained" | ||
onClick={onClose} | ||
> | ||
{t("label.close")} | ||
</Button> | ||
<Button | ||
className={classes.actionPrimary} | ||
color="primary" | ||
size="medium" | ||
type="submit" | ||
variant="contained" | ||
> | ||
{t("label.apply-filter")} | ||
</Button> | ||
</Box> | ||
</form> | ||
</Drawer> | ||
); | ||
}; |
25 changes: 25 additions & 0 deletions
25
...e-ui/src/app/components/additional-filters-drawer/additional-filters-drawer.interfaces.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2023 StarTree Inc | ||
* | ||
* Licensed under the StarTree Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at http://www.startree.ai/legal/startree-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND, | ||
* either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
import { TemplatePropertiesObject } from "../../rest/dto/alert.interfaces"; | ||
import { AnomaliesFilterConfiguratorRenderConfigs } from "../alert-wizard-v3/anomalies-filter-panel/anomalies-filter-panel.interfaces"; | ||
|
||
export interface AdditonalFiltersDrawerProps { | ||
defaultValues: TemplatePropertiesObject; | ||
isOpen: boolean; | ||
onApply: (fieldData: TemplatePropertiesObject) => void; | ||
onClose: () => void; | ||
availableConfigurations: AnomaliesFilterConfiguratorRenderConfigs[]; | ||
} |
81 changes: 81 additions & 0 deletions
81
thirdeye-ui/src/app/components/additional-filters-drawer/additional-filters-drawer.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright 2023 StarTree Inc | ||
* | ||
* Licensed under the StarTree Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at http://www.startree.ai/legal/startree-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND, | ||
* either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
import { makeStyles } from "@material-ui/core"; | ||
import { ColorV1 } from "../../platform/utils/material-ui/color.util"; | ||
import { PaletteV1 } from "../../platform/utils"; | ||
|
||
export const useAdditonalFiltersDrawerStyles = makeStyles((theme) => ({ | ||
drawerPaper: { | ||
backgroundColor: theme.palette.background.paper, | ||
maxWidth: 280, | ||
width: "100%", | ||
|
||
"& form": { | ||
height: "100%", | ||
display: "flex", | ||
flexDirection: "column", | ||
}, | ||
}, | ||
header: { | ||
padding: "10px 12px", | ||
|
||
"& h6": { | ||
color: PaletteV1.NavBarBackgroundColor, | ||
}, | ||
}, | ||
content: { | ||
borderBottom: `1px solid ${ColorV1.Grey10}`, | ||
borderTop: `1px solid ${ColorV1.Grey10}`, | ||
padding: "20px 12px", | ||
flex: "1 1 auto", | ||
overflowY: "auto", | ||
height: 0, | ||
}, | ||
footer: { | ||
padding: "10px 12px", | ||
backgroundColor: ColorV1.Grey9, | ||
}, | ||
actionSecondary: { | ||
textTransform: "none", | ||
backgroundColor: ColorV1.White1, | ||
border: `1px solid ${ColorV1.Grey10}`, | ||
}, | ||
actionPrimary: { | ||
textTransform: "none", | ||
}, | ||
configItem: { | ||
"& h6": { | ||
color: PaletteV1.NavBarBackgroundColor, | ||
fontWeight: 700, | ||
fontSize: 16, | ||
marginBottom: 6, | ||
}, | ||
}, | ||
configItemFields: { | ||
display: "flex", | ||
flexDirection: "column", | ||
gap: 4, | ||
}, | ||
formLabel: { | ||
display: "flex", | ||
justifyContent: "flex-start", | ||
alignItems: "center", | ||
gap: 8, | ||
fontWeight: 700, | ||
fontSize: 12, | ||
color: PaletteV1.NavBarBackgroundColor, | ||
marginBottom: 4, | ||
}, | ||
})); |
103 changes: 103 additions & 0 deletions
103
...c/app/components/alert-add-configuration-modal/alert-add-configration-modal.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Copyright 2023 StarTree Inc | ||
* | ||
* Licensed under the StarTree Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at http://www.startree.ai/legal/startree-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OF ANY KIND, | ||
* either express or implied. | ||
* | ||
* See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
import { Box, Button, Grid, Typography } from "@material-ui/core"; | ||
import React, { FunctionComponent } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import ControlPointOutlinedIcon from "@material-ui/icons/ControlPointOutlined"; | ||
import { Modal } from "../modal/modal.component"; | ||
import { AlertAddConfigrationModalProps } from "./alert-add-configration-modal.interfaces"; | ||
import Image from "../../../assets/images/alert-type-examples/configuration.png"; | ||
import { | ||
getSubscriptionGroupsCreatePathWithAlertId, | ||
getSubscriptionGroupsPath, | ||
} from "../../utils/routes/routes.util"; | ||
import { boxCardStyles } from "./alert-add-configration-modal.styles"; | ||
import { useSearchParams } from "react-router-dom"; | ||
import { QUERY_PARAM_KEY_ALERT_TYPE } from "../../pages/alerts-view-page/alerts-view-page.utils"; | ||
|
||
export const AlertAddConfigrationModal: FunctionComponent<AlertAddConfigrationModalProps> = | ||
({ alertId }) => { | ||
const { t } = useTranslation(); | ||
const classes = boxCardStyles(); | ||
const [searchParams] = useSearchParams(); | ||
|
||
return ( | ||
<Modal | ||
initiallyOpen | ||
showFooter={false} | ||
submitButtonLabel={t("label.got-it")} | ||
title={t("label.alert-completed")} | ||
> | ||
<Box className={classes.card}> | ||
<Grid container> | ||
<Grid item> | ||
<Box sx={{ width: "266px" }}> | ||
<Typography variant="h6"> | ||
{t("label.congratulations-,")} | ||
</Typography> | ||
<Typography variant="h6"> | ||
{searchParams.get( | ||
QUERY_PARAM_KEY_ALERT_TYPE | ||
) === "create" | ||
? t("label.your-alert-has-been-created") | ||
: t( | ||
"label.your-alert-has-been-updated" | ||
)} | ||
</Typography> | ||
<Box sx={{ my: 2 }}> | ||
<Typography variant="subtitle2"> | ||
{t( | ||
"message.to-receive-notifications-configure" | ||
)} | ||
</Typography> | ||
</Box> | ||
</Box> | ||
</Grid> | ||
<Grid item> | ||
<Box> | ||
<img | ||
alt={t("label.configure-notifications")} | ||
src={Image} | ||
/> | ||
</Box> | ||
</Grid> | ||
<Grid item> | ||
<Box display="flex" gridGap={10}> | ||
<Button | ||
color="primary" | ||
href={getSubscriptionGroupsCreatePathWithAlertId( | ||
alertId | ||
)} | ||
size="small" | ||
startIcon={<ControlPointOutlinedIcon />} | ||
variant="contained" | ||
> | ||
{t("label.create-notifications")} | ||
</Button> | ||
<Button | ||
color="primary" | ||
href={getSubscriptionGroupsPath()} | ||
size="small" | ||
variant="outlined" | ||
> | ||
{t("label.explore-all-notifications")} | ||
</Button> | ||
</Box> | ||
</Grid> | ||
</Grid> | ||
</Box> | ||
</Modal> | ||
); | ||
}; |
Oops, something went wrong.