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
feat: add support for role based access in trace funnels flows (#8481)
Shaheer Kochai629e50270346
diff --git a/frontend/src/components/SignozRadioGroup/SignozRadioGroup.styles.scss b/frontend/src/components/SignozRadioGroup/SignozRadioGroup.styles.scssindex 583ebec234..5c2a7b56f9 100644--- a/frontend/src/components/SignozRadioGroup/SignozRadioGroup.styles.scss+++ b/frontend/src/components/SignozRadioGroup/SignozRadioGroup.styles.scss@@ -1,6 +1,12 @@.signoz-radio-group.ant-radio-group {color: var(--text-vanilla-400);+ &.ant-radio-group-disabled {+ opacity: 0.5;+ pointer-events: none;+ cursor: not-allowed;+ }+.view-title {display: flex;gap: var(--margin-2);@@ -37,6 +43,22 @@// Light mode styles.lightMode {.signoz-radio-group {+ &.ant-radio-group-disabled {+ .tab,+ .selected_view {+ background: var(--bg-vanilla-200) !important;+ border-color: var(--bg-vanilla-400) !important;+ color: var(--text-ink-400) !important;+ }++ .tab:hover,+ .selected_view:hover {+ background: var(--bg-vanilla-200) !important;+ border-color: var(--bg-vanilla-400) !important;+ color: var(--text-ink-400) !important;+ }+ }+.tab {background: var(--bg-vanilla-100);}diff --git a/frontend/src/components/SignozRadioGroup/SignozRadioGroup.tsx b/frontend/src/components/SignozRadioGroup/SignozRadioGroup.tsxindex 71a1f255e2..3bb789e774 100644--- a/frontend/src/components/SignozRadioGroup/SignozRadioGroup.tsx+++ b/frontend/src/components/SignozRadioGroup/SignozRadioGroup.tsx@@ -13,6 +13,7 @@ interface SignozRadioGroupProps {options: Option[];onChange: (e: RadioChangeEvent) => void;className?: string;+ disabled?: boolean;}function SignozRadioGroup({@@ -20,6 +21,7 @@ function SignozRadioGroup({options,onChange,className = '',+ disabled = false,}: SignozRadioGroupProps): JSX.Element {return (<Radio.Group@@ -27,6 +29,7 @@ function SignozRadioGroup({buttonStyle="solid"className={`signoz-radio-group ${className}`}onChange={onChange}+ disabled={disabled}>{options.map((option) => (<Radio.Button@@ -43,6 +46,7 @@ function SignozRadioGroup({SignozRadioGroup.defaultProps = {className: '',+ disabled: false,};export default SignozRadioGroup;diff --git a/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/Success.tsx b/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/Success.tsxindex e9977a4e2b..5e8d536d62 100644--- a/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/Success.tsx+++ b/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/Success.tsx@@ -22,6 +22,7 @@ import {ChevronRight,Leaf,} from 'lucide-react';+import { useAppContext } from 'providers/App/App';import {Dispatch,SetStateAction,@@ -70,10 +71,10 @@ function SpanOverview({handleCollapseUncollapse: (id: string, collapse: boolean) => void;selectedSpan: Span | undefined;setSelectedSpan: Dispatch<SetStateAction<Span | undefined>>;-handleAddSpanToFunnel: (span: Span) => void;}): JSX.Element {const isRootSpan = span.level === 0;+ const { hasEditPermission } = useAppContext();let color = generateColor(span.serviceName, themeColors.traceDetailColors);if (span.hasError) {@@ -152,23 +153,32 @@ function SpanOverview({{!!span.serviceName && !!span.name && (<div className="add-funnel-button"><span className="add-funnel-button__separator">·</span>- <Button- type="text"- size="small"- className="add-funnel-button__button"- onClick={(e): void => {- e.preventDefault();- e.stopPropagation();- handleAddSpanToFunnel(span);- }}- icon={- <img- className="add-funnel-button__icon"- src="/Icons/funnel-add.svg"- alt="funnel-icon"- />+ <Tooltip+ title={+ !hasEditPermission+ ? 'You need editor or admin access to add spans to funnels'+ : ''}- />+ >+ <Button+ type="text"+ size="small"+ className="add-funnel-button__button"+ onClick={(e): void => {+ e.preventDefault();+ e.stopPropagation();+ handleAddSpanToFunnel(span);+ }}+ disabled={!hasEditPermission}+ icon={+ <img+ className="add-funnel-button__icon"+ src="/Icons/funnel-add.svg"+ alt="funnel-icon"+ />+ }+ />+ </Tooltip></div>)}</section>diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration.tsx b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration.tsxindex 799e53dda7..824de35b03 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration.tsx+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration.tsx@@ -8,6 +8,7 @@ import { PencilLine } from 'lucide-react';import FunnelItemPopover from 'pages/TracesFunnels/components/FunnelsList/FunnelItemPopover';import { useFunnelContext } from 'pages/TracesFunnels/FunnelContext';import CopyToClipboard from 'periscope/components/CopyToClipboard';+import { useAppContext } from 'providers/App/App';import { memo, useState } from 'react';import { Span } from 'types/api/trace/getTraceV2';import { FunnelData } from 'types/api/traceFunnels';@@ -33,6 +34,7 @@ function FunnelConfiguration({triggerAutoSave,showNotifications,}: FunnelConfigurationProps): JSX.Element {+ const { hasEditPermission } = useAppContext();const { triggerSave } = useFunnelContext();const {isPopoverOpen,@@ -62,7 +64,10 @@ function FunnelConfiguration({<div className="funnel-configuration__header-right"><Tooltiptitle={- funnel?.description+ // eslint-disable-next-line no-nested-ternary+ !hasEditPermission+ ? 'You need editor or admin access to edit funnel description'+ : funnel?.description? 'Edit funnel description': 'Add funnel description'}@@ -73,6 +78,7 @@ function FunnelConfiguration({icon={<PencilLine size={14} />}onClick={(): void => setIsDescriptionModalOpen(true)}aria-label="Edit Funnel Description"+ disabled={!hasEditPermission}/></Tooltip><CopyToClipboard textToCopy={window.location.href} />diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.styles.scss b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.styles.scssindex fe54b9ca80..2e5315a6b3 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.styles.scss+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.styles.scss@@ -10,6 +10,37 @@border: 1px solid var(--bg-slate-500);border-radius: 6px;width: 100%;++ &--readonly {+ opacity: 0.7;++ .filters {+ pointer-events: none;+ .ant-select-selector {+ cursor: not-allowed;+ }++ .ant-select {+ cursor: not-allowed;+ }++ .query-builder-search-v2 {+ .ant-select-selector {+ cursor: not-allowed;+ }++ .ant-select {+ cursor: not-allowed;+ }+ }+ }++ .error__switch {+ opacity: 0.5;+ cursor: not-allowed;+ }+ }+.step-popover {opacity: 0;width: 22px;diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.tsx b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.tsxindex f7eb60ae08..9788baf527 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.tsx+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.tsx@@ -1,12 +1,14 @@import './FunnelStep.styles.scss';import { Button, Divider, Form, Switch, Tooltip } from 'antd';+import cx from 'classnames';import { FilterSelect } from 'components/CeleryOverview/CeleryOverviewConfigOptions/CeleryOverviewConfigOptions';import { QueryParams } from 'constants/query';import { initialQueriesMap } from 'constants/queryBuilder';import QueryBuilderSearchV2 from 'container/QueryBuilder/filters/QueryBuilderSearchV2/QueryBuilderSearchV2';import { HardHat, PencilLine } from 'lucide-react';import { useFunnelContext } from 'pages/TracesFunnels/FunnelContext';+import { useAppContext } from 'providers/App/App';import { useMemo, useState } from 'react';import { FunnelStepData } from 'types/api/traceFunnels';import { DataSource } from 'types/common/queryBuilder';@@ -69,8 +71,14 @@ function FunnelStep({const query = updatedCurrentQuery?.builder?.queryData[0] || null;+ const { hasEditPermission } = useAppContext();+return (- <div className="funnel-step">+ <div+ className={cx('funnel-step', {+ 'funnel-step--readonly': !hasEditPermission,+ })}+ ><Form form={form}><div className="funnel-step__header"><div className="funnel-step-details">@@ -92,12 +100,19 @@ function FunnelStep({)}</div><div className="funnel-step-actions">- <Tooltip title="Add details to step">+ <Tooltip+ title={+ !hasEditPermission+ ? 'You need editor or admin access to add details to step'+ : 'Add details to step'+ }+ ><Buttontype="text"className="funnel-item__action-btn"icon={<PencilLine size={14} />}onClick={(): void => setIsAddDetailsModalOpen(true)}+ disabled={!hasEditPermission}/></Tooltip>@@ -129,9 +144,13 @@ function FunnelStep({shouldSetQueryParams={false}values={stepData.service_name}isMultiple={false}- onChange={(v): void => {- onStepChange(index, { service_name: (v ?? '') as string });- }}+ onChange={+ hasEditPermission+ ? (v): void => {+ onStepChange(index, { service_name: (v ?? '') as string });+ }+ : undefined+ }/></Form.Item></div>@@ -144,8 +163,11 @@ function FunnelStep({shouldSetQueryParams={false}values={stepData.span_name}isMultiple={false}- onChange={(v): void =>- onStepChange(index, { span_name: (v ?? '') as string })+ onChange={+ hasEditPermission+ ? (v): void =>+ onStepChange(index, { span_name: (v ?? '') as string })+ : undefined}/></Form.Item>@@ -156,7 +178,11 @@ function FunnelStep({<Form.Item name={['steps', stepData.id, 'filters']}><QueryBuilderSearchV2query={query}- onChange={(query): void => onStepChange(index, { filters: query })}+ onChange={+ hasEditPermission+ ? (query): void => onStepChange(index, { filters: query })+ : (): void => {}+ }hasPopupContainer={false}placeholder="Search for filters..."suffixIcon={<HardHat size={12} color="var(--bg-vanilla-400)" />}@@ -172,6 +198,7 @@ function FunnelStep({className="error__switch"size="small"checked={stepData.has_errors}+ disabled={!hasEditPermission}onChange={(): void =>onStepChange(index, { has_errors: !stepData.has_errors })}diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStepPopover.tsx b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStepPopover.tsxindex 7ddbd17569..6684a58064 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStepPopover.tsx+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStepPopover.tsx@@ -1,6 +1,7 @@import { Button, Popover, Tooltip } from 'antd';import cx from 'classnames';import { Ellipsis, PencilLine, Trash2 } from 'lucide-react';+import { useAppContext } from 'providers/App/App';import { useState } from 'react';import { FunnelStepData } from 'types/api/traceFunnels';@@ -27,6 +28,7 @@ interface FunnelStepActionsProps {setIsAddDetailsModalOpen: (isOpen: boolean) => void;setIsDeleteModalOpen: (isOpen: boolean) => void;stepsCount: number;+ hasEditPermission: boolean;}function FunnelStepActions({@@ -34,6 +36,7 @@ function FunnelStepActions({setIsAddDetailsModalOpen,setIsDeleteModalOpen,stepsCount,+ hasEditPermission,}: FunnelStepActionsProps): JSX.Element {return (<div className="funnel-item__actions">@@ -41,6 +44,7 @@ function FunnelStepActions({type="text"className="funnel-item__action-btn"icon={<PencilLine size={14} />}+ disabled={!hasEditPermission}onClick={(): void => {setIsPopoverOpen(false);setIsAddDetailsModalOpen(true);@@ -49,12 +53,21 @@ function FunnelStepActions({Add details</Button>- <Tooltip title={stepsCount <= 2 ? 'Minimum 2 steps required' : 'Delete'}>+ <Tooltip+ title={+ // eslint-disable-next-line no-nested-ternary+ !hasEditPermission+ ? 'You need editor or admin access to delete steps'+ : stepsCount <= 2+ ? 'Minimum 2 steps required'+ : 'Delete'+ }+ ><Buttontype="text"className="funnel-item__action-btn funnel-item__action-btn--delete"icon={<Trash2 size={14} />}- disabled={stepsCount <= 2}+ disabled={stepsCount <= 2 || !hasEditPermission}onClick={(): void => {if (stepsCount > 2) {setIsPopoverOpen(false);@@ -80,12 +93,26 @@ function FunnelStepPopover({setIsAddDetailsModalOpen,}: FunnelStepPopoverProps): JSX.Element {const [isDeleteModalOpen, setIsDeleteModalOpen] = useState<boolean>(false);+ const { hasEditPermission } = useAppContext();const preventDefault = (e: React.MouseEvent | React.KeyboardEvent): void => {e.preventDefault();e.stopPropagation();};+ if (!hasEditPermission) {+ return (+ <Tooltip title="You need editor or admin access to add details to step">+ <Button+ type="text"+ className="funnel-item__action-btn"+ icon={<Ellipsis size={14} />}+ disabled+ />+ </Tooltip>+ );+ }+return (// eslint-disable-next-line jsx-a11y/click-events-have-key-events<div onClick={preventDefault} role="button" tabIndex={0}>@@ -100,6 +127,7 @@ function FunnelStepPopover({setIsPopoverOpen={setIsPopoverOpen}setIsAddDetailsModalOpen={setIsAddDetailsModalOpen}stepsCount={stepsCount}+ hasEditPermission={hasEditPermission}/>}placement="bottomRight"diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/InterStepConfig.tsx b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/InterStepConfig.tsxindex 6490a1f1b9..6ab676d0dc 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/InterStepConfig.tsx+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/InterStepConfig.tsx@@ -3,6 +3,7 @@ import './InterStepConfig.styles.scss';import { Divider } from 'antd';import SignozRadioGroup from 'components/SignozRadioGroup/SignozRadioGroup';import { useFunnelContext } from 'pages/TracesFunnels/FunnelContext';+import { useAppContext } from 'providers/App/App';import { FunnelStepData, LatencyOptions } from 'types/api/traceFunnels';function InterStepConfig({@@ -13,6 +14,7 @@ function InterStepConfig({step: FunnelStepData;}): JSX.Element {const { handleStepChange: onStepChange } = useFunnelContext();+ const { hasEditPermission } = useAppContext();const options = Object.entries(LatencyOptions).map(([key, value]) => ({label: key,value,@@ -28,11 +30,15 @@ function InterStepConfig({<SignozRadioGroupvalue={step.latency_type ?? LatencyOptions.P99}options={options}- onChange={(e): void =>- onStepChange(index, {- ...step,- latency_type: e.target.value,- })+ disabled={!hasEditPermission}+ onChange={+ hasEditPermission+ ? (e): void =>+ onStepChange(index, {+ ...step,+ latency_type: e.target.value,+ })+ : (): void => {}}/></div>diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsContent.tsx b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsContent.tsxindex cd72c44eb1..aa78dcce7d 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsContent.tsx+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsContent.tsx@@ -1,9 +1,10 @@import './StepsContent.styles.scss';-import { Button, Steps } from 'antd';+import { Button, Steps, Tooltip } from 'antd';import logEvent from 'api/common/logEvent';import { PlusIcon, Undo2 } from 'lucide-react';import { useFunnelContext } from 'pages/TracesFunnels/FunnelContext';+import { useAppContext } from 'providers/App/App';import { memo, useCallback } from 'react';import { Span } from 'types/api/trace/getTraceV2';@@ -20,9 +21,10 @@ function StepsContent({span?: Span;}): JSX.Element {const { steps, handleAddStep, handleReplaceStep } = useFunnelContext();+ const { hasEditPermission } = useAppContext();const handleAddForNewStep = useCallback(() => {- if (!span) return;+ if (!span || !hasEditPermission) return;const stepWasAdded = handleAddStep();if (stepWasAdded) {@@ -32,7 +34,7 @@ function StepsContent({'Trace Funnels: span added for a new step from trace details page',{},);- }, [span, handleAddStep, handleReplaceStep, steps.length]);+ }, [span, handleAddStep, handleReplaceStep, steps.length, hasEditPermission]);return (<div className="steps-content">@@ -45,20 +47,29 @@ function StepsContent({<div className="funnel-step-wrapper"><FunnelStep stepData={step} index={index} stepsCount={steps.length} />{isTraceDetailsPage && span && (- <Button- type="default"- className="funnel-step-wrapper__replace-button"- icon={<Undo2 size={12} />}- disabled={- step.service_name === span.serviceName &&- step.span_name === span.name- }- onClick={(): void =>- handleReplaceStep(index, span.serviceName, span.name)+ <Tooltip+ title={+ !hasEditPermission+ ? 'You need editor or admin access to replace steps'+ : ''}>- Replace- </Button>+ <Button+ type="default"+ className="funnel-step-wrapper__replace-button"+ icon={<Undo2 size={12} />}+ disabled={+ (step.service_name === span.serviceName &&+ step.span_name === span.name) ||+ !hasEditPermission+ }+ onClick={(): void =>+ handleReplaceStep(index, span.serviceName, span.name)+ }+ >+ Replace+ </Button>+ </Tooltip>)}</div>{/* Display InterStepConfig only between steps */}@@ -76,23 +87,41 @@ function StepsContent({className="steps-content__add-step"description={!isTraceDetailsPage ? (- <Button- type="default"- className="steps-content__add-btn"- onClick={handleAddStep}- icon={<PlusIcon size={14} />}+ <Tooltip+ title={+ !hasEditPermission+ ? 'You need editor or admin access to add steps'+ : ''+ }>- Add Funnel Step- </Button>+ <Button+ type="default"+ className="steps-content__add-btn"+ onClick={handleAddStep}+ icon={<PlusIcon size={14} />}+ disabled={!hasEditPermission}+ >+ Add Funnel Step+ </Button>+ </Tooltip>) : (- <Button- type="default"- className="steps-content__add-btn"- onClick={handleAddForNewStep}- icon={<PlusIcon size={14} />}+ <Tooltip+ title={+ !hasEditPermission+ ? 'You need editor or admin access to add steps'+ : ''+ }>- Add for new Step- </Button>+ <Button+ type="default"+ className="steps-content__add-btn"+ onClick={handleAddForNewStep}+ icon={<PlusIcon size={14} />}+ disabled={!hasEditPermission}+ >+ Add for new Step+ </Button>+ </Tooltip>)}/>diff --git a/frontend/src/pages/TracesFunnels/components/FunnelsEmptyState/FunnelsEmptyState.tsx b/frontend/src/pages/TracesFunnels/components/FunnelsEmptyState/FunnelsEmptyState.tsxindex f6a50ab892..78bf63f802 100644--- a/frontend/src/pages/TracesFunnels/components/FunnelsEmptyState/FunnelsEmptyState.tsx+++ b/frontend/src/pages/TracesFunnels/components/FunnelsEmptyState/FunnelsEmptyState.tsx@@ -3,6 +3,7 @@ import './FunnelsEmptyState.styles.scss';import { Button } from 'antd';import LearnMore from 'components/LearnMore/LearnMore';import { Plus } from 'lucide-react';+import { useAppContext } from 'providers/App/App';interface FunnelsEmptyStateProps {onCreateFunnel?: () => void;@@ -11,6 +12,8 @@ interface FunnelsEmptyStateProps {function FunnelsEmptyState({onCreateFunnel,}: FunnelsEmptyStateProps): JSX.Element {+ const { hasEditPermission } = useAppContext();+return (<div className="funnels-empty"><div className="funnels-empty__content">@@ -29,14 +32,16 @@ function FunnelsEmptyState({</section><div className="funnels-empty__actions">- <Button- type="primary"- icon={<Plus size={16} />}- onClick={onCreateFunnel}- className="funnels-empty__new-btn"- >- New funnel- </Button>+ {hasEditPermission && (+ <Button+ type="primary"+ icon={<Plus size={16} />}+ onClick={onCreateFunnel}+ className="funnels-empty__new-btn"+ >+ New funnel+ </Button>+ )}<LearnMore url="https://signoz.io/blog/tracing-funnels-observability-distributed-systems/" /></div></div>diff --git a/frontend/src/pages/TracesFunnels/components/FunnelsList/FunnelItemPopover.tsx b/frontend/src/pages/TracesFunnels/components/FunnelsList/FunnelItemPopover.tsxindex 2fbc21b172..2da9a99fcd 100644--- a/frontend/src/pages/TracesFunnels/components/FunnelsList/FunnelItemPopover.tsx+++ b/frontend/src/pages/TracesFunnels/components/FunnelsList/FunnelItemPopover.tsx@@ -1,6 +1,7 @@-import { Button, Popover } from 'antd';+import { Button, Popover, Tooltip } from 'antd';import cx from 'classnames';import { Ellipsis, PencilLine, Trash2 } from 'lucide-react';+import { useAppContext } from 'providers/App/App';import { useState } from 'react';import { FunnelData } from 'types/api/traceFunnels';@@ -61,6 +62,7 @@ function FunnelItemPopover({}: FunnelItemPopoverProps): JSX.Element {const [isRenameModalOpen, setIsRenameModalOpen] = useState<boolean>(false);const [isDeleteModalOpen, setIsDeleteModalOpen] = useState<boolean>(false);+ const { hasEditPermission } = useAppContext();const handleRenameCancel = (): void => {setIsRenameModalOpen(false);@@ -71,6 +73,19 @@ function FunnelItemPopover({e.stopPropagation();};+ if (!hasEditPermission) {+ return (+ <Tooltip title="You need editor or admin access to edit funnels">+ <Button+ type="text"+ className="funnel-item__action-btn"+ icon={<Ellipsis size={14} />}+ disabled+ />+ </Tooltip>+ );+ }+return (// eslint-disable-next-line jsx-a11y/click-events-have-key-events<divdiff --git a/frontend/src/pages/TracesFunnels/components/SearchBar/SearchBar.tsx b/frontend/src/pages/TracesFunnels/components/SearchBar/SearchBar.tsxindex cd4a544b1a..dd93a985c6 100644--- a/frontend/src/pages/TracesFunnels/components/SearchBar/SearchBar.tsx+++ b/frontend/src/pages/TracesFunnels/components/SearchBar/SearchBar.tsx@@ -1,6 +1,7 @@import { Color } from '@signozhq/design-tokens';-import { Button, Input, Popover, Typography } from 'antd';+import { Button, Input, Popover, Tooltip, Typography } from 'antd';import { ArrowDownWideNarrow, Check, Plus, Search } from 'lucide-react';+import { useAppContext } from 'providers/App/App';import { ChangeEvent } from 'react';interface SearchBarProps {@@ -21,6 +22,8 @@ function SearchBar({onSort,onCreateFunnel,}: SearchBarProps): JSX.Element {+ const { hasEditPermission } = useAppContext();+return (<div className="search"><Popover@@ -70,14 +73,23 @@ function SearchBar({value={searchQuery}onChange={onSearch}/>- <Button- type="primary"- icon={<Plus size={16} />}- className="search__new-btn"- onClick={onCreateFunnel}+ <Tooltip+ title={+ !hasEditPermission+ ? 'You need editor or admin access to create funnels'+ : ''+ }>- New funnel- </Button>+ <Button+ type="primary"+ icon={<Plus size={16} />}+ className="search__new-btn"+ onClick={onCreateFunnel}+ disabled={!hasEditPermission}+ >+ New funnel+ </Button>+ </Tooltip></div>);}diff --git a/frontend/src/providers/App/App.tsx b/frontend/src/providers/App/App.tsxindex 786d2c40c3..9b01f1a5bf 100644--- a/frontend/src/providers/App/App.tsx+++ b/frontend/src/providers/App/App.tsx@@ -321,6 +321,8 @@ export function AppProvider({ children }: PropsWithChildren): JSX.Element {updateChangelog,toggleChangelogModal,versionData: versionData?.payload || null,+ hasEditPermission:+ user?.role === USER_ROLES.ADMIN || user?.role === USER_ROLES.EDITOR,}),[trialInfo,diff --git a/frontend/src/providers/App/types.ts b/frontend/src/providers/App/types.tsindex 6518cd8b4e..40fdd1ac50 100644--- a/frontend/src/providers/App/types.ts+++ b/frontend/src/providers/App/types.ts@@ -37,6 +37,7 @@ export interface IAppContext {updateChangelog(payload: ChangelogSchema): void;toggleChangelogModal(): void;versionData: PayloadProps | null;+ hasEditPermission: boolean;}// Userdiff --git a/frontend/src/tests/test-utils.tsx b/frontend/src/tests/test-utils.tsxindex aa56772cb4..687c6b7e1b 100644--- a/frontend/src/tests/test-utils.tsx+++ b/frontend/src/tests/test-utils.tsx@@ -22,7 +22,7 @@ import {LicenseState,LicenseStatus,} from 'types/api/licensesV3/getActive';-import { ROLES } from 'types/roles';+import { ROLES, USER_ROLES } from 'types/roles';const queryClient = new QueryClient({defaultOptions: {@@ -162,6 +162,7 @@ export function getAppContextMock(displayName: 'Pentagon',},],+ hasEditPermission: role === USER_ROLES.ADMIN || role === USER_ROLES.EDITOR,isFetchingUser: false,userFetchError: null,featureFlags: [