SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
chore: separate dashboard slider from dashboard provider + refactor (#10572)
Ashwin Bhatkal09b638282011
diff --git a/frontend/src/constants/queryBuilder.ts b/frontend/src/constants/queryBuilder.tsindex 5ba435229d..3761febe40 100644--- a/frontend/src/constants/queryBuilder.ts+++ b/frontend/src/constants/queryBuilder.ts@@ -1,5 +1,6 @@// ** Helpersimport { MetrictypesTypeDTO } from 'api/generated/services/sigNoz.schemas';+import { defaultTraceSelectedColumns } from 'container/OptionsMenu/constants';import { createIdFromObjectFields } from 'lib/createIdFromObjectFields';import { createNewBuilderItemName } from 'lib/newQueryBuilder/createNewBuilderItemName';import { IAttributeValuesResponse } from 'types/api/queryBuilder/getAttributesValues';@@ -548,3 +549,49 @@ export const DATA_TYPE_VS_ATTRIBUTE_VALUES_KEY: Record<[DataTypes.ArrayBool]: 'boolAttributeValues',[DataTypes.EMPTY]: 'stringAttributeValues',};++export const listViewInitialLogQuery: Query = {+ ...initialQueriesMap.logs,+ builder: {+ ...initialQueriesMap.logs.builder,+ queryData: [+ {+ ...initialQueriesMap.logs.builder.queryData[0],+ aggregateOperator: LogsAggregatorOperator.NOOP,+ orderBy: [{ columnName: 'timestamp', order: 'desc' }],+ offset: 0,+ pageSize: 100,+ },+ ],+ },+};++export const PANEL_TYPES_INITIAL_QUERY: Record<PANEL_TYPES, Query> = {+ [PANEL_TYPES.TIME_SERIES]: initialQueriesMap.metrics,+ [PANEL_TYPES.VALUE]: initialQueriesMap.metrics,+ [PANEL_TYPES.TABLE]: initialQueriesMap.metrics,+ [PANEL_TYPES.LIST]: listViewInitialLogQuery,+ [PANEL_TYPES.TRACE]: initialQueriesMap.traces,+ [PANEL_TYPES.BAR]: initialQueriesMap.metrics,+ [PANEL_TYPES.PIE]: initialQueriesMap.metrics,+ [PANEL_TYPES.HISTOGRAM]: initialQueriesMap.metrics,+ [PANEL_TYPES.EMPTY_WIDGET]: initialQueriesMap.metrics,+};++export const listViewInitialTraceQuery: Query = {+ // it should be the above commented query+ ...initialQueriesMap.traces,+ builder: {+ ...initialQueriesMap.traces.builder,+ queryData: [+ {+ ...initialQueriesMap.traces.builder.queryData[0],+ aggregateOperator: LogsAggregatorOperator.NOOP,+ orderBy: [{ columnName: 'timestamp', order: 'desc' }],+ offset: 0,+ pageSize: 10,+ selectColumns: defaultTraceSelectedColumns,+ },+ ],+ },+};diff --git a/frontend/src/container/DashboardContainer/ComponentsSlider/constants.ts b/frontend/src/container/DashboardContainer/ComponentsSlider/constants.tsdeleted file mode 100644index 1e16293a67..0000000000--- a/frontend/src/container/DashboardContainer/ComponentsSlider/constants.ts+++ /dev/null@@ -1,50 +0,0 @@-import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';-import { defaultTraceSelectedColumns } from 'container/OptionsMenu/constants';-import { Query } from 'types/api/queryBuilder/queryBuilderData';-import { LogsAggregatorOperator } from 'types/common/queryBuilder';--export const PANEL_TYPES_INITIAL_QUERY = {- [PANEL_TYPES.TIME_SERIES]: initialQueriesMap.metrics,- [PANEL_TYPES.VALUE]: initialQueriesMap.metrics,- [PANEL_TYPES.TABLE]: initialQueriesMap.metrics,- [PANEL_TYPES.LIST]: initialQueriesMap.logs,- [PANEL_TYPES.TRACE]: initialQueriesMap.traces,- [PANEL_TYPES.BAR]: initialQueriesMap.metrics,- [PANEL_TYPES.PIE]: initialQueriesMap.metrics,- [PANEL_TYPES.HISTOGRAM]: initialQueriesMap.metrics,- [PANEL_TYPES.EMPTY_WIDGET]: initialQueriesMap.metrics,-};--export const listViewInitialLogQuery: Query = {- ...initialQueriesMap.logs,- builder: {- ...initialQueriesMap.logs.builder,- queryData: [- {- ...initialQueriesMap.logs.builder.queryData[0],- aggregateOperator: LogsAggregatorOperator.NOOP,- orderBy: [{ columnName: 'timestamp', order: 'desc' }],- offset: 0,- pageSize: 100,- },- ],- },-};--export const listViewInitialTraceQuery: Query = {- // it should be the above commented query- ...initialQueriesMap.traces,- builder: {- ...initialQueriesMap.traces.builder,- queryData: [- {- ...initialQueriesMap.traces.builder.queryData[0],- aggregateOperator: LogsAggregatorOperator.NOOP,- orderBy: [{ columnName: 'timestamp', order: 'desc' }],- offset: 0,- pageSize: 10,- selectColumns: defaultTraceSelectedColumns,- },- ],- },-};diff --git a/frontend/src/container/DashboardContainer/ComponentsSlider/index.tsx b/frontend/src/container/DashboardContainer/ComponentsSlider/index.tsxdeleted file mode 100644index 32643a9eb2..0000000000--- a/frontend/src/container/DashboardContainer/ComponentsSlider/index.tsx+++ /dev/null@@ -1,94 +0,0 @@-import { Card, Modal } from 'antd';-import logEvent from 'api/common/logEvent';-import { QueryParams } from 'constants/query';-import { PANEL_TYPES } from 'constants/queryBuilder';-import createQueryParams from 'lib/createQueryParams';-import history from 'lib/history';-import { useDashboard } from 'providers/Dashboard/Dashboard';-import { LogsAggregatorOperator } from 'types/common/queryBuilder';-import { v4 as uuid } from 'uuid';--import { PANEL_TYPES_INITIAL_QUERY } from './constants';-import menuItems from './menuItems';-import { Text } from './styles';--import './ComponentSlider.styles.scss';--function DashboardGraphSlider(): JSX.Element {- const { handleToggleDashboardSlider, isDashboardSliderOpen } = useDashboard();-- const onClickHandler = (name: PANEL_TYPES) => (): void => {- const id = uuid();- handleToggleDashboardSlider(false);- logEvent('Dashboard Detail: New panel type selected', {- // dashboardId: '',- // dashboardName: '',- // numberOfPanels: 0, // todo - at this point we don't know these attributes- panelType: name,- widgetId: id,- });- const queryParamsLog = {- graphType: name,- widgetId: id,- [QueryParams.compositeQuery]: JSON.stringify({- ...PANEL_TYPES_INITIAL_QUERY[name],- builder: {- ...PANEL_TYPES_INITIAL_QUERY[name].builder,- queryData: [- {- ...PANEL_TYPES_INITIAL_QUERY[name].builder.queryData[0],- aggregateOperator: LogsAggregatorOperator.NOOP,- orderBy: [{ columnName: 'timestamp', order: 'desc' }],- offset: 0,- pageSize: 100,- },- ],- },- }),- };-- const queryParams = {- graphType: name,- widgetId: id,- [QueryParams.compositeQuery]: JSON.stringify(- PANEL_TYPES_INITIAL_QUERY[name],- ),- };- if (name === PANEL_TYPES.LIST) {- history.push(- `${history.location.pathname}/new?${createQueryParams(queryParamsLog)}`,- );- } else {- history.push(- `${history.location.pathname}/new?${createQueryParams(queryParams)}`,- );- }- };-- const handleCardClick = (panelType: PANEL_TYPES): void => {- onClickHandler(panelType)();- };-- return (- <Modal- open={isDashboardSliderOpen}- onCancel={(): void => {- handleToggleDashboardSlider(false);- }}- rootClassName="graph-selection"- footer={null}- title="New Panel"- >- <div className="panel-selection">- {menuItems.map(({ name, icon, display }) => (- <Card onClick={(): void => handleCardClick(name)} id={name} key={name}>- {icon}- <Text>{display}</Text>- </Card>- ))}- </div>- </Modal>- );-}--export default DashboardGraphSlider;diff --git a/frontend/src/container/DashboardContainer/ComponentsSlider/styles.ts b/frontend/src/container/DashboardContainer/ComponentsSlider/styles.tsdeleted file mode 100644index 171f4b563c..0000000000--- a/frontend/src/container/DashboardContainer/ComponentsSlider/styles.ts+++ /dev/null@@ -1,41 +0,0 @@-import { Card as CardComponent, Typography } from 'antd';-import styled from 'styled-components';--export const Container = styled.div`- display: flex;- justify-content: right;- gap: 8px;- margin-bottom: 12px;-`;--export const Card = styled(CardComponent)`- min-height: 80px;- min-width: 120px;- overflow-y: auto;- cursor: pointer;- transition: transform 0.2s;-- .ant-card-body {- padding: 12px;- height: 100%;- display: flex;- flex-direction: column;- justify-content: space-between;- align-items: center;-- .ant-typography {- font-size: 12px;- font-weight: 600;- }- }-- &:hover {- transform: scale(1.05);- border: 1px solid var(--bg-robin-400);- }-`;--export const Text = styled(Typography)`- text-align: center;- margin-top: 1rem;-`;diff --git a/frontend/src/container/DashboardContainer/DashboardDescription/__tests__/DashboardDescription.test.tsx b/frontend/src/container/DashboardContainer/DashboardDescription/__tests__/DashboardDescription.test.tsxindex 794c48b0a0..0d757f45ee 100644--- a/frontend/src/container/DashboardContainer/DashboardDescription/__tests__/DashboardDescription.test.tsx+++ b/frontend/src/container/DashboardContainer/DashboardDescription/__tests__/DashboardDescription.test.tsx@@ -182,9 +182,7 @@ describe('Dashboard landing page actions header tests', () => {(useLocation as jest.Mock).mockReturnValue(mockLocation);const mockContextValue: IDashboardContext = {- isDashboardSliderOpen: false,isDashboardLocked: false,- handleToggleDashboardSlider: jest.fn(),handleDashboardLockToggle: jest.fn(),dashboardResponse: {} as IDashboardContext['dashboardResponse'],selectedDashboard: (getDashboardById.data as unknown) as Dashboard,diff --git a/frontend/src/container/DashboardContainer/DashboardDescription/index.tsx b/frontend/src/container/DashboardContainer/DashboardDescription/index.tsxindex 2d3c60b260..822a130154 100644--- a/frontend/src/container/DashboardContainer/DashboardDescription/index.tsx+++ b/frontend/src/container/DashboardContainer/DashboardDescription/index.tsx@@ -40,6 +40,7 @@ import {} from 'lucide-react';import { useAppContext } from 'providers/App/App';import { useDashboard } from 'providers/Dashboard/Dashboard';+import { usePanelTypeSelectionModalStore } from 'providers/Dashboard/helpers/panelTypeSelectionModalHelper';import { sortLayout } from 'providers/Dashboard/util';import { DashboardData } from 'types/api/dashboard/getAll';import { Props } from 'types/api/dashboard/update';@@ -48,10 +49,10 @@ import { ComponentTypes } from 'utils/permission';import { v4 as uuid } from 'uuid';import DashboardHeader from '../components/DashboardHeader/DashboardHeader';-import DashboardGraphSlider from '../ComponentsSlider';import DashboardSettings from '../DashboardSettings';import { Base64Icons } from '../DashboardSettings/General/utils';import DashboardVariableSelection from '../DashboardVariablesSelection';+import PanelTypeSelectionModal from '../PanelTypeSelectionModal';import SettingsDrawer from './SettingsDrawer';import { VariablesSettingsTab } from './types';import {@@ -69,6 +70,9 @@ interface DashboardDescriptionProps {// eslint-disable-next-line sonarjs/cognitive-complexityfunction DashboardDescription(props: DashboardDescriptionProps): JSX.Element {const { handle } = props;+ const setIsPanelTypeSelectionModalOpen = usePanelTypeSelectionModalStore(+ (s) => s.setIsPanelTypeSelectionModalOpen,+ );const {selectedDashboard,panelMap,@@ -77,7 +81,6 @@ function DashboardDescription(props: DashboardDescriptionProps): JSX.Element {setLayouts,isDashboardLocked,setSelectedDashboard,- handleToggleDashboardSlider,handleDashboardLockToggle,} = useDashboard();@@ -145,14 +148,14 @@ function DashboardDescription(props: DashboardDescriptionProps): JSX.Element {const [addPanelPermission] = useComponentPermission(permissions, userRole);const onEmptyWidgetHandler = useCallback(() => {- handleToggleDashboardSlider(true);+ setIsPanelTypeSelectionModalOpen(true);logEvent('Dashboard Detail: Add new panel clicked', {dashboardId: selectedDashboard?.id,dashboardName: selectedDashboard?.data.title,numberOfPanels: selectedDashboard?.data.widgets?.length,});// eslint-disable-next-line react-hooks/exhaustive-deps- }, [handleToggleDashboardSlider]);+ }, [setIsPanelTypeSelectionModalOpen]);const handleLockDashboardToggle = (): void => {setIsDashbordSettingsOpen(false);@@ -521,7 +524,7 @@ function DashboardDescription(props: DashboardDescriptionProps): JSX.Element {<DashboardVariableSelection /></section>)}- <DashboardGraphSlider />+ <PanelTypeSelectionModal /><Modalopen={isRenameDashboardOpen}diff --git a/frontend/src/container/DashboardContainer/ComponentsSlider/ComponentSlider.styles.scss b/frontend/src/container/DashboardContainer/PanelTypeSelectionModal/PanelTypeSelectionModal.styles.scsssimilarity index 95%rename from frontend/src/container/DashboardContainer/ComponentsSlider/ComponentSlider.styles.scssrename to frontend/src/container/DashboardContainer/PanelTypeSelectionModal/PanelTypeSelectionModal.styles.scssindex 48f2a83ec8..58e168553f 100644--- a/frontend/src/container/DashboardContainer/ComponentsSlider/ComponentSlider.styles.scss+++ b/frontend/src/container/DashboardContainer/PanelTypeSelectionModal/PanelTypeSelectionModal.styles.scss@@ -1,4 +1,4 @@-.graph-selection {+.panel-type-selection-modal {.ant-modal-content {width: 515px;max-height: 646px;@@ -76,6 +76,11 @@content: none;}}++ .panel-type-text {+ text-align: center;+ margin-top: 1rem;+ }}}@@ -114,7 +119,7 @@}.lightMode {- .graph-selection {+ .panel-type-selection-modal {.ant-modal-content {border: 1px solid var(--bg-vanilla-300);background: var(--bg-vanilla-100);diff --git a/frontend/src/container/DashboardContainer/PanelTypeSelectionModal/index.tsx b/frontend/src/container/DashboardContainer/PanelTypeSelectionModal/index.tsxnew file mode 100644index 0000000000..f7e2ac2de0--- /dev/null+++ b/frontend/src/container/DashboardContainer/PanelTypeSelectionModal/index.tsx@@ -0,0 +1,68 @@+import { memo } from 'react';+import { Card, Modal, Typography } from 'antd';+import logEvent from 'api/common/logEvent';+import { QueryParams } from 'constants/query';+import { PANEL_TYPES, PANEL_TYPES_INITIAL_QUERY } from 'constants/queryBuilder';+import createQueryParams from 'lib/createQueryParams';+import history from 'lib/history';+import { usePanelTypeSelectionModalStore } from 'providers/Dashboard/helpers/panelTypeSelectionModalHelper';+import { v4 as uuid } from 'uuid';++import { PanelTypesWithData } from './menuItems';++import './PanelTypeSelectionModal.styles.scss';++function PanelTypeSelectionModal(): JSX.Element {+ const {+ isPanelTypeSelectionModalOpen,+ setIsPanelTypeSelectionModalOpen,+ } = usePanelTypeSelectionModalStore();++ const onClickHandler = (name: PANEL_TYPES) => (): void => {+ const id = uuid();+ setIsPanelTypeSelectionModalOpen(false);+ logEvent('Dashboard Detail: New panel type selected', {+ panelType: name,+ widgetId: id,+ });++ const queryParams = {+ graphType: name,+ widgetId: id,+ [QueryParams.compositeQuery]: JSON.stringify(+ PANEL_TYPES_INITIAL_QUERY[name],+ ),+ };++ history.push(+ `${history.location.pathname}/new?${createQueryParams(queryParams)}`,+ );+ };++ const handleCardClick = (panelType: PANEL_TYPES): void => {+ onClickHandler(panelType)();+ };++ return (+ <Modal+ open={isPanelTypeSelectionModalOpen}+ onCancel={(): void => {+ setIsPanelTypeSelectionModalOpen(false);+ }}+ rootClassName="panel-type-selection-modal"+ footer={null}+ title="New Panel"+ >+ <div className="panel-selection">+ {PanelTypesWithData.map(({ name, icon, display }) => (+ <Card onClick={(): void => handleCardClick(name)} id={name} key={name}>+ {icon}+ <Typography className="panel-type-text">{display}</Typography>+ </Card>+ ))}+ </div>+ </Modal>+ );+}++export default memo(PanelTypeSelectionModal);diff --git a/frontend/src/container/DashboardContainer/ComponentsSlider/menuItems.tsx b/frontend/src/container/DashboardContainer/PanelTypeSelectionModal/menuItems.tsxsimilarity index 95%rename from frontend/src/container/DashboardContainer/ComponentsSlider/menuItems.tsxrename to frontend/src/container/DashboardContainer/PanelTypeSelectionModal/menuItems.tsxindex db46c92272..f1fc475492 100644--- a/frontend/src/container/DashboardContainer/ComponentsSlider/menuItems.tsx+++ b/frontend/src/container/DashboardContainer/PanelTypeSelectionModal/menuItems.tsx@@ -9,7 +9,7 @@ import {Table,} from 'lucide-react';-const Items: ItemsProps[] = [+export const PanelTypesWithData: ItemsProps[] = [{name: PANEL_TYPES.TIME_SERIES,icon: <LineChart size={16} color={Color.BG_ROBIN_400} />,@@ -52,5 +52,3 @@ export interface ItemsProps {icon: JSX.Element;display: string;}--export default Items;diff --git a/frontend/src/container/GridCardLayout/DashboardEmptyState/DashboardEmptyState.tsx b/frontend/src/container/GridCardLayout/DashboardEmptyState/DashboardEmptyState.tsxindex 46415af904..6894625708 100644--- a/frontend/src/container/GridCardLayout/DashboardEmptyState/DashboardEmptyState.tsx+++ b/frontend/src/container/GridCardLayout/DashboardEmptyState/DashboardEmptyState.tsx@@ -9,17 +9,18 @@ import DashboardSettings from 'container/DashboardContainer/DashboardSettings';import useComponentPermission from 'hooks/useComponentPermission';import { useAppContext } from 'providers/App/App';import { useDashboard } from 'providers/Dashboard/Dashboard';+import { usePanelTypeSelectionModalStore } from 'providers/Dashboard/helpers/panelTypeSelectionModalHelper';import { ROLES, USER_ROLES } from 'types/roles';import { ComponentTypes } from 'utils/permission';import './DashboardEmptyState.styles.scss';export default function DashboardEmptyState(): JSX.Element {- const {- selectedDashboard,- isDashboardLocked,- handleToggleDashboardSlider,- } = useDashboard();+ const setIsPanelTypeSelectionModalOpen = usePanelTypeSelectionModalStore(+ (s) => s.setIsPanelTypeSelectionModalOpen,+ );++ const { selectedDashboard, isDashboardLocked } = useDashboard();const variablesSettingsTabHandle = useRef<VariablesSettingsTab>(null);const [isSettingsDrawerOpen, setIsSettingsDrawerOpen] = useState<boolean>(@@ -41,14 +42,14 @@ export default function DashboardEmptyState(): JSX.Element {const [addPanelPermission] = useComponentPermission(permissions, userRole);const onEmptyWidgetHandler = useCallback(() => {- handleToggleDashboardSlider(true);+ setIsPanelTypeSelectionModalOpen(true);logEvent('Dashboard Detail: Add new panel clicked', {dashboardId: selectedDashboard?.id,dashboardName: selectedDashboard?.data.title,numberOfPanels: selectedDashboard?.data.widgets?.length,});// eslint-disable-next-line react-hooks/exhaustive-deps- }, [handleToggleDashboardSlider]);+ }, [setIsPanelTypeSelectionModalOpen]);const onConfigureClick = useCallback((): void => {setIsSettingsDrawerOpen(true);diff --git a/frontend/src/container/GridCardLayout/GridCard/FullView/PanelTypeSelector.tsx b/frontend/src/container/GridCardLayout/GridCard/FullView/PanelTypeSelector.tsxindex 0b8507c4f5..efa045ba05 100644--- a/frontend/src/container/GridCardLayout/GridCard/FullView/PanelTypeSelector.tsx+++ b/frontend/src/container/GridCardLayout/GridCard/FullView/PanelTypeSelector.tsx@@ -2,7 +2,7 @@ import { useCallback } from 'react';import { Select, Typography } from 'antd';import { QueryParams } from 'constants/query';import { PANEL_TYPES } from 'constants/queryBuilder';-import GraphTypes from 'container/DashboardContainer/ComponentsSlider/menuItems';+import { PanelTypesWithData } from 'container/DashboardContainer/PanelTypeSelectionModal/menuItems';import { handleQueryChange } from 'container/NewWidget/utils';import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';import { Query } from 'types/api/queryBuilder/queryBuilderData';@@ -59,7 +59,7 @@ function PanelTypeSelector({data-testid="panel-change-select"disabled={disabled}>- {GraphTypes.map((item) => (+ {PanelTypesWithData.map((item) => (<Option key={item.name} value={item.name}><div className="view-panel-select-option"><div className="icon">{item.icon}</div>diff --git a/frontend/src/container/GridCardLayout/WidgetRow.tsx b/frontend/src/container/GridCardLayout/WidgetRow.tsxindex f6f9f350b5..5d7da07658 100644--- a/frontend/src/container/GridCardLayout/WidgetRow.tsx+++ b/frontend/src/container/GridCardLayout/WidgetRow.tsx@@ -5,6 +5,7 @@ import useComponentPermission from 'hooks/useComponentPermission';import { EllipsisIcon, PenLine, Plus, X } from 'lucide-react';import { useAppContext } from 'providers/App/App';import { useDashboard } from 'providers/Dashboard/Dashboard';+import { usePanelTypeSelectionModalStore } from 'providers/Dashboard/helpers/panelTypeSelectionModalHelper';import { setSelectedRowWidgetId } from 'providers/Dashboard/helpers/selectedRowWidgetIdHelper';import { ROLES, USER_ROLES } from 'types/roles';import { ComponentTypes } from 'utils/permission';@@ -34,11 +35,11 @@ export function WidgetRowHeader(props: WidgetRowHeaderProps): JSX.Element {} = props;const [isRowSettingsOpen, setIsRowSettingsOpen] = useState<boolean>(false);- const {- handleToggleDashboardSlider,- selectedDashboard,- isDashboardLocked,- } = useDashboard();+ const setIsPanelTypeSelectionModalOpen = usePanelTypeSelectionModalStore(+ (s) => s.setIsPanelTypeSelectionModalOpen,+ );++ const { selectedDashboard, isDashboardLocked } = useDashboard();const permissions: ComponentTypes[] = ['add_panel'];const { user } = useAppContext();@@ -87,7 +88,7 @@ export function WidgetRowHeader(props: WidgetRowHeaderProps): JSX.Element {}setSelectedRowWidgetId(selectedDashboard.id, id);- handleToggleDashboardSlider(true);+ setIsPanelTypeSelectionModalOpen(true);}}>New Paneldiff --git a/frontend/src/container/NewWidget/RightContainer/index.tsx b/frontend/src/container/NewWidget/RightContainer/index.tsxindex 00b9208bae..5625920e5e 100644--- a/frontend/src/container/NewWidget/RightContainer/index.tsx+++ b/frontend/src/container/NewWidget/RightContainer/index.tsx@@ -20,9 +20,10 @@ import {import { PrecisionOption, PrecisionOptionsEnum } from 'components/Graph/types';import TimePreference from 'components/TimePreferenceDropDown';import { PANEL_TYPES, PanelDisplay } from 'constants/queryBuilder';-import GraphTypes, {+import {ItemsProps,-} from 'container/DashboardContainer/ComponentsSlider/menuItems';+ PanelTypesWithData,+} from 'container/DashboardContainer/PanelTypeSelectionModal/menuItems';import { useDashboardVariables } from 'hooks/dashboard/useDashboardVariables';import useCreateAlerts from 'hooks/queryBuilder/useCreateAlerts';import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';@@ -150,7 +151,7 @@ function RightContainer({);const selectedGraphType =- GraphTypes.find((e) => e.name === selectedGraph)?.display || '';+ PanelTypesWithData.find((e) => e.name === selectedGraph)?.display || '';const onCreateAlertsHandler = useCreateAlerts(selectedWidget, 'panelView');@@ -176,7 +177,7 @@ function RightContainer({const { currentQuery } = useQueryBuilder();- const [graphTypes, setGraphTypes] = useState<ItemsProps[]>(GraphTypes);+ const [graphTypes, setGraphTypes] = useState<ItemsProps[]>(PanelTypesWithData);const dashboardVariableOptions = useMemo<VariableOption[]>(() => {return Object.entries(dashboardVariables).map(([, value]) => ({@@ -272,7 +273,7 @@ function RightContainer({prev.filter((graph) => graph.name !== PANEL_TYPES.LIST),);} else {- setGraphTypes(GraphTypes);+ setGraphTypes(PanelTypesWithData);}}, [currentQuery]);diff --git a/frontend/src/container/NewWidget/utils.ts b/frontend/src/container/NewWidget/utils.tsindex 4f64b24311..caf2672de6 100644--- a/frontend/src/container/NewWidget/utils.ts+++ b/frontend/src/container/NewWidget/utils.ts@@ -11,11 +11,8 @@ import { getYAxisCategories } from 'components/YAxisUnitSelector/utils';import {initialQueryBuilderFormValuesMap,PANEL_TYPES,-} from 'constants/queryBuilder';-import {- listViewInitialLogQuery,PANEL_TYPES_INITIAL_QUERY,-} from 'container/DashboardContainer/ComponentsSlider/constants';+} from 'constants/queryBuilder';import {defaultLogsSelectedColumns,defaultTraceSelectedColumns,@@ -549,10 +546,7 @@ export const getDefaultWidgetData = (nullZeroValues: '',opacity: '',panelTypes: name,- query:- name === PANEL_TYPES.LIST- ? listViewInitialLogQuery- : PANEL_TYPES_INITIAL_QUERY[name],+ query: PANEL_TYPES_INITIAL_QUERY[name],timePreferance: 'GLOBAL_TIME',softMax: null,softMin: null,diff --git a/frontend/src/hooks/queryBuilder/useQueryBuilderOperations.ts b/frontend/src/hooks/queryBuilder/useQueryBuilderOperations.tsindex b0f9fd369b..306d7ee877 100644--- a/frontend/src/hooks/queryBuilder/useQueryBuilderOperations.ts+++ b/frontend/src/hooks/queryBuilder/useQueryBuilderOperations.ts@@ -12,6 +12,8 @@ import {ATTRIBUTE_TYPES,initialAutocompleteData,initialQueryBuilderFormValuesMap,+ listViewInitialLogQuery,+ listViewInitialTraceQuery,mapOfFormulaToFilters,mapOfQueryFilters,PANEL_TYPES,@@ -23,10 +25,6 @@ import {metricsUnknownSpaceAggregateOperatorOptions,metricsUnknownTimeAggregateOperatorOptions,} from 'constants/queryBuilderOperators';-import {- listViewInitialLogQuery,- listViewInitialTraceQuery,-} from 'container/DashboardContainer/ComponentsSlider/constants';import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';import { getMetricsOperatorsByAttributeType } from 'lib/newQueryBuilder/getMetricsOperatorsByAttributeType';import { getOperatorsBySourceAndPanelType } from 'lib/newQueryBuilder/getOperatorsBySourceAndPanelType';diff --git a/frontend/src/providers/Dashboard/Dashboard.tsx b/frontend/src/providers/Dashboard/Dashboard.tsxindex b5175dccd7..33930dd654 100644--- a/frontend/src/providers/Dashboard/Dashboard.tsx+++ b/frontend/src/providers/Dashboard/Dashboard.tsx@@ -53,9 +53,7 @@ import { IDashboardContext, WidgetColumnWidths } from './types';import { sortLayout } from './util';export const DashboardContext = createContext<IDashboardContext>({- isDashboardSliderOpen: false,isDashboardLocked: false,- handleToggleDashboardSlider: () => {},handleDashboardLockToggle: () => {},dashboardResponse: {} as UseQueryResult<SuccessResponseV2<Dashboard>,@@ -82,8 +80,6 @@ export function DashboardProvider({children,dashboardId,}: PropsWithChildren<{ dashboardId: string }>): JSX.Element {- const [isDashboardSliderOpen, setIsDashboardSlider] = useState<boolean>(false);-const [isDashboardLocked, setIsDashboardLocked] = useState<boolean>(false);const [@@ -288,13 +284,8 @@ export function DashboardProvider({}}, [isVisible]);- const handleToggleDashboardSlider = (value: boolean): void => {- setIsDashboardSlider(value);- };-const { mutate: lockDashboard } = useMutation(locked, {onSuccess: (_, props) => {- setIsDashboardSlider(false);setIsDashboardLocked(props.lock);},onError: (error) => {@@ -319,9 +310,7 @@ export function DashboardProvider({const value: IDashboardContext = useMemo(() => ({- isDashboardSliderOpen,isDashboardLocked,- handleToggleDashboardSlider,handleDashboardLockToggle,dashboardResponse,selectedDashboard,@@ -341,7 +330,6 @@ export function DashboardProvider({}),// eslint-disable-next-line react-hooks/exhaustive-deps[- isDashboardSliderOpen,isDashboardLocked,dashboardResponse,selectedDashboard,diff --git a/frontend/src/providers/Dashboard/helpers/panelTypeSelectionModalHelper.ts b/frontend/src/providers/Dashboard/helpers/panelTypeSelectionModalHelper.tsnew file mode 100644index 0000000000..781d7a86e5--- /dev/null+++ b/frontend/src/providers/Dashboard/helpers/panelTypeSelectionModalHelper.ts@@ -0,0 +1,18 @@+import { create } from 'zustand';++interface IPanelTypeSelectionModalState {+ isPanelTypeSelectionModalOpen: boolean;+ setIsPanelTypeSelectionModalOpen: (isOpen: boolean) => void;+}++/**+ * This helper is used for selecting the panel type when creating a new panel in the dashboard.+ * It uses Zustand for state management to keep track of whether the panel type selection modal is open or closed.+ */+export const usePanelTypeSelectionModalStore = create<IPanelTypeSelectionModalState>(+ (set) => ({+ isPanelTypeSelectionModalOpen: false,+ setIsPanelTypeSelectionModalOpen: (isOpen): void =>+ set({ isPanelTypeSelectionModalOpen: isOpen }),+ }),+);diff --git a/frontend/src/providers/Dashboard/types.ts b/frontend/src/providers/Dashboard/types.tsindex ad21728caa..5dd1f3e67b 100644--- a/frontend/src/providers/Dashboard/types.ts+++ b/frontend/src/providers/Dashboard/types.ts@@ -9,9 +9,7 @@ export type WidgetColumnWidths = {};export interface IDashboardContext {- isDashboardSliderOpen: boolean;isDashboardLocked: boolean;- handleToggleDashboardSlider: (value: boolean) => void;handleDashboardLockToggle: (value: boolean) => void;dashboardResponse: UseQueryResult<SuccessResponseV2<Dashboard>, unknown>;selectedDashboard: Dashboard | undefined;