Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix install repo firing twice (#3678) #3891

Merged
merged 4 commits into from
Dec 7, 2021

Conversation

castelblanque
Copy link
Collaborator

@castelblanque castelblanque commented Dec 2, 2021

Signed-off-by: Rafa Castelblanque rcastelblanq@vmware.com

Description of the change

Fixes the problem of "Install Repo" button being fired multiple times.

Benefits

Repo installation process is not triggered more than once.

Possible drawbacks

N/A

Applicable issues

Additional information

Makes use of React's useRef

Rafa Castelblanque added 2 commits December 2, 2021 13:05
Signed-off-by: Rafa Castelblanque <rcastelblanq@vmware.com>
Signed-off-by: Rafa Castelblanque <rcastelblanq@vmware.com>
@castelblanque castelblanque marked this pull request as draft December 2, 2021 12:49
Signed-off-by: Rafa Castelblanque <rcastelblanq@vmware.com>
Copy link
Contributor

@antgamdia antgamdia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing that issue! Great work :)

@@ -620,7 +627,7 @@ export function AppRepoForm(props: IAppRepoFormProps) {
</Alert>
)}
<div className="margin-t-xl">
<CdsButton disabled={validating} onClick={install}>
<CdsButton type="submit" disabled={validating}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing the onClick event? Perhaps this same function is also being triggered in the onSubmit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

U nailed it! install function was being called twice: here and inside form's onSubmit logic.

@@ -49,6 +49,7 @@ const TYPE_OCI = "oci";

export function AppRepoForm(props: IAppRepoFormProps) {
const { onSubmit, onAfterInstall, namespace, kubeappsNamespace, repo, secret } = props;
const workingRef = useRef(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd maybe choose another name, a more self-explanatory one like isInstallingRef ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, will rename it. Initially I wanted to make the solution something general for all forms+buttons :)

Signed-off-by: Rafa Castelblanque <rcastelblanq@vmware.com>
@castelblanque castelblanque marked this pull request as ready for review December 7, 2021 15:50
@castelblanque castelblanque merged commit 911f945 into master Dec 7, 2021
@castelblanque castelblanque deleted the 3678-UI-button-fires-twice branch December 7, 2021 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI: app repository Install Repo button fires twice (sometimes)
2 participants