From 3bcd8dd607bcf48181dcb9ecf0f86d77261771f4 Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Thu, 22 May 2025 21:00:27 -0400 Subject: [PATCH 1/4] ref(explore): Prepare for the aggregate editor Preparing to add a column editor for aggregate mode. This does some light tidying up. --- static/app/views/explore/components/typeBadge.tsx | 8 ++++---- .../app/views/explore/tables/columnEditorModal.tsx | 14 ++++++++++---- static/app/views/explore/tables/index.tsx | 10 ++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/static/app/views/explore/components/typeBadge.tsx b/static/app/views/explore/components/typeBadge.tsx index b34b24cf9c06af..0f059abadab6aa 100644 --- a/static/app/views/explore/components/typeBadge.tsx +++ b/static/app/views/explore/components/typeBadge.tsx @@ -10,16 +10,16 @@ interface TypeBadgeProps { } export function TypeBadge({func, kind}: TypeBadgeProps) { - if (defined(func)) { - return {t('aggregation')}; + if (defined(func) || kind === FieldKind.FUNCTION) { + return {t('f(x)')}; } if (kind === FieldKind.MEASUREMENT) { - return {t('number')}; + return {t('number')}; } if (kind === FieldKind.TAG) { - return {t('string')}; + return {t('string')}; } return null; diff --git a/static/app/views/explore/tables/columnEditorModal.tsx b/static/app/views/explore/tables/columnEditorModal.tsx index 5d31bc6c2c3ee6..8126b1f552145d 100644 --- a/static/app/views/explore/tables/columnEditorModal.tsx +++ b/static/app/views/explore/tables/columnEditorModal.tsx @@ -242,7 +242,7 @@ function ColumnEditorRow({ ); } } - return {!column.column && t('None')}; + return {column.column || t('\u2014')}; }, [column.column, options]); return ( @@ -255,7 +255,7 @@ function ColumnEditorRow({ }} {...attributes} > - + ) : tab === Mode.AGGREGATE && + organization.features.includes('visibility-explore-aggregate-editor') ? ( + ) : ( Date: Thu, 22 May 2025 21:03:49 -0400 Subject: [PATCH 2/4] remove unused equation builder --- static/app/views/explore/toolbar/index.tsx | 4 +- .../explore/toolbar/toolbarVisualize.tsx | 129 ++---------------- 2 files changed, 13 insertions(+), 120 deletions(-) diff --git a/static/app/views/explore/toolbar/index.tsx b/static/app/views/explore/toolbar/index.tsx index 4bf6b35a8e6b23..7b95d2786fba01 100644 --- a/static/app/views/explore/toolbar/index.tsx +++ b/static/app/views/explore/toolbar/index.tsx @@ -20,7 +20,7 @@ interface ExploreToolbarProps { width?: number; } -export function ExploreToolbar({extras, width}: ExploreToolbarProps) { +export function ExploreToolbar({width}: ExploreToolbarProps) { const fields = useExploreFields(); const groupBys = useExploreGroupBys(); const visualizes = useExploreVisualizes(); @@ -29,7 +29,7 @@ export function ExploreToolbar({extras, width}: ExploreToolbarProps) { return ( - + {visualize.yAxes.map((yAxis, index) => ( - {equationSupport ? ( - - ) : ( - - )} + ))} @@ -255,93 +235,6 @@ function VisualizeDropdown({ ); } -interface VisualizeEquationProps { - canDelete: boolean; - deleteOverlay: (group: number, index: number) => void; - group: number; - index: number; - setVisualizes: (visualizes: BaseVisualize[], fields?: string[]) => void; - visualizes: Visualize[]; - label?: string; - yAxis?: string; -} - -function VisualizeEquation({ - canDelete, - deleteOverlay, - group, - index, - setVisualizes, - label, - yAxis, - visualizes, -}: VisualizeEquationProps) { - const setChartYAxis = useCallback( - (expression: Expression) => { - if (expression.isValid) { - const functions = expression.tokens.filter(isTokenFunction); - const newVisualizes = visualizes.map((visualize, i) => { - if (i === group) { - const yAxes = [...visualize.yAxes]; - yAxes[index] = expression.text; - visualize = visualize.replace({yAxes}); - } - return visualize.toJSON(); - }); - setVisualizes( - newVisualizes, - functions.flatMap(func => func.attributes.map(attr => attr.format())) - ); - } - }, - [group, index, setVisualizes, visualizes] - ); - - const aggregateFunctions = useMemo(() => { - return ALLOWED_EXPLORE_VISUALIZE_AGGREGATES.map(aggregate => { - return { - name: aggregate, - label: `${aggregate}(\u2026)`, - }; - }); - }, []); - - const yAxes: string[] = useMemo(() => { - return visualizes.flatMap(visualize => visualize.yAxes); - }, [visualizes]); - - const fieldOptions: Array> = useVisualizeFields({yAxes, yAxis}); - - const functionArguments = useMemo(() => { - return fieldOptions.map(o => { - return { - name: o.value, - label: o.label, - }; - }); - }, [fieldOptions]); - - return ( - - {label && {label}} - -