From d84615f64bd34d4c7b8ba514cb31ea52e3bde53f Mon Sep 17 00:00:00 2001 From: mabashian Date: Thu, 10 Sep 2020 16:21:24 -0400 Subject: [PATCH] Rename onLoading/onDoneLoading props to onCopyStart and onCopyFinish. Wrap the functions being passed in as those props in useCallback to keep them hooks safe. --- .../src/components/CopyButton/CopyButton.jsx | 26 ++++++++++++++----- .../components/CopyButton/CopyButton.test.jsx | 8 +++--- .../CredentialList/CredentialListItem.jsx | 12 +++++++-- .../InventoryList/InventoryListItem.jsx | 12 +++++++-- .../Project/ProjectList/ProjectListItem.jsx | 12 +++++++-- .../TemplateList/TemplateListItem.jsx | 12 +++++++-- 6 files changed, 64 insertions(+), 18 deletions(-) diff --git a/awx/ui_next/src/components/CopyButton/CopyButton.jsx b/awx/ui_next/src/components/CopyButton/CopyButton.jsx index dd1e91a7aa..f8eeda7626 100644 --- a/awx/ui_next/src/components/CopyButton/CopyButton.jsx +++ b/awx/ui_next/src/components/CopyButton/CopyButton.jsx @@ -9,17 +9,24 @@ import useRequest, { useDismissableError } from '../../util/useRequest'; import AlertModal from '../AlertModal'; import ErrorDetail from '../ErrorDetail'; -function CopyButton({ i18n, copyItem, onLoading, onDoneLoading, helperText }) { +function CopyButton({ + i18n, + copyItem, + isDisabled, + onCopyStart, + onCopyFinish, + helperText, +}) { const { isLoading, error: copyError, request: copyItemToAPI } = useRequest( copyItem ); useEffect(() => { if (isLoading) { - return onLoading(); + return onCopyStart(); } - return onDoneLoading(); - }, [isLoading, onLoading, onDoneLoading]); + return onCopyFinish(); + }, [isLoading, onCopyStart, onCopyFinish]); const { error, dismissError } = useDismissableError(copyError); @@ -27,6 +34,7 @@ function CopyButton({ i18n, copyItem, onLoading, onDoneLoading, helperText }) { <>