/* eslint-disable jsx-a11y/no-static-element-interactions */ /* eslint-disable jsx-a11y/click-events-have-key-events */ import './RightContainer.styles.scss'; import { Input, InputNumber, Select, Space, Switch, Typography } from 'antd'; import TimePreference from 'components/TimePreferenceDropDown'; import { PANEL_TYPES } from 'constants/queryBuilder'; import GraphTypes, { ItemsProps, } from 'container/NewDashboard/ComponentsSlider/menuItems'; import useCreateAlerts from 'hooks/queryBuilder/useCreateAlerts'; import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder'; import { ConciergeBell, Plus } from 'lucide-react'; import { Dispatch, SetStateAction, useCallback, useEffect, useState, } from 'react'; import { ColumnUnit, Widgets } from 'types/api/dashboard/getAll'; import { DataSource } from 'types/common/queryBuilder'; import { ColumnUnitSelector } from './ColumnUnitSelector/ColumnUnitSelector'; import { panelTypeVsBucketConfig, panelTypeVsColumnUnitPreferences, panelTypeVsCreateAlert, panelTypeVsFillSpan, panelTypeVsPanelTimePreferences, panelTypeVsSoftMinMax, panelTypeVsStackingChartPreferences, panelTypeVsThreshold, panelTypeVsYAxisUnit, } from './constants'; import ThresholdSelector from './Threshold/ThresholdSelector'; import { ThresholdProps } from './Threshold/types'; import { timePreferance } from './timeItems'; import YAxisUnitSelector from './YAxisUnitSelector'; const { TextArea } = Input; const { Option } = Select; function RightContainer({ description, setDescription, setTitle, title, selectedGraph, bucketCount, bucketWidth, stackedBarChart, setStackedBarChart, setBucketCount, setBucketWidth, setSelectedTime, selectedTime, yAxisUnit, setYAxisUnit, setGraphHandler, thresholds, combineHistogram, setCombineHistogram, setThresholds, selectedWidget, isFillSpans, setIsFillSpans, softMax, softMin, setSoftMax, setSoftMin, columnUnits, setColumnUnits, }: RightContainerProps): JSX.Element { const onChangeHandler = useCallback( (setFunc: Dispatch>, value: string) => { setFunc(value); }, [], ); const selectedGraphType = GraphTypes.find((e) => e.name === selectedGraph)?.display || ''; const onCreateAlertsHandler = useCreateAlerts(selectedWidget, 'panelView'); const allowThreshold = panelTypeVsThreshold[selectedGraph]; const allowSoftMinMax = panelTypeVsSoftMinMax[selectedGraph]; const allowFillSpans = panelTypeVsFillSpan[selectedGraph]; const allowYAxisUnit = panelTypeVsYAxisUnit[selectedGraph]; const allowCreateAlerts = panelTypeVsCreateAlert[selectedGraph]; const allowBucketConfig = panelTypeVsBucketConfig[selectedGraph]; const allowStackingBarChart = panelTypeVsStackingChartPreferences[selectedGraph]; const allowPanelTimePreference = panelTypeVsPanelTimePreferences[selectedGraph]; const allowPanelColumnPreference = panelTypeVsColumnUnitPreferences[selectedGraph]; const { currentQuery } = useQueryBuilder(); const [graphTypes, setGraphTypes] = useState(GraphTypes); useEffect(() => { const queryContainsMetricsDataSource = currentQuery.builder.queryData.some( (query) => query.dataSource === DataSource.METRICS, ); if (queryContainsMetricsDataSource) { setGraphTypes((prev) => prev.filter((graph) => graph.name !== PANEL_TYPES.LIST), ); } else { setGraphTypes(GraphTypes); } }, [currentQuery]); const softMinHandler = useCallback( (value: number | null) => { setSoftMin(value); }, [setSoftMin], ); const softMaxHandler = useCallback( (value: number | null) => { setSoftMax(value); }, [setSoftMax], ); return (
Panel details
Name onChangeHandler(setTitle, event.target.value)} value={title} rootClassName="name-input" /> Description