import {Fragment} from 'react';
import styled from '@emotion/styled';
import MenuItemActionLink from 'sentry/components/actions/menuItemActionLink';
import {Button} from 'sentry/components/button';
import ButtonBar from 'sentry/components/buttonBar';
import ConfirmDelete from 'sentry/components/confirmDelete';
import DropdownLink from 'sentry/components/dropdownLink';
import {Tooltip} from 'sentry/components/tooltip';
import {IconEllipsis} from 'sentry/icons/iconEllipsis';
import {t} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import TextBlock from 'sentry/views/settings/components/text/textBlock';
type Props = {
hasAccess: boolean;
hasFeature: boolean;
onDelete: () => void;
onEdit: () => void;
repositoryName: string;
disabled?: boolean;
syncNowButton?: React.ReactElement;
};
function Actions({
repositoryName,
disabled,
onEdit,
onDelete,
hasFeature,
hasAccess,
syncNowButton,
}: Props) {
function renderConfirmDelete(element: React.ReactElement) {
return (
{t('Removing this repository applies instantly to new events.')}
{t(
'Debug files from this repository will not be used to symbolicate future events. This may create new issues and alert members in your organization.'
)}
}
confirmInput={repositoryName}
priority="danger"
onConfirm={onDelete}
>
{element}
);
}
const actionsDisabled = !hasAccess || !hasFeature || disabled;
return (
{syncNowButton}
{t('Configure')}
{actionsDisabled ? (
{t('Delete')}
) : (
renderConfirmDelete({t('Delete')})
)}
}
/>
}
anchorRight
>
{t('Configure')}
{renderConfirmDelete({t('Delete')})}
);
}
export default Actions;
const StyledButton = styled(Button)`
height: 32px;
`;
const StyledButtonBar = styled(ButtonBar)`
gap: ${space(1)};
grid-column: 2/2;
grid-row: 4/4;
grid-auto-flow: row;
margin-top: ${space(0.5)};
@media (min-width: ${p => p.theme.breakpoints.small}) {
grid-column: 3/3;
grid-row: 1/3;
grid-auto-flow: column;
margin-top: 0;
}
`;
const ButtonTooltip = styled(Tooltip)`
@media (min-width: ${p => p.theme.breakpoints.small}) {
display: none;
}
`;
const ActionBtn = styled(Button)`
width: 100%;
@media (min-width: ${p => p.theme.breakpoints.small}) {
display: none;
}
`;
const DropDownWrapper = styled('div')`
display: none;
@media (min-width: ${p => p.theme.breakpoints.small}) {
display: block;
}
`;