-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
chore(github): Add business+ plan check for multi org #91905
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
Changes from 14 commits
e043866
7bd57c5
2ba5d3e
4e2d4cf
604bcab
5acabb2
bee5115
db11b20
e1a57cc
49e22aa
48b29d1
510aa8a
5ed8d97
156fb07
84a0414
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -755,7 +755,8 @@ class GitHubInstallationError(StrEnum): | |
INSTALLATION_EXISTS = "Github installed on another Sentry organization." | ||
USER_MISMATCH = "Authenticated user is not the same as who installed the app." | ||
MISSING_INTEGRATION = "Integration does not exist." | ||
INVALID_INSTALLATION = "User does not have access to given installation" | ||
INVALID_INSTALLATION = "User does not have access to given installation." | ||
FEATURE_NOT_AVAILABLE = "Your organization does not have access to this feature." | ||
|
||
|
||
def record_event(event: IntegrationPipelineViewType): | ||
|
@@ -887,6 +888,15 @@ def _get_eligible_multi_org_installations( | |
class GithubOrganizationSelection(PipelineView): | ||
def dispatch(self, request: HttpRequest, pipeline: Pipeline) -> HttpResponseBase: | ||
self.active_user_organization = determine_active_organization(request) | ||
has_scm_multi_org = ( | ||
features.has( | ||
"organizations:integrations-scm-multi-org", | ||
organization=self.active_user_organization.organization, | ||
actor=request.user, | ||
) | ||
if self.active_user_organization is not None | ||
else False | ||
) | ||
|
||
if self.active_user_organization is None or not features.has( | ||
"organizations:github-multi-org", | ||
|
@@ -915,6 +925,14 @@ def dispatch(self, request: HttpRequest, pipeline: Pipeline) -> HttpResponseBase | |
if chosen_installation_id == "-1": | ||
return pipeline.next_step() | ||
|
||
if not has_scm_multi_org: | ||
lifecycle.record_failure(GitHubInstallationError.FEATURE_NOT_AVAILABLE) | ||
return error( | ||
request, | ||
self.active_user_organization, | ||
error_short=GitHubInstallationError.FEATURE_NOT_AVAILABLE, | ||
) | ||
|
||
# Verify that the given GH installation belongs to the person installing the pipeline | ||
installation_ids = [ | ||
installation["installation_id"] for installation in installation_info | ||
|
@@ -936,7 +954,10 @@ def dispatch(self, request: HttpRequest, pipeline: Pipeline) -> HttpResponseBase | |
return self.render_react_view( | ||
request=request, | ||
pipeline_name="githubInstallationSelect", | ||
props={"installation_info": installation_info}, | ||
props={ | ||
"installation_info": installation_info, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if they don't have multi org, should we still be passing the full list of installations to the FE? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think we should also error if somebody tries to pass a chosen installation id that's not -1 and they don't have multi org There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the passing the full list comment, I think it's useful to keep in case we want to do the per gh org upsell in the dropdown in the UI. |
||
"has_scm_multi_org": has_scm_multi_org, | ||
}, | ||
) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq: whats the purpose of passing user here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I probably yoinked this from a previous feature flag checker, but looking further yeah we dont need to be passing the user/it wont be used.