diff --git a/frontend/src/components/QueryBuilderV2/QueryV2/TraceOperator/TraceOperator.styles.scss b/frontend/src/components/QueryBuilderV2/QueryV2/TraceOperator/TraceOperator.styles.scss index 454f24fe4454..a728d17991cb 100644 --- a/frontend/src/components/QueryBuilderV2/QueryV2/TraceOperator/TraceOperator.styles.scss +++ b/frontend/src/components/QueryBuilderV2/QueryV2/TraceOperator/TraceOperator.styles.scss @@ -25,6 +25,32 @@ } } + &-span-source-label { + display: flex; + align-items: center; + gap: 8px; + height: 24px; + + &-query { + font-size: 14px; + font-weight: 400; + color: var(--bg-vanilla-100); + } + &-query-name { + width: 18px; + height: 18px; + display: grid; + place-content: center; + padding: 2px; + + border-radius: 2px; + border: 1px solid rgba(242, 71, 105, 0.2); + background: rgba(242, 71, 105, 0.1); + color: var(--Sakura-400, #f56c87); + font-size: 12px; + } + } + &-arrow { position: relative; &::before { @@ -83,6 +109,13 @@ &-add-ons-input { position: relative; + display: flex; + align-items: center; + flex-direction: row; + + border-radius: 2px; + border: 1px solid var(--bg-slate-400); + background: var(--bg-ink-300); &::before { content: ''; @@ -93,5 +126,55 @@ width: 16px; background-color: var(--bg-slate-400); } + + .label { + color: var(--bg-vanilla-400); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + padding: 0px 8px; + border-right: 1px solid var(--bg-slate-400); + } + } +} + +.lightMode { + .qb-trace-operator { + &-arrow { + &::before { + background: repeating-linear-gradient( + to right, + var(--bg-vanilla-300), + var(--bg-vanilla-300) 4px, + transparent 4px, + transparent 8px + ); + } + &::after { + background-color: var(--bg-vanilla-300); + } + } + &.non-list-view { + &::before { + background: repeating-linear-gradient( + to bottom, + var(--bg-vanilla-300), + var(--bg-vanilla-300) 4px, + transparent 4px, + transparent 8px + ); + } + } + + &-add-ons-input { + border: 1px solid var(--bg-vanilla-300) !important; + background: var(--bg-vanilla-100) !important; + + .label { + color: var(--bg-ink-500) !important; + border-right: 1px solid var(--bg-vanilla-300) !important; + background: var(--bg-vanilla-100) !important; + } + } } } diff --git a/frontend/src/components/QueryBuilderV2/QueryV2/TraceOperator/TraceOperator.tsx b/frontend/src/components/QueryBuilderV2/QueryV2/TraceOperator/TraceOperator.tsx index cb667e2c0928..d181f2fa21a4 100644 --- a/frontend/src/components/QueryBuilderV2/QueryV2/TraceOperator/TraceOperator.tsx +++ b/frontend/src/components/QueryBuilderV2/QueryV2/TraceOperator/TraceOperator.tsx @@ -5,62 +5,87 @@ import InputWithLabel from 'components/InputWithLabel/InputWithLabel'; import cx from 'classnames'; import './TraceOperator.styles.scss'; import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder'; -import { useCallback } from 'react'; +import { useCallback, useMemo } from 'react'; import { IBuilderQuery, IBuilderTraceOperator, } from 'types/api/queryBuilder/queryBuilderData'; import QueryAddOns from '../QueryAddOns/QueryAddOns'; import QueryAggregation from '../QueryAggregation/QueryAggregation'; -import { useTraceOperatorOperations } from 'hooks/queryBuilder/userTraceOperatorOperations'; -import { Button, Tooltip } from 'antd'; +import { Button, Select, Tooltip, Typography } from 'antd'; import { Trash2 } from 'lucide-react'; +import { DataSource } from 'types/common/queryBuilder'; +import { useQueryOperations } from 'hooks/queryBuilder/useQueryBuilderOperations'; export default function TraceOperator({ traceOperator, isListViewPanel = false, }: { - traceOperator: IBuilderTraceOperator | undefined; + traceOperator: IBuilderTraceOperator; isListViewPanel?: boolean; }): JSX.Element { const { panelType, currentQuery, removeTraceOperator } = useQueryBuilder(); - const { handleChangeTraceOperatorData } = useTraceOperatorOperations({ + const { handleChangeQueryData } = useQueryOperations({ index: 0, query: traceOperator, + entityVersion: '', + isForTraceOperator: true, }); const handleTraceOperatorChange = useCallback( (traceOperatorExpression: string) => { - handleChangeTraceOperatorData('expression', traceOperatorExpression); + handleChangeQueryData('expression', traceOperatorExpression); }, - [handleChangeTraceOperatorData], + [handleChangeQueryData], ); const handleChangeAggregateEvery = useCallback( (value: IBuilderQuery['stepInterval']) => { - handleChangeTraceOperatorData('stepInterval', value); + handleChangeQueryData('stepInterval', value); }, - [handleChangeTraceOperatorData], + [handleChangeQueryData], ); const handleChangeAggregation = useCallback( (value: string) => { - handleChangeTraceOperatorData('aggregations', [ + handleChangeQueryData('aggregations', [ { expression: value, }, ]); }, - [handleChangeTraceOperatorData], + [handleChangeQueryData], ); const handleChangeSpanSource = useCallback( (value: string) => { - handleChangeTraceOperatorData('returnSpansFrom', value); + handleChangeQueryData('returnSpansFrom', value); }, - [handleChangeTraceOperatorData], + [handleChangeQueryData], ); + const defaultSpanSource = useMemo(() => { + return ( + traceOperator.returnSpansFrom || + currentQuery.builder.queryData[0].queryName || + '' + ); + }, [currentQuery.builder.queryData, traceOperator?.returnSpansFrom]); + + const spanSourceOptions = useMemo(() => { + return currentQuery.builder.queryData.map((query) => ({ + value: query.queryName, + label: ( +
+ {query.queryName} +
+