Skip to content

Commit

Permalink
Merge pull request #56 from Sanketika-Obsrv/main
Browse files Browse the repository at this point in the history
Main to Eneterprise feature
  • Loading branch information
manjudr authored Nov 5, 2024
2 parents 5768aa8 + c7ee14e commit 1e2f1e2
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 43 deletions.
12 changes: 6 additions & 6 deletions web-console-v2/src/components/EditDataset/EditDataset.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as yup from 'yup';
import en from '../../utils/locales/en.json';
import * as _ from 'lodash';
import { hasSpacesInField, hasSpecialCharacters, invalidNewFieldRegex } from '../../services/utils';
import { hasSpacesInField, hasSpecialCharacters, invalidNewFieldRegex, validFieldName, nameRegex } from '../../services/utils';
import { validFormatTypes } from 'pages/StepsPages/Ingestion/SchemaDetails/SchemaDetails';
export const filterForObjectArrivalFormat = (data: any[]) => {
const result: any[] = [];
Expand Down Expand Up @@ -75,8 +75,7 @@ export const inputFields = (
);

const arrivalTypeOptions = arrivalType.length <= 0 ? defaultDatatypeOptions : arrivalType;
const nameRegex = /^[^!@#$%^&()+{}[]:;<>,?~\|]$/;


return [
{
title: 'EditLiveDatasetInputs',
Expand Down Expand Up @@ -112,10 +111,11 @@ export const inputFields = (
)
.test('spaceInField', en.containsSpaces, (value) =>
hasSpacesInField(value)
).max(100, en.maxLen)
)
.max(100, en.maxLen)
.min(4, en.minLen)
.test('validCharacters', "The field should exclude any special characters, permitting only '.', '-', '_', alphabets, numbers", (value) =>
nameRegex.test(value)
.test('validCharacters', "The field should exclude any special characters, permitting only alphabets, numbers, '.', '-', '_'", (value: any) =>
validFieldName(value, nameRegex)
)
}
]
Expand Down
19 changes: 17 additions & 2 deletions web-console-v2/src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import logoIcon from 'assets/images/obsrv-logo.svg';
import { getBaseURL, getConfigValueV1 } from 'services/configData';
import { errorInterceptor, responseInterceptor } from 'services/http';
import { addHttpRequestsInterceptor } from 'services/http';
import { routeConfigurations } from 'router';

const OBSRV_WEB_CONSOLE = process.env.REACT_APP_OBSRV_WEB_CONSOLE as string || "/home/dashboard";

Expand Down Expand Up @@ -56,6 +57,17 @@ function BasicBreadcrumbs(): JSX.Element {
};
if(openNotification || _.isNull(alerts)) fetchAlerts();
}, [openNotification]);

const findRoute = (routes: any, path: string) => {
for (const route of routes) {
if (route.path === path) return route;
if (route.children) {
const childRoute = route.children.find((childData: { path: any; }) => `${route.path}/${childData.path}` === path);
if (childRoute) return { ...childRoute, path };
}
}
return null;
}

