Skip to content

OAuth: connect Project to RemoteRepository #9381

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

Closed
wants to merge 1 commit into from

Conversation

humitos
Copy link
Member

@humitos humitos commented Jun 28, 2022

There are multiple reasons why a Project could be disconnected from a
RemoteRepository:

  1. it was imported manually
  2. the user deleted their account, which also deleted the
    RemoteRepository (old behaviour)
  3. got disconnected when doing the data migration
  4. others?

If any of the previous scenarios happened, the user was not able to (re)connect
their project anymore. The only way was to delete the project and re-import it
using the wizard with a VCS account connected.

This commit adds a button under "Admin" -> "Integrations" page to "Connect VCS
repository" allowing users to perform this action by themselves.

When a Project is connected to a RemoteRepository permissions can be managed
at VCS level, allowing the organization to be able to use VCS SSO. Besides, this
connection will be used when sending status notifications to the VCS.

Closes #8229

There are multiple reasons why a `Project` could be disconnected from a
`RemoteRepository`:

1. it was imported manually
2. the user deleted their account, which also deleted the
   `RemoteRepository` (old behaviour)
3. got disconnected when doing the data migration
4. others?

If any of the previous scenarios happened, the user was not able to (re)connect
their project anymore. The only way was to delete the project and re-import it
using the wizard with a VCS account connected.

This commit adds a button under "Admin" -> "Integrations" page to "Connect VCS
repository" allowing users to perform this action by themselves.

When a `Project` is connected to a `RemoteRepository` permissions can be managed
at VCS level, allowing the organization to be able to use VCS SSO. Besides, this
connection will be used when sending status notifications to the VCS.
@humitos humitos requested a review from a team as a code owner June 28, 2022 13:09
@humitos humitos requested a review from stsewd June 28, 2022 13:09
Copy link
Member

@stsewd stsewd left a comment

Choose a reason for hiding this comment

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

We should have tests for this new feature

messages.add_message(
request,
messages.ERROR,
_(f"There was a problem connect your project."),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_(f"There was a problem connect your project."),
_(f"There was a problem connecting your project."),

Maybe we could add more information about the reason? Looks like if there isn't a remote_repository, it means the user isn't an admin or the project hasn't been synced yet.

@@ -14,6 +14,14 @@
{% block project_edit_content %}
<div class="button-bar">
<ul>
{% if connect_vcs_repository %}
<li>
<form style="float: left" method="post" action="{% url 'projects_integrations_connect_project' project_slug=project.slug %}">
Copy link
Member

Choose a reason for hiding this comment

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

I think we didn't wan to add inline styles on new code, @agjohnson may have more info about this.

"""

@staticmethod
def get_final_url(project):
Copy link
Member

Choose a reason for hiding this comment

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

we should put a docstring about this. The head request looks like it's to get normalize http and .git urls?

Comment on lines +874 to +879
context["connect_vcs_repository"] = all(
[
url,
remote_repository,
]
)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
context["connect_vcs_repository"] = all(
[
url,
remote_repository,
]
)
context["connect_vcs_repository"] = url and remote_repository

@humitos
Copy link
Member Author

humitos commented Jul 4, 2022

Thanks @stsewd for the review here. However, it seems that we won't expose this to users. We will try to do this automatically first without user intervention. We can come back to this PR if we consider it needed, tho.

@humitos humitos closed this Jul 4, 2022
@stsewd stsewd deleted the humitos/connect-project-remoterepository branch July 5, 2022 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Re-connect a Project to a RemoteRepository
2 participants