123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- import * as React from 'react';
- import {withRouter, WithRouterProps} from 'react-router';
- import styled from '@emotion/styled';
- import omit from 'lodash/omit';
- import {fetchOrgMembers} from 'sentry/actionCreators/members';
- import {Client} from 'sentry/api';
- import AssigneeSelector from 'sentry/components/assigneeSelector';
- import GuideAnchor from 'sentry/components/assistant/guideAnchor';
- import Badge from 'sentry/components/badge';
- import Count from 'sentry/components/count';
- import EventOrGroupTitle from 'sentry/components/eventOrGroupTitle';
- import ErrorLevel from 'sentry/components/events/errorLevel';
- import EventAnnotation from 'sentry/components/events/eventAnnotation';
- import EventMessage from 'sentry/components/events/eventMessage';
- import InboxReason from 'sentry/components/group/inboxBadges/inboxReason';
- import UnhandledInboxTag from 'sentry/components/group/inboxBadges/unhandledTag';
- import ProjectBadge from 'sentry/components/idBadge/projectBadge';
- import ExternalLink from 'sentry/components/links/externalLink';
- import Link from 'sentry/components/links/link';
- import ListLink from 'sentry/components/links/listLink';
- import NavTabs from 'sentry/components/navTabs';
- import SeenByList from 'sentry/components/seenByList';
- import ShortId from 'sentry/components/shortId';
- import Tooltip from 'sentry/components/tooltip';
- import {IconChat} from 'sentry/icons';
- import {t} from 'sentry/locale';
- import space from 'sentry/styles/space';
- import {Group, Organization, Project} from 'sentry/types';
- import {Event} from 'sentry/types/event';
- import {getMessage} from 'sentry/utils/events';
- import withApi from 'sentry/utils/withApi';
- import withOrganization from 'sentry/utils/withOrganization';
- import GroupActions from './actions';
- import {Tab} from './types';
- import {TagAndMessageWrapper} from './unhandledTag';
- import {ReprocessingStatus} from './utils';
- type Props = WithRouterProps & {
- currentTab: string;
- baseUrl: string;
- group: Group;
- groupReprocessingStatus: ReprocessingStatus;
- project: Project;
- api: Client;
- organization: Organization;
- event?: Event;
- };
- type MemberList = NonNullable<
- React.ComponentProps<typeof AssigneeSelector>['memberList']
- >;
- type State = {
- memberList?: MemberList;
- };
- class GroupHeader extends React.Component<Props, State> {
- state: State = {};
- componentDidMount() {
- const {group, api, organization} = this.props;
- const {project} = group;
- fetchOrgMembers(api, organization.slug, [project.id]).then(memberList => {
- const users = memberList.map(member => member.user);
- this.setState({memberList: users});
- });
- }
- getDisabledTabs() {
- const {organization} = this.props;
- const hasReprocessingV2Feature = organization.features.includes('reprocessing-v2');
- if (!hasReprocessingV2Feature) {
- return [];
- }
- const {groupReprocessingStatus} = this.props;
- if (groupReprocessingStatus === ReprocessingStatus.REPROCESSING) {
- return [
- Tab.ACTIVITY,
- Tab.USER_FEEDBACK,
- Tab.ATTACHMENTS,
- Tab.EVENTS,
- Tab.MERGED,
- Tab.GROUPING,
- Tab.SIMILAR_ISSUES,
- Tab.TAGS,
- ];
- }
- if (groupReprocessingStatus === ReprocessingStatus.REPROCESSED_AND_HASNT_EVENT) {
- return [
- Tab.DETAILS,
- Tab.ATTACHMENTS,
- Tab.EVENTS,
- Tab.MERGED,
- Tab.GROUPING,
- Tab.SIMILAR_ISSUES,
- Tab.TAGS,
- Tab.USER_FEEDBACK,
- ];
- }
- return [];
- }
- render() {
- const {project, group, currentTab, baseUrl, event, organization, location} =
- this.props;
- const projectFeatures = new Set(project ? project.features : []);
- const organizationFeatures = new Set(organization ? organization.features : []);
- const userCount = group.userCount;
- const hasGroupingTreeUI = organizationFeatures.has('grouping-tree-ui');
- const hasSimilarView = projectFeatures.has('similarity-view');
- const hasEventAttachments = organizationFeatures.has('event-attachments');
- let className = 'group-detail';
- if (group.hasSeen) {
- className += ' hasSeen';
- }
- if (group.status === 'resolved') {
- className += ' isResolved';
- }
- const {memberList} = this.state;
- const orgId = organization.slug;
- const message = getMessage(group);
- const searchTermWithoutQuery = omit(location.query, 'query');
- const eventRouteToObject = {
- pathname: `${baseUrl}events/`,
- query: searchTermWithoutQuery,
- };
- const disabledTabs = this.getDisabledTabs();
- const disableActions = !!disabledTabs.length;
- return (
- <div className={className}>
- <div className="row">
- <div className="col-sm-7">
- <TitleWrapper>
- <h3>
- <EventOrGroupTitle hasGuideAnchor data={group} />
- </h3>
- {group.inbox && (
- <InboxReasonWrapper>
- <InboxReason inbox={group.inbox} fontSize="md" />
- </InboxReasonWrapper>
- )}
- </TitleWrapper>
- <StyledTagAndMessageWrapper>
- {group.level && <ErrorLevel level={group.level} size="11px" />}
- {group.isUnhandled && <UnhandledInboxTag />}
- <EventMessage
- message={message}
- annotations={
- <React.Fragment>
- {group.logger && (
- <EventAnnotationWithSpace>
- <Link
- to={{
- pathname: `/organizations/${orgId}/issues/`,
- query: {query: 'logger:' + group.logger},
- }}
- >
- {group.logger}
- </Link>
- </EventAnnotationWithSpace>
- )}
- {group.annotations.map((annotation, i) => (
- <EventAnnotationWithSpace
- key={i}
- dangerouslySetInnerHTML={{__html: annotation}}
- />
- ))}
- </React.Fragment>
- }
- />
- </StyledTagAndMessageWrapper>
- </div>
- <div className="col-sm-5 stats">
- <div className="flex flex-justify-right">
- {group.shortId && (
- <GuideAnchor target="issue_number" position="bottom">
- <div className="short-id-box count align-right">
- <h6 className="nav-header">
- <Tooltip
- className="help-link"
- title={t(
- 'This identifier is unique across your organization, and can be used to reference an issue in various places, like commit messages.'
- )}
- position="bottom"
- >
- <ExternalLink href="https://docs.sentry.io/product/integrations/source-code-mgmt/github/#resolve-via-commit-or-pull-request">
- {t('Issue #')}
- </ExternalLink>
- </Tooltip>
- </h6>
- <ShortId
- shortId={group.shortId}
- avatar={
- <StyledProjectBadge project={project} avatarSize={20} hideName />
- }
- />
- </div>
- </GuideAnchor>
- )}
- <div className="count align-right m-l-1">
- <h6 className="nav-header">{t('Events')}</h6>
- {disableActions ? (
- <Count className="count" value={group.count} />
- ) : (
- <Link to={eventRouteToObject}>
- <Count className="count" value={group.count} />
- </Link>
- )}
- </div>
- <div className="count align-right m-l-1">
- <h6 className="nav-header">{t('Users')}</h6>
- {userCount !== 0 ? (
- disableActions ? (
- <Count className="count" value={userCount} />
- ) : (
- <Link to={`${baseUrl}tags/user/${location.search}`}>
- <Count className="count" value={userCount} />
- </Link>
- )
- ) : (
- <span>0</span>
- )}
- </div>
- <div className="assigned-to m-l-1">
- <h6 className="nav-header">{t('Assignee')}</h6>
- <AssigneeSelector
- id={group.id}
- memberList={memberList}
- disabled={disableActions}
- />
- </div>
- </div>
- </div>
- </div>
- <SeenByList
- seenBy={group.seenBy}
- iconTooltip={t('People who have viewed this issue')}
- />
- <GroupActions
- group={group}
- project={project}
- disabled={disableActions}
- event={event}
- />
- <NavTabs>
- <ListLink
- to={`${baseUrl}${location.search}`}
- isActive={() => currentTab === Tab.DETAILS}
- disabled={disabledTabs.includes(Tab.DETAILS)}
- >
- {t('Details')}
- </ListLink>
- <StyledListLink
- to={`${baseUrl}activity/${location.search}`}
- isActive={() => currentTab === Tab.ACTIVITY}
- disabled={disabledTabs.includes(Tab.ACTIVITY)}
- >
- {t('Activity')}
- <Badge>
- {group.numComments}
- <IconChat size="xs" />
- </Badge>
- </StyledListLink>
- <StyledListLink
- to={`${baseUrl}feedback/${location.search}`}
- isActive={() => currentTab === Tab.USER_FEEDBACK}
- disabled={disabledTabs.includes(Tab.USER_FEEDBACK)}
- >
- {t('User Feedback')} <Badge text={group.userReportCount} />
- </StyledListLink>
- {hasEventAttachments && (
- <ListLink
- to={`${baseUrl}attachments/${location.search}`}
- isActive={() => currentTab === Tab.ATTACHMENTS}
- disabled={disabledTabs.includes(Tab.ATTACHMENTS)}
- >
- {t('Attachments')}
- </ListLink>
- )}
- <ListLink
- to={`${baseUrl}tags/${location.search}`}
- isActive={() => currentTab === Tab.TAGS}
- disabled={disabledTabs.includes(Tab.TAGS)}
- >
- {t('Tags')}
- </ListLink>
- <ListLink
- to={eventRouteToObject}
- isActive={() => currentTab === Tab.EVENTS}
- disabled={disabledTabs.includes(Tab.EVENTS)}
- >
- {t('Events')}
- </ListLink>
- <ListLink
- to={`${baseUrl}merged/${location.search}`}
- isActive={() => currentTab === Tab.MERGED}
- disabled={disabledTabs.includes(Tab.MERGED)}
- >
- {t('Merged Issues')}
- </ListLink>
- {hasGroupingTreeUI && (
- <ListLink
- to={`${baseUrl}grouping/${location.search}`}
- isActive={() => currentTab === Tab.GROUPING}
- disabled={disabledTabs.includes(Tab.GROUPING)}
- >
- {t('Grouping')}
- </ListLink>
- )}
- {hasSimilarView && (
- <ListLink
- to={`${baseUrl}similar/${location.search}`}
- isActive={() => currentTab === Tab.SIMILAR_ISSUES}
- disabled={disabledTabs.includes(Tab.SIMILAR_ISSUES)}
- >
- {t('Similar Issues')}
- </ListLink>
- )}
- </NavTabs>
- </div>
- );
- }
- }
- export {GroupHeader};
- export default withApi(withRouter(withOrganization(GroupHeader)));
- const TitleWrapper = styled('div')`
- display: flex;
- line-height: 24px;
- `;
- const InboxReasonWrapper = styled('div')`
- margin-left: ${space(1)};
- `;
- const StyledTagAndMessageWrapper = styled(TagAndMessageWrapper)`
- display: grid;
- grid-auto-flow: column;
- gap: ${space(1)};
- justify-content: flex-start;
- line-height: 1.2;
- @media (max-width: ${p => p.theme.breakpoints[0]}) {
- margin-bottom: ${space(2)};
- }
- `;
- const StyledListLink = styled(ListLink)`
- svg {
- margin-left: ${space(0.5)};
- margin-bottom: ${space(0.25)};
- vertical-align: middle;
- }
- `;
- const StyledProjectBadge = styled(ProjectBadge)`
- flex-shrink: 0;
- `;
- const EventAnnotationWithSpace = styled(EventAnnotation)`
- margin-left: ${space(1)};
- `;
|