Skip to content

feat(slack): Add flags for Slack Thread options #71186

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

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions fixtures/js-stubs/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export function OrganizationFixture(
githubOpenPRBot: false,
githubPRBot: false,
githubNudgeInvite: false,
issueAlertsThreadFlag: false,
metricAlertsThreadFlag: false,
isDefault: false,
isDynamicallySampled: true,
isEarlyAdopter: false,
Expand Down
2 changes: 2 additions & 0 deletions static/app/types/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ export interface OrganizationSummary {
githubPRBot: boolean;
id: string;
isEarlyAdopter: boolean;
issueAlertsThreadFlag: boolean;
links: {
organizationUrl: string;
regionUrl: string;
};
metricAlertsThreadFlag: boolean;
name: string;
require2FA: boolean;
slug: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Button} from 'sentry/components/button';
import type DeprecatedAsyncComponent from 'sentry/components/deprecatedAsyncComponent';
import Form from 'sentry/components/forms/form';
import JsonForm from 'sentry/components/forms/jsonForm';
import type {JsonFormObject} from 'sentry/components/forms/types';
import type {Data, JsonFormObject} from 'sentry/components/forms/types';
import HookOrDefault from 'sentry/components/hookOrDefault';
import Panel from 'sentry/components/panels/panel';
import PanelItem from 'sentry/components/panels/panelItem';
Expand All @@ -27,7 +27,7 @@ import {AddIntegrationButton} from './addIntegrationButton';
import InstalledIntegration from './installedIntegration';

// Show the features tab if the org has features for the integration
const integrationFeatures = ['github'];
const integrationFeatures = ['github', 'slack'];

const FirstPartyIntegrationAlert = HookOrDefault({
hookName: 'component:first-party-integration-alert',
Expand Down Expand Up @@ -330,12 +330,54 @@ class IntegrationDetailedView extends AbstractIntegrationDetailedView<
);
}

renderFeatures() {
getSlackFeatures(): [JsonFormObject[], Data] {
const {configurations} = this.state;
const {organization} = this.props;
const hasIntegration = configurations ? configurations.length > 0 : false;

const forms: JsonFormObject[] = [
{
fields: [
{
name: 'issueAlertsThreadFlag',
type: 'boolean',
label: t('Enable Slack threads on Issue Alerts'),
help: t(
'Allow Slack integration to post replies in threads for an Issue Alert notification.'
),
disabled: !hasIntegration,
disabledReason: t(
'You must have a Slack integration to enable this feature.'
),
},
{
name: 'metricAlertsThreadFlag',
type: 'boolean',
label: t('Enable Slack threads on Metric Alerts'),
help: t(
'Allow Slack integration to post replies in threads for an Metric Alert notification.'
),
disabled: !hasIntegration,
disabledReason: t(
'You must have a Slack integration to enable this feature.'
),
},
],
},
];

const initialData = {
issueAlertsThreadFlag: organization.issueAlertsThreadFlag,
metricAlertsThreadFlag: organization.metricAlertsThreadFlag,
};

return [forms, initialData];
}

getGithubFeatures(): [JsonFormObject[], Data] {
const {configurations} = this.state;
const {organization} = this.props;
const hasIntegration = configurations ? configurations.length > 0 : false;
const endpoint = `/organizations/${organization.slug}/`;
const hasOrgWrite = organization.access.includes('org:write');

const forms: JsonFormObject[] = [
{
Expand Down Expand Up @@ -386,6 +428,28 @@ class IntegrationDetailedView extends AbstractIntegrationDetailedView<
githubNudgeInvite: organization.githubNudgeInvite,
};

return [forms, initialData];
}

renderFeatures() {
const {organization} = this.props;
const endpoint = `/organizations/${organization.slug}/`;
const hasOrgWrite = organization.access.includes('org:write');

let forms: JsonFormObject[], initialData: Data;
switch (this.provider.key) {
case 'github': {
[forms, initialData] = this.getGithubFeatures();
break;
}
case 'slack': {
[forms, initialData] = this.getSlackFeatures();
break;
}
default:
return null;
}

return (
<Form
apiMethod="PUT"
Expand Down
Loading