From 6ffc4ccb666afbb58aa50a78e19dd4693989155c Mon Sep 17 00:00:00 2001 From: Michelle Fu Date: Mon, 14 Aug 2023 10:40:55 -0700 Subject: [PATCH 1/2] add open PR comments toggle and org option --- .../api/endpoints/organization_details.py | 7 +++++++ .../api/serializers/models/organization.py | 7 +++++++ src/sentry/constants.py | 1 + static/app/types/organization.tsx | 1 + .../integrationDetailedView.tsx | 21 ++++++++++++++++++- 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/sentry/api/endpoints/organization_details.py b/src/sentry/api/endpoints/organization_details.py index 98e3de6584494..486a15ce378a3 100644 --- a/src/sentry/api/endpoints/organization_details.py +++ b/src/sentry/api/endpoints/organization_details.py @@ -137,6 +137,12 @@ bool, org_serializers.GITHUB_PR_BOT_DEFAULT, ), + ( + "githubOpenPRComments", + "sentry:github_open_pr_comments", + bool, + org_serializers.GITHUB_OPEN_PR_COMMENTS_DEFAULT, + ), ) DELETION_STATUSES = frozenset( @@ -180,6 +186,7 @@ class OrganizationSerializer(BaseOrganizationSerializer): isEarlyAdopter = serializers.BooleanField(required=False) aiSuggestedSolution = serializers.BooleanField(required=False) codecovAccess = serializers.BooleanField(required=False) + githubOpenPRComments = serializers.BooleanField(required=False) githubPRBot = serializers.BooleanField(required=False) require2FA = serializers.BooleanField(required=False) requireEmailVerification = serializers.BooleanField(required=False) diff --git a/src/sentry/api/serializers/models/organization.py b/src/sentry/api/serializers/models/organization.py index 2f97e5f77bda0..764d1fc5a9f11 100644 --- a/src/sentry/api/serializers/models/organization.py +++ b/src/sentry/api/serializers/models/organization.py @@ -42,6 +42,7 @@ ATTACHMENTS_ROLE_DEFAULT, DEBUG_FILES_ROLE_DEFAULT, EVENTS_MEMBER_ADMIN_DEFAULT, + GITHUB_OPEN_PR_COMMENTS_DEFAULT, GITHUB_PR_BOT_DEFAULT, JOIN_REQUESTS_DEFAULT, PROJECT_RATE_LIMIT_DEFAULT, @@ -417,6 +418,7 @@ class DetailedOrganizationSerializerResponse(_DetailedOrganizationSerializerResp codecovAccess: bool aiSuggestedSolution: bool githubPRBot: bool + githubOpenPRComments: bool isDynamicallySampled: bool @@ -523,6 +525,11 @@ def serialize( # type: ignore obj.get_option("sentry:ai_suggested_solution", AI_SUGGESTED_SOLUTION) ), "githubPRBot": bool(obj.get_option("sentry:github_pr_bot", GITHUB_PR_BOT_DEFAULT)), + "githubOpenPRComments": bool( + obj.get_option( + "sentry:github_open_pr_comments", GITHUB_OPEN_PR_COMMENTS_DEFAULT + ) + ), } ) diff --git a/src/sentry/constants.py b/src/sentry/constants.py index f6ab31b01c8da..54d31ebd9f747 100644 --- a/src/sentry/constants.py +++ b/src/sentry/constants.py @@ -633,6 +633,7 @@ def from_str(cls, string: str) -> Optional[int]: APDEX_THRESHOLD_DEFAULT = 300 AI_SUGGESTED_SOLUTION = True GITHUB_PR_BOT_DEFAULT = True +GITHUB_OPEN_PR_COMMENTS_DEFAULT = True # `sentry:events_member_admin` - controls whether the 'member' role gets the event:admin scope EVENTS_MEMBER_ADMIN_DEFAULT = True diff --git a/static/app/types/organization.tsx b/static/app/types/organization.tsx index 51eccd14a0976..163a29ef921b6 100644 --- a/static/app/types/organization.tsx +++ b/static/app/types/organization.tsx @@ -17,6 +17,7 @@ export interface OrganizationSummary { codecovAccess: boolean; dateCreated: string; features: string[]; + githubOpenPRComments: boolean; githubPRBot: boolean; id: string; isEarlyAdopter: boolean; diff --git a/static/app/views/settings/organizationIntegrations/integrationDetailedView.tsx b/static/app/views/settings/organizationIntegrations/integrationDetailedView.tsx index 2a62ed6dc2a1b..fe9e29bc5f451 100644 --- a/static/app/views/settings/organizationIntegrations/integrationDetailedView.tsx +++ b/static/app/views/settings/organizationIntegrations/integrationDetailedView.tsx @@ -331,7 +331,15 @@ class IntegrationDetailedView extends AbstractIntegrationDetailedView< const hasIntegration = configurations ? configurations.length > 0 : false; const endpoint = `/organizations/${organization.slug}/`; const hasOrgWrite = organization.access.includes('org:write'); - + let openPRDisabledReason = t( + 'You must have a GitHub integration to enable this feature.' + ); + if ( + hasIntegration && + !organization.features.includes('integrations-open-pr-comment') + ) { + openPRDisabledReason = t("This feature isn't available to you yet."); + } const forms: JsonFormObject[] = [ { fields: [ @@ -347,12 +355,23 @@ class IntegrationDetailedView extends AbstractIntegrationDetailedView< 'You must have a GitHub integration to enable this feature.' ), }, + { + name: 'githubOpenPRComments', + type: 'boolean', + label: t('Enable Open PR Comments'), + help: t('Allow Sentry to comment on open PRs.'), + disabled: + !hasIntegration || + !organization.features.includes('integrations-open-pr-comment'), + disabledReason: openPRDisabledReason, + }, ], }, ]; const initialData = { githubPRBot: organization.githubPRBot, + githubOpenPRComments: organization.githubOpenPRComments, }; return ( From 5a7aa98c2f77ce89d1d1ab5a48af9298ef8ce661 Mon Sep 17 00:00:00 2001 From: Michelle Fu Date: Mon, 14 Aug 2023 11:38:50 -0700 Subject: [PATCH 2/2] edit copy --- .../integrationDetailedView.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/static/app/views/settings/organizationIntegrations/integrationDetailedView.tsx b/static/app/views/settings/organizationIntegrations/integrationDetailedView.tsx index fe9e29bc5f451..2f6f96dfaabf9 100644 --- a/static/app/views/settings/organizationIntegrations/integrationDetailedView.tsx +++ b/static/app/views/settings/organizationIntegrations/integrationDetailedView.tsx @@ -334,10 +334,7 @@ class IntegrationDetailedView extends AbstractIntegrationDetailedView< let openPRDisabledReason = t( 'You must have a GitHub integration to enable this feature.' ); - if ( - hasIntegration && - !organization.features.includes('integrations-open-pr-comment') - ) { + if (!organization.features.includes('integrations-open-pr-comment')) { openPRDisabledReason = t("This feature isn't available to you yet."); } const forms: JsonFormObject[] = [ @@ -346,9 +343,9 @@ class IntegrationDetailedView extends AbstractIntegrationDetailedView< { name: 'githubPRBot', type: 'boolean', - label: t('Enable Pull Request Bot'), + label: t('Enable Comments on Suspect Pull Requests'), help: t( - 'Allow Sentry to comment on pull requests about issues impacting your app.' + 'Allow Sentry to comment on recent pull requests suspected of causing issues.' ), disabled: !hasIntegration, disabledReason: t( @@ -358,8 +355,10 @@ class IntegrationDetailedView extends AbstractIntegrationDetailedView< { name: 'githubOpenPRComments', type: 'boolean', - label: t('Enable Open PR Comments'), - help: t('Allow Sentry to comment on open PRs.'), + label: t('Enable Comments on Open Pull Requests'), + help: t( + 'Allow Sentry to comment on open pull requests to show recent error and performance issues for the code being changed.' + ), disabled: !hasIntegration || !organization.features.includes('integrations-open-pr-comment'),