From db3b52b879d76f2045746f973bea3cf0685923e4 Mon Sep 17 00:00:00 2001 From: Travis Jenkins Date: Thu, 6 Mar 2025 10:28:24 -0500 Subject: [PATCH] disable button while adding source capture collections (#1496) * Properly checking length and disabling button while it is working * Handling state for anything that needs to evaluate trial collections --- .../editor/Bindings/UpdateResourceConfigButton.tsx | 8 +++++++- .../SourceCapture/AddSourceCaptureToSpecButton.tsx | 13 +++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/editor/Bindings/UpdateResourceConfigButton.tsx b/src/components/editor/Bindings/UpdateResourceConfigButton.tsx index e8c9e47cd..77a3b7e9c 100644 --- a/src/components/editor/Bindings/UpdateResourceConfigButton.tsx +++ b/src/components/editor/Bindings/UpdateResourceConfigButton.tsx @@ -2,6 +2,7 @@ import { Button } from '@mui/material'; import { AddCollectionDialogCTAProps } from 'components/shared/Entity/types'; import invariableStores from 'context/Zustand/invariableStores'; import useTrialCollections from 'hooks/trialStorage/useTrialCollections'; +import { useState } from 'react'; import { FormattedMessage } from 'react-intl'; import { @@ -15,6 +16,8 @@ import { hasLength } from 'utils/misc-utils'; import { useStore } from 'zustand'; function UpdateResourceConfigButton({ toggle }: AddCollectionDialogCTAProps) { + const [updating, setUpdating] = useState(false); + const [selected] = useStore( invariableStores['Entity-Selector-Table'], (state) => { @@ -35,6 +38,8 @@ function UpdateResourceConfigButton({ toggle }: AddCollectionDialogCTAProps) { useBinding_setRestrictedDiscoveredCollections(); const close = () => { + setUpdating(true); + const value = Array.from(selected).map(([_id, row]) => { return { name: row.catalog_name, @@ -60,13 +65,14 @@ function UpdateResourceConfigButton({ toggle }: AddCollectionDialogCTAProps) { } } + setUpdating(false); toggle(false); }; return ( );