improvements: address feedback

This commit is contained in:
Scott Wilson
2025-09-15 14:45:21 -07:00
parent 1f4b50a6e0
commit 1e5244b2c3
4 changed files with 34 additions and 22 deletions
@@ -27,18 +27,20 @@ type ContentProps = {
selectedRotation: SecretRotation | null;
setSelectedRotation: (selectedRotation: SecretRotation | null) => void;
initialFormData?: Partial<TSecretRotationV2Form>;
onCancel: () => void;
} & SharedProps;
const Content = ({
setSelectedRotation,
selectedRotation,
initialFormData,
onCancel,
...props
}: ContentProps) => {
if (selectedRotation) {
return (
<SecretRotationV2Form
onCancel={() => setSelectedRotation(null)}
onCancel={onCancel}
type={selectedRotation}
initialFormData={initialFormData}
{...props}
@@ -93,13 +95,17 @@ export const CreateSecretRotationV2Modal = ({ onOpenChange, isOpen, ...props }:
}
}, [connectionId, connectionName]);
const handleReset = () => {
setSelectedRotation(null);
setInitialFormData(undefined);
};
return (
<Modal
isOpen={isOpen}
onOpenChange={(open) => {
if (!open) {
setSelectedRotation(null);
setInitialFormData(undefined);
handleReset();
}
onOpenChange(open);
}}
@@ -137,9 +143,10 @@ export const CreateSecretRotationV2Modal = ({ onOpenChange, isOpen, ...props }:
>
<Content
onComplete={() => {
setSelectedRotation(null);
handleReset();
onOpenChange(false);
}}
onCancel={handleReset}
initialFormData={initialFormData}
selectedRotation={selectedRotation}
setSelectedRotation={setSelectedRotation}
@@ -24,16 +24,18 @@ type ContentProps = {
selectedDataSource: SecretScanningDataSource | null;
setSelectedDataSource: (selectedDataSource: SecretScanningDataSource | null) => void;
initialFormData?: Partial<TSecretScanningDataSourceForm>;
onCancel: () => void;
};
const Content = ({ setSelectedDataSource, selectedDataSource, ...props }: ContentProps) => {
const Content = ({
setSelectedDataSource,
selectedDataSource,
onCancel,
...props
}: ContentProps) => {
if (selectedDataSource) {
return (
<SecretScanningDataSourceForm
onCancel={() => setSelectedDataSource(null)}
type={selectedDataSource}
{...props}
/>
<SecretScanningDataSourceForm onCancel={onCancel} type={selectedDataSource} {...props} />
);
}
@@ -86,11 +88,18 @@ export const CreateSecretScanningDataSourceModal = ({ onOpenChange, isOpen, ...p
}
}, [connectionId, connectionName]);
const resetModal = () => {
setSelectedDataSource(null);
setInitialFormData(undefined);
};
return (
<Modal
isOpen={isOpen}
onOpenChange={(open) => {
if (!open) setSelectedDataSource(null);
if (!open) {
resetModal();
}
onOpenChange(open);
}}
>
@@ -127,9 +136,10 @@ export const CreateSecretScanningDataSourceModal = ({ onOpenChange, isOpen, ...p
>
<Content
onComplete={() => {
setSelectedDataSource(null);
resetModal();
onOpenChange(false);
}}
onCancel={resetModal}
selectedDataSource={selectedDataSource}
setSelectedDataSource={setSelectedDataSource}
initialFormData={initialFormData}