Skip to content

Commit

Permalink
fix(experiments): hide "Participant Type" section if user don't use g…
Browse files Browse the repository at this point in the history
…roups (#26823)
  • Loading branch information
andehen authored Dec 11, 2024
1 parent e961500 commit 3908c7c
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions frontend/src/scenes/experiments/ExperimentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useActions, useValues } from 'kea'
import { Form, Group } from 'kea-forms'
import { ExperimentVariantNumber } from 'lib/components/SeriesGlyph'
import { MAX_EXPERIMENT_VARIANTS } from 'lib/constants'
import { groupsAccessLogic, GroupsAccessStatus } from 'lib/introductions/groupsAccessLogic'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonField } from 'lib/lemon-ui/LemonField'
import { LemonRadio } from 'lib/lemon-ui/LemonRadio'
Expand All @@ -20,6 +21,7 @@ const ExperimentFormFields = (): JSX.Element => {
const { addExperimentGroup, removeExperimentGroup, setExperiment, createExperiment, setExperimentType } =
useActions(experimentLogic)
const { webExperimentsAvailable } = useValues(experimentsLogic)
const { groupsAccessStatus } = useValues(groupsAccessLogic)

return (
<div>
Expand Down Expand Up @@ -103,37 +105,40 @@ const ExperimentFormFields = (): JSX.Element => {
/>
</div>
)}
<div>
<h3 className="mt-10">Participant type</h3>
<div className="text-xs text-muted">
The type on which to aggregate metrics. You can change this at any time during the experiment.
</div>
<LemonDivider />
<LemonRadio
value={
experiment.parameters.aggregation_group_type_index != undefined
? experiment.parameters.aggregation_group_type_index
: -1
}
onChange={(rawGroupTypeIndex) => {
const groupTypeIndex = rawGroupTypeIndex !== -1 ? rawGroupTypeIndex : undefined
{groupsAccessStatus === GroupsAccessStatus.AlreadyUsing && (
<div>
<h3 className="mt-10">Participant type</h3>
<div className="text-xs text-muted">
The type on which to aggregate metrics. You can change this at any time during the
experiment.
</div>
<LemonDivider />
<LemonRadio
value={
experiment.parameters.aggregation_group_type_index != undefined
? experiment.parameters.aggregation_group_type_index
: -1
}
onChange={(rawGroupTypeIndex) => {
const groupTypeIndex = rawGroupTypeIndex !== -1 ? rawGroupTypeIndex : undefined

setExperiment({
parameters: {
...experiment.parameters,
aggregation_group_type_index: groupTypeIndex ?? undefined,
},
})
}}
options={[
{ value: -1, label: 'Persons' },
...Array.from(groupTypes.values()).map((groupType) => ({
value: groupType.group_type_index,
label: capitalizeFirstLetter(aggregationLabel(groupType.group_type_index).plural),
})),
]}
/>
</div>
setExperiment({
parameters: {
...experiment.parameters,
aggregation_group_type_index: groupTypeIndex ?? undefined,
},
})
}}
options={[
{ value: -1, label: 'Persons' },
...Array.from(groupTypes.values()).map((groupType) => ({
value: groupType.group_type_index,
label: capitalizeFirstLetter(aggregationLabel(groupType.group_type_index).plural),
})),
]}
/>
</div>
)}
<div className="mt-10">
<h3 className="mb-1">Variants</h3>
<div className="text-xs text-muted">Add up to 9 variants to test against your control.</div>
Expand Down

0 comments on commit 3908c7c

Please sign in to comment.