import {Fragment} from 'react'; import {ClassNames} from '@emotion/react'; import styled from '@emotion/styled'; import {openCreateOwnershipRule} from 'sentry/actionCreators/modal'; import Access from 'sentry/components/acl/access'; import GuideAnchor from 'sentry/components/assistant/guideAnchor'; import Button from 'sentry/components/button'; import ButtonBar from 'sentry/components/buttonBar'; import HookOrDefault from 'sentry/components/hookOrDefault'; import {Hovercard} from 'sentry/components/hovercard'; import {Panel} from 'sentry/components/panels'; import {IconClose, IconQuestion} from 'sentry/icons'; import {t} from 'sentry/locale'; import space from 'sentry/styles/space'; import {CodeOwner, Organization, Project} from 'sentry/types'; import {trackIntegrationAnalytics} from 'sentry/utils/integrationUtil'; import SidebarSection from '../sidebarSection'; type Props = { codeowners: CodeOwner[]; handleCTAClose: () => void; isDismissed: boolean; issueId: string; organization: Organization; project: Project; }; const CodeOwnersCTA = HookOrDefault({ hookName: 'component:codeowners-cta', defaultComponent: ({organization, project}) => ( trackIntegrationAnalytics('integrations.code_owners_cta_setup_clicked', { view: 'stacktrace_issue_details', project_id: project.id, organization, }) } > {t('Setup')} ), }); const OwnershipRules = ({ project, organization, issueId, codeowners, isDismissed, handleCTAClose, }: Props) => { const handleOpenCreateOwnershipRule = () => { openCreateOwnershipRule({project, organization, issueId}); }; const showCTA = !codeowners.length && !isDismissed; const createRuleButton = ( {({hasAccess}) => ( {t('Create Ownership Rule')} )} ); const codeOwnersCTA = ( {t('Codeowners sync')}{' '} } priority="link" onClick={() => handleCTAClose()} aria-label={t('Close')} /> {t( 'Import GitHub or GitLab CODEOWNERS files to automatically assign issues to the right people.' )} trackIntegrationAnalytics('integrations.code_owners_cta_docs_clicked', { view: 'stacktrace_issue_details', project_id: project.id, organization, }) } > {t('Read Docs')} ); return ( {t('Ownership Rules')} {({css}) => ( {t( 'Ownership rules allow you to associate file paths and URLs to specific teams or users, so alerts can be routed to the right people.' )} {t('Learn more')} } containerClassName={css` display: flex; align-items: center; `} > )} } > {showCTA ? codeOwnersCTA : createRuleButton} ); }; export {OwnershipRules}; const StyledIconQuestion = styled(IconQuestion)` margin-left: ${space(0.5)}; `; const HelpfulBody = styled('div')` padding: ${space(1)}; text-align: center; `; const Container = styled(Panel)` background: none; display: flex; flex-direction: column; padding: ${space(2)}; `; const HeaderContainer = styled('div')` display: grid; grid-template-columns: max-content max-content 1fr; align-items: flex-start; `; const Header = styled('h6')` margin-bottom: ${space(1)}; text-transform: uppercase; font-weight: bold; color: ${p => p.theme.gray300}; font-size: ${p => p.theme.fontSizeExtraSmall}; `; const Content = styled('span')` color: ${p => p.theme.textColor}; margin-bottom: ${space(2)}; `; const SetupButton = styled(Button)` &:focus { color: ${p => p.theme.white}; } `; const DismissButton = styled(Button)` position: absolute; top: 0; right: ${space(1)}; color: ${p => p.theme.gray400}; `;
{t( 'Ownership rules allow you to associate file paths and URLs to specific teams or users, so alerts can be routed to the right people.' )}