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

kie-issues#129: chrome-extension: Open in KIE Sandbox button doesn't work in a private repository #1665

Merged
merged 13 commits into from
Jun 9, 2023

Conversation

kbowers-ibm
Copy link
Contributor

Closes apache/incubator-kie-issues#129
When clicking the Chrome Extensions's "Open in KIE Sandbox" button on a private repo, with no connected account, on KIE Sandbox, a user will now be directed to an error page that has a link to authenticate and reimport.
When clicking the Chrome Extensions's "Open in KIE Sandbox" button on a private repo, with a relevant connected account, it will now be imported in the same way as public repos currently are.

Video demonstrating changes:
https://github.com/kiegroup/kie-tools/assets/92726146/bc52cb97-3cca-4b63-9094-364e1d2982b2

@kbowers-ibm kbowers-ibm temporarily deployed to ci May 24, 2023 15:09 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci May 24, 2023 15:09 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci May 24, 2023 19:08 — with GitHub Actions Inactive
@tiagobento
Copy link
Contributor

@kbowers-ibm The video looks great, I think it's very nice the way it is!

Regarding the code, I think there's a better way to do that, instead of letting an exception occur and have the option to fix the error be shown in EditorPageErrorPage..

From what I understood, if there are no compatible authSessions with the URL being imported, a "cannot read 'id' from undefined" will happen, which will result in an Error being thrown, showing the Error page.

I think we could do better, and instead of relying on the EditorPageErrorPage, we could create an internal state directly on NewWorkspaceFromUrlPage that controls whether or not the user needs to authenticate to proceed. WDYT?

@kbowers-ibm
Copy link
Contributor Author

Yeah that sounds cleaner, good idea!

@kbowers-ibm kbowers-ibm temporarily deployed to ci May 30, 2023 07:10 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci May 30, 2023 07:10 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci May 30, 2023 07:10 — with GitHub Actions Inactive
@kbowers-ibm
Copy link
Contributor Author

kbowers-ibm commented May 30, 2023

Updated functionality from an error message with a clickable button to instead automatically open the import modal if it can't find a branch name - which should never happen with public repos and will always happen with a private repo (if no valid auth token available). If a valid auth token exists it will find the branch and therefore import automatically without opening the modal.

NewPrivateFunctionality.mp4

@tiagobento
Copy link
Contributor

@kbowers-ibm Aren't we still erroring out when there's no compatible authSession? I mean, I think the rule should be a combination of things, not only based of the branch name not being present.. I'm not saying it doesn't work like it is, just saying that the code can be written in a way that expressed the intended behavior better.

@kbowers-ibm kbowers-ibm temporarily deployed to ci June 1, 2023 12:49 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci June 1, 2023 12:49 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci June 1, 2023 18:36 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci June 1, 2023 18:36 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci June 6, 2023 15:47 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci June 6, 2023 15:47 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci June 6, 2023 15:48 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci June 7, 2023 07:27 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci June 7, 2023 07:28 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci June 7, 2023 07:28 — with GitHub Actions Inactive
Copy link
Contributor

@tiagobento tiagobento left a comment

Choose a reason for hiding this comment

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

Thanks @kbowers-ibm! We're almost there.

Comment on lines +256 to +258
if (!queryParamBranch && isCertainlyGit(importableUrl.type) && queryParamAuthSessionId !== AUTH_SESSION_NONE.id) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please explain this change? I struggle to understand it.

Copy link
Contributor Author

@kbowers-ibm kbowers-ibm Jun 7, 2023

Choose a reason for hiding this comment

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

So previously I had the state being set to false here. However when I removed it, I noticed that in the case of no auth token and repo is private we get the import modal as expected. However once the github token is added it briefly shows the error screen before carrying on through to import it properly. So this line stops that from happening.
https://github.com/kiegroup/kie-tools/assets/92726146/037a62d2-f0e9-4a9b-9393-548ede2b15d3

@@ -42,7 +42,7 @@ import { fetchSingleFileContent } from "./fetchSingleFileContent";
import { useGitHubClient } from "../github/Hooks";
import { AccountsDispatchActionKind, useAccountsDispatch } from "../accounts/AccountsContext";
import { useAuthSession, useAuthSessions } from "../authSessions/AuthSessionsContext";
import { useAuthProvider, useAuthProviders } from "../authProviders/AuthProvidersContext";
import { useAuthProviders } from "../authProviders/AuthProvidersContext";
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused?

Copy link
Contributor Author

@kbowers-ibm kbowers-ibm Jun 7, 2023

Choose a reason for hiding this comment

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

Yep, couldn't see any use of it anywhere, so got rid of that and a few others

@kbowers-ibm kbowers-ibm temporarily deployed to ci June 7, 2023 18:10 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci June 7, 2023 18:10 — with GitHub Actions Inactive
@kbowers-ibm kbowers-ibm temporarily deployed to ci June 7, 2023 18:10 — with GitHub Actions Inactive
@tiagobento tiagobento requested a review from ljmotta June 7, 2023 22:28
Copy link
Contributor

@yesamer yesamer left a comment

Choose a reason for hiding this comment

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

Hi @kbowers-ibm, I manually tested your PR, please take a look at the below video

Screen.Recording.2023-06-08.at.11.56.08.mov

Consider that I locally rebased your branch with main, so can you please rebase this PR and double-check this behavior?

@yesamer
Copy link
Contributor

yesamer commented Jun 8, 2023

@kbowers-ibm Not sure this behavior is related to your change, it seems it occurs with public repos too.

@kbowers-ibm
Copy link
Contributor Author

kbowers-ibm commented Jun 8, 2023

Hi Yeser,
Very confused how that's happening as I added that error message in my first commit, but removed it the second kiegroup@41fc420. Are you definitely testing the latest commit?

@kbowers-ibm
Copy link
Contributor Author

kbowers-ibm commented Jun 8, 2023

@yesamer Also judging by the error and that it's not working on public repos, can I confirm that you have git-cors-proxy-image package running?

@yesamer
Copy link
Contributor

yesamer commented Jun 8, 2023

@kbowers-ibm Good point, I forgot to launch it. Thank you.

@yesamer
Copy link
Contributor

yesamer commented Jun 8, 2023

@kbowers-ibm Sorry, my bad. I had in my local an old version of your PR.

Copy link
Contributor

@yesamer yesamer left a comment

Choose a reason for hiding this comment

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

Thank you @kbowers-ibm, it works well. Apologies for the confusion, my bad :/

@kbowers-ibm
Copy link
Contributor Author

Perfect! Thank you very much @yesamer, appreciate you taking the time :)

@kbowers-ibm
Copy link
Contributor Author

And no worries about the confusion! I forgot to launch git-cors-proxy myself a couple of times during this ticket as well and had a few moments where I thought I'd messed everything up!

@tiagobento tiagobento merged commit febba36 into apache:main Jun 9, 2023
ljmotta added a commit to ljmotta/kie-tools that referenced this pull request Jun 21, 2023
…doesn't work in a private repository (apache#1665)"

This reverts commit febba36.
ljmotta added a commit to ljmotta/kie-tools that referenced this pull request Jun 21, 2023
…doesn't work in a private repository (apache#1665)"

This reverts commit febba36.
ricardozanini pushed a commit to ricardozanini/kogito-tooling that referenced this pull request Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chrome-extension: "Open in KIE Sandbox" button doesn't work in a private repository
3 participants