|
@@ -1,4 +1,4 @@
|
|
|
-import {CSSProperties, useEffect, useState} from 'react';
|
|
|
+import {useEffect, useState} from 'react';
|
|
|
import {useTheme} from '@emotion/react';
|
|
|
import styled from '@emotion/styled';
|
|
|
import * as Sentry from '@sentry/react';
|
|
@@ -7,6 +7,7 @@ import {Button} from 'sentry/components/button';
|
|
|
import EmptyStateWarning from 'sentry/components/emptyStateWarning';
|
|
|
import Link from 'sentry/components/links/link';
|
|
|
import LoadingIndicator from 'sentry/components/loadingIndicator';
|
|
|
+import {IconImage} from 'sentry/icons';
|
|
|
import {t} from 'sentry/locale';
|
|
|
import {space} from 'sentry/styles/space';
|
|
|
import {safeURL} from 'sentry/utils/url/safeURL';
|
|
@@ -132,6 +133,7 @@ function DisabledImages(props: {onClickShowLinks?: () => void}) {
|
|
|
return (
|
|
|
<div>
|
|
|
<ChartPanelTextContainer>
|
|
|
+ <IconImage />
|
|
|
<h6>{t('Images not shown')}</h6>
|
|
|
{t(
|
|
|
'You know, you can see the actual images that are on your site if you opt into this feature.'
|
|
@@ -157,18 +159,10 @@ function ImageContainer(props: {
|
|
|
size: number;
|
|
|
src: string;
|
|
|
}) {
|
|
|
- const theme = useTheme();
|
|
|
const [hasError, setHasError] = useState(false);
|
|
|
|
|
|
const {fileName, size, src, showImage = true} = props;
|
|
|
|
|
|
- const commonStyles: CSSProperties = {
|
|
|
- width: '100%',
|
|
|
- height: '100%',
|
|
|
- objectFit: 'contain',
|
|
|
- objectPosition: 'center',
|
|
|
- };
|
|
|
-
|
|
|
return (
|
|
|
<div style={{width: '100%', wordWrap: 'break-word'}}>
|
|
|
{showImage && !hasError ? (
|
|
@@ -178,18 +172,51 @@ function ImageContainer(props: {
|
|
|
height: imageHeight,
|
|
|
}}
|
|
|
>
|
|
|
- <img onError={() => setHasError(true)} src={src} style={commonStyles} />
|
|
|
+ <img
|
|
|
+ onError={() => setHasError(true)}
|
|
|
+ src={src}
|
|
|
+ style={{
|
|
|
+ width: '100%',
|
|
|
+ height: '100%',
|
|
|
+ objectFit: 'contain',
|
|
|
+ objectPosition: 'center',
|
|
|
+ }}
|
|
|
+ />
|
|
|
</div>
|
|
|
) : (
|
|
|
- <div
|
|
|
- style={{width: imageWidth, height: imageHeight, backgroundColor: theme.gray100}}
|
|
|
- />
|
|
|
+ <MissingImage />
|
|
|
)}
|
|
|
{fileName} (<ResourceSize bytes={size} />)
|
|
|
</div>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+function MissingImage() {
|
|
|
+ const theme = useTheme();
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div
|
|
|
+ style={{
|
|
|
+ background: theme.gray100,
|
|
|
+ width: imageWidth,
|
|
|
+ height: imageHeight,
|
|
|
+ position: 'relative',
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <IconImage
|
|
|
+ style={{
|
|
|
+ position: 'absolute',
|
|
|
+ top: 0,
|
|
|
+ right: 0,
|
|
|
+ bottom: 0,
|
|
|
+ left: 0,
|
|
|
+ margin: 'auto',
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
const getFileNameFromDescription = (description: string) => {
|
|
|
const url = safeURL(description);
|
|
|
|