|
| 1 | +import {AutomationBuilderSelect} from 'sentry/components/workflowEngine/form/automationBuilderSelect'; |
| 2 | +import {tct} from 'sentry/locale'; |
| 3 | +import type {SelectValue} from 'sentry/types/core'; |
| 4 | +import type {DataCondition} from 'sentry/types/workflowEngine/dataConditions'; |
| 5 | +import {useDataConditionNodeContext} from 'sentry/views/automations/components/dataConditionNodes'; |
| 6 | + |
| 7 | +enum GroupCategory { |
| 8 | + ERROR = 1, |
| 9 | + FEEDBACK = 6, |
| 10 | + OUTAGE = 10, |
| 11 | + METRIC = 11, |
| 12 | + DB_QUERY = 12, |
| 13 | + HTTP_CLIENT = 13, |
| 14 | + FRONTEND = 14, |
| 15 | + MOBILE = 15, |
| 16 | +} |
| 17 | + |
| 18 | +const GROUP_CATEGORY_CHOICES = [ |
| 19 | + {value: GroupCategory.ERROR, label: 'error'}, |
| 20 | + {value: GroupCategory.FEEDBACK, label: 'feedback'}, |
| 21 | + {value: GroupCategory.OUTAGE, label: 'outage'}, |
| 22 | + {value: GroupCategory.METRIC, label: 'metric'}, |
| 23 | + {value: GroupCategory.DB_QUERY, label: 'db_query'}, |
| 24 | + {value: GroupCategory.HTTP_CLIENT, label: 'http_client'}, |
| 25 | + {value: GroupCategory.FRONTEND, label: 'frontend'}, |
| 26 | + {value: GroupCategory.MOBILE, label: 'mobile'}, |
| 27 | +]; |
| 28 | + |
| 29 | +export function IssueCategoryDetails({condition}: {condition: DataCondition}) { |
| 30 | + return tct('Issue category is equal to [category]', { |
| 31 | + category: |
| 32 | + GROUP_CATEGORY_CHOICES.find(choice => choice.value === condition.comparison.value) |
| 33 | + ?.label || condition.comparison.value, |
| 34 | + }); |
| 35 | +} |
| 36 | + |
| 37 | +export function IssueCategoryNode() { |
| 38 | + const {condition, condition_id, onUpdate} = useDataConditionNodeContext(); |
| 39 | + return tct('Issue category is equal to [category]', { |
| 40 | + category: ( |
| 41 | + <AutomationBuilderSelect |
| 42 | + name={`${condition_id}.comparison.value`} |
| 43 | + value={condition.comparison.value} |
| 44 | + options={GROUP_CATEGORY_CHOICES} |
| 45 | + onChange={(option: SelectValue<GroupCategory>) => { |
| 46 | + onUpdate({comparison: {value: option.value}}); |
| 47 | + }} |
| 48 | + /> |
| 49 | + ), |
| 50 | + }); |
| 51 | +} |
0 commit comments