mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
34 lines
852 B
TypeScript
34 lines
852 B
TypeScript
import {memo} from 'react';
|
|
|
|
import {Role} from 'sentry/components/acl/role';
|
|
import type {IssueAttachment, Organization} from 'sentry/types';
|
|
import withOrganization from 'sentry/utils/withOrganization';
|
|
|
|
type Props = {
|
|
attachment: IssueAttachment;
|
|
children: (downloadUrl: string | null) => React.ReactElement | null;
|
|
eventId: string;
|
|
organization: Organization;
|
|
projectSlug: string;
|
|
};
|
|
|
|
function AttachmentUrl({
|
|
attachment,
|
|
organization,
|
|
eventId,
|
|
projectSlug,
|
|
children,
|
|
}: Props) {
|
|
function getDownloadUrl() {
|
|
return `/api/0/projects/${organization.slug}/${projectSlug}/events/${eventId}/attachments/${attachment.id}/`;
|
|
}
|
|
|
|
return (
|
|
<Role role={organization.attachmentsRole}>
|
|
{({hasRole}) => children(hasRole ? getDownloadUrl() : null)}
|
|
</Role>
|
|
);
|
|
}
|
|
|
|
export default withOrganization(memo(AttachmentUrl));
|