import {Component, Fragment} from 'react'; import styled from '@emotion/styled'; import capitalize from 'lodash/capitalize'; import Access from 'sentry/components/acl/access'; import Button from 'sentry/components/button'; import Confirm from 'sentry/components/confirm'; import Pagination from 'sentry/components/pagination'; import {Panel, PanelBody, PanelHeader, PanelItem} from 'sentry/components/panels'; import Tooltip from 'sentry/components/tooltip'; import {IconAdd, IconDelete, IconEdit} from 'sentry/icons'; import {t, tct} from 'sentry/locale'; import space from 'sentry/styles/space'; import {ExternalActorMapping, Integration} from 'sentry/types'; import {getIntegrationIcon} from 'sentry/utils/integrationUtil'; import EmptyMessage from 'sentry/views/settings/components/emptyMessage'; type Props = { integration: Integration; mappings: {id: string; externalName: string; sentryName: string}[]; type: 'team' | 'user'; onCreateOrEdit: (mapping?: ExternalActorMapping) => void; onDelete: (mapping: ExternalActorMapping) => void; pageLinks?: string; }; type State = {}; class IntegrationExternalMappings extends Component { render() { const {integration, mappings, type, onCreateOrEdit, onDelete, pageLinks} = this.props; return ( {tct('External [type]', {type})} {tct('Sentry [type]', {type})} {({hasAccess}) => ( onCreateOrEdit()} size="xsmall" icon={} disabled={!hasAccess} > {tct('Add [type] Mapping', {type})} )} {!mappings.length && ( {tct('Set up External [type] Mappings.', {type: capitalize(type)})} )} {mappings.map(item => ( {({hasAccess}) => ( {item.externalName} {item.sentryName} } label={t('edit')} disabled={!hasAccess} onClick={() => onCreateOrEdit(item)} /> onDelete(item)} message={t( 'Are you sure you want to remove this external user mapping?' )} > } label={t('delete')} disabled={!hasAccess} /> )} ))} ); } } export default IntegrationExternalMappings; const AddButton = styled(Button)` text-transform: capitalize; `; const Layout = styled('div')` display: grid; grid-column-gap: ${space(1)}; width: 100%; align-items: center; grid-template-columns: 2.5fr 2.5fr 1fr; grid-template-areas: 'external-name sentry-name button'; `; const HeaderLayout = styled(Layout)` align-items: center; margin: 0; margin-left: ${space(2)}; text-transform: uppercase; `; const ConfigPanelItem = styled(PanelItem)``; const StyledButton = styled(Button)` margin: ${space(0.5)}; `; // Columns below const Column = styled('span')` overflow: hidden; overflow-wrap: break-word; `; const ExternalNameColumn = styled(Column)` grid-area: external-name; `; const SentryNameColumn = styled(Column)` grid-area: sentry-name; `; const ButtonColumn = styled(Column)` grid-area: button; text-align: right; `;