From 65f8e7cc022b94297f312c2056d8bb09fed0b96b Mon Sep 17 00:00:00 2001 From: Nar Saynorath Date: Tue, 10 Dec 2024 14:35:40 -0500 Subject: [PATCH] chore(widget-builder): Remove dev builder (#81921) --- .../widgetBuilder/components/devBuilder.tsx | 328 ------------------ .../components/widgetBuilderSlideout.tsx | 2 - 2 files changed, 330 deletions(-) delete mode 100644 static/app/views/dashboards/widgetBuilder/components/devBuilder.tsx diff --git a/static/app/views/dashboards/widgetBuilder/components/devBuilder.tsx b/static/app/views/dashboards/widgetBuilder/components/devBuilder.tsx deleted file mode 100644 index 022e8791c2cfe5..00000000000000 --- a/static/app/views/dashboards/widgetBuilder/components/devBuilder.tsx +++ /dev/null @@ -1,328 +0,0 @@ -import styled from '@emotion/styled'; - -import RadioGroup from 'sentry/components/forms/controls/radioGroup'; -import SelectControl from 'sentry/components/forms/controls/selectControl'; -import SelectField from 'sentry/components/forms/fields/selectField'; -import Input from 'sentry/components/input'; -import {SearchQueryBuilder} from 'sentry/components/searchQueryBuilder'; -import {space} from 'sentry/styles/space'; -import {CustomMeasurementsProvider} from 'sentry/utils/customMeasurements/customMeasurementsProvider'; -import {type Column, generateFieldAsString} from 'sentry/utils/discover/fields'; -import {useLocalStorageState} from 'sentry/utils/useLocalStorageState'; -import useOrganization from 'sentry/utils/useOrganization'; -import {getDatasetConfig} from 'sentry/views/dashboards/datasetConfig/base'; -import {DisplayType, WidgetType} from 'sentry/views/dashboards/types'; -import {ColumnFields} from 'sentry/views/dashboards/widgetBuilder/buildSteps/columnsStep/columnFields'; -import {YAxisSelector} from 'sentry/views/dashboards/widgetBuilder/buildSteps/yAxisStep/yAxisSelector'; -import {useWidgetBuilderContext} from 'sentry/views/dashboards/widgetBuilder/contexts/widgetBuilderContext'; -import {BuilderStateAction} from 'sentry/views/dashboards/widgetBuilder/hooks/useWidgetBuilderState'; -import {formatSort} from 'sentry/views/explore/tables/aggregatesTable'; - -function DevBuilder() { - const {state, dispatch} = useWidgetBuilderContext(); - const [showDevBuilder] = useLocalStorageState('showDevBuilder', false); - - if (!showDevBuilder) { - return null; - } - - return ( - -
-

Title:

-
{state.title}
- - dispatch({type: BuilderStateAction.SET_TITLE, payload: e.target.value}) - } - /> -
-
-

Description:

-
{state.description}
- - dispatch({ - type: BuilderStateAction.SET_DESCRIPTION, - payload: e.target.value, - }) - } - /> -
-
-

Display Type:

-
{state.displayType}
- ({ - label: value, - value, - }))} - onChange={newValue => - dispatch({ - type: BuilderStateAction.SET_DISPLAY_TYPE, - payload: newValue, - }) - } - style={{width: '200px'}} - /> -
-
-

Dataset:

-
{state.dataset}
- - dispatch({ - type: BuilderStateAction.SET_DATASET, - payload: newValue, - }) - } - /> -
-
-

Fields:

-
{state.fields?.map(generateFieldAsString).join(', ')}
- { - dispatch({ - type: BuilderStateAction.SET_FIELDS, - payload: newFields, - }); - }} - /> -
-
-

Y-Axis:

-
{state.yAxis?.map(generateFieldAsString).join(', ')}
- { - dispatch({ - type: BuilderStateAction.SET_Y_AXIS, - payload: newAggregates, - }); - }} - /> -
-
-

Query:

-
    - {state.query?.map((query, index) =>
  1. {query}
  2. )} -
