Skip to content

Commit 63b3c41

Browse files
author
Chandrasekhar Ramakrishnan
committed
track selected values
1 parent 807e759 commit 63b3c41

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

client/src/features/sessionsV2/SessionView/SessionLaunchLinkModal.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,23 @@ function SessionLaunchLink({
290290
);
291291
}
292292

293+
interface SessionLaunchLinkCustomizationProps
294+
extends Pick<CustomizeLaunchLinkFormProps, "fields"> {
295+
watch: ReturnType<typeof useForm<EnvVariablesCustomizationForm>>["watch"];
296+
}
293297
function SessionLaunchLinkCustomization({
294298
fields,
295-
}: Pick<CustomizeLaunchLinkFormProps, "fields">) {
296-
const shownFields = fields.filter((field) => field.isCustomized);
299+
watch,
300+
}: SessionLaunchLinkCustomizationProps) {
301+
const names = fields.map(
302+
(_f, i) => `envVariables.${i}.isCustomized`
303+
) as `envVariables.${number}.isCustomized`[];
304+
const values = watch(names);
305+
const shownFields = fields.filter((_f, i) => values[i]);
297306
if (shownFields.length < 1) return null;
298307
return (
299308
<>
300-
<Row>
309+
<Row className="mt-3">
301310
<Col>
302311
<p>The link and badge above include the following customizations:</p>
303312
</Col>
@@ -347,6 +356,7 @@ export default function SessionLaunchLinkModal({
347356
register,
348357
reset,
349358
resetField,
359+
watch,
350360
} = useForm<EnvVariablesCustomizationForm>({
351361
defaultValues,
352362
});
@@ -377,7 +387,7 @@ export default function SessionLaunchLinkModal({
377387
</ModalHeader>
378388
<ModalBody>
379389
<SessionLaunchLink launcher={launcher} project={project} />
380-
<SessionLaunchLinkCustomization fields={fields} />
390+
<SessionLaunchLinkCustomization fields={fields} watch={watch} />
381391
<CustomizeLaunchLinkForm
382392
control={control}
383393
errors={errors}

0 commit comments

Comments
 (0)