Compare commits

..

2 Commits

Author SHA1 Message Date
Vinícius Lourenço
2b73b58acc feat(select-combobox): migrate to signozhq/ui/select and signozhq/ui/combobox 2026-05-22 15:58:57 -03:00
Gaurav Tewari
f2a18e8b6c fix(trace-details): make back button reliably return to previous in-app page (#11414)
Some checks failed
build-staging / prepare (push) Has been cancelled
build-staging / js-build (push) Has been cancelled
build-staging / go-build (push) Has been cancelled
build-staging / staging (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
* fix: back button issue

* chore: add unit test

* fix : test cases

---------

Co-authored-by: Gaurav Tewari <tewarig@users.noreply.github.com>
2026-05-22 16:13:26 +00:00
283 changed files with 2971 additions and 10030 deletions

View File

@@ -19,6 +19,8 @@ const BANNED_COMPONENTS = {
Switch: 'Use @signozhq/ui/switch Switch instead of antd Switch.',
Badge: 'Use @signozhq/ui/badge instead of antd Badge.',
Progress: 'Use @signozhq/ui/progress instead of antd Progress.',
Select:
'Use SelectSimple / ComboboxSimple from @signozhq/ui/select or @signozhq/ui/combobox instead of antd Select.',
};
export default {

View File

@@ -4,7 +4,7 @@
"no_alerts_found": "No alerts found during the evaluation. This happens when rule condition is unsatisfied. You may adjust the rule threshold and retry.",
"button_testrule": "Test Notification",
"label_channel_select": "Notification Channels",
"placeholder_channel_select": "select one or more channels",
"placeholder_channel_select": "Select one or more channels",
"channel_select_tooltip": "Leave empty to send this alert on all the configured channels",
"preview_chart_unexpected_error": "An unexpeced error occurred updating the chart, please check your query.",
"preview_chart_threshold_label": "Threshold",

View File

@@ -4,7 +4,7 @@
"no_alerts_found": "No alerts found during the evaluation. This happens when rule condition is unsatisfied. You may adjust the rule threshold and retry.",
"button_testrule": "Test Notification",
"label_channel_select": "Notification Channels",
"placeholder_channel_select": "select one or more channels",
"placeholder_channel_select": "Select one or more channels",
"channel_select_tooltip": "Leave empty to send this alert on all the configured channels",
"preview_chart_unexpected_error": "An unexpeced error occurred updating the chart, please check your query.",
"preview_chart_threshold_label": "Threshold",

View File

@@ -1,12 +1,12 @@
import { useCallback, useMemo, useState } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { Row, Select, Spin } from 'antd';
import { Row } from 'antd';
import { ComboboxSimple, ComboboxSimpleItem } from '@signozhq/ui/combobox';
import {
getValuesFromQueryParams,
setQueryParamsFromOptions,
} from 'components/CeleryTask/CeleryUtils';
import { useCeleryFilterOptions } from 'components/CeleryTask/useCeleryFilterOptions';
import { SelectMaxTagPlaceholder } from 'components/MessagingQueues/MQCommon/MQCommon';
import { QueryParams } from 'constants/query';
import useUrlQuery from 'hooks/useUrlQuery';
@@ -48,7 +48,7 @@ export function FilterSelect({
: getValuesFromQueryParams(queryParam, urlQuery) || [];
// Memoize options to include the typed value if not present
const mergedOptions = useMemo(() => {
const mergedOptions = useMemo<ComboboxSimpleItem[]>(() => {
if (
!!searchValue.trim().length &&
!options.some((opt) => opt.value === searchValue)
@@ -84,35 +84,16 @@ export function FilterSelect({
],
);
// Update searchValue on user input
const handleSearchInput = (input: string): void => {
setSearchValue(input);
handleSearch(input);
};
return (
<Select
<ComboboxSimple
key={filterType.toString()}
placeholder={placeholder}
showSearch
{...(isMultiple ? { mode: 'multiple' } : {})}
options={mergedOptions}
multiple={isMultiple}
items={mergedOptions}
loading={isFetching}
className="config-select-option"
onSearch={handleSearchInput}
maxTagCount={4}
allowClear
maxTagPlaceholder={SelectMaxTagPlaceholder}
value={selectValue}
notFoundContent={
isFetching ? (
<span>
<Spin size="small" /> Loading...
</span>
) : (
<span>No {placeholder} found</span>
)
}
emptyPlaceholder={`No ${placeholder} found`}
onChange={handleSelectChange}
/>
);

View File

@@ -1,7 +1,6 @@
import { useHistory, useLocation } from 'react-router-dom';
import { Select, Spin } from 'antd';
import { ComboboxSimple } from '@signozhq/ui/combobox';
import { Typography } from '@signozhq/ui/typography';
import { SelectMaxTagPlaceholder } from 'components/MessagingQueues/MQCommon/MQCommon';
import { QueryParams } from 'constants/query';
import useUrlQuery from 'hooks/useUrlQuery';
@@ -27,30 +26,18 @@ function CeleryTaskConfigOptions(): JSX.Element {
<Typography.Text style={{ whiteSpace: 'nowrap' }}>
Task Name
</Typography.Text>
<Select
<ComboboxSimple
placeholder="Task Name"
showSearch
mode="multiple"
options={options}
multiple
items={options}
loading={isFetching}
className="config-select-option"
onSearch={handleSearch}
maxTagCount={4}
maxTagPlaceholder={SelectMaxTagPlaceholder}
value={getValuesFromQueryParams(QueryParams.taskName, urlQuery) || []}
notFoundContent={
isFetching ? (
<span>
<Spin size="small" /> Loading...
</span>
) : (
<span>No Task Name found</span>
)
}
emptyPlaceholder="No Task Name found"
onChange={(value): void => {
handleSearch('');
setQueryParamsFromOptions(
value,
value as string[],
urlQuery,
history,
location,

View File

@@ -1,7 +1,7 @@
import { useQuery } from 'react-query';
// eslint-disable-next-line no-restricted-imports
import { useSelector } from 'react-redux';
import type { DefaultOptionType } from 'antd/es/select';
import type { ComboboxSimpleItem } from '@signozhq/ui/combobox';
import { getAttributesValues } from 'api/queryBuilder/getAttributesValues';
import { DATA_TYPE_VS_ATTRIBUTE_VALUES_KEY } from 'constants/queryBuilder';
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
@@ -21,7 +21,7 @@ export interface Filters {
}
export interface GetAllFiltersResponse {
options: DefaultOptionType[];
options: ComboboxSimpleItem[];
isFetching: boolean;
}

View File

@@ -1,5 +1,5 @@
import { useState } from 'react';
import type { DefaultOptionType } from 'antd/es/select';
import type { ComboboxSimpleItem } from '@signozhq/ui/combobox';
import useDebouncedFn from 'hooks/useDebouncedFunction';
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
import { DataSource } from 'types/common/queryBuilder';
@@ -17,7 +17,7 @@ export const useCeleryFilterOptions = (
searchText: string;
handleSearch: (value: string) => void;
isFetching: boolean;
options: DefaultOptionType[];
options: ComboboxSimpleItem[];
} => {
const [searchText, setSearchText] = useState<string>('');
const { isFetching, options } = useGetAllFilters({

View File

@@ -5,17 +5,25 @@ import {
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import { Color } from '@signozhq/design-tokens';
import { Select, Tag, Tooltip } from 'antd';
import {
Combobox,
ComboboxCommand,
ComboboxContent,
ComboboxEmpty,
ComboboxItem,
ComboboxList,
ComboboxMultiTrigger,
ComboboxPill,
} from '@signozhq/ui/combobox';
import { Tag, Tooltip } from 'antd';
import {
OPERATORS,
QUERY_BUILDER_OPERATORS_BY_TYPES,
QUERY_BUILDER_SEARCH_VALUES,
} from 'constants/queryBuilder';
import { CustomTagProps } from 'container/QueryBuilder/filters/QueryBuilderSearch';
import { selectStyle } from 'container/QueryBuilder/filters/QueryBuilderSearch/config';
import { PLACEHOLDER } from 'container/QueryBuilder/filters/QueryBuilderSearch/constant';
import { TypographyText } from 'container/QueryBuilder/filters/QueryBuilderSearch/style';
@@ -38,7 +46,6 @@ import { operatorTypeMapper } from 'hooks/queryBuilder/useOperatorType';
import { useIsDarkMode } from 'hooks/useDarkMode';
import { isArray, isEmpty, isEqual, isObject } from 'lodash-es';
import { ChevronDown, ChevronUp } from '@signozhq/icons';
import type { BaseSelectRef } from 'rc-select';
import {
BaseAutocompleteData,
DataTypes,
@@ -47,7 +54,6 @@ import {
IBuilderQuery,
TagFilter,
} from 'types/api/queryBuilder/queryBuilderData';
import { popupContainer } from 'utils/selectPopupContainer';
import { v4 as uuid } from 'uuid';
import './ClientSideQBSearch.styles.scss';
@@ -93,8 +99,6 @@ function ClientSideQBSearch(
const isDarkMode = useIsDarkMode();
const selectRef = useRef<BaseSelectRef>(null);
const [isOpen, setIsOpen] = useState<boolean>(false);
// create the tags from the initial query here, this should only be computed on the first load as post that tags and query will be always in sync.
@@ -214,7 +218,7 @@ function ClientSideQBSearch(
}, []);
const onInputKeyDownHandler = useCallback(
(event: KeyboardEvent<Element>): void => {
(event: KeyboardEvent<HTMLInputElement>): void => {
if (event.key === 'Backspace' && !searchValue) {
event.stopPropagation();
setTags((prev) => prev.slice(0, -1));
@@ -516,29 +520,23 @@ function ClientSideQBSearch(
[tags],
);
const onTagRender = ({
value,
closable,
onClose,
}: CustomTagProps): React.ReactElement => {
const renderPill = (value: string, index: number): React.ReactElement => {
const { tagOperator } = getTagToken(value);
const isInNin = isInNInOperator(tagOperator);
const chipValue = isInNin
? value?.trim()?.replace(/,\s*$/, '')
: value?.trim();
const indexInQueryTags = queryTags.findIndex((qTag) => isEqual(qTag, value));
const tagDetails = tags[indexInQueryTags];
const tagDetails = tags[index];
const onCloseHandler = (): void => {
onClose();
setSearchValue('');
setTags((prev) => prev.filter((t) => !isEqual(t, tagDetails)));
};
const tagEditHandler = (value: string): void => {
const tagEditHandler = (next: string): void => {
setCurrentFilterItem(tagDetails);
setSearchValue(value);
setSearchValue(next);
setCurrentState(DropdownState.ATTRIBUTE_VALUE);
setTags((prev) => prev.filter((t) => !isEqual(t, tagDetails)));
};
@@ -546,12 +544,13 @@ function ClientSideQBSearch(
const isDisabled = !!searchValue;
return (
<span className="qb-search-bar-tokenised-tags">
<Tag
closable={!searchValue && closable}
onClose={onCloseHandler}
className={tagDetails?.key?.type || ''}
>
<ComboboxPill
key={`${value}-${index}`}
value={value}
onRemove={onCloseHandler}
className="qb-search-bar-tokenised-tags"
>
<Tag closable={false} className={tagDetails?.key?.type || ''}>
<Tooltip title={chipValue}>
<TypographyText
$isInNin={isInNin}
@@ -567,7 +566,7 @@ function ClientSideQBSearch(
</TypographyText>
</Tooltip>
</Tag>
</span>
</ComboboxPill>
);
};
@@ -588,59 +587,73 @@ function ClientSideQBSearch(
);
}, [isDarkMode, isOpen, suffixIcon]);
const handleItemSelect = (rawValue: string): void => {
handleDropdownSelect(rawValue);
setIsOpen(true);
};
const handleInputKeyDownWrapper = (
e: KeyboardEvent<HTMLInputElement>,
): void => {
onInputKeyDownHandler(e);
};
return (
<div className="query-builder-search-v2 ">
<Select
ref={selectRef}
getPopupContainer={popupContainer}
virtual={false}
showSearch
tagRender={onTagRender}
transitionName=""
choiceTransitionName=""
filterOption={false}
open={isOpen}
suffixIcon={suffixIconContent}
onDropdownVisibleChange={setIsOpen}
autoClearSearchValue={false}
mode="multiple"
placeholder={placeholder}
value={queryTags}
searchValue={searchValue}
className={className}
rootClassName="query-builder-search client-side-qb-search"
disabled={!attributeKeys.length}
style={selectStyle}
onSearch={handleSearch}
onSelect={handleDropdownSelect}
onInputKeyDown={onInputKeyDownHandler}
notFoundContent={null}
showAction={['focus']}
onBlur={handleOnBlur}
>
{dropdownOptions.map((option) => {
let val = option.value;
try {
if (isObject(option.value)) {
val = JSON.stringify(option.value);
} else {
val = option.value;
}
} catch {
val = option.value;
}
return (
<Select.Option key={isObject(val) ? `select-option` : val} value={val}>
<Suggestions
label={option.label}
value={option.value}
option={currentState}
searchValue={searchValue}
/>
</Select.Option>
);
})}
</Select>
<div className="query-builder-search-v2" style={selectStyle}>
<Combobox open={isOpen} onOpenChange={setIsOpen}>
<ComboboxMultiTrigger
id="client-side-qb-search-trigger"
testId="client-side-qb-search"
className={className ?? 'query-builder-search client-side-qb-search'}
placeholder={placeholder ?? PLACEHOLDER}
inputValue={searchValue}
onInputChange={handleSearch}
onKeyDown={handleInputKeyDownWrapper}
onFocus={(): void => setIsOpen(true)}
disabled={!attributeKeys.length}
>
{queryTags.map((tagValue, idx) => renderPill(tagValue, idx))}
</ComboboxMultiTrigger>
<ComboboxContent
onCloseAutoFocus={(): void => {
handleOnBlur();
}}
>
<ComboboxCommand shouldFilter={false}>
<ComboboxList>
{dropdownOptions.map((option) => {
let val = option.value as unknown as string;
try {
if (isObject(option.value)) {
val = JSON.stringify(option.value);
}
} catch {
val = String(option.value);
}
const itemKey = isObject(val) ? `select-option` : String(val);
return (
<ComboboxItem
key={itemKey}
value={String(val)}
onSelect={(): void => handleItemSelect(String(val))}
>
<Suggestions
label={option.label}
value={option.value}
option={currentState}
searchValue={searchValue}
/>
</ComboboxItem>
);
})}
<ComboboxEmpty>No results found.</ComboboxEmpty>
</ComboboxList>
</ComboboxCommand>
</ComboboxContent>
</Combobox>
<div className="qb-search-suffix" aria-hidden>
{suffixIconContent}
</div>
</div>
);
}

View File

@@ -1,15 +1,7 @@
import { useState } from 'react';
import { useMemo, useState } from 'react';
import { useCopyToClipboard } from 'react-use';
import {
Button,
Col,
Dropdown,
MenuProps,
Popover,
Row,
Select,
Space,
} from 'antd';
import { Button, Col, Dropdown, MenuProps, Popover, Row, Space } from 'antd';
import { ComboboxSimple } from '@signozhq/ui/combobox';
import { Typography } from '@signozhq/ui/typography';
import axios from 'axios';
import TextToolTip from 'components/TextToolTip';
@@ -31,11 +23,7 @@ import { popupContainer } from 'utils/selectPopupContainer';
import { ExploreHeaderToolTip, SaveButtonText } from './constants';
import MenuItemGenerator from './MenuItemGenerator';
import SaveViewWithName from './SaveViewWithName';
import {
DropDownOverlay,
ExplorerCardHeadContainer,
OffSetCol,
} from './styles';
import { ExplorerCardHeadContainer, OffSetCol } from './styles';
import { ExplorerCardProps } from './types';
import { deleteViewHandler } from './utils';
import { Ellipsis, Save, Share2, Trash2 } from '@signozhq/icons';
@@ -164,6 +152,26 @@ function ExplorerCard({
const showSaveView = false;
const viewItems = useMemo(
() =>
(viewsData?.data.data ?? []).map((view) => ({
value: view.name,
label: (
<MenuItemGenerator
viewName={view.name}
viewKey={viewKey}
createdBy={view.createdBy}
uuid={view.id}
refetchAllView={refetchAllView}
viewData={viewsData?.data.data ?? []}
sourcePage={sourcepage}
/>
),
displayValue: view.name,
})),
[refetchAllView, sourcepage, viewKey, viewsData?.data.data],
);
return (
<>
{showSaveView && (
@@ -183,30 +191,12 @@ function ExplorerCard({
<Space size="large">
{viewsData?.data.data && viewsData?.data.data.length && (
<Space>
<Select
getPopupContainer={popupContainer}
<ComboboxSimple
loading={isLoading || isRefetching}
showSearch
placeholder="Select a view"
dropdownStyle={DropDownOverlay}
dropdownMatchSelectWidth={false}
optionLabelProp="value"
items={viewItems}
value={viewName || undefined}
>
{viewsData?.data.data.map((view) => (
<Select.Option key={view.id} value={view.name}>
<MenuItemGenerator
viewName={view.name}
viewKey={viewKey}
createdBy={view.createdBy}
uuid={view.id}
refetchAllView={refetchAllView}
viewData={viewsData.data.data}
sourcePage={sourcepage}
/>
</Select.Option>
))}
</Select>
/>
</Space>
)}
{isQueryUpdated && (

View File

@@ -20,9 +20,9 @@
padding: 0px 8px;
border-radius: 2px 0px 0px 2px;
border: 1px solid var(--l2-border);
background: var(--l2-background);
color: var(--l2-foreground);
border: 1px solid var(--input-with-label-border-color, var(--l2-border));
background: var(--input-with-label-background-color, var(--l2-background));
color: var(--input-with-label-color, var(--l2-foreground));
display: flex;
justify-content: flex-start;
@@ -35,21 +35,28 @@
min-width: 150px;
font-family: 'Space Mono', monospace !important;
border-radius: 2px 0px 0px 2px;
border: 1px solid var(--l1-border);
background: var(--l2-background);
border-radius: 2px;
border: 1px solid var(--input-with-label-border-color, var(--l2-border));
background: var(--input-with-label-background-color, var(--l2-background));
color: var(--input-with-label-color, var(--l2-foreground));
border-right: none;
border-left: none;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
font-size: 12px !important;
line-height: 27px;
line-height: 25px;
&.input__has-label-after {
border-left: none;
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
}
&.input__has-close-button {
border-right: none;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
&::placeholder {
color: var(--l2-foreground) !important;
color: var(--input-with-label-color, var(--l3-foreground)) !important;
font-size: 12px !important;
}
&[type='number']::-webkit-inner-spin-button,
@@ -63,25 +70,24 @@
.close-btn {
border-radius: 0px 2px 2px 0px;
border: 1px solid var(--l2-border);
background: var(--l2-background);
height: 38px;
border: 1px solid var(--input-with-label-border-color, var(--l2-border));
background: var(--input-with-label-background-color, var(--l2-background));
height: 100%;
width: 38px;
}
&.labelAfter {
.input {
border-radius: 0px 2px 2px 0px;
border: 1px solid var(--l1-border);
background: var(--l2-background);
border-radius: 2px;
border: 1px solid var(--input-with-label-border-color, var(--l2-border));
background: var(--input-with-label-background-color, var(--l2-background));
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
.label {
border-left: none;
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
border-radius: 0px 2px 2px 0px;
}
}
}

View File

@@ -44,7 +44,10 @@ function InputWithLabel({
>
{!labelAfter && <Typography.Text className="label">{label}</Typography.Text>}
<Input
className="input"
className={cx('input', {
'input__has-label-after': !labelAfter,
'input__has-close-button': !!onClose,
})}
placeholder={placeholder}
type={type}
value={inputValue}

View File

@@ -1,12 +1,12 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import { Style } from '@signozhq/design-tokens';
import { ChevronDown, Plus, Trash2, X } from '@signozhq/icons';
import { Plus, Trash2, X } from '@signozhq/icons';
import { Button } from '@signozhq/ui/button';
import { Callout } from '@signozhq/ui/callout';
import { DialogFooter, DialogWrapper } from '@signozhq/ui/dialog';
import { Input } from '@signozhq/ui/input';
import { SelectSimple } from '@signozhq/ui/select';
import { toast } from '@signozhq/ui/sonner';
import { Select } from 'antd';
import inviteUsers from 'api/v1/invite/bulk/create';
import sendInvite from 'api/v1/invite/create';
import { cloneDeep, debounce } from 'lodash-es';
@@ -15,7 +15,6 @@ import APIError from 'types/api/error';
import { ROLES } from 'types/roles';
import { EMAIL_REGEX } from 'utils/app';
import { getBaseUrl } from 'utils/basePath';
import { popupContainer } from 'utils/selectPopupContainer';
import { v4 as uuid } from 'uuid';
import './InviteMembersModal.styles.scss';
@@ -254,18 +253,17 @@ function InviteMembersModal({
)}
</div>
<div className="team-member-cell role-cell">
<Select
<SelectSimple
value={row.role || undefined}
onChange={(role): void => updateRole(row.id, role as ROLES)}
className="team-member-role-select"
placeholder="Select roles"
suffixIcon={<ChevronDown size={14} />}
getPopupContainer={popupContainer}
>
<Select.Option value="VIEWER">Viewer</Select.Option>
<Select.Option value="EDITOR">Editor</Select.Option>
<Select.Option value="ADMIN">Admin</Select.Option>
</Select>
items={[
{ value: 'VIEWER', label: 'Viewer' },
{ value: 'EDITOR', label: 'Editor' },
{ value: 'ADMIN', label: 'Admin' },
]}
/>
</div>
<div className="team-member-cell action-cell">
{rows.length > 1 && (

View File

@@ -1,7 +1,7 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import { Button, Input, InputNumber, Popover, Tooltip } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import type { DefaultOptionType } from 'antd/es/select';
import type { ComboboxSimpleItem } from '@signozhq/ui/combobox';
import cx from 'classnames';
import { LogViewMode } from 'container/LogsTable';
import { FontSize, OptionsMenuConfig } from 'container/OptionsMenu/types';
@@ -113,15 +113,11 @@ function OptionsMenu({
function handleColumnSelection(
currentIndex: number,
optionsData: DefaultOptionType[],
optionsData: ComboboxSimpleItem[],
): void {
const currentItem = optionsData[currentIndex];
const itemLength = optionsData.length;
if (addColumn && addColumn?.onSelect) {
addColumn?.onSelect(selectedValue, {
label: currentItem.label,
disabled: false,
});
if (addColumn && addColumn?.onSelect && selectedValue) {
addColumn?.onSelect(selectedValue);
// if the last element is selected then select the previous one
if (currentIndex === itemLength - 1) {
@@ -175,7 +171,7 @@ function OptionsMenu({
}
case 'Enter':
e.preventDefault();
handleColumnSelection(currentIndex, optionsData);
handleColumnSelection(currentIndex, optionsData as ComboboxSimpleItem[]);
break;
default:
break;
@@ -317,7 +313,10 @@ function OptionsMenu({
}}
onClick={(eve): void => {
eve.stopPropagation();
handleColumnSelection(index, addColumn?.options || []);
handleColumnSelection(
index,
(addColumn?.options || []) as ComboboxSimpleItem[],
);
}}
>
<div className="name">

View File

@@ -10,7 +10,8 @@ import {
Loader,
X,
} from '@signozhq/icons';
import { Modal, Select, Spin, Tooltip, Tree, TreeDataNode } from 'antd';
import { Modal, Spin, Tooltip, Tree, TreeDataNode } from 'antd';
import { SelectSimple } from '@signozhq/ui/select';
import { OnboardingStatusResponse } from 'api/messagingQueues/onboarding/getOnboardingStatus';
import { QueryParams } from 'constants/query';
import ROUTES from 'constants/routes';
@@ -181,8 +182,8 @@ function AttributeCheckList({
const [filter, setFilter] = useState<AttributesFilters>(AttributesFilters.ALL);
const [treeData, setTreeData] = useState<TreeDataNode[]>([]);
const handleFilterChange = (value: AttributesFilters): void => {
setFilter(value);
const handleFilterChange = (value: string | string[]): void => {
setFilter(value as AttributesFilters);
};
const { isCloudUser: isCloudUserVal } = useGetTenantLicense();
const history = useHistory();
@@ -237,11 +238,11 @@ function AttributeCheckList({
</div>
) : (
<div className="modal-content">
<Select
<SelectSimple
defaultValue={AttributesFilters.ALL}
className="attribute-select"
onChange={handleFilterChange}
options={[
items={[
{
value: AttributesFilters.ALL,
label: AttributeLabels({ title: 'Attributes: All' }),

View File

@@ -1,6 +1,6 @@
import { Color } from '@signozhq/design-tokens';
import { Tooltip } from 'antd';
import type { DefaultOptionType } from 'antd/es/select';
import type { ComboboxSimpleItem } from '@signozhq/ui/combobox';
import { Info } from '@signozhq/icons';
import './MQCommon.styles.scss';
@@ -35,7 +35,7 @@ export function ComingSoon(): JSX.Element {
}
export function SelectMaxTagPlaceholder(
omittedValues: Partial<DefaultOptionType>[],
omittedValues: Partial<ComboboxSimpleItem>[],
): JSX.Element {
return (
<Tooltip title={omittedValues.map(({ value }) => value).join(', ')}>

View File

@@ -18,7 +18,9 @@ import {
RefreshCw,
} from '@signozhq/icons';
import { Color } from '@signozhq/design-tokens';
import { Button, Checkbox, Select } from 'antd';
// oxlint-disable-next-line signoz/no-antd-components This component for now is too complex to be migrated in one PR
import { Select } from 'antd';
import { Button, Checkbox } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import cx from 'classnames';
import TextToolTip from 'components/TextToolTip/TextToolTip';

View File

@@ -16,6 +16,7 @@ import {
X,
} from '@signozhq/icons';
import { Color } from '@signozhq/design-tokens';
// oxlint-disable-next-line signoz/no-antd-components This component for now is too complex to be migrated in one PR
import { Select } from 'antd';
import cx from 'classnames';
import TextToolTip from 'components/TextToolTip';

View File

@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';
import { useQuery } from 'react-query';
import { Select, Spin } from 'antd';
import { ComboboxSimple, ComboboxSimpleItem } from '@signozhq/ui/combobox';
import { getKeySuggestions } from 'api/querySuggestions/getKeySuggestions';
import { QueryKeyDataSuggestionsProps } from 'types/api/querySuggestions/types';
import { DataSource } from 'types/common/queryBuilder';
@@ -13,48 +13,25 @@ interface ListViewOrderByProps {
dataSource: DataSource;
}
// Loader component for the dropdown when loading or no results
function Loader({ isLoading }: { isLoading: boolean }): JSX.Element {
return (
<div className="order-by-loading-container">
{isLoading ? <Spin size="default" /> : 'No results found'}
</div>
);
}
function ListViewOrderBy({
value,
onChange,
dataSource,
}: ListViewOrderByProps): JSX.Element {
const [searchInput, setSearchInput] = useState('');
const [debouncedInput, setDebouncedInput] = useState('');
const [selectOptions, setSelectOptions] = useState<
{ label: string; value: string }[]
>([]);
const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
const [selectOptions, setSelectOptions] = useState<ComboboxSimpleItem[]>([]);
// Fetch key suggestions based on debounced input
// Fetch key suggestions once; ComboboxSimple handles local filtering.
const { data, isLoading } = useQuery({
queryKey: ['orderByKeySuggestions', dataSource, debouncedInput],
queryKey: ['orderByKeySuggestions', dataSource],
queryFn: async () => {
const response = await getKeySuggestions({
signal: dataSource,
searchText: debouncedInput,
searchText: '',
});
return response.data;
},
});
useEffect(
() => (): void => {
if (debounceTimer.current) {
clearTimeout(debounceTimer.current);
}
},
[],
);
// Update options when API data changes
useEffect(() => {
const rawKeys: QueryKeyDataSuggestionsProps[] = data?.data?.keys
@@ -62,52 +39,33 @@ function ListViewOrderBy({
: [];
const keyNames = rawKeys.map((key) => key.name);
const uniqueKeys = [
...new Set(searchInput ? keyNames : ['timestamp', ...keyNames]),
];
const uniqueKeys = [...new Set(['timestamp', ...keyNames])];
const updatedOptions = uniqueKeys.flatMap((key) => [
const updatedOptions: ComboboxSimpleItem[] = uniqueKeys.flatMap((key) => [
{ label: `${key} (desc)`, value: `${key}:desc` },
{ label: `${key} (asc)`, value: `${key}:asc` },
]);
setSelectOptions(updatedOptions);
}, [data, searchInput]);
}, [data]);
// Handle search input with debounce
const handleSearch = (input: string): void => {
setSearchInput(input);
// Filter current options for instant client-side match
const filteredOptions = selectOptions.filter((option) =>
option.value.toLowerCase().includes(input.trim().toLowerCase()),
);
// If no match found or input is empty, trigger debounced fetch
if (filteredOptions.length === 0 || input === '') {
if (debounceTimer.current) {
clearTimeout(debounceTimer.current);
}
debounceTimer.current = setTimeout(() => {
setDebouncedInput(input);
}, 100);
}
};
const handleChange = useMemo(
() =>
(val: string | string[]): void => {
onChange(val as string);
},
[onChange],
);
return (
<Select
showSearch
<ComboboxSimple
value={value}
onChange={onChange}
onSearch={handleSearch}
notFoundContent={<Loader isLoading={isLoading} />}
onChange={handleChange}
loading={isLoading}
placeholder="Select a field"
style={{ width: 200 }}
options={selectOptions}
filterOption={(input, option): boolean =>
(option?.value ?? '').toLowerCase().includes(input.trim().toLowerCase())
}
items={selectOptions}
emptyPlaceholder="No results found"
/>
);
}

View File

@@ -22,6 +22,37 @@
border-right: none;
border-left: none;
--select-trigger-height: 2.25rem;
--select-trigger-background-color: var(
--query-builder-v2-background-color,
var(--l2-background)
);
--select-trigger-border-color: var(
--query-builder-v2-border-color,
var(--l2-border)
);
--combobox-trigger-height: 2.25rem;
--combobox-trigger-padding: 7px var(--spacing-6);
--combobox-trigger-background-color: var(
--query-builder-v2-background-color,
var(--l2-background)
);
--combobox-trigger-border-color: var(
--query-builder-v2-border-color,
var(--l2-border)
);
[data-slot='combobox-trigger'],
[data-slot='select-trigger'] {
color: var(--query-builder-v2-color, var(--l2-foreground));
}
[data-slot='combobox-placeholder'],
[data-slot='select-placeholder'] {
color: var(--query-builder-v2-placeholder-color, var(--l3-foreground));
}
.qb-content-container {
display: flex;
flex-direction: column;
@@ -80,8 +111,8 @@
width: 1px;
background: repeating-linear-gradient(
to bottom,
var(--l1-border),
var(--l1-border) 4px,
var(--query-builder-v2-border-color, var(--l2-border)),
var(--query-builder-v2-border-color, var(--l2-border)) 4px,
transparent 4px,
transparent 8px
);
@@ -101,7 +132,8 @@
top: 12px;
width: 6px;
height: 6px;
border-left: 6px dotted var(--l1-border);
border-left: 6px dotted
var(--query-builder-v2-border-color, var(--l2-border));
}
/* Horizontal line pointing from vertical to the item */
@@ -114,8 +146,8 @@
height: 1px;
background: repeating-linear-gradient(
to right,
var(--l1-border),
var(--l1-border) 4px,
var(--query-builder-v2-border-color, var(--l2-border)),
var(--query-builder-v2-border-color, var(--l2-border)) 4px,
transparent 4px,
transparent 8px
);
@@ -241,7 +273,8 @@
top: 12px;
width: 6px;
height: 6px;
border-left: 6px dotted var(--l1-border);
border-left: 6px dotted
var(--query-builder-v2-border-color, var(--l2-border));
}
/* Horizontal line pointing from vertical to the item */
@@ -254,8 +287,8 @@
height: 1px;
background: repeating-linear-gradient(
to right,
var(--l1-border),
var(--l1-border) 4px,
var(--query-builder-v2-border-color, var(--l2-border)),
var(--query-builder-v2-border-color, var(--l2-border)) 4px,
transparent 4px,
transparent 8px
);
@@ -273,6 +306,16 @@
line-height: 16px; /* 128.571% */
resize: none;
background-color: var(
--query-builder-v2-background-color,
var(--l2-background)
);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
&:placeholder {
color: var(--query-builder-v2-placeholder-color, var(--l3-foreground));
}
}
.formula-legend {
@@ -282,15 +325,30 @@
.ant-input-group-addon {
border-top-left-radius: 0px !important;
border-top-right-radius: 0px !important;
background: var(--l2-background);
color: var(--l2-foreground);
background: var(
--query-builder-v2-background-color,
var(--l2-background)
);
color: var(--query-builder-v2-color, var(--l2-foreground));
font-size: 12px;
font-weight: 300;
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
}
.ant-input {
border-top-left-radius: 0px !important;
border-top-right-radius: 0px !important;
background-color: var(
--query-builder-v2-background-color,
var(--l2-background)
);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
&:placeholder {
color: var(--query-builder-v2-placeholder-color, var(--l3-foreground));
}
}
}
}
@@ -323,8 +381,8 @@
width: 1px;
background: repeating-linear-gradient(
to bottom,
var(--l1-border),
var(--l1-border) 4px,
var(--query-builder-v2-border-color, var(--l2-border)),
var(--query-builder-v2-border-color, var(--l2-border)) 4px,
transparent 4px,
transparent 8px
);
@@ -395,8 +453,8 @@
width: 1px;
background: repeating-linear-gradient(
to bottom,
var(--l1-border),
var(--l1-border) 4px,
var(--query-builder-v2-border-color, var(--l2-border)),
var(--query-builder-v2-border-color, var(--l2-border)) 4px,
transparent 4px,
transparent 8px
);
@@ -412,7 +470,7 @@
min-width: 120px;
border-radius: 2px;
border: 1px solid var(--l1-border);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
background: var(--l1-background);
box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.1);
@@ -457,7 +515,7 @@
.ant-select-selector {
border-radius: 2px;
border: 1px solid var(--l1-border) !important;
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border)) !important;
background: var(--l1-background) !important;
height: 34px !important;
box-sizing: border-box !important;

View File

@@ -57,6 +57,7 @@
.group-by-filter-container {
min-width: 340px !important;
--combobox-trigger-height: auto;
}
.metrics-aggregation-section-content-item {
@@ -146,17 +147,3 @@
}
}
}
.metrics-operators-select {
border-radius: 2px;
border: 1.005px solid var(--l1-border);
background: var(--l1-background);
color: var(--l1-foreground);
font-family: 'Geist Mono';
font-size: 13px;
font-style: normal;
font-weight: 400;
line-height: 20px; /* 142.857% */
letter-spacing: -0.07px;
}

View File

@@ -118,7 +118,6 @@ const MetricsAggregateSection = memo(function MetricsAggregateSection({
value={queryAggregation.timeAggregation || ''}
onChange={handleChangeOperator}
operators={operators}
className="metrics-operators-select"
/>
</div>
</div>

View File

@@ -6,11 +6,13 @@
gap: 8px;
width: 100%;
--select-trigger-width: auto;
.ant-select-selection-search-input {
font-size: 12px !important;
line-height: 27px;
line-height: 25px;
&::placeholder {
color: var(--l2-foreground) !important;
color: var(--query-builder-v2-color, var(--l2-foreground)) !important;
font-size: 12px !important;
}
}
@@ -22,9 +24,9 @@
.ant-select-selector {
width: 100%;
border-radius: 2px;
border: 1px solid var(--l1-border) !important;
background: var(--l1-background);
color: var(--l1-foreground);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border)) !important;
background: var(--query-builder-v2-background-color, var(--l2-background));
color: var(--query-builder-v2-color, var(--l2-foreground));
font-family: 'Geist Mono';
font-size: 13px;
font-style: normal;
@@ -33,20 +35,23 @@
min-height: 36px;
.ant-select-selection-placeholder {
color: var(--l2-foreground) !important;
color: var(
--query-builder-v2-placeholder-color,
var(--l3-foreground)
) !important;
font-size: 12px !important;
}
}
.ant-select-dropdown {
border-radius: 4px;
border: 1px solid var(--l1-border);
background: var(--l1-background);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
background: var(--query-builder-v2-background-color, var(--l2-background));
box-shadow: 4px 10px 16px 2px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(20px);
.ant-select-item {
color: var(--l1-foreground);
color: var(--query-builder-v2-color, var(--l2-foreground));
font-family: 'Geist Mono';
font-size: 13px;
font-style: normal;
@@ -55,12 +60,18 @@
&:hover,
&.ant-select-item-option-active {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selected-background-color,
var(--l3-background)
) !important;
}
&.ant-select-item-option-selected {
background: var(--l3-background) !important;
border: 1px solid var(--l1-border);
background: var(
--query-builder-v2-selected-background-color,
var(--l3-background)
) !important;
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
font-weight: 600;
}
}

View File

@@ -1,5 +1,5 @@
import { memo, useCallback, useMemo } from 'react';
import { Select } from 'antd';
import { SelectSimple, type SelectSimpleItem } from '@signozhq/ui/select';
import {
initialQueriesMap,
initialQueryMeterWithType,
@@ -10,7 +10,6 @@ import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { useQueryOperations } from 'hooks/queryBuilder/useQueryBuilderOperations';
import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
import { DataSource } from 'types/common/queryBuilder';
import { SelectOption } from 'types/common/select';
import {
getPreviousQueryFromKey,
@@ -21,7 +20,7 @@ import {
import './MetricsSelect.styles.scss';
export const SOURCE_OPTIONS: SelectOption<string, string>[] = [
export const SOURCE_OPTIONS: SelectSimpleItem[] = [
{ value: 'metrics', label: 'Metrics' },
{ value: 'meter', label: 'Meter' },
];
@@ -140,14 +139,14 @@ export const MetricsSelect = memo(function MetricsSelect({
return (
<div className="metrics-source-select-container">
{signalSourceChangeEnabled && (
<Select
<SelectSimple
className="source-selector"
placeholder="Source"
options={SOURCE_OPTIONS}
items={SOURCE_OPTIONS}
value={source}
defaultValue="metrics"
data-testid={`metrics-source-selector-${index}`}
onChange={handleSignalSourceChange}
testId={`metrics-source-selector-${index}`}
onChange={(value): void => handleSignalSourceChange(value as string)}
/>
)}

View File

@@ -22,34 +22,35 @@
font-style: normal;
font-weight: var(--font-weight-normal);
color: var(--l2-foreground);
color: var(--query-builder-v2-color, var(--l2-foreground));
}
.tab {
border: 1px solid var(--l1-border);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
border-left: none;
min-width: 120px;
height: 36px;
line-height: 36px;
&:first-child {
border-left: 1px solid var(--l1-border);
border-left: 1px solid
var(--query-builder-v2-border-color, var(--l2-border));
}
}
.tab::before {
background: var(--l1-border);
background: var(--query-builder-v2-border-color, var(--l2-border));
}
.selected-view {
color: var(--text-robin-500);
border: 1px solid var(--l1-border);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
display: none;
}
.selected-view::before {
background: var(--l1-border);
background: var(--query-builder-v2-border-color, var(--l2-border));
}
}
@@ -58,7 +59,7 @@
height: 30px;
border-radius: 2px;
border: 1px solid var(--l1-border);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
background: var(--l3-background);
box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.1);
}
@@ -71,10 +72,13 @@
align-items: center;
.having-filter-select-container {
position: relative;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
align-items: flex-start;
background: var(--query-builder-v2-background-color, var(--l2-background));
padding-right: 38px;
.having-filter-select-editor {
border-radius: 2px;
@@ -99,15 +103,17 @@
}
.cm-content {
border-radius: 2px;
border: 1px solid var(--l1-border);
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
border-left-width: 0px;
border-right-width: 0px;
padding: 0px !important;
background-color: var(--l2-background) !important;
background-color: var(
--query-builder-v2-background-color,
var(--l2-background)
) !important;
&:focus-within {
border-color: var(--l1-border);
border-color: var(--query-builder-v2-border-color, var(--l2-border));
}
}
@@ -211,17 +217,32 @@
}
.cm-line {
line-height: 36px !important;
min-height: 34px;
line-height: 32px !important;
font-family: 'Space Mono', monospace !important;
background-color: var(--l2-background) !important;
background-color: var(
--query-builder-v2-background-color,
var(--l2-background)
) !important;
&,
.ͼ1a {
color: var(--query-builder-v2-color, var(--l2-foreground));
}
::-moz-selection {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selection-background-color,
var(--l3-background)
) !important;
opacity: 0.5 !important;
}
::selection {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selection-background-color,
var(--l3-background)
) !important;
opacity: 0.5 !important;
}
@@ -230,8 +251,11 @@
}
.chip-decorator {
background: var(--l3-background) !important;
color: var(--l1-foreground) !important;
background: var(
--query-builder-v2-chip-decorator-background-color,
var(--l3-background)
) !important;
color: var(--query-builder-v2-color, var(--l2-foreground)) !important;
border-radius: 4px;
padding: 2px 4px;
margin-right: 4px;
@@ -239,24 +263,36 @@
}
.cm-selectionBackground {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selection-background-color,
var(--l3-background)
) !important;
opacity: 0.5 !important;
}
.cm-activeLine > span {
font-size: 12px !important;
}
.cm-placeholder {
color: var(
--query-builder-v2-placeholder-color,
var(--l3-foreground)
) !important;
}
}
}
.close-btn {
position: absolute;
top: 0;
right: 0;
border-radius: 0px 2px 2px 0px;
border: 1px solid var(--l2-border);
background: var(--l2-background);
height: 38px;
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
background: var(--query-builder-v2-background-color, var(--l2-background));
height: 100%;
width: 38px;
border-left: transparent;
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
}

View File

@@ -23,7 +23,7 @@
flex: 1;
min-width: 0;
font-size: 12px;
color: var(--l2-foreground) !important;
color: var(--query-builder-v2-color, var(--l2-foreground)) !important;
&.error {
.cm-editor {
@@ -51,14 +51,15 @@
.cm-content {
border-radius: 2px;
border: 1px solid var(--l1-border);
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
padding: 0px !important;
background-color: var(--l1-background) !important;
background-color: var(
--query-builder-v2-background-color,
var(--l2-background)
) !important;
&:focus-within {
border-color: var(--l1-border);
border-color: var(--query-builder-v2-border-color, var(--l2-border));
}
}
@@ -74,7 +75,7 @@
right: 0px !important;
border-radius: 4px;
border: 1px solid var(--l1-border);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
background: linear-gradient(
139deg,
color-mix(in srgb, var(--card) 80%, transparent) 0%,
@@ -118,7 +119,7 @@
box-sizing: border-box;
overflow: hidden;
color: var(--l2-foreground) !important;
color: var(--query-builder-v2-color, var(--l2-foreground)) !important;
font-family: 'Space Mono', monospace !important;
.cm-completionIcon {
@@ -127,7 +128,10 @@
&:hover,
&[aria-selected='true'] {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selection-background-color,
var(--l3-background)
) !important;
color: var(--l1-foreground) !important;
font-weight: 600 !important;
}
@@ -142,15 +146,24 @@
.cm-line {
line-height: 36px !important;
font-family: 'Space Mono', monospace !important;
background-color: var(--l2-background) !important;
background-color: var(
--query-builder-v2-background-color,
var(--l2-background)
) !important;
::-moz-selection {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selection-background-color,
var(--l3-background)
) !important;
opacity: 0.5 !important;
}
::selection {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selection-background-color,
var(--l3-background)
) !important;
opacity: 0.5 !important;
}
@@ -159,8 +172,11 @@
}
.chip-decorator {
background: var(--l3-background) !important;
color: var(--l1-foreground) !important;
background: var(
--query-builder-v2-chip-decorator-background-color,
var(--l3-background)
) !important;
color: var(--query-builder-v2-color, var(--l1-foreground)) !important;
border-radius: 4px;
padding: 2px 4px;
margin-right: 4px;
@@ -168,7 +184,10 @@
}
.cm-selectionBackground {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selection-background-color,
var(--l3-background)
) !important;
opacity: 0.5 !important;
}
}
@@ -201,12 +220,11 @@
.close-btn {
border-radius: 0px 2px 2px 0px;
border: 1px solid var(--l1-border);
background: var(--l1-background);
height: 38px;
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
background: var(--query-builder-v2-background-color, var(--l2-background));
height: 100%;
width: 38px;
border-left: transparent;
border-top-left-radius: 0px;
border-bottom-left-radius: 0px;
}
@@ -217,13 +235,13 @@
height: 36px;
line-height: 36px;
border-radius: 2px;
border: 1px solid var(--l1-border);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.1);
font-family: 'Space Mono', monospace !important;
&::placeholder {
color: var(--l1-foreground);
color: var(--query-builder-v2-color, var(--l2-foreground));
opacity: 0.5;
}
}
@@ -240,7 +258,7 @@
input {
max-width: 120px;
&::placeholder {
color: var(--l2-foreground);
color: var(--query-builder-v2-color, var(--l2-foreground));
}
}
}
@@ -251,8 +269,8 @@
.query-aggregation-error-popover {
.ant-popover-inner {
background-color: var(--l1-border);
border: 1px solid var(--l1-border);
background-color: var(--query-builder-v2-border-color, var(--l2-border));
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
border-radius: 4px;
box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
}

View File

@@ -1,7 +1,7 @@
.add-trace-operator-button,
.add-new-query-button,
.add-formula-button {
border: 1px solid var(--l1-border);
background: var(--l2-background);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
background: var(--query-builder-v2-background-color, var(--l2-background));
box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.1);
}

View File

@@ -34,11 +34,14 @@
.query-status-container {
width: 32px;
background-color: var(--l1-background) !important;
background-color: var(
--query-builder-v2-background-color,
var(--l2-background)
) !important;
display: flex;
justify-content: center;
align-items: center;
border: 1px solid var(--l1-border);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
border-radius: 2px;
border-top-left-radius: 0px !important;
border-bottom-left-radius: 0px !important;
@@ -77,16 +80,16 @@
.cm-content {
border-radius: 2px;
border: 1px solid var(--l1-border);
border: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
padding: 0px !important;
&:focus-within {
border-color: var(--l1-border);
border-color: var(--query-builder-v2-border-color, var(--l2-border));
}
}
&.cm-focused {
outline: 1px solid var(--l1-border);
outline: 1px solid var(--query-builder-v2-border-color, var(--l2-border));
}
.cm-tooltip-autocomplete {
@@ -148,11 +151,17 @@
font-family: 'Space Mono', monospace !important;
background-color: var(--l1-background) !important;
color: var(--l2-foreground) !important;
background-color: var(
--query-builder-v2-background-color,
var(--l2-background)
) !important;
color: var(--query-builder-v2-color, var(--l2-foreground)) !important;
&:hover {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selection-background-color,
var(--l3-background)
) !important;
}
.cm-completionIcon {
@@ -160,7 +169,10 @@
}
&[aria-selected='true'] {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selection-background-color,
var(--l3-background)
) !important;
font-weight: 600 !important;
}
}
@@ -172,25 +184,49 @@
}
.cm-line {
line-height: 34px !important;
line-height: 36px !important;
font-family: 'Space Mono', monospace !important;
background-color: var(--l2-background) !important;
background-color: var(
--query-builder-v2-background-color,
var(--l2-background)
) !important;
&,
.ͼ1a {
color: var(--query-builder-v2-color, var(--l2-foreground));
}
::-moz-selection {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selection-background-color,
var(--l3-background)
) !important;
opacity: 0.5 !important;
}
::selection {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selection-background-color,
var(--l3-background)
) !important;
opacity: 0.5 !important;
}
}
.cm-selectionBackground {
background: var(--l3-background) !important;
background: var(
--query-builder-v2-selection-background-color,
var(--l3-background)
) !important;
opacity: 0.5 !important;
}
.cm-placeholder {
color: var(
--query-builder-v2-placeholder-color,
var(--l3-foreground)
) !important;
}
}
.cursor-position {

View File

@@ -1,11 +1,10 @@
import { CircleAlert, RefreshCw } from '@signozhq/icons';
import { Checkbox, Select } from 'antd';
import { ComboboxSimple, ComboboxSimpleItem } from '@signozhq/ui/combobox';
import { convertToApiError } from 'api/ErrorResponseHandlerForGeneratedAPIs';
import { useListRoles } from 'api/generated/services/role';
import type { AuthtypesRoleDTO } from 'api/generated/services/sigNoz.schemas';
import cx from 'classnames';
import APIError from 'types/api/error';
import { popupContainer } from 'utils/selectPopupContainer';
import './RolesSelect.styles.scss';
@@ -74,7 +73,6 @@ interface BaseProps {
id?: string;
placeholder?: string;
className?: string;
getPopupContainer?: (trigger: HTMLElement) => HTMLElement;
roles?: AuthtypesRoleDTO[];
loading?: boolean;
isError?: boolean;
@@ -112,14 +110,13 @@ function RolesSelect(props: RolesSelectProps): JSX.Element {
});
const roles = externalRoles ?? data?.data ?? [];
const options = getRoleOptions(roles);
const items: ComboboxSimpleItem[] = getRoleOptions(roles);
const {
mode,
id,
placeholder = 'Select role',
className,
getPopupContainer = popupContainer,
loading = internalLoading,
isError = internalError,
error = convertToApiError(internalErrorObj),
@@ -127,55 +124,47 @@ function RolesSelect(props: RolesSelectProps): JSX.Element {
disabled,
} = props;
const notFoundContent = isError ? (
<ErrorContent error={error} onRefetch={onRefetch} />
) : undefined;
const emptyPlaceholder = isError
? error?.message || 'Failed to load roles'
: 'No roles available';
if (mode === 'multiple') {
const { value = [], onChange } = props as MultipleProps;
return (
<Select
id={id}
mode="multiple"
value={value}
onChange={onChange}
placeholder={placeholder}
className={cx('roles-select', className)}
loading={loading}
notFoundContent={notFoundContent}
options={options}
optionFilterProp="label"
optionRender={(option): JSX.Element => (
<Checkbox
checked={value.includes(option.value as string)}
style={{ pointerEvents: 'none' }}
>
{option.label}
</Checkbox>
)}
getPopupContainer={getPopupContainer}
disabled={disabled}
/>
<>
<ComboboxSimple
id={id}
multiple
value={value}
onChange={(v): void => onChange?.(v as string[])}
placeholder={placeholder}
className={cx('roles-select', className)}
loading={loading}
emptyPlaceholder={emptyPlaceholder}
items={items}
style={disabled ? { pointerEvents: 'none', opacity: 0.5 } : undefined}
/>
{isError && <ErrorContent error={error} onRefetch={onRefetch} />}
</>
);
}
const { value, onChange, allowClear = true } = props as SingleProps;
const { value, onChange } = props as SingleProps;
return (
<Select
id={id}
showSearch
value={value || undefined}
onChange={onChange}
placeholder={placeholder}
allowClear={allowClear}
className={cx('roles-single-select', className)}
loading={loading}
notFoundContent={notFoundContent}
options={options}
optionFilterProp="label"
getPopupContainer={getPopupContainer}
disabled={disabled}
/>
<>
<ComboboxSimple
id={id}
value={value || undefined}
onChange={(v): void => onChange?.((v as string) || undefined)}
placeholder={placeholder}
className={cx('roles-single-select', className)}
loading={loading}
emptyPlaceholder={emptyPlaceholder}
items={items}
style={disabled ? { pointerEvents: 'none', opacity: 0.5 } : undefined}
/>
{isError && <ErrorContent error={error} onRefetch={onRefetch} />}
</>
);
}

View File

@@ -1,7 +1,11 @@
import { useMemo } from 'react';
import { SolidAlertTriangle } from '@signozhq/icons';
import { Select, Tooltip } from 'antd';
import type { DefaultOptionType } from 'antd/es/select';
import {
ComboboxSimple,
ComboboxSimpleGroup,
ComboboxSimpleItem,
} from '@signozhq/ui/combobox';
import { Tooltip } from 'antd';
import classNames from 'classnames';
import { UniversalYAxisUnitMappings } from './constants';
@@ -42,69 +46,53 @@ function YAxisUnitSelector({
return '';
}, [initialValue, value, loading]);
const handleSearch = (
searchTerm: string,
currentOption: DefaultOptionType | undefined,
): boolean => {
if (!currentOption?.value) {
return false;
}
const categoriesToRender = useMemo(
() => categoriesOverride || getYAxisCategories(source),
[categoriesOverride, source],
);
const search = searchTerm.toLowerCase();
const unitId = currentOption.value.toString().toLowerCase();
const unitLabel = currentOption.children?.toString().toLowerCase() || '';
const groups: ComboboxSimpleGroup[] = useMemo(
() =>
categoriesToRender.map((category) => ({
heading: category.name,
items: category.units.map((unit): ComboboxSimpleItem => {
const aliases = Array.from(
UniversalYAxisUnitMappings[unit.id as UniversalYAxisUnit] ?? [],
);
return {
value: unit.id,
label: unit.name,
keywords: aliases,
};
}),
})),
[categoriesToRender],
);
// Check label and id
if (unitId.includes(search) || unitLabel.includes(search)) {
return true;
}
// Check aliases (from the mapping) using array iteration
const aliases = Array.from(
UniversalYAxisUnitMappings[currentOption.value as UniversalYAxisUnit] ?? [],
);
return aliases.some((alias) => alias.toLowerCase().includes(search));
const handleChange = (val: string | string[]): void => {
onChange(val as UniversalYAxisUnit);
};
const categoriesToRender = useMemo(() => {
return categoriesOverride || getYAxisCategories(source);
}, [categoriesOverride, source]);
return (
<div
className={classNames('y-axis-unit-selector-component', containerClassName)}
>
<Select
showSearch
value={universalUnit}
onChange={onChange}
<ComboboxSimple
value={universalUnit ?? undefined}
onChange={handleChange}
placeholder={placeholder}
filterOption={(input, option): boolean => handleSearch(input, option)}
loading={loading}
suffixIcon={
incompatibleUnitMessage ? (
<Tooltip title={incompatibleUnitMessage}>
<SolidAlertTriangle role="img" aria-label="warning" size="md" />
</Tooltip>
) : undefined
}
className={classNames({
'warning-state': incompatibleUnitMessage,
'warning-state': !!incompatibleUnitMessage,
})}
data-testid={dataTestId}
allowClear
>
{categoriesToRender.map((category) => (
<Select.OptGroup key={category.name} label={category.name}>
{category.units.map((unit) => (
<Select.Option key={unit.id} value={unit.id}>
{unit.name}
</Select.Option>
))}
</Select.OptGroup>
))}
</Select>
testId={dataTestId}
groups={groups}
/>
{incompatibleUnitMessage && (
<Tooltip title={incompatibleUnitMessage}>
<SolidAlertTriangle role="img" aria-label="warning" size="md" />
</Tooltip>
)}
</div>
);
}

View File

@@ -1,5 +1,8 @@
.y-axis-unit-selector-component {
.ant-select {
--combobox-trigger-background-color: var(--l2-background);
--combobox-trigger-border-color: var(--l2-border);
[data-slot='combobox-trigger'] {
width: 220px;
}
}

View File

@@ -11,5 +11,4 @@ export enum FeatureKeys {
DOT_METRICS_ENABLED = 'dot_metrics_enabled',
USE_JSON_BODY = 'use_json_body',
USE_FINE_GRAINED_AUTHZ = 'use_fine_grained_authz',
DASHBOARD_V2 = 'dashboard_v2',
}

View File

@@ -42,5 +42,4 @@ export enum LOCALSTORAGE {
LICENSE_KEY_CALLOUT_DISMISSED = 'LICENSE_KEY_CALLOUT_DISMISSED',
DASHBOARD_PREFERENCES = 'DASHBOARD_PREFERENCES',
ACTIVE_SIGNOZ_INSTANCE_URL = 'ACTIVE_SIGNOZ_INSTANCE_URL',
DASHBOARDS_LIST_VISIBLE_COLUMNS = 'DASHBOARDS_LIST_VISIBLE_COLUMNS',
}

View File

@@ -1,5 +1,5 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import { Select } from 'antd';
import { ComboboxSimple } from '@signozhq/ui/combobox';
import { ENTITY_VERSION_V5 } from 'constants/app';
import { initialQueriesMap } from 'constants/queryBuilder';
import {
@@ -115,11 +115,11 @@ function AllEndPoints({
// --- GROUP BY STATE SYNC (existing) ---
const handleGroupByChange = useCallback(
(value: IBuilderQuery['groupBy']) => {
(value: string[]) => {
const newGroupBy = [];
for (let index = 0; index < value.length; index++) {
const element = value[index] as unknown as string;
const element = value[index];
// Check if the key exists in our cached options first
if (allAvailableGroupByOptions[element]) {
@@ -242,17 +242,14 @@ function AllEndPoints({
</div>
<div className="group-by-container">
<div className="group-by-label"> Group by </div>
<Select
<ComboboxSimple
className="group-by-select"
loading={isLoadingGroupByFilters}
mode="multiple"
value={groupBy}
allowClear
maxTagCount="responsive"
multiple
value={groupBy.map((g) => g.key)}
placeholder="Search for attribute"
options={groupByOptions}
onChange={handleGroupByChange}
onSearch={(value: string): void => setGroupBySearchValue(value)}
items={groupByOptions}
onChange={(value): void => handleGroupByChange(value as string[])}
/>{' '}
</div>
<div className="endpoints-table-container">

View File

@@ -211,14 +211,14 @@
.group-by-label {
display: flex;
padding: 6px 15px;
padding: 4px 15px;
justify-content: center;
align-items: center;
gap: 4px;
flex-shrink: 0;
border-radius: 2px 0px 0px 2px;
border: 1px solid var(--l1-border);
border: 1px solid var(--l2-border);
border-right: none;
background: var(--l3-background);
@@ -227,18 +227,15 @@
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 18px;
line-height: 22px;
letter-spacing: -0.07px;
}
.group-by-select {
width: 100%;
.ant-select-selector {
font-size: 14px;
border-radius: 2px 0px 0px 2px;
border: 1px solid var(--l1-border);
background: var(--l3-background);
}
box-sizing: border-box;
--combobox-trigger-border-radius: 0px;
}
}
// Add border-bottom to table cells when pagination is not present
@@ -461,14 +458,13 @@
}
.endpoint-details-filters-container-dropdown {
width: 120px;
width: 150px;
border-right: 1px solid var(--l1-border);
height: 36px;
display: flex;
align-items: center;
.ant-select-single {
height: 32px;
}
--combobox-trigger-border-color: transparent;
}
.endpoint-details-filters-container-search {

View File

@@ -263,7 +263,6 @@ function EndPointDetails({
setSelectedEndPointName={setSelectedEndPointName}
endPointDropDownDataQuery={endPointDropDownDataQuery}
parentContainerDiv=".endpoint-details-filters-container"
dropdownStyle={{ width: 'calc(100% - 36px)' }}
/>
</div>
<div className="endpoint-details-filters-container-search">

View File

@@ -1,6 +1,6 @@
import { useMemo } from 'react';
import { UseQueryResult } from 'react-query';
import { Select } from 'antd';
import { ComboboxSimple, ComboboxSimpleItem } from '@signozhq/ui/combobox';
import { getFormattedEndPointDropDownData } from 'container/ApiMonitoring/utils';
import { SuccessResponse } from 'types/api';
@@ -22,40 +22,33 @@ function EndPointsDropDown({
selectedEndPointName,
setSelectedEndPointName,
endPointDropDownDataQuery,
parentContainerDiv,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
parentContainerDiv: _parentContainerDiv,
dropdownStyle,
}: EndPointsDropDownProps): JSX.Element {
const { data, isLoading, isFetching } = endPointDropDownDataQuery;
const handleChange = (value: string): void => {
setSelectedEndPointName(value);
const handleChange = (value: string | string[]): void => {
setSelectedEndPointName(value as string);
};
const formattedData = useMemo(
() =>
getFormattedEndPointDropDownData(data?.payload.data.result[0].table.rows),
getFormattedEndPointDropDownData(
data?.payload.data.result[0].table.rows,
) as ComboboxSimpleItem[],
[data?.payload.data.result],
);
return (
<Select
<ComboboxSimple
value={selectedEndPointName || undefined}
placeholder="Select endpoint"
loading={isLoading || isFetching}
style={{ width: '100%' }}
style={{ width: '100%', ...dropdownStyle }}
onChange={handleChange}
options={formattedData}
getPopupContainer={
parentContainerDiv
? (): HTMLElement =>
document.querySelector(parentContainerDiv) as HTMLElement
: (triggerNode): HTMLElement => triggerNode.parentNode as HTMLElement
}
dropdownStyle={dropdownStyle}
allowClear
onClear={(): void => {
setSelectedEndPointName('');
}}
items={formattedData}
virtualized
/>
);
}

View File

@@ -1,8 +1,8 @@
import { memo, useMemo } from 'react';
import { ChevronLeft, ChevronRight } from '@signozhq/icons';
import { Button, Flex, Select } from 'antd';
import { SelectSimple } from '@signozhq/ui/select';
import { Button, Flex } from 'antd';
import { DEFAULT_PER_PAGE_OPTIONS, Pagination } from 'hooks/queryPagination';
import { popupContainer } from 'utils/selectPopupContainer';
import { defaultSelectStyle } from './config';
import { Container } from './styles';
@@ -59,20 +59,18 @@ function Controls({
</Button>
{showSizeChanger && (
<Select<Pagination['limit']>
<SelectSimple
style={defaultSelectStyle}
loading={isLoading}
value={countPerPage}
onChange={handleCountItemsPerPageChange}
getPopupContainer={popupContainer}
>
{perPageOptions.map((count) => (
<Select.Option
key={count}
value={count}
>{`${count} / page`}</Select.Option>
))}
</Select>
disabled={isLoading}
value={String(countPerPage)}
onChange={(value): void =>
handleCountItemsPerPageChange(Number(value) as Pagination['limit'])
}
items={perPageOptions.map((count) => ({
value: String(count),
label: `${count} / page`,
}))}
/>
)}
</Container>
);

View File

@@ -61,10 +61,6 @@
margin-left: 16px;
}
&:not(:first-of-type) {
margin-left: 24px !important;
}
[aria-selected='false'] {
.periscope-tab {
color: var(--l2-foreground);

View File

@@ -1,5 +1,6 @@
import { useEffect } from 'react';
import { Button, Select, Tooltip } from 'antd';
import { Button, Tooltip } from 'antd';
import { SelectSimple } from '@signozhq/ui/select';
import { Typography } from '@signozhq/ui/typography';
import classNames from 'classnames';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
@@ -231,15 +232,18 @@ function AlertThreshold({
<Typography.Text className="sentence-text">
Send a notification when
</Typography.Text>
<Select
<SelectSimple
value={thresholdState.selectedQuery}
onChange={handleSelectedQueryChange}
onChange={(value): void => handleSelectedQueryChange(value as string)}
style={{ width: 80 }}
options={queryNames}
items={queryNames.map((q) => ({
value: String(q.value),
label: q.label as React.ReactNode,
}))}
data-testid="alert-threshold-query-select"
/>
<Typography.Text className="sentence-text">is</Typography.Text>
<Select
<SelectSimple
value={
(normalizeOperator(thresholdState.operator) ??
thresholdState.operator) as AlertThresholdOperator
@@ -247,17 +251,17 @@ function AlertThreshold({
onChange={(value): void => {
setThresholdState({
type: 'SET_OPERATOR',
payload: value,
payload: value as AlertThresholdOperator,
});
}}
style={{ width: 180 }}
options={THRESHOLD_OPERATOR_OPTIONS}
items={THRESHOLD_OPERATOR_OPTIONS}
data-testid="alert-threshold-operator-select"
/>
<Typography.Text className="sentence-text">
the threshold(s)
</Typography.Text>
<Select
<SelectSimple
value={
(normalizeMatchType(thresholdState.matchType) ??
thresholdState.matchType) as AlertThresholdMatchType
@@ -265,11 +269,11 @@ function AlertThreshold({
onChange={(value): void => {
setThresholdState({
type: 'SET_MATCH_TYPE',
payload: value,
payload: value as AlertThresholdMatchType,
});
}}
style={{ width: 180 }}
options={matchTypeOptionsWithTooltips}
items={matchTypeOptionsWithTooltips}
data-testid="alert-threshold-match-type-select"
/>
<Typography.Text className="sentence-text">

View File

@@ -1,8 +1,8 @@
import { useMemo } from 'react';
import { Select } from 'antd';
import { ComboboxSimple } from '@signozhq/ui/combobox';
import { SelectSimple } from '@signozhq/ui/select';
import { Typography } from '@signozhq/ui/typography';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { useAppContext } from 'providers/App/App';
import { useCreateAlertState } from '../context';
import {
@@ -18,19 +18,13 @@ import {
} from '../context/types';
import { normalizeMatchType, normalizeOperator } from '../utils';
import { AnomalyAndThresholdProps } from './types';
import {
getQueryNames,
NotificationChannelsNotFoundContent,
RoutingPolicyBanner,
} from './utils';
import { getQueryNames, RoutingPolicyBanner } from './utils';
function AnomalyThreshold({
channels,
isLoadingChannels,
isErrorChannels,
refreshChannels,
}: AnomalyAndThresholdProps): JSX.Element {
const { user } = useAppContext();
const {
thresholdState,
setThresholdState,
@@ -42,13 +36,14 @@ function AnomalyThreshold({
const queryNames = getQueryNames(currentQuery);
const deviationOptions = useMemo(() => {
const options = [];
for (let i = 1; i <= 7; i++) {
options.push({ label: i.toString(), value: i });
}
return options;
}, []);
const deviationOptions = useMemo(
() =>
Array.from({ length: 7 }, (_, i) => ({
label: (i + 1).toString(),
value: (i + 1).toString(),
})),
[],
);
const updateThreshold = (
id: string,
@@ -71,16 +66,16 @@ function AnomalyThreshold({
<Typography.Text data-testid="notification-text" className="sentence-text">
Send notification when the observed value for
</Typography.Text>
<Select
<SelectSimple
value={thresholdState.selectedQuery}
data-testid="query-select"
testId="query-select"
onChange={(value): void => {
setThresholdState({
type: 'SET_SELECTED_QUERY',
payload: value,
payload: value as string,
});
}}
options={queryNames}
items={queryNames}
/>
<Typography.Text
data-testid="evaluation-window-text"
@@ -88,16 +83,16 @@ function AnomalyThreshold({
>
during the last
</Typography.Text>
<Select
<SelectSimple
value={thresholdState.evaluationWindow}
data-testid="evaluation-window-select"
testId="evaluation-window-select"
onChange={(value): void => {
setThresholdState({
type: 'SET_EVALUATION_WINDOW',
payload: value,
payload: value as string,
});
}}
options={ANOMALY_TIME_DURATION_OPTIONS}
items={ANOMALY_TIME_DURATION_OPTIONS}
/>
</div>
<div className="alert-condition-sentence">
@@ -105,34 +100,34 @@ function AnomalyThreshold({
<Typography.Text data-testid="threshold-text" className="sentence-text">
is
</Typography.Text>
<Select
value={thresholdState.thresholds[0].thresholdValue}
data-testid="threshold-value-select"
<SelectSimple
value={thresholdState.thresholds[0].thresholdValue?.toString()}
testId="threshold-value-select"
onChange={(value): void => {
updateThreshold(
thresholdState.thresholds[0].id,
'thresholdValue',
value.toString(),
(value as string).toString(),
);
}}
options={deviationOptions}
items={deviationOptions}
/>
<Typography.Text data-testid="deviations-text" className="sentence-text">
deviations
</Typography.Text>
<Select
<SelectSimple
value={
(normalizeOperator(thresholdState.operator) ??
thresholdState.operator) as AlertThresholdOperator
}
data-testid="operator-select"
testId="operator-select"
onChange={(value): void => {
setThresholdState({
type: 'SET_OPERATOR',
payload: value,
payload: value as AlertThresholdOperator,
});
}}
options={ANOMALY_THRESHOLD_OPERATOR_OPTIONS}
items={ANOMALY_THRESHOLD_OPERATOR_OPTIONS}
/>
<Typography.Text
data-testid="predicted-data-text"
@@ -140,19 +135,19 @@ function AnomalyThreshold({
>
the predicted data
</Typography.Text>
<Select
<SelectSimple
value={
(normalizeMatchType(thresholdState.matchType) ??
thresholdState.matchType) as AlertThresholdMatchType
}
data-testid="match-type-select"
testId="match-type-select"
onChange={(value): void => {
setThresholdState({
type: 'SET_MATCH_TYPE',
payload: value,
payload: value as AlertThresholdMatchType,
});
}}
options={ANOMALY_THRESHOLD_MATCH_TYPE_OPTIONS}
items={ANOMALY_THRESHOLD_MATCH_TYPE_OPTIONS}
/>
</div>
{/* Sentence 3 */}
@@ -160,16 +155,16 @@ function AnomalyThreshold({
<Typography.Text data-testid="using-the-text" className="sentence-text">
using the
</Typography.Text>
<Select
<SelectSimple
value={thresholdState.algorithm}
data-testid="algorithm-select"
testId="algorithm-select"
onChange={(value): void => {
setThresholdState({
type: 'SET_ALGORITHM',
payload: value,
payload: value as string,
});
}}
options={ANOMALY_ALGORITHM_OPTIONS}
items={ANOMALY_ALGORITHM_OPTIONS}
/>
<Typography.Text
data-testid="algorithm-with-text"
@@ -177,16 +172,16 @@ function AnomalyThreshold({
>
algorithm with
</Typography.Text>
<Select
<SelectSimple
value={thresholdState.seasonality}
data-testid="seasonality-select"
testId="seasonality-select"
onChange={(value): void => {
setThresholdState({
type: 'SET_SEASONALITY',
payload: value,
payload: value as string,
});
}}
options={ANOMALY_SEASONALITY_OPTIONS}
items={ANOMALY_SEASONALITY_OPTIONS}
/>
{notificationSettings.routingPolicies ? (
<>
@@ -196,35 +191,25 @@ function AnomalyThreshold({
>
seasonality to
</Typography.Text>
<Select
<ComboboxSimple
value={thresholdState.thresholds[0].channels}
onChange={(value): void =>
updateThreshold(thresholdState.thresholds[0].id, 'channels', value)
updateThreshold(
thresholdState.thresholds[0].id,
'channels',
value as string[],
)
}
style={{ width: 350 }}
options={channels.map((channel) => ({
items={channels.map((channel) => ({
value: channel.id,
label: channel.name,
}))}
mode="multiple"
multiple
placeholder="Select notification channels"
showSearch
maxTagCount={2}
maxTagPlaceholder={(omittedValues): string =>
`+${omittedValues.length} more`
}
maxTagTextLength={10}
filterOption={(input, option): boolean =>
option?.label?.toLowerCase().includes(input.toLowerCase()) || false
}
status={isErrorChannels ? 'error' : undefined}
disabled={isLoadingChannels}
notFoundContent={
<NotificationChannelsNotFoundContent
user={user}
refreshChannels={refreshChannels}
/>
}
loading={isLoadingChannels}
className={isErrorChannels ? 'error' : undefined}
emptyPlaceholder="No channels found"
/>
</>
) : (

View File

@@ -1,14 +1,14 @@
import { useMemo, useState } from 'react';
import { Button, Input, Select, Tooltip } from 'antd';
import { Button, Input, Tooltip } from 'antd';
import { ComboboxSimple } from '@signozhq/ui/combobox';
import { SelectSimple } from '@signozhq/ui/select';
import { Typography } from '@signozhq/ui/typography';
import { CircleX, Trash } from '@signozhq/icons';
import { useAppContext } from 'providers/App/App';
import { useCreateAlertState } from '../context';
import { AlertThresholdOperator } from '../context/types';
import { normalizeOperator } from '../utils';
import { ThresholdItemProps } from './types';
import { NotificationChannelsNotFoundContent } from './utils';
function ThresholdItem({
threshold,
@@ -18,36 +18,38 @@ function ThresholdItem({
channels,
units,
isErrorChannels,
refreshChannels,
isLoadingChannels,
}: ThresholdItemProps): JSX.Element {
const { user } = useAppContext();
const { thresholdState, notificationSettings } = useCreateAlertState();
const [showRecoveryThreshold, setShowRecoveryThreshold] = useState(false);
const yAxisUnitSelect = useMemo(() => {
let component = (
<Select
<SelectSimple
placeholder="Unit"
value={threshold.unit ? threshold.unit : null}
onChange={(value): void => updateThreshold(threshold.id, 'unit', value)}
value={threshold.unit ? threshold.unit : undefined}
onChange={(value): void =>
updateThreshold(threshold.id, 'unit', value as string)
}
style={{ width: 150 }}
options={units}
items={units}
disabled={units.length === 0}
data-testid="threshold-unit-select"
testId="threshold-unit-select"
/>
);
if (units.length === 0) {
component = (
<Tooltip trigger="hover" title="No compatible units available">
<Select
<SelectSimple
placeholder="Unit"
value={threshold.unit ? threshold.unit : null}
onChange={(value): void => updateThreshold(threshold.id, 'unit', value)}
value={threshold.unit ? threshold.unit : undefined}
onChange={(value): void =>
updateThreshold(threshold.id, 'unit', value as string)
}
style={{ width: 150 }}
options={units}
items={units}
disabled={units.length === 0}
data-testid="threshold-unit-select"
testId="threshold-unit-select"
/>
</Tooltip>
);
@@ -117,37 +119,22 @@ function ThresholdItem({
{!notificationSettings.routingPolicies && (
<>
<Typography.Text className="sentence-text">send to</Typography.Text>
<Select
<ComboboxSimple
value={threshold.channels}
onChange={(value): void =>
updateThreshold(threshold.id, 'channels', value)
updateThreshold(threshold.id, 'channels', value as string[])
}
data-testid="threshold-notification-channel-select"
testId="threshold-notification-channel-select"
style={{ width: 350 }}
options={channels.map((channel) => ({
items={channels.map((channel) => ({
value: channel.name,
label: channel.name,
'data-testid': `threshold-notification-channel-option-${threshold.label}`,
}))}
mode="multiple"
multiple
placeholder="Select notification channels"
showSearch
maxTagCount={2}
maxTagPlaceholder={(omittedValues): string =>
`+${omittedValues.length} more`
}
maxTagTextLength={10}
filterOption={(input, option): boolean =>
option?.label?.toLowerCase().includes(input.toLowerCase()) || false
}
status={isErrorChannels ? 'error' : undefined}
disabled={isLoadingChannels}
notFoundContent={
<NotificationChannelsNotFoundContent
user={user}
refreshChannels={refreshChannels}
/>
}
loading={isLoadingChannels}
className={isErrorChannels ? 'error' : undefined}
emptyPlaceholder="No channels found"
/>
</>
)}

View File

@@ -1,5 +1,5 @@
import { fireEvent, render, screen } from '@testing-library/react';
import type { DefaultOptionType } from 'antd/es/select';
import type { ComboboxSimpleItem } from '@signozhq/ui/combobox';
import { createMockAlertContextState } from 'container/CreateAlertV2/EvaluationSettings/__tests__/testUtils';
import { getAppContextMockState } from 'container/RoutingPolicies/__tests__/testUtils';
import * as appHooks from 'providers/App/App';
@@ -66,7 +66,7 @@ const mockChannels: Channels[] = [
{ id: TEST_CONSTANTS.CHANNEL_3, name: 'PagerDuty Channel' } as any,
];
const mockUnits: DefaultOptionType[] = [
const mockUnits: ComboboxSimpleItem[] = [
{ label: 'Bytes', value: 'bytes' },
{ label: 'KB', value: 'kb' },
{ label: 'MB', value: 'mb' },

View File

@@ -11,7 +11,7 @@
.alert-condition-tabs {
display: flex;
border-radius: 2px;
border: 1px solid var(--l1-border);
border: 1px solid var(--l2-border);
background: var(--l2-background);
flex-direction: row;
border-bottom: none;
@@ -26,19 +26,19 @@
padding: 9px;
box-shadow: none;
border-radius: 0px;
border-left: 0.5px solid var(--l1-border);
border-bottom: 0.5px solid var(--l1-border);
border-left: 0.5px solid var(--l2-border);
border-bottom: 0.5px solid var(--l2-border);
width: 120px;
height: 36px;
gap: 8px;
&.active-tab {
background-color: var(--l1-background);
background-color: var(--l2-background);
border-bottom: none;
&:hover {
background-color: var(--l1-background) !important;
background-color: var(--l2-background-hover) !important;
}
}
@@ -54,7 +54,7 @@
&:hover {
background-color: transparent !important;
border-left: 1px solid transparent !important;
color: var(--l1-foreground);
color: var(--l3-foreground);
}
}
}
@@ -65,10 +65,16 @@
.anomaly-threshold-container {
padding: 24px;
padding-right: 72px;
background-color: var(--l1-background);
border: 1px solid var(--l1-border);
background-color: var(--l2-background);
border: 1px solid var(--l2-border);
width: 100%;
--select-trigger-background-color: var(--l3-background);
--select-trigger-border-color: var(--l3-border);
--combobox-trigger-background-color: var(--l3-background);
--combobox-trigger-border-color: var(--l3-border);
.alert-condition-sentences {
display: flex;
flex-direction: column;
@@ -88,34 +94,6 @@
align-items: center;
gap: 8px;
}
.ant-select {
width: 240px;
.ant-select-selector {
background-color: var(--l2-background);
border: 1px solid var(--l1-border);
color: var(--muted-foreground);
font-family: 'Space Mono';
&:hover {
border-color: var(--l1-border);
}
&:focus {
border-color: var(--l1-border);
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}
}
.ant-select-selection-item {
color: var(--l1-foreground);
}
.ant-select-arrow {
color: var(--muted-foreground);
}
}
}
}
@@ -151,9 +129,9 @@
flex-wrap: wrap;
.ant-input {
background-color: var(--card);
border: 1px solid var(--l1-border);
color: var(--l1-foreground);
background-color: var(--l3-background);
border: 1px solid var(--l3-border);
color: var(--l2-foreground);
height: 32px;
&::placeholder {
@@ -161,28 +139,28 @@
}
&:hover {
border-color: var(--l1-border);
border-color: var(--l3-border);
}
&:focus {
border-color: var(--l1-border);
border-color: var(--l3-border);
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}
}
.ant-select {
.ant-select-selector {
background-color: var(--card);
border: 1px solid var(--l1-border);
color: var(--l1-foreground);
background-color: var(--l3-background);
border: 1px solid var(--l3-border);
color: var(--l2-foreground);
height: 32px;
&:hover {
border-color: var(--l1-border);
border-color: var(--l2-border);
}
&:focus {
border-color: var(--l1-border);
border-color: var(--l2-border);
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}
@@ -192,21 +170,23 @@
}
.ant-select-selection-item {
color: var(--l1-foreground);
color: var(--l2-foreground);
}
.ant-select-arrow {
color: var(--muted-foreground);
color: var(--l2-foreground);
}
}
.icon-btn {
color: var(--muted-foreground);
border: 1px solid var(--l1-border);
color: var(--l2-foreground);
border: 1px solid var(--l3-border);
background-color: var(--l3-background);
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
box-shadow: none;
}
}
}
@@ -226,8 +206,8 @@
pointer-events: none;
cursor: default;
color: var(--muted-foreground);
background-color: var(--card) !important;
border: 1px solid var(--l1-border);
background-color: var(--l3-background) !important;
border: 1px solid var(--l3-border);
border-radius: 4px;
display: flex;
align-items: center;
@@ -235,9 +215,9 @@
}
.ant-input {
background-color: var(--card);
border: 1px solid var(--l1-border);
color: var(--l1-foreground);
background-color: var(--l3-background);
border: 1px solid var(--l3-border);
color: var(--l2-foreground);
height: 32px;
&::placeholder {
@@ -245,11 +225,11 @@
}
&:hover {
border-color: var(--l1-border);
border-color: var(--l3-border);
}
&:focus {
border-color: var(--l1-border);
border-color: var(--l2-border);
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}
}
@@ -258,7 +238,7 @@
.add-threshold-btn {
margin-top: 8px;
border: 1px dashed var(--l1-border);
border: 1px dashed var(--l3-border);
color: var(--l2-foreground);
background-color: transparent;
border-radius: 4px;
@@ -267,10 +247,11 @@
display: flex;
align-items: center;
justify-content: center;
box-shadow: none;
&:hover {
border-color: var(--l1-border);
color: var(--l1-foreground);
border-color: var(--l2-border);
color: var(--l3-foreground);
}
.anticon {
@@ -339,8 +320,9 @@
min-width: 240px;
width: auto;
justify-content: space-between;
background-color: var(--l2-background);
border: 1px solid var(--l1-border);
background-color: var(--l3-background);
border: 1px solid var(--l3-border);
box-shadow: none;
.evaluate-alert-conditions-button-left {
color: var(--l2-foreground);
@@ -358,7 +340,7 @@
.evaluate-alert-conditions-button-right-text {
font-size: 12px;
font-weight: 500;
background-color: var(--l1-border);
background-color: var(--l3-border);
padding: 1px 4px;
}
}

View File

@@ -1,4 +1,4 @@
import type { DefaultOptionType } from 'antd/es/select';
import type { ComboboxSimpleItem } from '@signozhq/ui/combobox';
import { Channels } from 'types/api/channels/getAll';
import {
@@ -23,7 +23,7 @@ export interface ThresholdItemProps {
showRemoveButton: boolean;
channels: Channels[];
isLoadingChannels: boolean;
units: DefaultOptionType[];
units: ComboboxSimpleItem[];
isErrorChannels: boolean;
refreshChannels: () => void;
}

View File

@@ -1,7 +1,7 @@
import { Button, Flex, SelectProps } from 'antd';
import { Button, Flex } from 'antd';
import { Switch } from '@signozhq/ui/switch';
import { ComboboxSimpleItem } from '@signozhq/ui/combobox';
import { Typography } from '@signozhq/ui/typography';
import type { BaseOptionType, DefaultOptionType } from 'antd/es/select';
import { getInvolvedQueriesInTraceOperator } from 'components/QueryBuilderV2/QueryV2/TraceOperator/utils/utils';
import { YAxisSource } from 'components/YAxisUnitSelector/types';
import { getYAxisCategories } from 'components/YAxisUnitSelector/utils';
@@ -22,11 +22,11 @@ import { openInNewTab } from 'utils/navigation';
import { ROUTING_POLICIES_ROUTE } from './constants';
import { RoutingPolicyBannerProps } from './types';
export function getQueryNames(currentQuery: Query): BaseOptionType[] {
export function getQueryNames(currentQuery: Query): ComboboxSimpleItem[] {
const involvedQueriesInTraceOperator = getInvolvedQueriesInTraceOperator(
currentQuery.builder.queryTraceOperator,
);
const queryConfig: Record<EQueryType, () => SelectProps['options']> = {
const queryConfig: Record<EQueryType, () => ComboboxSimpleItem[]> = {
[EQueryType.QUERY_BUILDER]: () => [
...(getSelectedQueryOptions(currentQuery.builder.queryData)?.filter(
(option) =>
@@ -52,7 +52,7 @@ export function getCategoryByOptionId(id: string): string | undefined {
export function getCategorySelectOptionByName(
name: string | undefined,
): DefaultOptionType[] {
): ComboboxSimpleItem[] {
if (!name) {
return [];
}
@@ -68,7 +68,6 @@ export function getCategorySelectOptionByName(
?.units.map((unit) => ({
label: unit.name,
value: unit.id,
'data-testid': `threshold-unit-select-option-${unit.id}`,
})) || []
);
}

View File

@@ -3,6 +3,7 @@ import { X } from '@signozhq/icons';
import { useNotifications } from 'hooks/useNotifications';
import { LabelInputState, LabelsInputProps } from './types';
import { Button } from '@signozhq/ui/button';
function LabelsInput({
labels,
@@ -144,14 +145,16 @@ function LabelsInput({
)}
{!isAdding ? (
<button
<Button
className="labels-input__add-button"
type="button"
variant="outlined"
color="secondary"
onClick={handleAddLabelsClick}
data-testid="alert-add-label-button"
>
+ Add labels
</button>
</Button>
) : (
<div className="labels-input__input-container">
<input

View File

@@ -39,9 +39,14 @@
&__input.title {
background-color: transparent;
color: var(--l1-foreground);
background: var(--l2-background);
color: var(--l2-foreground);
width: 100%;
min-width: 300px;
&:hover {
background: var(--l2-background);
}
}
&__input.description {
@@ -49,15 +54,6 @@
background-color: transparent;
color: var(--l2-foreground);
}
.ant-btn {
display: flex;
gap: 4px;
align-items: center;
color: var(--l1-foreground);
border: 1px solid var(--l1-border);
margin-right: 16px;
}
}
.labels-input {
@@ -66,19 +62,7 @@
gap: 8px;
&__add-button {
width: fit-content;
font-size: 13px;
color: var(--l2-foreground);
border: 1px solid var(--l1-border);
background-color: transparent;
cursor: pointer;
padding: 4px 8px;
border-radius: 4px;
&:hover {
border-color: var(--l1-border);
color: var(--l1-foreground);
}
width: 80px;
}
&__existing-labels {
@@ -121,6 +105,7 @@
align-items: center;
background-color: transparent;
border: none;
border: 1px solid var(--l2-border);
}
&__input {

View File

@@ -93,16 +93,16 @@
gap: 8px;
.ant-input {
background-color: var(--l2-background);
border: 1px solid var(--l1-border);
color: var(--l1-foreground);
background-color: var(--l3-background);
border: 1px solid var(--l3-border);
color: var(--l2-foreground);
&:hover {
border-color: var(--l1-border);
border-color: var(--l3-border);
}
&:focus {
border-color: var(--l1-border);
border-color: var(--l3-border);
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}
}

View File

@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react';
import { Input, Select, Tooltip } from 'antd';
import { Input, Tooltip } from 'antd';
import { SelectSimple } from '@signozhq/ui/select';
import { Typography } from '@signozhq/ui/typography';
import { Info } from '@signozhq/icons';
@@ -79,8 +80,8 @@ function EvaluationCadence(): JSX.Element {
}
data-testid="evaluation-cadence-duration-input"
/>
<Select
options={ADVANCED_OPTIONS_TIME_UNIT_OPTIONS}
<SelectSimple
items={ADVANCED_OPTIONS_TIME_UNIT_OPTIONS}
placeholder="Select time unit"
style={{ width: 120 }}
value={advancedOptions.evaluationCadence.default.timeUnit}
@@ -91,7 +92,7 @@ function EvaluationCadence(): JSX.Element {
...advancedOptions.evaluationCadence,
default: {
...advancedOptions.evaluationCadence.default,
timeUnit: value,
timeUnit: value as string,
},
},
})

View File

@@ -1,5 +1,6 @@
import { useEffect, useMemo, useState } from 'react';
import { Button, DatePicker, Input, Select } from 'antd';
import { Button, DatePicker, Input } from 'antd';
import { ComboboxSimple } from '@signozhq/ui/combobox';
import { Typography } from '@signozhq/ui/typography';
import classNames from 'classnames';
import { useCreateAlertState } from 'container/CreateAlertV2/context';
@@ -42,10 +43,6 @@ function EvaluationCadenceDetails({
},
});
const [searchTimezoneString, setSearchTimezoneString] = useState('');
const [occurenceSearchString, setOccurenceSearchString] = useState('');
const [repeatEverySearchString, setRepeatEverySearchString] = useState('');
const tabs = [
{
label: 'Editor',
@@ -93,45 +90,39 @@ function EvaluationCadenceDetails({
<div className="editor-view" data-testid="editor-view">
<div className="select-group">
<Typography.Text>REPEAT EVERY</Typography.Text>
<Select
options={EVALUATION_CADENCE_REPEAT_EVERY_OPTIONS}
value={evaluationCadence.custom.repeatEvery || null}
<ComboboxSimple
items={EVALUATION_CADENCE_REPEAT_EVERY_OPTIONS}
value={evaluationCadence.custom.repeatEvery || undefined}
onChange={(value): void =>
setEvaluationCadence({
...evaluationCadence,
custom: {
...evaluationCadence.custom,
repeatEvery: value,
repeatEvery: value as string,
occurence: [],
},
})
}
placeholder="Select repeat every"
showSearch
searchValue={repeatEverySearchString}
onSearch={setRepeatEverySearchString}
/>
</div>
{evaluationCadence.custom.repeatEvery !== 'day' && (
<div className="select-group">
<Typography.Text>ON DAY(S)</Typography.Text>
<Select
options={occurenceOptions}
value={evaluationCadence.custom.occurence || null}
mode="multiple"
<ComboboxSimple
items={occurenceOptions}
value={evaluationCadence.custom.occurence || []}
multiple
onChange={(value): void =>
setEvaluationCadence({
...evaluationCadence,
custom: {
...evaluationCadence.custom,
occurence: value,
occurence: value as string[],
},
})
}
placeholder="Select day(s)"
showSearch
searchValue={occurenceSearchString}
onSearch={setOccurenceSearchString}
/>
</div>
)}
@@ -152,22 +143,19 @@ function EvaluationCadenceDetails({
</div>
<div className="select-group">
<Typography.Text>TIMEZONE</Typography.Text>
<Select
options={TIMEZONE_DATA}
value={evaluationCadence.custom.timezone || null}
<ComboboxSimple
items={TIMEZONE_DATA}
value={evaluationCadence.custom.timezone || undefined}
onChange={(value): void =>
setEvaluationCadence({
...evaluationCadence,
custom: {
...evaluationCadence.custom,
timezone: value,
timezone: value as string,
},
})
}
placeholder="Select timezone"
onSearch={setSearchTimezoneString}
searchValue={searchTimezoneString}
showSearch
/>
</div>
</div>

View File

@@ -1,5 +1,9 @@
.evaluation-cadence-container {
border-bottom: 1px solid var(--l1-border);
--select-trigger-background-color: var(--l3-background);
--select-trigger-border-color: var(--l3-border);
.evaluation-cadence-item {
border-bottom: none !important;
}
@@ -157,24 +161,6 @@
font-weight: 500;
}
.ant-select {
border: 1px solid var(--l1-border);
.ant-select-selector {
background-color: var(--l2-background);
border: 1px solid var(--l1-border);
color: var(--l1-foreground);
&:hover {
border-color: var(--l1-border);
}
&:focus {
border-color: var(--l1-border);
}
}
}
.ant-picker {
background-color: var(--l2-background);
border: 1px solid var(--l1-border);

View File

@@ -1,5 +1,6 @@
import { useMemo } from 'react';
import { Input, Select } from 'antd';
import { Input } from 'antd';
import { SelectSimple } from '@signozhq/ui/select';
import { Typography } from '@signozhq/ui/typography';
import { ADVANCED_OPTIONS_TIME_UNIT_OPTIONS } from '../../context/constants';
@@ -19,7 +20,7 @@ function EvaluationWindowDetails({
const currentHourOptions = useMemo(() => {
const options = [];
for (let i = 0; i < 60; i++) {
options.push({ label: i.toString(), value: i });
options.push({ label: i.toString(), value: i.toString() });
}
return options;
}, []);
@@ -27,7 +28,7 @@ function EvaluationWindowDetails({
const currentMonthOptions = useMemo(() => {
const options = [];
for (let i = 1; i <= 31; i++) {
options.push({ label: i.toString(), value: i });
options.push({ label: i.toString(), value: i.toString() });
}
return options;
}, []);
@@ -123,10 +124,10 @@ function EvaluationWindowDetails({
<Typography.Text>{displayText}</Typography.Text>
<div className="select-group">
<Typography.Text>STARTING AT MINUTE</Typography.Text>
<Select
options={currentHourOptions}
value={evaluationWindow.startingAt.number || null}
onChange={handleNumberChange}
<SelectSimple
items={currentHourOptions}
value={evaluationWindow.startingAt.number || undefined}
onChange={(value): void => handleNumberChange(value as string)}
placeholder="Select starting at"
data-testid="evaluation-window-details-starting-at-select"
/>
@@ -151,10 +152,10 @@ function EvaluationWindowDetails({
</div>
<div className="select-group">
<Typography.Text>SELECT TIMEZONE</Typography.Text>
<Select
options={TIMEZONE_DATA}
value={evaluationWindow.startingAt.timezone || null}
onChange={handleTimezoneChange}
<SelectSimple
items={TIMEZONE_DATA}
value={evaluationWindow.startingAt.timezone || undefined}
onChange={(value): void => handleTimezoneChange(value as string)}
placeholder="Select timezone"
data-testid="evaluation-window-details-timezone-select"
/>
@@ -172,10 +173,10 @@ function EvaluationWindowDetails({
<Typography.Text>{displayText}</Typography.Text>
<div className="select-group">
<Typography.Text>STARTING ON DAY</Typography.Text>
<Select
options={currentMonthOptions}
value={evaluationWindow.startingAt.number || null}
onChange={handleNumberChange}
<SelectSimple
items={currentMonthOptions}
value={evaluationWindow.startingAt.number || undefined}
onChange={(value): void => handleNumberChange(value as string)}
placeholder="Select starting at"
data-testid="evaluation-window-details-starting-at-select"
/>
@@ -189,10 +190,10 @@ function EvaluationWindowDetails({
</div>
<div className="select-group">
<Typography.Text>SELECT TIMEZONE</Typography.Text>
<Select
options={TIMEZONE_DATA}
value={evaluationWindow.startingAt.timezone || null}
onChange={handleTimezoneChange}
<SelectSimple
items={TIMEZONE_DATA}
value={evaluationWindow.startingAt.timezone || undefined}
onChange={(value): void => handleTimezoneChange(value as string)}
placeholder="Select timezone"
data-testid="evaluation-window-details-timezone-select"
/>
@@ -221,10 +222,10 @@ function EvaluationWindowDetails({
</div>
<div className="select-group time-select-group">
<Typography.Text>UNIT</Typography.Text>
<Select
options={ADVANCED_OPTIONS_TIME_UNIT_OPTIONS}
value={evaluationWindow.startingAt.unit || null}
onChange={handleUnitChange}
<SelectSimple
items={ADVANCED_OPTIONS_TIME_UNIT_OPTIONS}
value={evaluationWindow.startingAt.unit || undefined}
onChange={(value): void => handleUnitChange(value as string)}
placeholder="Select unit"
data-testid="evaluation-window-details-custom-rolling-window-unit-select"
/>

View File

@@ -1,5 +1,6 @@
import { useCallback, useMemo } from 'react';
import { Select, Tooltip } from 'antd';
import { Tooltip } from 'antd';
import { SelectSimple } from '@signozhq/ui/select';
import { Typography } from '@signozhq/ui/typography';
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { Info } from '@signozhq/icons';
@@ -87,16 +88,15 @@ function MultipleNotifications(): JSX.Element {
: 'No grouping fields available';
let input = (
<div>
<Select
options={spaceAggregationOptions}
onChange={onSelectChange}
value={notificationSettings.multipleNotifications}
mode="multiple"
<SelectSimple
items={spaceAggregationOptions}
onChange={(value): void => onSelectChange(value as string[])}
value={notificationSettings.multipleNotifications || []}
multiple
placeholder={placeholder}
disabled={!isMultipleNotificationsEnabled}
aria-disabled={!isMultipleNotificationsEnabled}
maxTagCount={3}
data-testid="multiple-notifications-select"
maxDisplayedPills={3}
testId="multiple-notifications-select"
/>
{isMultipleNotificationsEnabled && (
<Typography.Text className="multiple-notifications-select-description">

View File

@@ -1,4 +1,5 @@
import { Input, Select } from 'antd';
import { Input } from 'antd';
import { SelectSimple } from '@signozhq/ui/select';
import { Typography } from '@signozhq/ui/typography';
import { useCreateAlertState } from '../context';
@@ -38,31 +39,31 @@ function NotificationSettings(): JSX.Element {
}}
data-testid="repeat-notifications-time-input"
/>
<Select
value={notificationSettings.reNotification.unit || null}
<SelectSimple
value={notificationSettings.reNotification.unit || undefined}
placeholder="Select unit"
disabled={!notificationSettings.reNotification.enabled}
options={RE_NOTIFICATION_TIME_UNIT_OPTIONS}
items={RE_NOTIFICATION_TIME_UNIT_OPTIONS}
onChange={(value): void => {
setNotificationSettings({
type: 'SET_RE_NOTIFICATION',
payload: {
enabled: notificationSettings.reNotification.enabled,
value: notificationSettings.reNotification.value,
unit: value,
unit: value as string,
conditions: notificationSettings.reNotification.conditions,
},
});
}}
data-testid="repeat-notifications-unit-select"
testId="repeat-notifications-unit-select"
/>
<Typography.Text>while</Typography.Text>
<Select
mode="multiple"
value={notificationSettings.reNotification.conditions || null}
<SelectSimple
multiple
value={notificationSettings.reNotification.conditions || []}
placeholder="Select conditions"
disabled={!notificationSettings.reNotification.enabled}
options={RE_NOTIFICATION_CONDITION_OPTIONS}
items={RE_NOTIFICATION_CONDITION_OPTIONS}
onChange={(value): void => {
setNotificationSettings({
type: 'SET_RE_NOTIFICATION',
@@ -70,11 +71,11 @@ function NotificationSettings(): JSX.Element {
enabled: notificationSettings.reNotification.enabled,
value: notificationSettings.reNotification.value,
unit: notificationSettings.reNotification.unit,
conditions: value,
conditions: value as ('firing' | 'nodata')[],
},
});
}}
data-testid="repeat-notifications-conditions-select"
testId="repeat-notifications-conditions-select"
/>
</div>
);

View File

@@ -3,6 +3,9 @@
flex-direction: column;
margin: 0 16px;
--select-trigger-background-color: var(--l3-background);
--select-trigger-border-color: var(--l3-border);
.notification-message-container {
display: flex;
flex-direction: column;
@@ -54,8 +57,8 @@
textarea {
height: 150px;
background: var(--l2-background);
border: 1px solid var(--l1-border);
background: var(--l3-background);
border: 1px solid var(--l3-border);
border-radius: 4px;
color: var(--l2-foreground) !important;
font-family: Inter;
@@ -77,8 +80,9 @@
gap: 8px;
.ant-input {
width: 120px;
border: 1px solid var(--l1-border);
width: 190px;
border: 1px solid var(--l3-border);
background-color: var(--l3-background);
}
.ant-select {

View File

@@ -37,11 +37,11 @@
gap: 8px;
&.active-tab {
background-color: var(--l1-background);
background-color: var(--l3-background);
border-bottom: none;
&:hover {
background-color: var(--l1-background) !important;
background-color: var(--l3-background) !important;
}
}

View File

@@ -7,7 +7,7 @@ import {
useState,
} from 'react';
import { Color } from '@signozhq/design-tokens';
import { Select } from 'antd';
import { SelectSimple } from '@signozhq/ui/select';
import { Typography } from '@signozhq/ui/typography';
import CustomSelect from 'components/NewSelect/CustomSelect';
import TextToolTip from 'components/TextToolTip';
@@ -204,10 +204,9 @@ function DynamicVariable({
}
/>
</span>
<Select
<SelectSimple
placeholder="Source"
defaultValue={AttributeSource.ALL_TELEMETRY}
options={sources.map((source) => ({ label: source, value: source }))}
items={sources.map((source) => ({ label: source, value: source }))}
onChange={(value): void => setAttributeSource(value as AttributeSource)}
value={attributeSource || dynamicVariablesSelectedValue?.value}
/>

View File

@@ -5,8 +5,9 @@ import { useQuery } from 'react-query';
import { useSelector } from 'react-redux';
import { orange } from '@ant-design/colors';
import { Color } from '@signozhq/design-tokens';
import { Button, Collapse, Input, Select, Tag } from 'antd';
import { Switch } from '@signozhq/ui/switch';
import { Button, Collapse, Input, Tag } from 'antd';
import { SelectSimple } from '@signozhq/ui/select';
import { Typography } from '@signozhq/ui/typography';
import dashboardVariablesQuery from 'api/dashboard/variables/dashboardVariablesQuery';
import cx from 'classnames';
@@ -56,7 +57,11 @@ import { WidgetSelector } from './WidgetSelector';
import './VariableItem.styles.scss';
const { Option } = Select;
const SORT_ITEMS = [
{ value: VariableSortTypeArr[0], label: 'Disabled' },
{ value: VariableSortTypeArr[1], label: 'Ascending' },
{ value: VariableSortTypeArr[2], label: 'Descending' },
];
interface VariableItemProps {
variableData: IDashboardVariable;
@@ -743,19 +748,14 @@ function VariableItem({
<Typography className="typography-variables">Sort Values</Typography>
</LabelContainer>
<Select
defaultActiveFirstOption
defaultValue={VariableSortTypeArr[0]}
<SelectSimple
value={variableSortType}
onChange={(value: TSortVariableValuesType): void =>
setVariableSortType(value)
onChange={(value): void =>
setVariableSortType(value as TSortVariableValuesType)
}
className="sort-input"
>
<Option value={VariableSortTypeArr[0]}>Disabled</Option>
<Option value={VariableSortTypeArr[1]}>Ascending</Option>
<Option value={VariableSortTypeArr[2]}>Descending</Option>
</Select>
items={SORT_ITEMS}
/>
</VariableItemRow>
<VariableItemRow className="multiple-values-section">
<LabelContainer>
@@ -798,10 +798,10 @@ function VariableItem({
<CustomSelect
placeholder="Select a default value"
value={variableDefaultValue}
onChange={(value): void => setVariableDefaultValue(value)}
options={previewValues.map((value) => ({
label: value,
value,
onChange={(value): void => setVariableDefaultValue(value ?? '')}
options={previewValues.map((val) => ({
label: val,
value: val,
}))}
/>
</VariableItemRow>

View File

@@ -98,6 +98,14 @@
.nameIconInput {
display: flex;
--select-trigger-width: 40px;
--select-trigger-background-color: var(--l3-background);
--select-trigger-border-color: var(--l1-border);
[data-slot='select-trigger'] svg {
display: none;
}
}
.dashboardImageInput {
@@ -108,7 +116,7 @@
padding: 6px;
justify-content: center;
align-items: center;
border-radius: 2px 0px 0px 2px;
border-radius: 2var (--l3-border) px 0px 0px 2px;
border: 1px solid var(--l1-border) !important;
background: var(--l3-background) !important;

View File

@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Col, Input, Radio, Select, Space, Tooltip } from 'antd';
import { Col, Input, Radio, Space, Tooltip } from 'antd';
import { SelectSimple } from '@signozhq/ui/select';
import { Typography } from '@signozhq/ui/typography';
import AddTags from 'container/DashboardContainer/DashboardSettings/General/AddTags';
import { useDashboardCursorSyncMode } from 'hooks/dashboard/useDashboardCursorSyncMode';
@@ -21,8 +22,6 @@ import logEvent from 'api/common/logEvent';
import { Events } from 'constants/events';
import { getAbsoluteUrl } from 'utils/basePath';
const { Option } = Select;
function GeneralDashboardSettings(): JSX.Element {
const { dashboardData, setDashboardData } = useDashboardStore();
@@ -130,24 +129,22 @@ function GeneralDashboardSettings(): JSX.Element {
<div>
<Typography className={styles.dashboardName}>Dashboard Name</Typography>
<section className={styles.nameIconInput}>
<Select
defaultActiveFirstOption
<SelectSimple
data-testid="dashboard-image"
suffixIcon={null}
rootClassName={styles.dashboardImageInput}
className={styles.dashboardImageInput}
value={updatedImage}
onChange={(value: string): void => setUpdatedImage(value)}
>
{Base64Icons.map((icon) => (
<Option value={icon} key={icon}>
onChange={(value): void => setUpdatedImage(value as string)}
items={Base64Icons.map((icon) => ({
value: icon,
label: (
<img
src={icon}
alt="dashboard-icon"
className={styles.listItemImage}
/>
</Option>
))}
</Select>
),
}))}
/>
<Input
data-testid="dashboard-name"
className={styles.dashboardNameInput}

View File

@@ -3,7 +3,8 @@ import { useMutation } from 'react-query';
import { useCopyToClipboard } from 'react-use';
import { Checkbox } from '@signozhq/ui/checkbox';
import { toast } from '@signozhq/ui/sonner';
import { Button, Select } from 'antd';
import { Button } from 'antd';
import { SelectSimple } from '@signozhq/ui/select';
import { Typography } from '@signozhq/ui/typography';
import createPublicDashboardAPI from 'api/dashboard/public/createPublicDashboard';
import revokePublicDashboardAccessAPI from 'api/dashboard/public/revokePublicDashboardAccess';
@@ -270,12 +271,12 @@ function PublicDashboardSetting(): JSX.Element {
Default time range
</Typography.Text>
</div>
<Select
<SelectSimple
placeholder="Select default time range"
options={TIME_RANGE_PRESETS_OPTIONS}
items={TIME_RANGE_PRESETS_OPTIONS}
value={defaultTimeRange}
onChange={handleDefaultTimeRange}
data-testid="default-time-range-select-dropdown"
onChange={(value): void => handleDefaultTimeRange(value as string)}
testId="default-time-range-select-dropdown"
className="default-time-range-select-dropdown"
/>
</div>

View File

@@ -1,43 +0,0 @@
.settings-container-root {
.ant-drawer-wrapper-body {
border-left: 1px solid var(--l1-border);
background: var(--l2-background);
box-shadow: -4px 10px 16px 2px rgba(0, 0, 0, 0.2);
.ant-drawer-header {
height: 48px;
border-bottom: 1px solid var(--l1-border);
padding: 14px 14px 14px 11px;
.ant-drawer-header-title {
gap: 16px;
.ant-drawer-title {
color: var(--l2-foreground);
font-family: Inter;
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 20px; /* 142.857% */
letter-spacing: -0.07px;
padding-left: 16px;
border-left: 1px solid var(--l1-border);
}
.ant-drawer-close {
height: 16px;
width: 16px;
margin-inline-end: 0px !important;
}
}
}
.ant-drawer-body {
padding: 16px;
&::-webkit-scrollbar {
width: 0.1rem;
}
}
}
}

View File

@@ -1,34 +0,0 @@
import { memo, PropsWithChildren, ReactElement } from 'react';
import { Drawer } from 'antd';
import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar';
import './SettingsDrawer.styles.scss';
type SettingsDrawerProps = PropsWithChildren<{
drawerTitle: string;
isOpen: boolean;
onClose: () => void;
}>;
function SettingsDrawer({
children,
drawerTitle,
isOpen,
onClose,
}: SettingsDrawerProps): JSX.Element {
return (
<Drawer
title={drawerTitle}
placement="right"
width="50%"
onClose={onClose}
open={isOpen}
rootClassName="settings-container-root"
>
{/* Need to type cast because of OverlayScrollbar type definition. We should be good once we remove it. */}
<OverlayScrollbar>{children as ReactElement}</OverlayScrollbar>
</Drawer>
);
}
export default memo(SettingsDrawer);

View File

@@ -1,411 +0,0 @@
import { useEffect, useMemo, useState } from 'react';
import { FullScreenHandle } from 'react-full-screen';
import { useTranslation } from 'react-i18next';
import { useCopyToClipboard } from 'react-use';
import {
Check,
ClipboardCopy,
Ellipsis,
FileJson,
Fullscreen,
Globe,
LockKeyhole,
PenLine,
Plus,
X,
} from '@signozhq/icons';
import { Button, Card, Input, Modal, Popover, Tag, Tooltip } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import logEvent from 'api/common/logEvent';
import {
lockDashboardV2,
patchDashboardV2,
unlockDashboardV2,
} from 'api/generated/services/dashboard';
import type { DashboardtypesJSONPatchOperationDTO } from 'api/generated/services/sigNoz.schemas';
import ConfigureIcon from 'assets/Integrations/ConfigureIcon';
import { DeleteButton } from 'container/ListOfDashboard/TableComponents/DeleteButton';
import DateTimeSelectionV2 from 'container/TopNav/DateTimeSelectionV2';
import useComponentPermission from 'hooks/useComponentPermission';
import { useNotifications } from 'hooks/useNotifications';
import { isEmpty } from 'lodash-es';
import { useAppContext } from 'providers/App/App';
import { useErrorModal } from 'providers/ErrorModalProvider';
import APIError from 'types/api/error';
import { USER_ROLES } from 'types/roles';
import { Base64Icons } from '../../DashboardContainer/DashboardSettings/General/utils';
import DashboardSettingsV2 from '../DashboardSettings';
import DashboardHeader from '../components/DashboardHeader/DashboardHeader';
import DashboardVariablesV2 from '../DashboardVariablesV2';
import SettingsDrawer from './SettingsDrawer';
import '../../DashboardContainer/DashboardDescription/Description.styles.scss';
import type { V2Dashboard } from '../utils';
interface DashboardDescriptionV2Props {
dashboard: V2Dashboard | undefined;
handle: FullScreenHandle;
onRefetch: () => void;
}
// eslint-disable-next-line sonarjs/cognitive-complexity
function DashboardDescriptionV2(props: DashboardDescriptionV2Props): JSX.Element {
const { dashboard, handle, onRefetch } = props;
const id = dashboard?.id ?? '';
const isDashboardLocked = !!dashboard?.locked;
const [isSettingsDrawerOpen, setIsSettingsDrawerOpen] =
useState<boolean>(false);
const title = dashboard?.data?.spec?.display?.name ?? '';
const description = dashboard?.data?.spec?.display?.description ?? '';
const image = dashboard?.data?.metadata?.image || Base64Icons[0];
const tags = useMemo(
() =>
(dashboard?.data?.metadata?.tags ?? []).map((t) =>
t.key === t.value ? t.key : `${t.key}:${t.value}`,
),
[dashboard?.data?.metadata?.tags],
);
const dashboardVariables = dashboard?.data?.spec?.variables ?? [];
const [updatedTitle, setUpdatedTitle] = useState<string>(title);
const { user } = useAppContext();
const [editDashboard] = useComponentPermission(['edit_dashboard'], user.role);
const [isDashboardSettingsOpen, setIsDashbordSettingsOpen] =
useState<boolean>(false);
const [isRenameDashboardOpen, setIsRenameDashboardOpen] =
useState<boolean>(false);
const isAuthor =
!!user?.email && !!dashboard?.createdBy && dashboard.createdBy === user.email;
const addPanelPermission = !isDashboardLocked;
// V2 public dashboard wiring lives separately; treat as not-public for chrome.
const isPublicDashboard = false;
const { notifications } = useNotifications();
const { showErrorModal } = useErrorModal();
const { t } = useTranslation(['dashboard', 'common']);
const [isRenameLoading, setIsRenameLoading] = useState<boolean>(false);
useEffect(() => {
if (dashboard) setUpdatedTitle(title);
}, [dashboard, title]);
const handleLockDashboardToggle = async (): Promise<void> => {
if (!id) return;
setIsDashbordSettingsOpen(false);
try {
if (isDashboardLocked) {
await unlockDashboardV2({ id });
notifications.success({ message: 'Dashboard unlocked' });
} else {
await lockDashboardV2({ id });
notifications.success({ message: 'Dashboard locked' });
}
onRefetch();
} catch (error) {
showErrorModal(error as APIError);
}
};
const onNameChangeHandler = async (): Promise<void> => {
const trimmed = updatedTitle.trim();
if (!id || !trimmed || trimmed === title) {
setIsRenameDashboardOpen(false);
return;
}
try {
setIsRenameLoading(true);
const patch: DashboardtypesJSONPatchOperationDTO[] = [
{
op: 'replace' as DashboardtypesJSONPatchOperationDTO['op'],
path: '/spec/display/name',
value: trimmed,
},
];
await patchDashboardV2({ id }, patch);
notifications.success({ message: 'Dashboard renamed successfully' });
setIsRenameDashboardOpen(false);
onRefetch();
} catch (error) {
showErrorModal(error as APIError);
setIsRenameDashboardOpen(true);
} finally {
setIsRenameLoading(false);
}
};
const onEmptyWidgetHandler = (): void => {
logEvent('Dashboard Detail V2: Add new panel clicked', {
dashboardId: id,
});
notifications.info({
message: 'V2 panel editor coming next',
});
};
const [state, setCopy] = useCopyToClipboard();
useEffect(() => {
if (state.error) {
notifications.error({
message: t('something_went_wrong', { ns: 'common' }),
});
}
if (state.value) {
notifications.success({ message: t('success', { ns: 'common' }) });
}
}, [state.error, state.value, t, notifications]);
const dashboardDataJSON = (): string =>
JSON.stringify(dashboard?.data ?? {}, null, 2);
const exportJSON = (): void => {
const blob = new Blob([dashboardDataJSON()], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `${title || 'dashboard'}.json`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
};
const onConfigureClick = (): void => {
setIsSettingsDrawerOpen(true);
};
const onSettingsDrawerClose = (): void => {
setIsSettingsDrawerOpen(false);
};
return (
<Card className="dashboard-description-container">
<DashboardHeader title={title} image={image} />
<section className="dashboard-details">
<div className="left-section">
<img src={image} alt="dashboard-img" className="dashboard-img" />
<Tooltip title={title.length > 30 ? title : ''}>
<Typography.Text
className="dashboard-title"
data-testid="dashboard-title"
>
{title}
</Typography.Text>
</Tooltip>
{isPublicDashboard && (
<Tooltip title="This dashboard is publicly accessible">
<Globe size={14} className="public-dashboard-icon" />
</Tooltip>
)}
{isDashboardLocked && (
<Tooltip title="This dashboard is locked">
<LockKeyhole size={14} className="lock-dashboard-icon" />
</Tooltip>
)}
</div>
<div className="right-section">
<DateTimeSelectionV2 showAutoRefresh hideShareModal />
<Popover
open={isDashboardSettingsOpen}
arrow={false}
onOpenChange={(visible): void => setIsDashbordSettingsOpen(visible)}
rootClassName="dashboard-settings"
content={
<div className="menu-content">
<section className="section-1">
{(isAuthor || user.role === USER_ROLES.ADMIN) && (
<Tooltip
title={
dashboard?.createdBy === 'integration' &&
'Dashboards created by integrations cannot be unlocked'
}
>
<Button
type="text"
icon={<LockKeyhole size={14} />}
disabled={dashboard?.createdBy === 'integration'}
onClick={handleLockDashboardToggle}
data-testid="lock-unlock-dashboard"
>
{isDashboardLocked ? 'Unlock Dashboard' : 'Lock Dashboard'}
</Button>
</Tooltip>
)}
{!isDashboardLocked && editDashboard && (
<Button
type="text"
icon={<PenLine size={14} />}
onClick={(): void => {
setIsRenameDashboardOpen(true);
setIsDashbordSettingsOpen(false);
}}
>
Rename
</Button>
)}
<Button
type="text"
icon={<Fullscreen size={14} />}
onClick={handle.enter}
>
Full screen
</Button>
</section>
<section className="section-2">
<Button
type="text"
icon={<FileJson size={14} />}
onClick={(): void => {
exportJSON();
setIsDashbordSettingsOpen(false);
}}
>
Export JSON
</Button>
<Button
type="text"
icon={<ClipboardCopy size={14} />}
onClick={(): void => {
setCopy(dashboardDataJSON());
setIsDashbordSettingsOpen(false);
}}
>
Copy as JSON
</Button>
</section>
<section className="delete-dashboard">
<DeleteButton
createdBy={dashboard?.createdBy || ''}
name={title}
id={id}
isLocked={isDashboardLocked}
routeToListPage
/>
</section>
</div>
}
trigger="click"
placement="bottomRight"
>
<Button
icon={<Ellipsis size={14} />}
type="text"
className="icons"
data-testid="options"
/>
</Popover>
{!isDashboardLocked && editDashboard && (
<>
<Button
type="text"
className="configure-button"
icon={<ConfigureIcon />}
data-testid="show-drawer"
onClick={onConfigureClick}
>
Configure
</Button>
<SettingsDrawer
drawerTitle="Dashboard Configuration"
isOpen={isSettingsDrawerOpen}
onClose={onSettingsDrawerClose}
>
<DashboardSettingsV2
dashboard={dashboard}
onRefetch={onRefetch}
/>
</SettingsDrawer>
</>
)}
{!isDashboardLocked && addPanelPermission && (
<Button
className="add-panel-btn"
onClick={onEmptyWidgetHandler}
icon={<Plus size="md" />}
type="primary"
data-testid="add-panel-header"
>
New Panel
</Button>
)}
</div>
</section>
{tags.length > 0 && (
<div className="dashboard-tags">
{tags.map((tag) => (
<Tag key={tag} className="tag">
{tag}
</Tag>
))}
</div>
)}
{!isEmpty(description) && (
<section className="dashboard-description-section">{description}</section>
)}
{dashboardVariables.length > 0 && (
<section className="dashboard-variables">
<DashboardVariablesV2
dashboardId={id}
variables={dashboardVariables}
/>
</section>
)}
<Modal
open={isRenameDashboardOpen}
title="Rename Dashboard"
onOk={onNameChangeHandler}
onCancel={(): void => {
setIsRenameDashboardOpen(false);
}}
rootClassName="rename-dashboard"
footer={
<div className="dashboard-rename">
<Button
type="primary"
icon={<Check size={14} />}
className="rename-btn"
onClick={onNameChangeHandler}
disabled={isRenameLoading}
>
Rename Dashboard
</Button>
<Button
type="text"
icon={<X size={14} />}
className="cancel-btn"
onClick={(): void => setIsRenameDashboardOpen(false)}
>
Cancel
</Button>
</div>
}
>
<div className="dashboard-content">
<Typography.Text className="name-text">Enter a new name</Typography.Text>
<Input
data-testid="dashboard-name"
className="dashboard-name-input"
value={updatedTitle}
onChange={(e): void => setUpdatedTitle(e.target.value)}
/>
</div>
</Modal>
</Card>
);
}
export default DashboardDescriptionV2;

View File

@@ -1,227 +0,0 @@
.overviewContent {
display: flex;
flex-direction: column;
gap: 16px;
}
.overviewSettings {
border-radius: 3px;
border: 1px solid var(--l1-border);
padding: 16px !important;
}
.crossPanelSyncGroup {
display: flex;
flex-direction: column;
gap: 16px;
}
.crossPanelSyncSectionTitle {
color: var(--l1-foreground);
font-family: Inter;
font-size: 14px;
font-weight: 500;
line-height: 20px;
}
.crossPanelSyncSectionHeader {
display: flex;
align-items: center;
gap: 6px;
align-self: flex-start;
}
.crossPanelSyncInfoIcon {
cursor: help;
color: var(--l3-foreground);
}
.crossPanelSyncTooltipContent {
display: flex;
flex-direction: column;
gap: 8px;
max-width: 300px;
}
.crossPanelSyncTooltipTitle {
font-size: 14px;
}
.crossPanelSyncTooltipDescription {
font-size: 12px;
line-height: 1.5;
}
.crossPanelSyncTooltipDocLink {
display: flex;
align-items: center;
gap: 4px;
color: var(--primary-background);
font-size: 12px;
margin-top: 4px;
}
.crossPanelSyncRow {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
gap: 16px;
& + & {
padding-top: 16px;
border-top: 1px solid var(--l1-border);
}
}
.crossPanelSyncInfo {
display: flex;
flex-direction: column;
gap: 4px;
}
.crossPanelSyncTitle {
color: var(--l2-foreground);
font-family: Inter;
font-size: 14px;
font-weight: 400;
line-height: 20px;
}
.crossPanelSyncDescription {
color: var(--l3-foreground);
font-family: Inter;
font-size: 13px;
font-weight: 400;
line-height: 20px;
}
.nameIconInput {
display: flex;
}
.dashboardImageInput {
:global(.ant-select-selector) {
display: flex;
width: 32px;
height: 32px;
padding: 6px;
justify-content: center;
align-items: center;
border-radius: 2px 0px 0px 2px;
border: 1px solid var(--l1-border) !important;
background: var(--l3-background) !important;
:global(.ant-select-selection-item) {
display: flex;
align-items: center;
}
}
&:global(.ant-select-dropdown) {
padding: 0px !important;
}
:global(.ant-select-item) {
padding: 0px;
align-items: center;
justify-content: center;
:global(.ant-select-item-option-content) {
display: flex;
align-items: center;
justify-content: center;
}
}
}
.listItemImage {
height: 16px;
width: 16px;
}
.dashboardNameInput {
border-radius: 0px 2px 2px 0px;
border: 1px solid var(--l1-border);
background: var(--l3-background);
}
.dashboardName {
color: var(--l2-foreground);
font-family: Inter;
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 20px;
margin-bottom: 0.5rem;
}
.descriptionTextArea {
padding: 6px 6px 6px 8px;
border-radius: 2px;
border: 1px solid var(--l1-border);
background: var(--l3-background);
}
.overviewSettingsFooter {
display: flex;
justify-content: space-between;
align-items: center;
width: -webkit-fill-available;
padding: 12px 16px 12px 0px;
position: fixed;
bottom: 0;
height: 32px;
border-top: 1px solid var(--l1-border);
background: var(--l2-background);
}
.unsaved {
display: flex;
align-items: center;
gap: 8px;
}
.unsavedDot {
width: 6px;
height: 6px;
border-radius: 50px;
background: var(--primary-background);
box-shadow: 0px 0px 6px 0px
color-mix(in srgb, var(--primary-background) 40%, transparent);
}
.unsavedChanges {
color: var(--bg-robin-400);
font-family: Inter;
font-size: 14px;
font-style: normal;
font-weight: 400;
line-height: 24px;
letter-spacing: -0.07px;
}
.footerActionBtns {
display: flex;
gap: 8px;
}
.discardBtn {
margin: '16px 0';
color: var(--l1-foreground);
font-family: Inter;
font-size: 12px;
font-style: normal;
font-weight: 500;
line-height: 24px;
}
.saveBtn {
margin: 0px !important;
color: var(--l1-foreground);
font-family: Inter;
font-size: 12px;
font-style: normal;
font-weight: 500;
line-height: 24px;
}

View File

@@ -1,357 +0,0 @@
import { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Col, Input, Radio, Select, Space, Tooltip } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import AddTags from 'container/DashboardContainer/DashboardSettings/General/AddTags';
import { useDashboardCursorSyncMode } from 'hooks/dashboard/useDashboardCursorSyncMode';
import { useSyncTooltipFilterMode } from 'hooks/dashboard/useSyncTooltipFilterMode';
import {
DashboardCursorSync,
SyncTooltipFilterMode,
} from 'lib/uPlotV2/plugins/TooltipPlugin/types';
import { isEqual } from 'lodash-es';
import { Check, ExternalLink, SolidInfoCircle, X } from '@signozhq/icons';
import { patchDashboardV2 } from 'api/generated/services/dashboard';
import type {
DashboardtypesJSONPatchOperationDTO,
TagtypesPostableTagDTO,
} from 'api/generated/services/sigNoz.schemas';
import { useNotifications } from 'hooks/useNotifications';
import { useErrorModal } from 'providers/ErrorModalProvider';
import APIError from 'types/api/error';
import styles from './GeneralSettings.module.scss';
import { Button } from './styles';
import { Base64Icons } from './utils';
import logEvent from 'api/common/logEvent';
import { Events } from 'constants/events';
import { getAbsoluteUrl } from 'utils/basePath';
import type { V2Dashboard } from '../../utils';
const { Option } = Select;
interface Props {
dashboard: V2Dashboard | undefined;
onRefetch: () => void;
}
// Convert V2 tags ({key, value}[]) into "key:value" strings for the V1
// AddTags component (which expects string[]), and back on save.
//
// V2 tags require both `key` and `value` to be non-empty server-side
// (returns `tag_invalid_value` otherwise). To preserve the V1 single-word
// tag UX, a string with no ':' is round-tripped as `{key: x, value: x}` and
// collapsed back to just `x` for display.
function tagsToStrings(tags: TagtypesPostableTagDTO[]): string[] {
return tags.map((t) => (t.key === t.value ? t.key : `${t.key}:${t.value}`));
}
function stringsToTags(tagStrings: string[]): TagtypesPostableTagDTO[] {
return tagStrings
.map((s) => {
const trimmed = s.trim();
const idx = trimmed.indexOf(':');
if (idx === -1) return { key: trimmed, value: trimmed };
const key = trimmed.slice(0, idx).trim();
const value = trimmed.slice(idx + 1).trim();
return { key, value: value || key };
})
.filter((t) => t.key.length > 0);
}
function GeneralDashboardSettingsV2({
dashboard,
onRefetch,
}: Props): JSX.Element {
const id = dashboard?.id ?? '';
const [cursorSyncMode, setCursorSyncMode] = useDashboardCursorSyncMode(id);
const [syncTooltipFilterMode, setSyncTooltipFilterMode] =
useSyncTooltipFilterMode(id);
const title = dashboard?.data?.spec?.display?.name ?? '';
const description = dashboard?.data?.spec?.display?.description ?? '';
const image = dashboard?.data?.metadata?.image || Base64Icons[0];
const tagsAsStrings = useMemo(
() => tagsToStrings(dashboard?.data?.metadata?.tags ?? []),
[dashboard?.data?.metadata?.tags],
);
const [updatedTitle, setUpdatedTitle] = useState<string>(title);
const [updatedTags, setUpdatedTags] = useState<string[]>(tagsAsStrings);
const [updatedDescription, setUpdatedDescription] = useState<string>(
description,
);
const [updatedImage, setUpdatedImage] = useState<string>(image);
const [isSaving, setIsSaving] = useState<boolean>(false);
const [numberOfUnsavedChanges, setNumberOfUnsavedChanges] = useState<number>(
0,
);
const { t } = useTranslation('common');
const { notifications } = useNotifications();
const { showErrorModal } = useErrorModal();
// Sync state when dashboard refetches after a save
useEffect(() => {
setUpdatedTitle(title);
setUpdatedDescription(description);
setUpdatedImage(image);
setUpdatedTags(tagsAsStrings);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [dashboard?.updatedAt]);
const buildPatch = (): DashboardtypesJSONPatchOperationDTO[] => {
const ops: DashboardtypesJSONPatchOperationDTO[] = [];
const replace = (
path: string,
value: unknown,
): DashboardtypesJSONPatchOperationDTO => ({
op: 'replace' as DashboardtypesJSONPatchOperationDTO['op'],
path,
value,
});
if (updatedTitle !== title) {
ops.push(replace('/spec/display/name', updatedTitle));
}
if (updatedDescription !== description) {
ops.push(replace('/spec/display/description', updatedDescription));
}
if (updatedImage !== image) {
ops.push(replace('/metadata/image', updatedImage));
}
if (!isEqual(updatedTags, tagsAsStrings)) {
ops.push(replace('/metadata/tags', stringsToTags(updatedTags)));
}
return ops;
};
const onSaveHandler = async (): Promise<void> => {
if (!id) return;
const ops = buildPatch();
if (ops.length === 0) return;
try {
setIsSaving(true);
await patchDashboardV2({ id }, ops);
notifications.success({ message: 'Dashboard updated' });
onRefetch();
} catch (error) {
showErrorModal(error as APIError);
} finally {
setIsSaving(false);
}
};
useEffect(() => {
let n = 0;
const initialValues = [title, description, tagsAsStrings, image];
const updatedValues = [
updatedTitle,
updatedDescription,
updatedTags,
updatedImage,
];
initialValues.forEach((val, index) => {
if (!isEqual(val, updatedValues[index])) n += 1;
});
setNumberOfUnsavedChanges(n);
}, [
description,
image,
tagsAsStrings,
title,
updatedDescription,
updatedImage,
updatedTags,
updatedTitle,
]);
const discardHandler = (): void => {
setUpdatedTitle(title);
setUpdatedImage(image);
setUpdatedTags(tagsAsStrings);
setUpdatedDescription(description);
};
return (
<div className={styles.overviewContent}>
<Col className={styles.overviewSettings}>
<Space
direction="vertical"
style={{
width: '100%',
display: 'flex',
flexDirection: 'column',
gap: '21px',
}}
>
<div>
<Typography className={styles.dashboardName}>Dashboard Name</Typography>
<section className={styles.nameIconInput}>
<Select
defaultActiveFirstOption
data-testid="dashboard-image"
suffixIcon={null}
rootClassName={styles.dashboardImageInput}
value={updatedImage}
onChange={(value: string): void => setUpdatedImage(value)}
>
{Base64Icons.map((icon) => (
<Option value={icon} key={icon}>
<img
src={icon}
alt="dashboard-icon"
className={styles.listItemImage}
/>
</Option>
))}
</Select>
<Input
data-testid="dashboard-name"
className={styles.dashboardNameInput}
value={updatedTitle}
onChange={(e): void => setUpdatedTitle(e.target.value)}
/>
</section>
</div>
<div>
<Typography className={styles.dashboardName}>Description</Typography>
<Input.TextArea
data-testid="dashboard-desc"
rows={6}
value={updatedDescription}
className={styles.descriptionTextArea}
onChange={(e): void => setUpdatedDescription(e.target.value)}
/>
</div>
<div>
<Typography className={styles.dashboardName}>Tags</Typography>
<AddTags tags={updatedTags} setTags={setUpdatedTags} />
</div>
</Space>
</Col>
<Col className={`${styles.overviewSettings} ${styles.crossPanelSyncGroup}`}>
<div className={styles.crossPanelSyncSectionHeader}>
<Typography.Text className={styles.crossPanelSyncSectionTitle}>
Cross-Panel Sync
</Typography.Text>
<Tooltip
title={
<div className={styles.crossPanelSyncTooltipContent}>
<strong className={styles.crossPanelSyncTooltipTitle}>
Cross-Panel Sync
</strong>
<span className={styles.crossPanelSyncTooltipDescription}>
Sync crosshair and tooltip across all the dashboard panels
</span>
<a
href="https://signoz.io/docs/dashboards/interactivity/#cross-panel-sync"
target="_blank"
rel="noopener noreferrer"
className={styles.crossPanelSyncTooltipDocLink}
>
Learn more
<ExternalLink size={12} />
</a>
</div>
}
placement="top"
mouseEnterDelay={0.5}
>
<SolidInfoCircle size="md" className={styles.crossPanelSyncInfoIcon} />
</Tooltip>
</div>
<div className={styles.crossPanelSyncRow}>
<div className={styles.crossPanelSyncInfo}>
<Typography.Text className={styles.crossPanelSyncTitle}>
Sync Mode
</Typography.Text>
<Typography.Text className={styles.crossPanelSyncDescription}>
Sync crosshair and tooltip across all the dashboard panels
</Typography.Text>
</div>
<Radio.Group
value={cursorSyncMode}
onChange={(e): void => {
setCursorSyncMode(e.target.value as DashboardCursorSync);
}}
>
<Radio.Button value={DashboardCursorSync.None}>No Sync</Radio.Button>
<Radio.Button value={DashboardCursorSync.Crosshair}>
Crosshair
</Radio.Button>
<Radio.Button value={DashboardCursorSync.Tooltip}>Tooltip</Radio.Button>
</Radio.Group>
</div>
{cursorSyncMode === DashboardCursorSync.Tooltip && (
<div className={styles.crossPanelSyncRow}>
<div className={styles.crossPanelSyncInfo}>
<Typography.Text className={styles.crossPanelSyncTitle}>
Synced Tooltip Series
</Typography.Text>
<Typography.Text className={styles.crossPanelSyncDescription}>
Show only series that intersect on group-by, or every series with the
matching ones highlighted
</Typography.Text>
</div>
<Radio.Group
value={syncTooltipFilterMode}
onChange={(e): void => {
logEvent(Events.TOOLTIP_SYNC_MODE_CHANGED, {
path: getAbsoluteUrl(window.location.pathname),
mode: e.target.value,
});
setSyncTooltipFilterMode(e.target.value as SyncTooltipFilterMode);
}}
>
<Radio.Button value={SyncTooltipFilterMode.All}>All</Radio.Button>
<Radio.Button value={SyncTooltipFilterMode.Filtered}>
Filtered
</Radio.Button>
</Radio.Group>
</div>
)}
</Col>
{numberOfUnsavedChanges > 0 && (
<div className={styles.overviewSettingsFooter}>
<div className={styles.unsaved}>
<div className={styles.unsavedDot} />
<Typography.Text className={styles.unsavedChanges}>
{numberOfUnsavedChanges} unsaved change
{numberOfUnsavedChanges > 1 && 's'}
</Typography.Text>
</div>
<div className={styles.footerActionBtns}>
<Button
disabled={isSaving}
icon={<X size={14} />}
onClick={discardHandler}
type="text"
className={styles.discardBtn}
>
Discard
</Button>
<Button
style={{ margin: '16px 0' }}
disabled={isSaving}
loading={isSaving}
icon={<Check size={14} />}
data-testid="save-dashboard-config"
onClick={onSaveHandler}
type="primary"
className={styles.saveBtn}
>
{t('save')}
</Button>
</div>
</div>
)}
</div>
);
}
export default GeneralDashboardSettingsV2;

View File

@@ -1,20 +0,0 @@
import { Button as ButtonComponent, Drawer } from 'antd';
import styled from 'styled-components';
export const Container = styled.div`
margin-top: 0.5rem;
`;
export const Button = styled(ButtonComponent)`
&&& {
display: flex;
align-items: center;
}
`;
export const DrawerContainer = styled(Drawer)`
.ant-drawer-header {
padding: 0;
border: none;
}
`;

File diff suppressed because one or more lines are too long

View File

@@ -1,46 +0,0 @@
import { Collapse, Input } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import { VariableItemRow } from '../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
interface Props {
customValue: string;
onChange: (v: string) => void;
error?: string;
}
function CustomFields({ customValue, onChange, error }: Props): JSX.Element {
return (
<VariableItemRow className="variable-custom-section">
<Collapse
collapsible="header"
rootClassName="custom-collapse"
defaultActiveKey={['1']}
items={[
{
key: '1',
label: 'Options',
children: (
<>
<Input.TextArea
value={customValue}
placeholder="Enter options separated by commas."
rootClassName="comma-input"
onChange={(e): void => onChange(e.target.value)}
data-testid="variable-custom-value-v2"
/>
{error ? (
<div>
<Typography.Text color="warning">{error}</Typography.Text>
</div>
) : null}
</>
),
},
]}
/>
</VariableItemRow>
);
}
export default CustomFields;

View File

@@ -1,74 +0,0 @@
import { useCallback, useMemo } from 'react';
import DynamicVariable from 'container/DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/DynamicVariable/DynamicVariable';
import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
interface Props {
dynamicName: string;
dynamicSignal: TelemetrytypesSignalDTO | undefined;
onNameChange: (v: string) => void;
onSignalChange: (v: TelemetrytypesSignalDTO | undefined) => void;
error?: string;
}
// V1 DynamicVariable stores the source as a UI-friendly label:
// 'All telemetry' | 'Logs' | 'Metrics' | 'Traces'. V2 stores the API enum
// signal value: undefined (= all) | 'metrics' | 'traces' | 'logs'. We convert
// at this boundary so the V1 component can stay untouched.
const ALL_TELEMETRY = 'All telemetry';
function signalToV1Source(
signal: TelemetrytypesSignalDTO | undefined,
): string {
if (signal === TelemetrytypesSignalDTO.logs) return 'Logs';
if (signal === TelemetrytypesSignalDTO.metrics) return 'Metrics';
if (signal === TelemetrytypesSignalDTO.traces) return 'Traces';
return ALL_TELEMETRY;
}
function v1SourceToSignal(
source: string,
): TelemetrytypesSignalDTO | undefined {
if (source === 'Logs') return TelemetrytypesSignalDTO.logs;
if (source === 'Metrics') return TelemetrytypesSignalDTO.metrics;
if (source === 'Traces') return TelemetrytypesSignalDTO.traces;
return undefined;
}
function DynamicFields({
dynamicName,
dynamicSignal,
onNameChange,
onSignalChange,
error,
}: Props): JSX.Element {
const v1Value = useMemo(
() => ({ name: dynamicName, value: signalToV1Source(dynamicSignal) }),
[dynamicName, dynamicSignal],
);
const setV1Value: React.Dispatch<
React.SetStateAction<{ name: string; value: string } | undefined>
> = useCallback(
(action) => {
const next =
typeof action === 'function' ? action(v1Value) : action;
if (!next) return;
if (next.name !== dynamicName) onNameChange(next.name);
const nextSignal = v1SourceToSignal(next.value);
if (nextSignal !== dynamicSignal) onSignalChange(nextSignal);
},
[v1Value, dynamicName, dynamicSignal, onNameChange, onSignalChange],
);
return (
<div className="variable-dynamic-section">
<DynamicVariable
setDynamicVariablesSelectedValue={setV1Value}
dynamicVariablesSelectedValue={v1Value}
errorAttributeKeyMessage={error}
/>
</div>
);
}
export default DynamicFields;

View File

@@ -1,43 +0,0 @@
import { Button } from 'antd';
import { Check, X } from '@signozhq/icons';
import { VariableItemRow } from '../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
interface Props {
saving: boolean;
canSave: boolean;
onSave: () => void;
onCancel: () => void;
}
function Footer({ saving, canSave, onSave, onCancel }: Props): JSX.Element {
return (
<div className="variable-item-footer">
<VariableItemRow>
<Button
type="default"
onClick={onCancel}
icon={<X size={14} />}
className="footer-btn-discard"
disabled={saving}
data-testid="variable-cancel-v2"
>
Discard
</Button>
<Button
type="primary"
onClick={onSave}
icon={<Check size={14} />}
className="footer-btn-save"
loading={saving}
disabled={!canSave || saving}
data-testid="variable-save-v2"
>
Save Variable
</Button>
</VariableItemRow>
</div>
);
}
export default Footer;

View File

@@ -1,80 +0,0 @@
import type { V2VariableKind } from '../types';
import AllOptionRow from './ListOptions/AllOptionRow';
import CapturingRegexpRow from './ListOptions/CapturingRegexpRow';
import CustomAllValueRow from './ListOptions/CustomAllValueRow';
import DefaultValueRow from './ListOptions/DefaultValueRow';
import MultiSelectRow from './ListOptions/MultiSelectRow';
import SortRow from './ListOptions/SortRow';
interface Props {
kind: V2VariableKind;
allowAllValue: boolean;
allowMultiple: boolean;
sort: string;
defaultValue: string;
customAllValue: string;
capturingRegexp: string;
previewValues: string[];
onAllowAllChange: (v: boolean) => void;
onAllowMultipleChange: (v: boolean) => void;
onSortChange: (v: string) => void;
onDefaultValueChange: (v: string) => void;
onCustomAllValueChange: (v: string) => void;
onCapturingRegexpChange: (v: string) => void;
}
function ListBasicOptions({
kind,
allowAllValue,
allowMultiple,
sort,
defaultValue,
customAllValue,
capturingRegexp,
previewValues,
onAllowAllChange,
onAllowMultipleChange,
onSortChange,
onDefaultValueChange,
onCustomAllValueChange,
onCapturingRegexpChange,
}: Props): JSX.Element {
return (
<>
<SortRow sort={sort} onChange={onSortChange} />
<MultiSelectRow
allowMultiple={allowMultiple}
onChange={(v): void => {
onAllowMultipleChange(v);
if (!v) onAllowAllChange(false);
}}
/>
{allowMultiple && kind !== 'DYNAMIC' ? (
<AllOptionRow
allowAllValue={allowAllValue}
onChange={onAllowAllChange}
/>
) : null}
{allowAllValue ? (
<CustomAllValueRow
customAllValue={customAllValue}
onChange={onCustomAllValueChange}
/>
) : null}
{kind === 'QUERY' || kind === 'DYNAMIC' ? (
<CapturingRegexpRow
capturingRegexp={capturingRegexp}
onChange={onCapturingRegexpChange}
/>
) : null}
<DefaultValueRow
kind={kind}
defaultValue={defaultValue}
previewValues={previewValues}
onChange={onDefaultValueChange}
/>
</>
);
}
export default ListBasicOptions;

View File

@@ -1,28 +0,0 @@
import { Switch } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import { LabelContainer, VariableItemRow } from '../../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
interface Props {
allowAllValue: boolean;
onChange: (v: boolean) => void;
}
function AllOptionRow({ allowAllValue, onChange }: Props): JSX.Element {
return (
<VariableItemRow className="all-option-section">
<LabelContainer>
<Typography className="typography-variables">
Include an option for ALL values
</Typography>
</LabelContainer>
<Switch
checked={allowAllValue}
onChange={onChange}
data-testid="variable-allow-all-v2"
/>
</VariableItemRow>
);
}
export default AllOptionRow;

View File

@@ -1,43 +0,0 @@
import { Input } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import { LabelContainer, VariableItemRow } from '../../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
interface Props {
capturingRegexp: string;
onChange: (v: string) => void;
}
function CapturingRegexpRow({
capturingRegexp,
onChange,
}: Props): JSX.Element {
return (
<VariableItemRow className="capturing-regexp-section">
<LabelContainer>
<Typography
className="typography-variables"
style={{ display: 'block' }}
>
Capturing regex
</Typography>
<Typography
className="default-value-description"
style={{ display: 'block' }}
>
Regex applied to each value; the first capture group becomes the
selectable option.
</Typography>
</LabelContainer>
<Input
value={capturingRegexp}
placeholder="e.g. env-(.*)-\\d+"
onChange={(e): void => onChange(e.target.value)}
style={{ width: 400 }}
data-testid="variable-capturing-regexp-v2"
/>
</VariableItemRow>
);
}
export default CapturingRegexpRow;

View File

@@ -1,42 +0,0 @@
import { Input } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import { LabelContainer, VariableItemRow } from '../../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
interface Props {
customAllValue: string;
onChange: (v: string) => void;
}
function CustomAllValueRow({
customAllValue,
onChange,
}: Props): JSX.Element {
return (
<VariableItemRow className="custom-all-value-section">
<LabelContainer>
<Typography
className="typography-variables"
style={{ display: 'block' }}
>
Custom &quot;ALL&quot; value
</Typography>
<Typography
className="default-value-description"
style={{ display: 'block' }}
>
Literal value emitted when the user picks ALL (e.g. * or .*).
</Typography>
</LabelContainer>
<Input
value={customAllValue}
placeholder="Leave blank to send the full union of values"
onChange={(e): void => onChange(e.target.value)}
style={{ width: 400 }}
data-testid="variable-custom-all-value-v2"
/>
</VariableItemRow>
);
}
export default CustomAllValueRow;

View File

@@ -1,43 +0,0 @@
import CustomSelect from 'components/NewSelect/CustomSelect';
import { Typography } from '@signozhq/ui/typography';
import { LabelContainer, VariableItemRow } from '../../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
import type { V2VariableKind } from '../../types';
interface Props {
kind: V2VariableKind;
defaultValue: string;
previewValues: string[];
onChange: (v: string) => void;
}
function DefaultValueRow({
kind,
defaultValue,
previewValues,
onChange,
}: Props): JSX.Element {
const description =
kind === 'QUERY'
? 'Click Test Run Query to see the values or add custom value'
: 'Select a value from the preview values or add custom value';
return (
<VariableItemRow className="default-value-section">
<LabelContainer>
<Typography className="typography-variables">Default Value</Typography>
<Typography className="default-value-description">
{description}
</Typography>
</LabelContainer>
<CustomSelect
placeholder="Select a default value"
value={defaultValue}
onChange={(v): void => onChange((v as string) ?? '')}
options={previewValues.map((v) => ({ label: v, value: v }))}
/>
</VariableItemRow>
);
}
export default DefaultValueRow;

View File

@@ -1,28 +0,0 @@
import { Switch } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import { LabelContainer, VariableItemRow } from '../../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
interface Props {
allowMultiple: boolean;
onChange: (v: boolean) => void;
}
function MultiSelectRow({ allowMultiple, onChange }: Props): JSX.Element {
return (
<VariableItemRow className="multiple-values-section">
<LabelContainer>
<Typography className="typography-variables">
Enable multiple values to be checked
</Typography>
</LabelContainer>
<Switch
checked={allowMultiple}
onChange={onChange}
data-testid="variable-allow-multiple-v2"
/>
</VariableItemRow>
);
}
export default MultiSelectRow;

View File

@@ -1,29 +0,0 @@
import { Select } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import { LabelContainer, VariableItemRow } from '../../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
import { SORT_OPTIONS } from '../../types';
interface Props {
sort: string;
onChange: (v: string) => void;
}
function SortRow({ sort, onChange }: Props): JSX.Element {
return (
<VariableItemRow className="sort-values-section">
<LabelContainer>
<Typography className="typography-variables">Sort Values</Typography>
</LabelContainer>
<Select
value={sort}
onChange={onChange}
options={SORT_OPTIONS}
className="sort-input"
data-testid="variable-sort-v2"
/>
</VariableItemRow>
);
}
export default SortRow;

View File

@@ -1,59 +0,0 @@
import { Input } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import { LabelContainer, VariableItemRow } from '../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
interface Props {
name: string;
description: string;
onNameChange: (v: string) => void;
onDescriptionChange: (v: string) => void;
nameError?: string;
}
function NameDisplay({
name,
description,
onNameChange,
onDescriptionChange,
nameError,
}: Props): JSX.Element {
return (
<>
<VariableItemRow className="variable-name-section">
<LabelContainer>
<Typography className="typography-variables">Name</Typography>
</LabelContainer>
<div>
<Input
placeholder="Unique name of the variable"
value={name}
className="name-input"
onChange={(e): void => onNameChange(e.target.value)}
data-testid="variable-name-v2"
/>
{nameError ? (
<div>
<Typography.Text color="warning">{nameError}</Typography.Text>
</div>
) : null}
</div>
</VariableItemRow>
<VariableItemRow className="variable-description-section">
<LabelContainer>
<Typography className="typography-variables">Description</Typography>
</LabelContainer>
<Input.TextArea
value={description}
placeholder="Enter a description for the variable"
className="description-input"
rows={3}
onChange={(e): void => onDescriptionChange(e.target.value)}
data-testid="variable-description-v2"
/>
</VariableItemRow>
</>
);
}
export default NameDisplay;

View File

@@ -1,33 +0,0 @@
import { Tag } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import { orange } from '@ant-design/colors';
import { LabelContainer, VariableItemRow } from '../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
interface Props {
previewValues: string[];
error?: string | null;
}
function PreviewValues({ previewValues, error }: Props): JSX.Element {
return (
<VariableItemRow className="variables-preview-section">
<LabelContainer style={{ width: '100%' }}>
<Typography className="typography-variables">
Preview of Values
</Typography>
</LabelContainer>
<div className="preview-values">
{error ? (
<Typography style={{ color: orange[5] }}>{error}</Typography>
) : (
previewValues.map((v, idx) => (
<Tag key={`${v}${idx}`}>{v.toString()}</Tag>
))
)}
</div>
</VariableItemRow>
);
}
export default PreviewValues;

View File

@@ -1,66 +0,0 @@
import { Button } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import Editor from 'components/Editor';
import { LabelContainer } from '../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
interface Props {
queryValue: string;
onChange: (v: string) => void;
onTestRun?: () => void;
testRunLoading?: boolean;
error?: string;
}
function QueryFields({
queryValue,
onChange,
onTestRun,
testRunLoading,
error,
}: Props): JSX.Element {
return (
<div className="query-container">
<LabelContainer>
<Typography>Query</Typography>
</LabelContainer>
<div style={{ flex: 1, position: 'relative' }}>
<Editor
language="sql"
value={queryValue}
onChange={onChange}
height="240px"
options={{
fontSize: 13,
wordWrap: 'on',
lineNumbers: 'off',
glyphMargin: false,
folding: false,
lineDecorationsWidth: 0,
lineNumbersMinChars: 0,
minimap: { enabled: false },
}}
/>
{onTestRun ? (
<Button
type="primary"
size="small"
onClick={onTestRun}
style={{ position: 'absolute', bottom: 0 }}
loading={testRunLoading}
>
Test Run Query
</Button>
) : null}
{error ? (
<div>
<Typography.Text color="warning">{error}</Typography.Text>
</div>
) : null}
</div>
</div>
);
}
export default QueryFields;

View File

@@ -1,37 +0,0 @@
import { Input } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import { LabelContainer, VariableItemRow } from '../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
interface Props {
textValue: string;
onChange: (v: string) => void;
error?: string;
}
function TextFields({ textValue, onChange, error }: Props): JSX.Element {
return (
<VariableItemRow className="variable-textbox-section">
<LabelContainer>
<Typography className="typography-variables">Default Value</Typography>
</LabelContainer>
<div>
<Input
value={textValue}
className="default-input"
onChange={(e): void => onChange(e.target.value)}
placeholder="Enter a default value (if any)..."
style={{ width: 400 }}
data-testid="variable-text-value-v2"
/>
{error ? (
<div>
<Typography.Text color="warning">{error}</Typography.Text>
</div>
) : null}
</div>
</VariableItemRow>
);
}
export default TextFields;

View File

@@ -1,126 +0,0 @@
import { Button, Tag } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import {
ClipboardType,
DatabaseZap,
Info,
LayoutList,
Pyramid,
} from '@signozhq/icons';
import { Color } from '@signozhq/design-tokens';
import cx from 'classnames';
import TextToolTip from 'components/TextToolTip';
import { useIsDarkMode } from 'hooks/useDarkMode';
import { LabelContainer, VariableItemRow } from '../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/styles';
import type { V2VariableKind } from '../types';
import '../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/VariableItem.styles.scss';
interface Props {
kind: V2VariableKind;
onChange: (kind: V2VariableKind) => void;
}
function TypeSelector({ kind, onChange }: Props): JSX.Element {
const isDarkMode = useIsDarkMode();
return (
<VariableItemRow className="variable-type-section">
<LabelContainer className="variable-type-label-container">
<Typography className="typography-variables">Variable Type</Typography>
<TextToolTip
text="Learn more about supported variable types"
url="https://signoz.io/docs/userguide/manage-variables/#supported-variable-types"
urlText="here"
useFilledIcon={false}
outlinedIcon={
<Info
size={14}
style={{
color: isDarkMode ? Color.BG_VANILLA_100 : Color.BG_INK_500,
marginTop: 1,
}}
/>
}
/>
</LabelContainer>
<div className="variable-type-btn-group">
<Button
type="text"
icon={<Pyramid size={14} />}
className={cx(
'variable-type-btn',
kind === 'DYNAMIC' ? 'selected' : '',
)}
onClick={(): void => onChange('DYNAMIC')}
data-testid="variable-type-dynamic-v2"
>
Dynamic
<Tag bordered={false} className="sidenav-beta-tag" color="geekblue">
Beta
</Tag>
</Button>
<Button
type="text"
icon={<ClipboardType size={14} />}
className={cx(
'variable-type-btn',
kind === 'TEXT' ? 'selected' : '',
)}
onClick={(): void => onChange('TEXT')}
data-testid="variable-type-text-v2"
>
Textbox
</Button>
<Button
type="text"
icon={<LayoutList size={14} />}
className={cx(
'variable-type-btn',
kind === 'CUSTOM' ? 'selected' : '',
)}
onClick={(): void => onChange('CUSTOM')}
data-testid="variable-type-custom-v2"
>
Custom
</Button>
<Button
type="text"
icon={<DatabaseZap size={14} />}
className={cx(
'variable-type-btn',
kind === 'QUERY' ? 'selected' : '',
)}
onClick={(): void => onChange('QUERY')}
data-testid="variable-type-query-v2"
>
Query
<Tag bordered={false} className="sidenav-beta-tag" color="warning">
Not Recommended
</Tag>
<div onClick={(e): void => e.stopPropagation()}>
<TextToolTip
text="Learn why we don't recommend"
url="https://signoz.io/docs/userguide/manage-variables/#why-avoid-clickhouse-query-variables"
urlText="here"
useFilledIcon={false}
outlinedIcon={
<Info
size={14}
style={{
color: isDarkMode ? Color.BG_VANILLA_100 : Color.BG_INK_500,
marginTop: 1,
}}
/>
}
/>
</div>
</Button>
</div>
</VariableItemRow>
);
}
export default TypeSelector;

View File

@@ -1,188 +0,0 @@
import { useCallback, useMemo, useState } from 'react';
import { Button } from 'antd';
import { ArrowLeft } from '@signozhq/icons';
import { commaValuesParser } from 'lib/dashboardVariables/customCommaValuesParser';
import { draftToVariableDTO, validateDraft } from '../draft';
import type { SaveCallback, VariableDraft, V2VariableKind } from '../types';
import CustomFields from './CustomFields';
import DynamicFields from './DynamicFields';
import Footer from './Footer';
import ListBasicOptions from './ListBasicOptions';
import NameDisplay from './NameDisplay';
import PreviewValues from './PreviewValues';
import QueryFields from './QueryFields';
import TextFields from './TextFields';
import TypeSelector from './TypeSelector';
import '../../../../DashboardContainer/DashboardSettings/DashboardVariableSettings/VariableItem/VariableItem.styles.scss';
interface Props {
initialDraft: VariableDraft;
existingNames: string[];
saving: boolean;
onSave: SaveCallback;
onCancel: () => void;
}
/**
* Editor for a single V2 variable.
*
* Type-switch contract: changing `kind` does NOT clear the per-kind fields
* the user already typed. They remain in local state and are restored if the
* user navigates back to the same kind. Only the fields relevant to the
* active `kind` are written into the V2 envelope on save (see
* `draftToVariableDTO`).
*/
function VariableItem({
initialDraft,
existingNames,
saving,
onSave,
onCancel,
}: Props): JSX.Element {
const [draft, setDraft] = useState<VariableDraft>(initialDraft);
const update = useCallback(
<K extends keyof VariableDraft>(key: K, value: VariableDraft[K]): void => {
setDraft((prev) => ({ ...prev, [key]: value }));
},
[],
);
const onKindChange = useCallback(
(kind: V2VariableKind): void => {
// Retain every other field — only the discriminator changes.
update('kind', kind);
},
[update],
);
const namesExcludingSelf = useMemo(
() => existingNames.filter((n) => n !== initialDraft.name),
[existingNames, initialDraft.name],
);
const validationError = useMemo(
() => validateDraft(draft, namesExcludingSelf),
[draft, namesExcludingSelf],
);
// Local preview values — currently populated only for CUSTOM (CSV parse).
// Query / Dynamic previews are wired in the variable execution subsystem.
const previewValues = useMemo<string[]>(() => {
if (draft.kind === 'CUSTOM') {
return commaValuesParser(draft.customValue).map((v) => String(v));
}
return [];
}, [draft.kind, draft.customValue]);
const handleSave = useCallback((): void => {
if (validationError) return;
onSave(draftToVariableDTO(draft));
}, [draft, validationError, onSave]);
const errorFor = (
field: NonNullable<typeof validationError>['field'],
): string | undefined => {
if (validationError && validationError.field === field) {
return validationError.message;
}
return undefined;
};
const showListOptions =
draft.kind === 'QUERY' || draft.kind === 'CUSTOM' || draft.kind === 'DYNAMIC';
return (
<>
<div className="variable-item-container">
<div className="all-variables">
<Button
type="text"
className="all-variables-btn"
icon={<ArrowLeft size={14} />}
onClick={onCancel}
>
All variables
</Button>
</div>
<div className="variable-item-content">
<NameDisplay
name={draft.name}
description={draft.displayName}
onNameChange={(v): void => update('name', v)}
onDescriptionChange={(v): void => update('displayName', v)}
nameError={errorFor('name')}
/>
<TypeSelector kind={draft.kind} onChange={onKindChange} />
{draft.kind === 'DYNAMIC' ? (
<DynamicFields
dynamicName={draft.dynamicName}
dynamicSignal={draft.dynamicSignal}
onNameChange={(v): void => update('dynamicName', v)}
onSignalChange={(v): void => update('dynamicSignal', v)}
error={errorFor('dynamicName')}
/>
) : null}
{draft.kind === 'QUERY' ? (
<QueryFields
queryValue={draft.queryValue}
onChange={(v): void => update('queryValue', v)}
error={errorFor('queryValue')}
/>
) : null}
{draft.kind === 'CUSTOM' ? (
<CustomFields
customValue={draft.customValue}
onChange={(v): void => update('customValue', v)}
error={errorFor('customValue')}
/>
) : null}
{draft.kind === 'TEXT' ? (
<TextFields
textValue={draft.textValue}
onChange={(v): void => update('textValue', v)}
error={errorFor('textValue')}
/>
) : null}
{showListOptions ? (
<>
<PreviewValues previewValues={previewValues} />
<ListBasicOptions
kind={draft.kind}
allowAllValue={draft.allowAllValue}
allowMultiple={draft.allowMultiple}
sort={draft.sort}
defaultValue={draft.defaultValue}
customAllValue={draft.customAllValue}
capturingRegexp={draft.capturingRegexp}
previewValues={previewValues}
onAllowAllChange={(v): void => update('allowAllValue', v)}
onAllowMultipleChange={(v): void => update('allowMultiple', v)}
onSortChange={(v): void => update('sort', v)}
onDefaultValueChange={(v): void => update('defaultValue', v)}
onCustomAllValueChange={(v): void =>
update('customAllValue', v)
}
onCapturingRegexpChange={(v): void =>
update('capturingRegexp', v)
}
/>
</>
) : null}
</div>
</div>
<Footer
saving={saving}
canSave={!validationError}
onSave={handleSave}
onCancel={onCancel}
/>
</>
);
}
export default VariableItem;

View File

@@ -1,58 +0,0 @@
import React from 'react';
import { CSS } from '@dnd-kit/utilities';
import { useSortable } from '@dnd-kit/sortable';
import type { RowProps } from 'antd';
import { GripVertical } from '@signozhq/icons';
/**
* Sortable table row that injects a drag handle into the `name` cell —
* matches V1's [DashboardVariableSettings/index.tsx:31](TableRow component).
*/
function TableRow({ children, ...props }: RowProps): JSX.Element {
const {
attributes,
listeners,
setNodeRef,
setActivatorNodeRef,
transform,
transition,
isDragging,
} = useSortable({
// @ts-expect-error — antd Table's RowProps doesn't type the data-row-key it injects
id: props['data-row-key'],
});
const style: React.CSSProperties = {
...props.style,
transform: CSS.Transform.toString(transform && { ...transform, scaleY: 1 }),
transition,
...(isDragging ? { position: 'relative', zIndex: 9999 } : {}),
};
return (
<tr {...props} ref={setNodeRef} style={style} {...attributes}>
{React.Children.map(children, (child) => {
const childElement = child as React.ReactElement;
if (childElement.key === 'name') {
return React.cloneElement(childElement, {
key: 'name-with-drag',
children: (
<div className="variable-name-drag">
<GripVertical
ref={setActivatorNodeRef as unknown as React.Ref<SVGSVGElement>}
style={{ touchAction: 'none', cursor: 'move' }}
size="md"
{...listeners}
/>
{child}
</div>
),
});
}
return childElement;
})}
</tr>
);
}
export default TableRow;

View File

@@ -1,50 +0,0 @@
import { Button, Space, Tag } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import { PenLine, Trash2 } from '@signozhq/icons';
interface Props {
description: string;
kindLabel: string;
onEdit: () => void;
onDelete: () => void;
}
/**
* Right cell of the variable table — description text + edit/delete actions.
* Variable name + kind tag render in the left cell via column config.
*/
function VariableRow({
description,
kindLabel,
onEdit,
onDelete,
}: Props): JSX.Element {
return (
<div className="variable-description-actions">
<Typography.Text className="variable-description">
{description}
</Typography.Text>
<Space className="actions-btns">
<Tag>{kindLabel}</Tag>
<Button
type="text"
onClick={onEdit}
className="edit-variable-button"
data-testid="variable-edit-v2"
>
<PenLine size={14} />
</Button>
<Button
type="text"
onClick={onDelete}
className="delete-variable-button"
data-testid="variable-delete-v2"
>
<Trash2 size={14} />
</Button>
</Space>
</div>
);
}
export default VariableRow;

View File

@@ -1,119 +0,0 @@
import { Empty, Table } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import {
DndContext,
PointerSensor,
useSensor,
useSensors,
type DragEndEvent,
} from '@dnd-kit/core';
import { restrictToVerticalAxis } from '@dnd-kit/modifiers';
import { arrayMove, SortableContext } from '@dnd-kit/sortable';
import type { DashboardtypesVariableDTO } from 'api/generated/services/sigNoz.schemas';
import { getVariableKindLabel, getVariableName } from '../draft';
import TableRow from './TableRow';
import VariableRow from './VariableRow';
import '../../../../DashboardContainer/DashboardSettings/DashboardSettings.styles.scss';
interface TableEntry {
key: string;
name: string;
description: string;
kindLabel: string;
index: number;
}
interface Props {
variables: DashboardtypesVariableDTO[];
onEdit: (index: number) => void;
onDelete: (index: number) => void;
onReorder: (next: DashboardtypesVariableDTO[]) => void;
}
function VariableList({
variables,
onEdit,
onDelete,
onReorder,
}: Props): JSX.Element {
const sensors = useSensors(
useSensor(PointerSensor, {
activationConstraint: { distance: 1 },
}),
);
if (variables.length === 0) {
return (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={
<Typography.Text>
No variables yet. Click &quot;Add variable&quot; to create one.
</Typography.Text>
}
/>
);
}
const dataSource: TableEntry[] = variables.map((v, idx) => ({
key: getVariableName(v) || String(idx),
name: getVariableName(v),
description:
(v.spec as { display?: { name?: string } })?.display?.name ?? '',
kindLabel: getVariableKindLabel(v),
index: idx,
}));
const columns = [
{
title: 'Variable',
dataIndex: 'name',
key: 'name',
width: '50%',
},
{
title: 'Description',
key: 'description',
width: '50%',
render: (entry: TableEntry): JSX.Element => (
<VariableRow
description={entry.description}
kindLabel={entry.kindLabel}
onEdit={(): void => onEdit(entry.index)}
onDelete={(): void => onDelete(entry.index)}
/>
),
},
];
const onDragEnd = ({ active, over }: DragEndEvent): void => {
if (!over || active.id === over.id) return;
const fromIdx = dataSource.findIndex((d) => d.key === active.id);
const toIdx = dataSource.findIndex((d) => d.key === over.id);
if (fromIdx < 0 || toIdx < 0) return;
onReorder(arrayMove(variables, fromIdx, toIdx));
};
return (
<DndContext
sensors={sensors}
modifiers={[restrictToVerticalAxis]}
onDragEnd={onDragEnd}
>
<SortableContext items={dataSource.map((d) => d.key)}>
<Table
components={{ body: { row: TableRow } }}
rowKey="key"
columns={columns}
pagination={false}
dataSource={dataSource}
className="dashboard-variable-settings-table"
/>
</SortableContext>
</DndContext>
);
}
export default VariableList;

View File

@@ -1,202 +0,0 @@
import { v4 as generateUUID } from 'uuid';
import type {
DashboardtypesVariableDTO,
DashboardtypesVariablePluginDTO,
DashboardtypesListVariableSpecDTO,
DashboardTextVariableSpecDTO,
TelemetrytypesSignalDTO,
} from 'api/generated/services/sigNoz.schemas';
import type { V2VariableKind, VariableDraft } from './types';
export function emptyDraft(): VariableDraft {
return {
id: generateUUID(),
kind: 'QUERY',
name: '',
displayName: '',
allowAllValue: false,
allowMultiple: false,
sort: 'none',
defaultValue: '',
customAllValue: '',
capturingRegexp: '',
queryValue: '',
customValue: '',
dynamicName: '',
dynamicSignal: undefined,
textValue: '',
};
}
/**
* Hydrate the relevant slot from a V2 envelope; other slots stay empty.
*/
export function variableDTOToDraft(
dto: DashboardtypesVariableDTO,
): VariableDraft {
const base = emptyDraft();
if (dto.kind === 'TextVariable') {
const spec = dto.spec as DashboardTextVariableSpecDTO;
return {
...base,
kind: 'TEXT',
name: spec?.name ?? '',
displayName: spec?.display?.name ?? '',
textValue: spec?.value ?? '',
};
}
// ListVariable
const spec = dto.spec as DashboardtypesListVariableSpecDTO;
const pluginKind = spec?.plugin?.kind;
let kind: V2VariableKind = 'QUERY';
if (pluginKind === 'signoz/DynamicVariable') kind = 'DYNAMIC';
else if (pluginKind === 'signoz/CustomVariable') kind = 'CUSTOM';
else if (pluginKind === 'signoz/QueryVariable') kind = 'QUERY';
const draft: VariableDraft = {
...base,
kind,
name: spec?.name ?? '',
displayName: spec?.display?.name ?? '',
allowAllValue: !!spec?.allowAllValue,
allowMultiple: !!spec?.allowMultiple,
sort: spec?.sort ?? 'none',
defaultValue: typeof spec?.defaultValue === 'string' ? spec.defaultValue : '',
customAllValue: spec?.customAllValue ?? '',
capturingRegexp: spec?.capturingRegexp ?? '',
};
const pluginSpec = spec?.plugin?.spec as Record<string, unknown> | undefined;
if (kind === 'QUERY') {
draft.queryValue = (pluginSpec?.queryValue as string) ?? '';
} else if (kind === 'CUSTOM') {
draft.customValue = (pluginSpec?.customValue as string) ?? '';
} else if (kind === 'DYNAMIC') {
draft.dynamicName = (pluginSpec?.name as string) ?? '';
draft.dynamicSignal = pluginSpec?.signal as TelemetrytypesSignalDTO | undefined;
}
return draft;
}
/**
* Serialize draft to a V2 envelope, reading ONLY the fields relevant to the
* active kind. Other fields the user touched stay in React state and are
* silently dropped.
*/
export function draftToVariableDTO(
draft: VariableDraft,
): DashboardtypesVariableDTO {
const display = draft.displayName ? { name: draft.displayName } : undefined;
if (draft.kind === 'TEXT') {
return ({
kind: 'TextVariable',
spec: {
name: draft.name,
display,
value: draft.textValue,
},
} as unknown) as DashboardtypesVariableDTO;
}
let plugin: DashboardtypesVariablePluginDTO | undefined;
if (draft.kind === 'QUERY') {
plugin = ({
kind: 'signoz/QueryVariable',
spec: { queryValue: draft.queryValue },
} as unknown) as DashboardtypesVariablePluginDTO;
} else if (draft.kind === 'CUSTOM') {
plugin = ({
kind: 'signoz/CustomVariable',
spec: { customValue: draft.customValue },
} as unknown) as DashboardtypesVariablePluginDTO;
} else if (draft.kind === 'DYNAMIC') {
plugin = ({
kind: 'signoz/DynamicVariable',
spec: {
name: draft.dynamicName,
signal: draft.dynamicSignal,
},
} as unknown) as DashboardtypesVariablePluginDTO;
}
const spec: DashboardtypesListVariableSpecDTO = {
name: draft.name,
display,
allowAllValue: draft.allowAllValue,
allowMultiple: draft.allowMultiple,
sort: draft.sort,
plugin,
// VariableDefaultValueDTO is an open `{[key]: unknown}` shape, so a bare
// string isn't structurally assignable. We cast at the boundary.
defaultValue: draft.defaultValue
? ((draft.defaultValue as unknown) as DashboardtypesListVariableSpecDTO['defaultValue'])
: undefined,
customAllValue: draft.customAllValue || undefined,
capturingRegexp: draft.capturingRegexp || undefined,
};
return ({
kind: 'ListVariable',
spec,
} as unknown) as DashboardtypesVariableDTO;
}
export interface DraftValidationError {
field:
| 'name'
| 'queryValue'
| 'customValue'
| 'dynamicName'
| 'textValue'
| 'cycle';
message: string;
}
export function validateDraft(
draft: VariableDraft,
existingNames: string[],
): DraftValidationError | null {
const trimmedName = draft.name.trim();
if (!trimmedName) {
return { field: 'name', message: 'Variable name is required' };
}
if (/\s/.test(trimmedName)) {
return { field: 'name', message: 'Variable name cannot contain whitespace' };
}
if (existingNames.includes(trimmedName)) {
return { field: 'name', message: 'Variable name already exists' };
}
if (draft.kind === 'QUERY' && !draft.queryValue.trim()) {
return { field: 'queryValue', message: 'Query is required' };
}
if (draft.kind === 'CUSTOM' && !draft.customValue.trim()) {
return { field: 'customValue', message: 'Custom values are required' };
}
if (draft.kind === 'DYNAMIC' && !draft.dynamicName.trim()) {
return { field: 'dynamicName', message: 'Attribute name is required' };
}
if (draft.kind === 'TEXT' && !draft.textValue.trim()) {
return { field: 'textValue', message: 'Default text value is required' };
}
return null;
}
export function getVariableName(dto: DashboardtypesVariableDTO): string {
if (dto.kind === 'TextVariable') {
return (dto.spec as DashboardTextVariableSpecDTO)?.name ?? '';
}
return (dto.spec as DashboardtypesListVariableSpecDTO)?.name ?? '';
}
export function getVariableKindLabel(dto: DashboardtypesVariableDTO): string {
if (dto.kind === 'TextVariable') return 'Text';
const spec = dto.spec as DashboardtypesListVariableSpecDTO;
const pluginKind = spec?.plugin?.kind;
if (pluginKind === 'signoz/DynamicVariable') return 'Dynamic';
if (pluginKind === 'signoz/CustomVariable') return 'Custom';
return 'Query';
}

View File

@@ -1,156 +0,0 @@
import { useCallback, useMemo, useState } from 'react';
import { Button } from 'antd';
import { Plus } from '@signozhq/icons';
import { patchDashboardV2 } from 'api/generated/services/dashboard';
import type {
DashboardtypesJSONPatchOperationDTO,
DashboardtypesVariableDTO,
} from 'api/generated/services/sigNoz.schemas';
import { useNotifications } from 'hooks/useNotifications';
import { useErrorModal } from 'providers/ErrorModalProvider';
import APIError from 'types/api/error';
import {
buildDependencyMap,
detectCycle,
} from '../../DashboardVariablesV2/dependencyGraph';
import type { V2Dashboard } from '../../utils';
import {
emptyDraft,
getVariableName,
variableDTOToDraft,
} from './draft';
import type { VariableDraft } from './types';
import VariableItem from './VariableItem';
import VariableList from './VariableList';
interface Props {
dashboard: V2Dashboard | undefined;
onRefetch: () => void;
}
type EditorState =
| { kind: 'closed' }
| { kind: 'add'; draft: VariableDraft }
| { kind: 'edit'; index: number; draft: VariableDraft };
function VariablesSettingsV2({ dashboard, onRefetch }: Props): JSX.Element {
const dashboardId = dashboard?.id ?? '';
const variables = useMemo<DashboardtypesVariableDTO[]>(
() => dashboard?.data?.spec?.variables ?? [],
[dashboard?.data?.spec?.variables],
);
const [editor, setEditor] = useState<EditorState>({ kind: 'closed' });
const [saving, setSaving] = useState<boolean>(false);
const { notifications } = useNotifications();
const { showErrorModal } = useErrorModal();
const existingNames = useMemo(() => variables.map(getVariableName), [
variables,
]);
const persistVariables = useCallback(
async (next: DashboardtypesVariableDTO[]): Promise<void> => {
if (!dashboardId) return;
const cycle = detectCycle(buildDependencyMap(next));
if (cycle.hasCycle) {
notifications.error({
message: `Cyclic variable dependency: ${cycle.cycle?.join(' → ')}`,
});
return;
}
setSaving(true);
try {
const patch: DashboardtypesJSONPatchOperationDTO[] = [
{
op: 'replace' as DashboardtypesJSONPatchOperationDTO['op'],
path: '/spec/variables',
value: next,
},
];
await patchDashboardV2({ id: dashboardId }, patch);
notifications.success({ message: 'Variables updated' });
onRefetch();
setEditor({ kind: 'closed' });
} catch (error) {
showErrorModal(error as APIError);
} finally {
setSaving(false);
}
},
[dashboardId, notifications, onRefetch, showErrorModal],
);
const handleSave = useCallback(
async (dto: DashboardtypesVariableDTO): Promise<void> => {
if (editor.kind === 'add') {
await persistVariables([...variables, dto]);
} else if (editor.kind === 'edit') {
const next = variables.slice();
next[editor.index] = dto;
await persistVariables(next);
}
},
[editor, variables, persistVariables],
);
const handleDelete = useCallback(
async (index: number): Promise<void> => {
const next = variables.slice();
next.splice(index, 1);
await persistVariables(next);
},
[variables, persistVariables],
);
return (
<div
style={{
display: 'flex',
flexDirection: 'column',
gap: 12,
padding: 16,
}}
>
{editor.kind === 'closed' ? (
<>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
<Button
type="primary"
icon={<Plus size={14} />}
onClick={(): void =>
setEditor({ kind: 'add', draft: emptyDraft() })
}
data-testid="add-variable-v2"
>
Add variable
</Button>
</div>
<VariableList
variables={variables}
onEdit={(index): void =>
setEditor({
kind: 'edit',
index,
draft: variableDTOToDraft(variables[index]),
})
}
onDelete={handleDelete}
onReorder={persistVariables}
/>
</>
) : (
<VariableItem
initialDraft={editor.draft}
existingNames={existingNames}
saving={saving}
onSave={handleSave}
onCancel={(): void => setEditor({ kind: 'closed' })}
/>
)}
</div>
);
}
export default VariablesSettingsV2;

View File

@@ -1,61 +0,0 @@
import type {
DashboardtypesVariableDTO,
TelemetrytypesSignalDTO,
} from 'api/generated/services/sigNoz.schemas';
export type V2VariableKind = 'QUERY' | 'CUSTOM' | 'DYNAMIC' | 'TEXT';
/**
* Internal editor state. Holds every per-kind field so that switching `kind`
* does not discard user input. Only the fields relevant to the active kind
* are written into the resulting V2 envelope on save.
*/
export interface VariableDraft {
id: string; // local identifier for list keys; not persisted to V2
kind: V2VariableKind;
name: string;
displayName: string;
// Shared by all List variants (QUERY / CUSTOM / DYNAMIC)
allowAllValue: boolean;
allowMultiple: boolean;
sort: string;
defaultValue: string;
// V2-only: literal value emitted when the user picks "ALL"
customAllValue: string;
// V2-only: regex applied to query/dynamic results to extract the actual value
capturingRegexp: string;
// QUERY
queryValue: string;
// CUSTOM
customValue: string;
// DYNAMIC
dynamicName: string;
dynamicSignal: TelemetrytypesSignalDTO | undefined;
// TEXT
textValue: string;
}
export type SaveCallback = (dto: DashboardtypesVariableDTO) => void;
export const VARIABLE_KIND_LABEL: Record<V2VariableKind, string> = {
QUERY: 'Query',
CUSTOM: 'Custom',
DYNAMIC: 'Dynamic',
TEXT: 'Text',
};
// V2 supports a finer sort taxonomy than V1: separate alphabetical and
// numerical orderings (V1 only exposed Disabled / Ascending / Descending).
// Values match the strings used in the perses fixture and backend.
export const SORT_OPTIONS: { label: string; value: string }[] = [
{ label: 'Disabled', value: 'none' },
{ label: 'Alphabetical ascending', value: 'alphabetical-asc' },
{ label: 'Alphabetical descending', value: 'alphabetical-desc' },
{ label: 'Numerical ascending', value: 'numerical-asc' },
{ label: 'Numerical descending', value: 'numerical-desc' },
];

View File

@@ -1,70 +0,0 @@
import { Button, Empty, Tabs } from 'antd';
import { Typography } from '@signozhq/ui/typography';
import { Braces, Globe, Table } from '@signozhq/icons';
import '../../DashboardContainer/DashboardSettings/DashboardSettingsContent.styles.scss';
import GeneralDashboardSettingsV2 from './General';
import VariablesSettingsV2 from './Variables';
import type { V2Dashboard } from '../utils';
interface Props {
dashboard: V2Dashboard | undefined;
onRefetch: () => void;
}
function Placeholder({ message }: { message: string }): JSX.Element {
return (
<div style={{ padding: 24 }}>
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={<Typography.Text>{message}</Typography.Text>}
/>
</div>
);
}
function DashboardSettingsV2({ dashboard, onRefetch }: Props): JSX.Element {
const items = [
{
label: (
<Button type="text" icon={<Table size={14} />}>
General
</Button>
),
key: 'general',
children: (
<GeneralDashboardSettingsV2
dashboard={dashboard}
onRefetch={onRefetch}
/>
),
},
{
label: (
<Button type="text" icon={<Braces size={14} />}>
Variables
</Button>
),
key: 'variables',
children: (
<VariablesSettingsV2 dashboard={dashboard} onRefetch={onRefetch} />
),
},
{
label: (
<Button type="text" icon={<Globe size={14} />}>
Publish
</Button>
),
key: 'public-dashboard',
children: (
<Placeholder message="V2 public dashboard publishing coming next." />
),
},
];
return <Tabs items={items} />;
}
export default DashboardSettingsV2;

View File

@@ -1,135 +0,0 @@
import type {
DashboardtypesListVariableSpecDTO,
DashboardtypesVariableDTO,
} from 'api/generated/services/sigNoz.schemas';
import { referencedVariables } from './substitution';
/**
* Extracts the strings on a variable that may contain `$var` references —
* i.e. the dependency edges out of this variable.
*
* Currently only QUERY variables produce dependencies (their `queryValue`
* may reference other variables). CUSTOM and DYNAMIC plugin specs don't
* embed substitutable strings, and TEXT variables are leaf nodes.
*/
function dependencyStrings(dto: DashboardtypesVariableDTO): string[] {
if (dto.kind !== 'ListVariable') return [];
const spec = dto.spec as DashboardtypesListVariableSpecDTO;
const pluginKind = spec?.plugin?.kind;
const pluginSpec = spec?.plugin?.spec as Record<string, unknown> | undefined;
if (pluginKind === 'signoz/QueryVariable') {
return [String(pluginSpec?.queryValue ?? '')];
}
return [];
}
function nameOf(dto: DashboardtypesVariableDTO): string {
return (dto.spec as { name?: string })?.name ?? '';
}
/**
* Direct dependencies for each variable (name → set of names it references).
*/
export function buildDependencyMap(
variables: DashboardtypesVariableDTO[],
): Record<string, Set<string>> {
const knownNames = new Set(variables.map(nameOf).filter(Boolean));
const deps: Record<string, Set<string>> = {};
variables.forEach((v) => {
const name = nameOf(v);
if (!name) return;
const refs = new Set<string>();
dependencyStrings(v).forEach((s) => {
referencedVariables(s).forEach((ref) => {
if (ref !== name && knownNames.has(ref)) refs.add(ref);
});
});
deps[name] = refs;
});
return deps;
}
export interface CycleResult {
hasCycle: boolean;
cycle?: string[];
}
/**
* Detect a cycle via DFS; returns the participating names in traversal order.
* Used at save time and to guard re-resolution.
*/
export function detectCycle(
deps: Record<string, Set<string>>,
): CycleResult {
const WHITE = 0;
const GRAY = 1;
const BLACK = 2;
const color: Record<string, number> = {};
const stack: string[] = [];
const names = Object.keys(deps);
names.forEach((n) => {
color[n] = WHITE;
});
function visit(node: string): string[] | null {
color[node] = GRAY;
stack.push(node);
for (const next of deps[node] ?? []) {
if (color[next] === GRAY) {
const idx = stack.indexOf(next);
return stack.slice(idx).concat(next);
}
if (color[next] === WHITE) {
const found = visit(next);
if (found) return found;
}
}
stack.pop();
color[node] = BLACK;
return null;
}
for (const n of names) {
if (color[n] === WHITE) {
const cycle = visit(n);
if (cycle) return { hasCycle: true, cycle };
}
}
return { hasCycle: false };
}
/**
* Kahn's algorithm — returns variable names in dependency order
* (dependencies first). If there's a cycle the result excludes the
* participating nodes; combine with `detectCycle` for validation.
*/
export function topoSort(
deps: Record<string, Set<string>>,
): string[] {
const incoming: Record<string, number> = {};
const downstream: Record<string, string[]> = {};
Object.keys(deps).forEach((n) => {
incoming[n] = 0;
downstream[n] = [];
});
Object.entries(deps).forEach(([n, refs]) => {
refs.forEach((ref) => {
incoming[n] += 1;
downstream[ref] = downstream[ref] ?? [];
downstream[ref].push(n);
});
});
const queue: string[] = Object.keys(incoming).filter((n) => incoming[n] === 0);
const out: string[] = [];
while (queue.length > 0) {
const n = queue.shift() as string;
out.push(n);
(downstream[n] ?? []).forEach((next) => {
incoming[next] -= 1;
if (incoming[next] === 0) queue.push(next);
});
}
return out;
}

View File

@@ -1,81 +0,0 @@
import { useEffect, useMemo } from 'react';
import type {
DashboardtypesListVariableSpecDTO,
DashboardTextVariableSpecDTO,
DashboardtypesVariableDTO,
} from 'api/generated/services/sigNoz.schemas';
import { buildDependencyMap, detectCycle, topoSort } from './dependencyGraph';
import VariableSelector from './selectors/VariableSelector';
import { useVariableSelectionStore } from './state/selectionStore';
import '../../DashboardContainer/DashboardVariablesSelection/DashboardVariableSelection.styles.scss';
interface Props {
dashboardId: string;
variables: DashboardtypesVariableDTO[] | undefined;
}
function nameOf(v: DashboardtypesVariableDTO): string {
return (
(v.spec as DashboardtypesListVariableSpecDTO | DashboardTextVariableSpecDTO)
?.name ?? ''
);
}
function kindHint(v: DashboardtypesVariableDTO): 'list' | 'text' {
return v.kind === 'TextVariable' ? 'text' : 'list';
}
function DashboardVariablesV2({ dashboardId, variables }: Props): JSX.Element | null {
const hydrate = useVariableSelectionStore((s) => s.hydrate);
// Build hints map (variable-name → list/text) so the store can decode the URL.
const hints = useMemo<Record<string, 'list' | 'text'>>(() => {
const out: Record<string, 'list' | 'text'> = {};
(variables ?? []).forEach((v) => {
const n = nameOf(v);
if (n) out[n] = kindHint(v);
});
return out;
}, [variables]);
useEffect(() => {
if (!dashboardId) return;
hydrate(dashboardId, hints);
}, [dashboardId, hints, hydrate]);
// Sort variables in dependency order so dependent resolvers see fresh
// selections from their parents. (Render order doesn't affect the React
// Query cache but it does affect *visual* order.)
const ordered = useMemo(() => {
if (!variables?.length) return [];
const deps = buildDependencyMap(variables);
const cycle = detectCycle(deps);
if (cycle.hasCycle) {
// Render in the original order; the cycle is surfaced separately at save
// time via validateDraft. Resolution will still execute; it just won't
// converge.
return variables;
}
const order = topoSort(deps);
const byName: Record<string, DashboardtypesVariableDTO> = {};
variables.forEach((v) => {
const n = nameOf(v);
if (n) byName[n] = v;
});
return order.map((n) => byName[n]).filter(Boolean);
}, [variables]);
if (!variables || variables.length === 0) return null;
return (
<div className="variables-container">
{ordered.map((v) => (
<VariableSelector key={nameOf(v)} variable={v} />
))}
</div>
);
}
export default DashboardVariablesV2;

View File

@@ -1,29 +0,0 @@
/**
* Applies V2 `capturingRegexp` to each value: if the regex matches and has a
* capture group, replace the value with the first capture; otherwise keep
* the raw value. Invalid regex silently passes values through.
*
* Empty results (no match at all) are filtered out — they would be useless
* as selectable options.
*/
export function applyCapturingRegexp(
values: string[],
pattern: string | undefined | null,
): string[] {
if (!pattern) return values;
let re: RegExp;
try {
re = new RegExp(pattern);
} catch {
return values;
}
const out: string[] = [];
values.forEach((v) => {
const m = re.exec(v);
if (!m) return;
out.push(m[1] !== undefined ? m[1] : m[0]);
});
return out;
}

View File

@@ -1,37 +0,0 @@
/**
* Apply V2 sort modes to a resolved value list.
*
* Sort values come from the perses spec — `none`, `alphabetical-asc`,
* `alphabetical-desc`, `numerical-asc`, `numerical-desc`. Numerical sort
* falls back to string compare for values that aren't numbers so we never
* throw away non-numeric entries.
*/
export function applySort(
values: string[],
sort: string | null | undefined,
): string[] {
if (!sort || sort === 'none' || values.length <= 1) return values;
const copy = values.slice();
if (sort === 'alphabetical-asc') {
copy.sort((a, b) => a.localeCompare(b));
} else if (sort === 'alphabetical-desc') {
copy.sort((a, b) => b.localeCompare(a));
} else if (sort === 'numerical-asc' || sort === 'numerical-desc') {
copy.sort((a, b) => {
const na = Number(a);
const nb = Number(b);
const aFinite = Number.isFinite(na);
const bFinite = Number.isFinite(nb);
if (aFinite && bFinite) {
return sort === 'numerical-asc' ? na - nb : nb - na;
}
// Mixed numeric/non-numeric: keep non-numerics at the end, sorted alpha.
if (aFinite) return -1;
if (bFinite) return 1;
return sort === 'numerical-asc'
? a.localeCompare(b)
: b.localeCompare(a);
});
}
return copy;
}

View File

@@ -1,18 +0,0 @@
/**
* Output of resolving a single list variable. Text variables don't go
* through resolution — their value is the literal string.
*/
export interface ResolvedValues {
values: string[];
status: 'idle' | 'loading' | 'success' | 'error';
error?: string;
}
export const idle: ResolvedValues = { values: [], status: 'idle' };
export const loading: ResolvedValues = { values: [], status: 'loading' };
export function success(values: string[]): ResolvedValues {
return { values, status: 'success' };
}
export function failure(error: string): ResolvedValues {
return { values: [], status: 'error', error };
}

View File

@@ -1,15 +0,0 @@
import { useMemo } from 'react';
import { commaValuesParser } from 'lib/dashboardVariables/customCommaValuesParser';
import { success, type ResolvedValues } from './types';
/**
* CUSTOM variables: the comma-separated user input is the value list.
* No network call, purely client-side.
*/
export function useCustomResolver(customValue: string): ResolvedValues {
return useMemo(
() => success(commaValuesParser(customValue).map((v) => String(v))),
[customValue],
);
}

View File

@@ -1,50 +0,0 @@
import { useSelector } from 'react-redux';
import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
import { useGetFieldValues } from 'hooks/dynamicVariables/useGetFieldValues';
import { AppState } from 'store/reducers';
import { GlobalReducer } from 'types/reducer/globalTime';
import { failure, idle, loading, success, type ResolvedValues } from './types';
function signalToV1(
signal: TelemetrytypesSignalDTO | undefined,
): 'traces' | 'logs' | 'metrics' | undefined {
if (signal === TelemetrytypesSignalDTO.traces) return 'traces';
if (signal === TelemetrytypesSignalDTO.logs) return 'logs';
if (signal === TelemetrytypesSignalDTO.metrics) return 'metrics';
return undefined;
}
/**
* DYNAMIC variables: telemetry attribute lookup.
* - `signal === undefined` → search across all telemetry types.
* - Otherwise scoped to the specific signal.
*
* Uses the existing V1 hook directly; the API is V2-shape-agnostic.
*/
export function useDynamicResolver(
attributeName: string,
signal: TelemetrytypesSignalDTO | undefined,
): ResolvedValues {
const { maxTime, minTime } = useSelector<AppState, GlobalReducer>(
(state) => state.globalTime,
);
const enabled = !!attributeName;
const { data, isLoading, isError, error } = useGetFieldValues({
signal: signalToV1(signal),
name: attributeName,
enabled,
startUnixMilli: minTime,
endUnixMilli: maxTime,
});
if (!enabled) return idle;
if (isLoading) return loading;
if (isError) {
return failure(
(error as Error)?.message ?? 'Failed to resolve dynamic variable',
);
}
return success(data?.data?.normalizedValues ?? []);
}

View File

@@ -1,78 +0,0 @@
import { useQuery } from 'react-query';
import dashboardVariablesQuery from 'api/dashboard/variables/dashboardVariablesQuery';
import type { PayloadVariables } from 'types/api/dashboard/variables/query';
import { substituteVariables } from '../substitution';
import type { SelectionsByName } from '../state/types';
import { failure, idle, loading, success, type ResolvedValues } from './types';
/**
* Reduce the user's V2 selections to the V1 `PayloadVariables` shape the
* variables/query endpoint expects (a plain name → selected-value map).
*/
function selectionsToPayload(
selections: SelectionsByName,
): PayloadVariables {
const out: PayloadVariables = {};
Object.entries(selections).forEach(([name, sel]) => {
if (!sel) return;
if (sel.kind === 'text') {
out[name] = sel.value;
} else if (sel.allSelected) {
// Endpoint understands `__ALL__`-style markers via the substitution
// done client-side; leave the value out so server doesn't double up.
// (Callers using IN ($var) expand via substituteVariables instead.)
} else if (sel.values.length === 1) {
out[name] = sel.values[0];
} else {
out[name] = sel.values;
}
});
return out;
}
interface UseQueryResolverArgs {
variableName: string;
queryValue: string;
selections: SelectionsByName;
enabled: boolean;
}
/**
* QUERY variables: substitute `$var` references using current selections,
* then POST to `/api/v2/variables/query`. React Query caches per
* (name, substitutedQuery) so re-render with the same inputs reuses results.
*/
export function useQueryResolver({
variableName,
queryValue,
selections,
enabled,
}: UseQueryResolverArgs): ResolvedValues {
const substituted = substituteVariables(queryValue, selections);
const { data, isLoading, isError, error } = useQuery({
queryKey: ['v2-variable-query', variableName, substituted],
queryFn: () =>
dashboardVariablesQuery({
query: substituted,
variables: selectionsToPayload(selections),
}),
enabled: enabled && !!substituted,
refetchOnWindowFocus: false,
});
if (!enabled || !substituted) return idle;
if (isLoading) return loading;
if (isError) {
return failure(
(error as { details?: { error?: string } })?.details?.error ??
(error as Error)?.message ??
'Variable query failed',
);
}
const payload = (data as { payload?: { variableValues?: unknown[] } } | undefined)
?.payload;
const values = (payload?.variableValues ?? []).map((v) => String(v));
return success(values);
}

View File

@@ -1,74 +0,0 @@
import { useMemo } from 'react';
import type {
DashboardtypesListVariableSpecDTO,
DashboardtypesVariableDTO,
TelemetrytypesSignalDTO,
} from 'api/generated/services/sigNoz.schemas';
import { useVariableSelectionStore } from '../state/selectionStore';
import { applyCapturingRegexp } from './capturingRegexp';
import { applySort } from './sorting';
import { useCustomResolver } from './useCustomResolver';
import { useDynamicResolver } from './useDynamicResolver';
import { useQueryResolver } from './useQueryResolver';
import { idle, success, type ResolvedValues } from './types';
interface UseResolveVariableArgs {
variable: DashboardtypesVariableDTO;
}
/**
* Routes a variable to the correct resolver hook and applies the V2
* post-processing pipeline:
*
* raw values → capturingRegexp → sort → final list
*
* Text variables short-circuit since they don't have a value list.
*/
export function useResolveVariable({
variable,
}: UseResolveVariableArgs): ResolvedValues {
const selections = useVariableSelectionStore((s) => s.selections);
// Read all fields up front so the React Query / hook order is stable
// across renders (hooks must not be called conditionally).
const isText = variable.kind === 'TextVariable';
const listSpec = (variable.spec as DashboardtypesListVariableSpecDTO) ?? {};
const pluginKind = listSpec.plugin?.kind;
const pluginSpec = (listSpec.plugin?.spec as Record<string, unknown> | undefined) ?? {};
const name = listSpec?.name ?? '';
const customValue = (pluginSpec.customValue as string) ?? '';
const queryValue = (pluginSpec.queryValue as string) ?? '';
const dynName = (pluginSpec.name as string) ?? '';
const dynSignal = pluginSpec.signal as TelemetrytypesSignalDTO | undefined;
const customRes = useCustomResolver(
pluginKind === 'signoz/CustomVariable' ? customValue : '',
);
const dynRes = useDynamicResolver(
pluginKind === 'signoz/DynamicVariable' ? dynName : '',
dynSignal,
);
const queryRes = useQueryResolver({
variableName: name,
queryValue: pluginKind === 'signoz/QueryVariable' ? queryValue : '',
selections,
enabled: pluginKind === 'signoz/QueryVariable',
});
const raw: ResolvedValues = useMemo(() => {
if (isText) return success([]);
if (pluginKind === 'signoz/CustomVariable') return customRes;
if (pluginKind === 'signoz/DynamicVariable') return dynRes;
if (pluginKind === 'signoz/QueryVariable') return queryRes;
return idle;
}, [isText, pluginKind, customRes, dynRes, queryRes]);
return useMemo(() => {
if (raw.status !== 'success') return raw;
const afterRegex = applyCapturingRegexp(raw.values, listSpec.capturingRegexp);
const afterSort = applySort(afterRegex, listSpec.sort);
return success(afterSort);
}, [raw, listSpec.capturingRegexp, listSpec.sort]);
}

Some files were not shown because too many files have changed in this diff Show More