import {Fragment, useCallback} from 'react'; import styled from '@emotion/styled'; import CheckboxFancy from 'sentry/components/checkboxFancy/checkboxFancy'; import {FeatureFeedback} from 'sentry/components/featureFeedback'; import {TextField} from 'sentry/components/forms'; import Textarea from 'sentry/components/forms/controls/textarea'; import Field from 'sentry/components/forms/field'; import {t} from 'sentry/locale'; import ConfigStore from 'sentry/stores/configStore'; import space from 'sentry/styles/space'; enum TracingCapturingPriorities { TRANSACTION_NAME = 'transaction_name', CUSTOM_TAG = 'custom_tag', OTHER = 'other', } type Option = { checked: boolean; title: string; value: string | number; }; type InitialData = { opinionAboutFeature: string; tracingCapturingOtherPriority: string; tracingCapturingPriorities: Option[]; }; const initialData: InitialData = { opinionAboutFeature: '', tracingCapturingPriorities: [ { title: t('By transaction name'), value: TracingCapturingPriorities.TRANSACTION_NAME, checked: false, }, { title: t('By custom tag'), value: TracingCapturingPriorities.CUSTOM_TAG, checked: false, }, { title: t('Other'), value: TracingCapturingPriorities.OTHER, checked: false, }, ], tracingCapturingOtherPriority: '', }; function MultipleCheckboxField({ options, onChange, otherTextField, }: { onChange: (options: Option[]) => void; options: Option[]; otherTextField: React.ReactNode; }) { const handleClick = useCallback( (newOption: Option) => { const newOptions = options.map(option => { if (option.value === newOption.value) { return { ...option, checked: !option.checked, }; } return option; }); onChange(newOptions); }, [onChange, options] ); return ( {options.map(option => { if (option.value === 'other') { return ( handleClick(option)} > {option.title} {otherTextField} ); } return ( handleClick(option)}> {option.title} ); })} ); } export function SamplingFeedback() { const feedbackMessage = `Dynamic Sampling feedback by ${ConfigStore.get('user').email}`; return ( {({Header, Body, Footer, state, onFieldChange}) => { return (
{t('Submit Feedback')}
{t('What do you think about this feature?')}} stacked inline={false} flexibleControlStateSize >