return (pathname !== '/login' ? (
<Grid container className={styles.navMain} role="presentation" alignItems="center">
Expand All @@ -66,11 +78,14 @@ function BasicBreadcrumbs(): JSX.Element {
</Grid>
<Grid item xs={9.5} className={styles.breadcrumb}>
<Breadcrumbs aria-label="breadcrumb">
{pathnames.map((name, index) => {
{
pathnames.map((name, index) => {
const routeTo = `/${pathnames.slice(0, index + 1).join('/')}`;
const matchedRoute = findRoute(routeConfigurations, routeTo);
const isLast = index === pathnames.length - 1;
// Capitalize first letter apart from datasetId
const displayName = isLast ? name : _.capitalize(name);
// const displayName = isLast ? name : _.capitalize(name);
const displayName = matchedRoute?.label !== undefined ? matchedRoute.label : name;
return isLast ? (
<Typography
variant="body1"
Expand Down
2 changes: 1 addition & 1 deletion web-console-v2/src/components/Sidebar/SidebarElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const SidebarElements = () => {
},
{
id: 'api',
color: theme.palette.secondary.main,
color: theme.palette.error.main,
title: 'API',
route: '/home/dashboard/api'
},
Expand Down
3 changes: 2 additions & 1 deletion web-console-v2/src/pages/NewDataset/NewDataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Grid, Typography, Box, Button } from '@mui/material';
import { useNavigate } from 'react-router-dom';
import { t } from 'utils/i18n';
import { getBaseURL } from 'services/configData';
import datasetImg from 'assets/images/DatasetLaunch.svg';

const NewDataset: React.FC = () => {
const navigate = useNavigate();
Expand Down Expand Up @@ -48,7 +49,7 @@ const NewDataset: React.FC = () => {
<img
height="70%"
width="80%"
src={`${getBaseURL()}/images/DatasetLaunch.svg`}
src={datasetImg}
alt="Please check your connection"
className={styles.image}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const mapDatasetToProcessingData = (dataset: any) => {
return processingData;
};

const keyMapping: any = {
export const keyMapping: any = {
validation: 'validation_config',
transformations: 'transformations_config',
dedup: 'dedup_config',
Expand Down Expand Up @@ -255,6 +255,7 @@ const Processing: React.FC = () => {
component: (
<div onClick={() => handleDatasetNameClick('section1')}>
<DataValidation
datasetData={datasetData}
data={_.get(processingData, 'validation')}
handleAddOrEdit={(data: any) => {
const validation = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import DataValidationForm from 'components/Form/DynamicForm';
import schema from './Schema';
import { RJSFSchema, UiSchema } from '@rjsf/utils';
import _ from 'lodash';
import { setAdditionalProperties } from 'services/json-schema';
import { useUpdateDataset } from 'services/dataset';
import { keyMapping } from '../../Processing';

interface FormData {
[key: string]: unknown;
Expand All @@ -23,7 +26,7 @@ interface ConfigureConnectorFormProps {
}

const DataValidation = (props: any) => {
const { data, handleAddOrEdit } = props;
const { data, handleAddOrEdit, datasetData } = props;

const [, setFormErrors] = useState<any>(null);
const [formData, setFormData] = useState<{ [key: string]: unknown }>({});
Expand All @@ -38,9 +41,11 @@ const DataValidation = (props: any) => {

};

setAdditionalProperties(_.get(datasetData, ['data_schema']), data?.mode);
handleAddOrEdit(data?.mode, 'validation');
setFormData(existingData);
}
}, [data]);
}, [data.mode]);

const handleChange: ConfigureConnectorFormProps['onChange'] = (formData, errors) => {
setFormData(formData);
Expand Down
11 changes: 3 additions & 8 deletions web-console-v2/src/pages/dashboardV1/datasets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ const ClusterHealth = () => {
onClick: () => navigate(`/home/new-dataset`),
icon: <PlusOutlined />,
disabled: false
}, {
id: "add-master-dataset",
label: <FormattedMessage id="dataset-actions-add-master-dataset" />,
onClick: () => navigate(`/home/new-dataset`),
icon: <PlusOutlined />,
disabled: false
}]

const renderDatasetTables = () => {
Expand Down Expand Up @@ -148,7 +142,8 @@ const ClusterHealth = () => {
label={<Tooltip title={tooltip}>
<Box alignItems={"center"} display={"flex"}>
<FiberManualRecordIcon color={color as any} sx={{ fontSize: '1.25rem', mr: 1 }} />
<Typography variant='body1' fontWeight={500}>{label}</Typography>
<Typography variant={datasetType === id ? 'button' : 'body1'}
fontWeight={500}>{label}</Typography>
</Box>
</Tooltip>} value={id} />
}
Expand Down Expand Up @@ -181,7 +176,7 @@ const ClusterHealth = () => {
onClose={handleClose}
/>
</Box>

)
};

Expand Down
46 changes: 24 additions & 22 deletions web-console-v2/src/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,54 +34,56 @@ import RollupConfig from 'pages/Rollup/components';
interface RouteConfig {
path: string;
element: React.ReactElement;
label?: string;
children?: RouteConfig[];
}
const CustomAlerts = lazy(() => import('pages/alertManager/views/CustomRules'));
// Base path for all routes
const BASE_PATH = '/home';

const routeConfigurations: RouteConfig[] = [
{ path: '/', element: <Navigate to={`${BASE_PATH}/dashboard`} replace /> },
{ path: `${BASE_PATH}`, element: <Navigate to={`${BASE_PATH}`} replace /> },
{ path: `${BASE_PATH}/new-dataset`, element: <NewDatasetPage /> },
export const routeConfigurations: RouteConfig[] = [
{ path: '/', label: "Dashboard", element: <Navigate to={`${BASE_PATH}/dashboard`} replace /> },
{ path: `${BASE_PATH}`, label: "Home", element: <Navigate to={`${BASE_PATH}`} replace /> },
{ path: `${BASE_PATH}/new-dataset`, label: "New Dataset", element: <NewDatasetPage /> },
{
path: `${BASE_PATH}`,
element: <StepperPage />,
children: [
{ path: 'ingestion', element: <IngestionPage /> },
{ path: 'ingestion', label: "Ingestion", element: <IngestionPage /> },
{ path: 'ingestion/schema-details/:datasetId', element: <SchemaDetailsPage /> },
{ path: 'processing/:datasetId', element: <ProcessingPage /> },
{ path: 'storage/:datasetId', element: <StoragePage /> },
{ path: 'preview/:datasetId', element: <PreviewPage /> }
],
},
{ path: `${BASE_PATH}/new-dataset/connector-configuration`, element: <ConnectorConfigurationPage /> },
{ path: `${BASE_PATH}/new-dataset/connector-list`, element: <SelectConnectorPage /> },
{ path: `${BASE_PATH}/dashboard`, element: <Dashboard /> },
{ path: `${BASE_PATH}/dashboard/infrastructure`, element: <IndividualMetricDashboards id="overallInfra" /> },
{ path: `${BASE_PATH}/dashboard/ingestion`, element: <IndividualMetricDashboards id="ingestion" /> },
{ path: `${BASE_PATH}/dashboard/api`, element: <IndividualMetricDashboards id="api" /> },
{ path: `${BASE_PATH}/dashboard/processing`, element: <IndividualMetricDashboards id="processing" /> },
{ path: `${BASE_PATH}/dashboard/storage`, element: <IndividualMetricDashboards id="storage" /> },
{ path: `${BASE_PATH}/connector-management`, element: <ConnectorConfigurationPage /> },
{ path: `${BASE_PATH}/connector-management/manage`, element: <ManageConnectorsPage /> },
{ path: `${BASE_PATH}/settings`, element: <SettingsPage /> },
{ path: `${BASE_PATH}/new-dataset/connector-configuration`, label: `Connector Configuration`, element: <ConnectorConfigurationPage /> },
{ path: `${BASE_PATH}/new-dataset/connector-list`, label: "Connector List", element: <SelectConnectorPage /> },
{ path: `${BASE_PATH}/dashboard`, label: "Dashboard" ,element: <Dashboard /> },
{ path: `${BASE_PATH}/dashboard/infrastructure`, label: "Infrastructure", element: <IndividualMetricDashboards id="overallInfra" /> },
{ path: `${BASE_PATH}/dashboard/ingestion`, label: "Ingestion", element: <IndividualMetricDashboards id="ingestion" /> },
{ path: `${BASE_PATH}/dashboard/api`, label: "API", element: <IndividualMetricDashboards id="api" /> },
{ path: `${BASE_PATH}/dashboard/processing`, label: "Processing", element: <IndividualMetricDashboards id="processing" /> },
{ path: `${BASE_PATH}/dashboard/storage`, label: "Storage", element: <IndividualMetricDashboards id="storage" /> },
{ path: `${BASE_PATH}/connector-management`, label: "Connector Management", element: <ConnectorConfigurationPage /> },
{ path: `${BASE_PATH}/connector-management/manage`, label: "Manage", element: <ManageConnectorsPage /> },
{ path: `${BASE_PATH}/settings`, label: "Settings", element: <SettingsPage /> },
{
path: `${BASE_PATH}/alertRules`,
label: "Alert Rules",
element: <AlertRules />,
children: [
{ path: 'custom', element: <CustomAlerts /> },
{ path: 'system', element: <SystemAlerts /> }
{ path: 'custom', label: "Custom", element: <CustomAlerts /> },
{ path: 'system', label: "System", element: <SystemAlerts /> }
],
},
{ path: `${BASE_PATH}/alertRules/add`, element: <AddAlert /> },
{ path: `${BASE_PATH}/alertRules/add`, label: "Add", element: <AddAlert /> },
{ path: `${BASE_PATH}/alertRules/view/:id`, element: <ViewAlert /> },
{ path: `${BASE_PATH}/alertRules/edit/:id`, element: <EditAlert /> },
{ path: `${BASE_PATH}/alertChannels`, element: <ListChannels /> },
{ path: `${BASE_PATH}/alertChannels/new`, element: <AddChannel /> },
{ path: `${BASE_PATH}/alertChannels`, label: "Alert Channels", element: <ListChannels /> },
{ path: `${BASE_PATH}/alertChannels/new`, label: "New", element: <AddChannel /> },
{ path: `${BASE_PATH}/alertChannels/edit/:id`, element: <UpdateChannel /> },
{ path: `${BASE_PATH}/alertChannels/view/:id`, element: <ViewChannel /> },
{ path: `${BASE_PATH}/datasets`, element: <ClusterHealth /> },
{ path: `${BASE_PATH}/datasets`, label: "Datasets", element: <ClusterHealth /> },
{ path: `${BASE_PATH}/datasets/:datasetId`, element: <DatasetMetrics /> },
{ path: `${BASE_PATH}/datasets/addEvents/:datasetId`, element: <DatasetCreateEvents /> },
{ path: `${BASE_PATH}/datasets/rollups/:datasetId`, element: <RollupConfig />},
Expand Down
10 changes: 10 additions & 0 deletions web-console-v2/src/services/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const spaceValidationRegEx = /(\s)/;

export const invalidNewFieldRegex = /^(?![!@#$%^&*()_ +=\-[\]{};':"\\|,.<>/?`~]+$).*/;

export const nameRegex = /^[a-zA-Z0-9._-]+$/;

export const hasSpacesInField = (
value: string | undefined,
regex: RegExp = spaceValidationRegEx
Expand All @@ -23,6 +25,14 @@ export const hasSpacesInField = (
return !regex.test(value);
};

export const validFieldName = (
value: string | undefined,
regex: RegExp = nameRegex
) => {
if (!value || !regex) return false;
return regex.test(value);
};

export const validateFormValues = async (form: React.MutableRefObject<any>, value: Record<string, any>) => {
let validationStatus = true;
if (form.current) {
Expand Down

0 comments on commit 1e2f1e2

Please sign in to comment.