import {Fragment} from 'react'; import styled from '@emotion/styled'; import ActorAvatar from 'sentry/components/avatar/actorAvatar'; import {SectionHeading} from 'sentry/components/charts/styles'; import {KeyValueTable, KeyValueTableRow} from 'sentry/components/keyValueTable'; import PanelBody from 'sentry/components/panels/panelBody'; import TimeSince from 'sentry/components/timeSince'; import {IconChevron} from 'sentry/icons'; import {t, tct} from 'sentry/locale'; import {space} from 'sentry/styles/space'; import type {Actor, Member, Team} from 'sentry/types'; import {IssueAlertRule} from 'sentry/types/alerts'; import {useApiQuery} from 'sentry/utils/queryClient'; import useOrganization from 'sentry/utils/useOrganization'; import {TextAction, TextCondition} from './textRule'; type Props = { projectSlug: string; rule: IssueAlertRule; teams: Team[]; }; function Conditions({rule, teams, projectSlug}: Props) { const organization = useOrganization(); const {data: memberList} = useApiQuery( [`/organizations/${organization.slug}/users/`, {query: {projectSlug}}], {staleTime: 60000} ); return ( {tct('[when:When] an event is captured [selector]', { when: , selector: rule.conditions.length ? t('and %s...', rule.actionMatch) : '', })} {rule.conditions.map((condition, idx) => ( ))} {rule.filters.length ? ( {tct('[if:If] [selector] of these filters match', { if: , selector: rule.filterMatch, })} {rule.filters.map((filter, idx) => ( {filter.time ? filter.name + '(s)' : filter.name} ))} ) : null}
{tct('[then:Then] perform these actions', { then: , })} {rule.actions.length ? ( rule.actions.map((action, idx) => { return ( ); }) ) : ( {t('Do nothing')} )}
); } function Sidebar({rule, teams, projectSlug}: Props) { const ownerId = rule.owner?.split(':')[1]; const teamActor = ownerId && {type: 'team' as Actor['type'], id: ownerId, name: ''}; return ( {t('Last Triggered')} {rule.lastTriggered ? ( ) : ( t('No alerts triggered') )} {t('Alert Conditions')} {t('Alert Rule Details')} {rule.environment ?? '-'}} /> {rule.dateCreated && ( } /> )} {rule.createdBy && ( {rule.createdBy.name ?? '-'} } /> )} : t('Unassigned') } /> ); } export default Sidebar; const SidebarGroup = styled('div')` margin-bottom: ${space(3)}; `; const HeaderItem = styled('div')` flex: 1; display: flex; flex-direction: column; > *:nth-child(2) { flex: 1; display: flex; align-items: center; } `; const Status = styled('div')` position: relative; display: grid; grid-template-columns: auto auto auto; gap: ${space(0.5)}; font-size: ${p => p.theme.fontSizeLarge}; `; const StatusContainer = styled('div')` height: 60px; display: flex; margin-bottom: ${space(1.5)}; `; const Step = styled('div')` position: relative; margin-top: ${space(4)}; :first-child { margin-top: ${space(1)}; } `; const StepContainer = styled('div')` display: flex; align-items: flex-start; flex-grow: 1; `; const StepContent = styled('div')` &::before { content: ''; position: absolute; height: 100%; top: 28px; left: ${space(1)}; border-right: 1px ${p => p.theme.gray200} dashed; } `; const StepLead = styled('div')` margin-bottom: ${space(0.5)}; font-size: ${p => p.theme.fontSizeMedium}; font-weight: 400; `; const ChevronContainer = styled('div')` display: flex; align-items: center; padding: ${space(0.5)} ${space(1)} ${space(0.5)} 0; `; const Badge = styled('span')` display: inline-block; background-color: ${p => p.theme.purple300}; padding: 0 ${space(0.75)}; border-radius: ${p => p.theme.borderRadius}; color: ${p => p.theme.white}; text-transform: uppercase; text-align: center; font-size: ${p => p.theme.fontSizeSmall}; font-weight: 400; line-height: 1.5; `; const ConditionsBadge = styled('span')` display: block; background-color: ${p => p.theme.surface200}; padding: 0 ${space(0.75)}; border-radius: ${p => p.theme.borderRadius}; color: ${p => p.theme.textColor}; font-size: ${p => p.theme.fontSizeSmall}; margin-bottom: ${space(1)}; width: fit-content; font-weight: 400; `; const Heading = styled(SectionHeading)<{noMargin?: boolean}>` margin-top: ${p => (p.noMargin ? 0 : space(2))}; margin-bottom: ${p => (p.noMargin ? 0 : space(1))}; `; const OverflowTableValue = styled('div')` ${p => p.theme.overflowEllipsis} `;