Skip to content

Commit

Permalink
Merge branch 'main' into ux-refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
SanthoshVasabhaktula authored Nov 13, 2024
2 parents 55f9cbc + 74b06a3 commit 470860e
Show file tree
Hide file tree
Showing 22 changed files with 280 additions and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ const Processing: React.FC = () => {
dialog={<AddPIIDialog />}
transformationOptions={transformationOptions}
addedSuggestions={piiSuggestions}
setPiiSuggestions={setPiiSuggestions}
data={_.map(_.get(processingData, 'pii'), (obj1) => {
const matchingObj = _.find(piiSuggestions, {
column: _.get(obj1, 'column')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const AddTransformationExpression = (props: any) => {
}, [data]);

const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setEvaluationData(transformationType)
setAnchorEl(event.currentTarget);
};

Expand All @@ -100,6 +101,13 @@ const AddTransformationExpression = (props: any) => {
};

const closeTransformations = () => {
setFormData((prevState: any) => ({
...prevState,
section: {
...prevState.section,
transformationType: ''
}
}));
setAnchorEl(null);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const AddNewField = (props: any) => {
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
const [evaluationData, setEvaluationData] = useState<string>('');
const [transformErrors, setTransformErrors] = useState<boolean>(false);
const [transformationError, setTransformationError] = useState<string | null>(null);
const [transformationTypeError, setTransformationTypeError] = useState<string | null>(null);

const open = Boolean(anchorEl);

Expand Down Expand Up @@ -74,6 +76,7 @@ const AddNewField = (props: any) => {
}, [data]);

const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setEvaluationData(transformationType)
setAnchorEl(event.currentTarget);
};

Expand All @@ -92,6 +95,13 @@ const AddNewField = (props: any) => {
};

const closeTransformations = () => {
setFormData((prevState: any) => ({
...prevState,
section: {
...prevState.section,
transformationType: ''
}
}));
setAnchorEl(null);
};

Expand Down Expand Up @@ -131,9 +141,6 @@ const AddNewField = (props: any) => {
onClose();
};

const [transformationError, setTransformationError] = useState<string | null>(null);
const [transformationTypeError, setTransformationTypeError] = useState<string | null>(null);

const transformation = _.get(formData, ['section', 'transformations']);
const transformationType = _.get(formData, ['section', 'transformationType']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ const AddPIIDialog = (props: any) => {

useEffect(() => {
const transformations = _.get(data, ['column'], '');

if (!_.isEmpty(data)) {
const existingData = {
section: {
transformations,
transformationType: _.get(data, ['transformationType']),
transformationMode: _.get(data, ['transformationMode'])
transformations: transformations,
transformationType: _.capitalize(_.get(data, ['transformationType'])),
transformationMode: _.capitalize(_.get(data, ['transformationMode']))
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const ProcessingSection = (props: any) => {
dialog,
transformationOptions,
jsonData,
addedSuggestions
addedSuggestions,
setPiiSuggestions
} = props;

const [dialogOpen, setDialogOpen] = useState(false);
Expand Down Expand Up @@ -180,43 +181,41 @@ const ProcessingSection = (props: any) => {
const renderSuggestedFields = () => {
const suggestedFields = _.differenceBy(addedSuggestions, data, 'column');

if (!_.isEmpty(suggestedFields))
const handleRemoveSuggestion = (suggestion: any) => {
setPiiSuggestions((prevSuggestions:any) =>
prevSuggestions.filter((item:any) => !_.isEqual(_.get(item, 'column'), _.get(suggestion, 'column')))
);
};

if (!_.isEmpty(suggestedFields))
return (
<Grid>
<Box sx={{ pt: 1, textAlign: 'start' }}>
<Typography variant="body2" fontWeight="500">
Add suggested fields :
</Typography>
</Box>
<Box
sx={{
textAlign: 'start',
overflowY: 'scroll',
scrollbarWidth: 'none',
height: '5rem',
mt: 2
}}
>
{_.map(suggestedFields, (ele: any) => (
<Chip
onDelete={() => {
addedSuggestions.filter(
(item: any) =>
!_.isEqual(
_.get(item, ['column']),
_.get(ele, ['column'])
)
);
}}
key={_.get(ele, ['column'])}
label={_.get(ele, ['column'])}
onClick={() => handleEditValues(ele)}
sx={{ ml: 1, mb: 1 }}
variant="outlined"
/>
))}
</Box>
</Grid>
<Grid>
<Box sx={{ pt: 1, textAlign: 'start' }}>
<Typography variant="body2" fontWeight="500">
Add suggested fields:
</Typography>
</Box>
<Box
sx={{
textAlign: 'start',
overflowY: 'scroll',
scrollbarWidth: 'none',
height: '5rem',
mt: 2
}}
>
{_.map(suggestedFields, (ele: any) => (
<Chip
onDelete={() => handleRemoveSuggestion(ele)}
key={_.get(ele, ['column'])}
label={_.get(ele, ['column'])}
onClick={() => handleEditValues(ele)}
sx={{ ml: 1, mb: 1 }}
variant="outlined"
/>
))}
</Box>
</Grid>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,15 @@ const NotificationComponent = (props: any) => {
/>
</Grid>
<Grid item xs={6}>
<Button variant="contained" onClick={() => navigate("/alertChannels")}>Create Notification Channel</Button>
<Button size="small" variant="outlined" sx={{
borderColor: 'primary.main',
color: 'primary.main',
'&:hover': {
backgroundColor: 'primary.main',
color: 'white',
borderColor: 'primary.main',
},
}} onClick={() => navigate("/alertChannels")}>Create Notification Channel</Button>
</Grid>
</Grid>
}
Expand All @@ -101,17 +109,15 @@ const NotificationComponent = (props: any) => {
There are no live notification channels yet. Please create/publish one to proceed further
</Typography>
<Box>
<StandardWidthButton
data-edataid={interactIds.add_notification_channel}
onClick={() => navigate('/alertChannels/new')}
variant="contained"
size="large"
sx={{ width: 'auto' }}
>
<Typography variant="button">
Create Notification Channel
</Typography>
</StandardWidthButton>
<Button size="small" variant="outlined" sx={{
borderColor: 'primary.main',
color: 'primary.main',
'&:hover': {
backgroundColor: 'primary.main',
color: 'white',
borderColor: 'primary.main',
},
}} data-edataid={interactIds.add_notification_channel} onClick={() => navigate("/alertChannels/new")}>Create Notification Channel</Button>
</Box>
</Stack>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,15 @@ const QueryBuilder = (props: any) => {
return (
<>
<Grid item xs={12}>
<Button disabled={!validQuery} startIcon={<PlayArrowOutlined />} variant="contained" onClick={(_) => updateRunQuery()}>
<Button size="small" sx={{
borderColor: 'primary.main',
color: 'primary.main',
'&:hover': {
backgroundColor: 'primary.main',
color: 'white',
borderColor: 'primary.main',
},
}} disabled={!validQuery} startIcon={<PlayArrowOutlined />} variant="outlined" onClick={(_) => updateRunQuery()}>
Run Query
</Button>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const QueryChart = ({ handleClose, open = false, context = {} }: any) => {
color="error"
sx={{ marginX: '0.5rem' }}
variant="contained"
size="small"
onClick={(e) => handleClose()}
>
Close
Expand Down
12 changes: 11 additions & 1 deletion web-console-v2/src/pages/alertManager/components/RuleLabels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,17 @@ const LabelComponent = (props: any) => {
{renderCreateLabelsForm()}
<Grid item xs={12}>
<Button
variant="contained"
size="small"
variant="outlined"
sx={{
borderColor: 'primary.main',
color: 'primary.main',
'&:hover': {
backgroundColor: 'primary.main',
color: 'white',
borderColor: 'primary.main',
},
}}
color="primary"
disabled={formErrors}
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,10 @@ const RuleHeader = (props: any) => {
if (!configuration?.allowedActions?.includes(button.name)) return null;
return (
<Button
size="small"
id={button.id}
key={button.name}
variant={button.variant}
variant="outlined"
startIcon={button.icon}
onClick={button.onClick}
color={button.color}
Expand Down
24 changes: 22 additions & 2 deletions web-console-v2/src/pages/alertManager/services/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ export const renderSections = (context: Record<string, any>) => {
<Stack direction="row" spacing={2}>
{context.actionHandler && context.actionLabel && (
<Button
variant="contained"
size="small"
variant="outlined"
sx={{
borderColor: 'primary.main',
color: 'primary.main',
'&:hover': {
backgroundColor: 'primary.main',
color: 'white',
borderColor: 'primary.main',
},
}}
disabled={
!validateForm(_.get(context.formData, 'error')) ||
!testChannel
Expand All @@ -45,7 +55,17 @@ export const renderSections = (context: Record<string, any>) => {
)}
{context.notificationTestHandler && (
<Button
variant="contained"
size="small"
variant="outlined"
sx={{
borderColor: 'primary.main',
color: 'primary.main',
'&:hover': {
backgroundColor: 'primary.main',
color: 'white',
borderColor: 'primary.main',
},
}}
disabled={!validateForm(_.get(context.formData, 'error'))}
onClick={(_) => context.notificationTestHandler()}
>
Expand Down
18 changes: 17 additions & 1 deletion web-console-v2/src/pages/alertManager/views/AddRule.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Grid } from '@mui/material';
import { Grid, Box, Button } from '@mui/material';
import _ from 'lodash';
import { useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';
Expand All @@ -12,6 +12,8 @@ import { useAlert } from 'contexts/AlertContextProvider';
import { validateForm } from '../services/queryBuilder';
import { transformRulePayload, renderSections } from '../services/utils';
import Loader from 'components/Loader';
import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace';
import { default as alertStyle} from '../views/Alert.module.css'

const AddAlertrules = () => {
const navigate = useNavigate();
Expand Down Expand Up @@ -89,7 +91,21 @@ const AddAlertrules = () => {
?
<Loader loading={loading} />
:
<>
<Box mx={4}>
<Button variant="back"
startIcon={
<KeyboardBackspaceIcon
className={alertStyle.backIcon}
/>
}
onClick={() => { navigate(`/alertRules/custom`) }}
>
Back
</Button>
</Box>
<Grid>{renderSections({ sections: sections, formData: formData, actionHandler: createAlertRule, actionLabel: "Create Rule" })}</Grid>
</>
}
</>
};
Expand Down
5 changes: 5 additions & 0 deletions web-console-v2/src/pages/alertManager/views/Alert.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.backIcon {
color: black;
width: 1.5rem;
height: 1.5rem;
}
2 changes: 1 addition & 1 deletion web-console-v2/src/pages/alertManager/views/AlertRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const AlertRules = () => {

const renderAlertRules = () => {
return (
<Grid container spacing={3}>
<Grid container spacing={3} sx={{width: '100%'}}>
<Grid item xs={12} id="tabSectionStart">
<Box sx={{ width: '100%', margin: '1rem' }}>
{renderTabs()}
Expand Down
Loading

0 comments on commit 470860e

Please sign in to comment.