|
1 | 1 | import styled from '@emotion/styled';
|
2 | 2 |
|
| 3 | +import {Button} from 'sentry/components/core/button'; |
| 4 | +import {Flex} from 'sentry/components/core/layout'; |
3 | 5 | import useFeedbackSummary from 'sentry/components/feedback/list/useFeedbackSummary';
|
4 | 6 | import LoadingIndicator from 'sentry/components/loadingIndicator';
|
| 7 | +import {IconThumb} from 'sentry/icons'; |
5 | 8 | import {IconSeer} from 'sentry/icons/iconSeer';
|
6 | 9 | import {t} from 'sentry/locale';
|
7 | 10 | import {space} from 'sentry/styles/space';
|
| 11 | +import {useFeedbackForm} from 'sentry/utils/useFeedbackForm'; |
8 | 12 | import useOrganization from 'sentry/utils/useOrganization';
|
9 | 13 |
|
10 | 14 | export default function FeedbackSummary() {
|
11 | 15 | const {isError, isPending, summary, tooFewFeedbacks} = useFeedbackSummary();
|
12 | 16 |
|
13 | 17 | const organization = useOrganization();
|
14 | 18 |
|
| 19 | + const openForm = useFeedbackForm(); |
| 20 | + |
15 | 21 | if (!organization.features.includes('user-feedback-ai-summaries')) {
|
16 | 22 | return null;
|
17 | 23 | }
|
18 | 24 |
|
| 25 | + const feedbackButton = ({type}: {type: 'positive' | 'negative'}) => { |
| 26 | + return openForm ? ( |
| 27 | + <Button |
| 28 | + aria-label={t('Give feedback on the AI-powered summary')} |
| 29 | + icon={<IconThumb direction={type === 'positive' ? 'up' : 'down'} />} |
| 30 | + title={type === 'positive' ? t('I like this') : t(`I don't like this`)} |
| 31 | + size={'xs'} |
| 32 | + onClick={() => |
| 33 | + openForm({ |
| 34 | + messagePlaceholder: |
| 35 | + type === 'positive' |
| 36 | + ? t('What did you like about the AI-powered summary?') |
| 37 | + : t('How can we make the summary work better for you?'), |
| 38 | + tags: { |
| 39 | + ['feedback.source']: 'feedback_ai_summary', |
| 40 | + ['feedback.owner']: 'replay', |
| 41 | + ['feedback.type']: type, |
| 42 | + }, |
| 43 | + }) |
| 44 | + } |
| 45 | + /> |
| 46 | + ) : null; |
| 47 | + }; |
| 48 | + |
19 | 49 | return (
|
20 | 50 | <SummaryIconContainer>
|
21 | 51 | <IconSeer size="xs" />
|
22 | 52 | <SummaryContainer>
|
23 |
| - <SummaryHeader>{t('Feedback Summary')}</SummaryHeader> |
| 53 | + <Flex justify="space-between" align="center"> |
| 54 | + <SummaryHeader>{t('Summary')}</SummaryHeader> |
| 55 | + <Flex gap={space(0.5)}> |
| 56 | + {feedbackButton({type: 'positive'})} |
| 57 | + {feedbackButton({type: 'negative'})} |
| 58 | + </Flex> |
| 59 | + </Flex> |
| 60 | + |
24 | 61 | {isPending ? (
|
25 | 62 | <LoadingContainer>
|
26 | 63 | <StyledLoadingIndicator size={24} />
|
|
0 commit comments