Browse Source

fix(discord): Clean up frontend of rule form (#57395)

Closes https://github.com/getsentry/sentry/issues/57406

![Screenshot 2023-10-03 at 1 02 22
PM](https://github.com/getsentry/sentry/assets/22582037/c968fc22-6baf-469e-9b2c-f23bcd797c68)
Julia Hoge 1 year ago
parent
commit
0ca790dcb5

+ 1 - 1
static/app/views/alerts/rules/metric/ruleForm.tsx

@@ -607,7 +607,7 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
       transaction.setTag('operation', !rule.id ? 'create' : 'edit');
       for (const trigger of sanitizedTriggers) {
         for (const action of trigger.actions) {
-          if (action.type === 'slack') {
+          if (action.type === 'slack' || action.type === 'discord') {
             transaction.setTag(action.type, true);
           }
         }

+ 1 - 0
static/app/views/alerts/rules/metric/triggers/actionsPanel/actionTargetSelector.tsx

@@ -90,6 +90,7 @@ export default function ActionTargetSelector(props: Props) {
           type="text"
           autoComplete="off"
           disabled={disabled}
+          required={action.type === 'discord'} // Only required for discord channel ID
           key={action.type}
           value={action.targetIdentifier || ''}
           onChange={handleChangeSpecificTargetIdentifier}

+ 38 - 19
static/app/views/alerts/rules/metric/triggers/actionsPanel/index.tsx

@@ -142,26 +142,45 @@ class ActionsPanel extends PureComponent<Props> {
     const {triggers} = this.props;
     const {actions} = triggers[triggerIndex];
     const newAction = {...actions[index]};
-    if (newAction.type !== 'slack') {
-      return null;
+    if (newAction.type === 'slack') {
+      return (
+        <MarginlessAlert
+          type="info"
+          showIcon
+          trailingItems={
+            <Button
+              href="https://docs.sentry.io/product/integrations/notification-incidents/slack/#rate-limiting-error"
+              external
+              size="xs"
+            >
+              {t('Learn More')}
+            </Button>
+          }
+        >
+          {t('Having rate limiting problems? Enter a channel or user ID.')}
+        </MarginlessAlert>
+      );
     }
-    return (
-      <MarginlessAlert
-        type="info"
-        showIcon
-        trailingItems={
-          <Button
-            href="https://docs.sentry.io/product/integrations/notification-incidents/slack/#rate-limiting-error"
-            external
-            size="xs"
-          >
-            {t('Learn More')}
-          </Button>
-        }
-      >
-        {t('Having rate limiting problems? Enter a channel or user ID.')}
-      </MarginlessAlert>
-    );
+    if (newAction.type === 'discord') {
+      return (
+        <MarginlessAlert
+          type="info"
+          showIcon
+          trailingItems={
+            <Button
+              href="https://docs.sentry.io/product/accounts/early-adopter-features/discord/#issue-alerts"
+              external
+              size="xs"
+            >
+              {t('Learn More')}
+            </Button>
+          }
+        >
+          {t('Note that you must enter a Discord channel ID, not a channel name.')}
+        </MarginlessAlert>
+      );
+    }
+    return null;
   }
 
   handleAddAction = () => {