-
- {state.query?.map((query, index) => ( -
- { - dispatch({ - type: BuilderStateAction.SET_QUERY, - payload: - state.query?.map((q, i) => (i === index ? queryString : q)) ?? [], - }); - }} - /> - -
- ))} - -
-
-
-

Sort:

-
{state.sort?.map(formatSort).join(', ')}
- -
- - ); -} - -function ColumnSelector({ - displayType, - fields, - dataset, - onChange, -}: { - dataset: WidgetType; - displayType: DisplayType; - fields: Column[]; - onChange: (newFields: Column[]) => void; -}) { - const organization = useOrganization(); - const datasetConfig = getDatasetConfig(dataset); - - const fieldOptions = datasetConfig.getTableFieldOptions(organization); - - return ( - true} - filterPrimaryOptions={() => true} - onChange={onChange} - /> - ); -} - -function YAxis({ - displayType, - widgetType, - aggregates, - onChange, -}: { - aggregates: Column[]; - displayType: DisplayType; - onChange: (newFields: Column[]) => void; - widgetType: WidgetType; -}) { - const organization = useOrganization(); - return ( - - - - ); -} - -function QueryField({ - query, - onSearch, -}: { - onSearch: (query: string) => void; - query: string; -}) { - return ( - Promise.resolve([])} - showUnsubmittedIndicator - /> - ); -} - -function SortSelector() { - const {state, dispatch} = useWidgetBuilderContext(); - - // There's a SortDirection enum in the widgetBuilder utils, but it's not used anywhere else - // so I'd rather just get rid of the dependency and use a new object that uses standard terms - const sortDirections = { - desc: 'High to low', - asc: 'Low to high', - }; - const direction = state.sort?.[0]?.kind; - const sortBy = state.sort?.[0]?.field; - - return ( -
- ({ - label: sortDirections[value], - value, - }))} - value={direction} - onChange={option => { - dispatch({ - type: BuilderStateAction.SET_SORT, - payload: [{field: sortBy ?? '', kind: option.value}], - }); - }} - /> - ({ - label: generateFieldAsString(field), - value: generateFieldAsString(field), - }))} - onChange={option => { - dispatch({ - type: BuilderStateAction.SET_SORT, - payload: [{field: option.value, kind: direction ?? 'asc'}], - }); - }} - /> -
- ); -} - -const Body = styled('div')` - margin: ${space(2)}; - padding: ${space(2)}; -`; - -const Section = styled('section')` - display: flex; - flex-direction: row; - justify-content: space-around; - border: 1px solid ${p => p.theme.border}; - align-items: center; - - > * { - flex: 1; - } -`; - -const SimpleInput = styled(Input)` - width: 100%; -`; - -export default DevBuilder; diff --git a/static/app/views/dashboards/widgetBuilder/components/widgetBuilderSlideout.tsx b/static/app/views/dashboards/widgetBuilder/components/widgetBuilderSlideout.tsx index 10020cd7be614e..05d8bf8d85fdeb 100644 --- a/static/app/views/dashboards/widgetBuilder/components/widgetBuilderSlideout.tsx +++ b/static/app/views/dashboards/widgetBuilder/components/widgetBuilderSlideout.tsx @@ -8,7 +8,6 @@ import {space} from 'sentry/styles/space'; import {useParams} from 'sentry/utils/useParams'; import {DisplayType, type Widget} from 'sentry/views/dashboards/types'; import WidgetBuilderDatasetSelector from 'sentry/views/dashboards/widgetBuilder/components/datasetSelector'; -import DevBuilder from 'sentry/views/dashboards/widgetBuilder/components/devBuilder'; import WidgetBuilderFilterBar from 'sentry/views/dashboards/widgetBuilder/components/filtersBar'; import WidgetBuilderGroupBySelector from 'sentry/views/dashboards/widgetBuilder/components/groupBySelector'; import WidgetBuilderNameAndDescription from 'sentry/views/dashboards/widgetBuilder/components/nameAndDescFields'; @@ -77,7 +76,6 @@ function WidgetBuilderSlideout({isOpen, onClose, onSave}: WidgetBuilderSlideoutP - );