Dear Gitlab users, due to maintenance reasons, Gitlab will not be available on Thursday 30.09.2021 from 5:00 pm to approximately 5:30 pm.

Commit 34c2975a authored by Stefan Probst's avatar Stefan Probst
Browse files

fix: show thumbnail in edit form

parent fc3b08f1
Pipeline #193586 passed with stages
in 15 minutes and 25 seconds
......@@ -20,7 +20,7 @@ export function Thumbnail(props: ThumbnailProps): JSX.Element | null {
const caption = props.caption
return (
<figure className="relative flex flex-col items-center p-2 space-y-2 w-80">
<figure className="relative flex flex-col items-center max-w-xs p-2 space-y-2">
{props.onRemove !== undefined ? (
<button
onClick={props.onRemove}
......@@ -42,7 +42,9 @@ export function Thumbnail(props: ThumbnailProps): JSX.Element | null {
<img src={DocumentIcon} alt="" className="w-6 h-6" />
</div>
)}
<figcaption>{caption ?? filename ?? location?.sourceUrl}</figcaption>
<figcaption className="break-all">
{caption ?? filename ?? location?.sourceUrl}
</figcaption>
</figure>
)
}
......@@ -37,7 +37,7 @@ export function ThumbnailFormSection(
{input.value != null && input.value !== '' ? (
<Thumbnail
onRemove={() => input.onChange(null)}
media={input.value}
media={{ ...input.value, hasThumbnail: true }}
/>
) : null}
<div className="flex items-center space-x-8">
......@@ -48,7 +48,10 @@ export function ThumbnailFormSection(
isOpen={addThumbnailDialog.isOpen}
onDismiss={addThumbnailDialog.close}
onSuccess={(mediaInfo, caption) => {
if (mediaInfo.category !== 'image') {
if (
mediaInfo.category !== 'image' ||
mediaInfo.hasThumbnail !== true
) {
throw new MediaError('A thumbnail must be an image.')
}
input.onChange({ ...mediaInfo, caption })
......@@ -59,7 +62,8 @@ export function ThumbnailFormSection(
{({ input: media }) => {
const images =
media.value?.filter(
(m: MediaDetails) => m.category === 'image',
(m: MediaDetails) =>
m.category === 'image' && m.hasThumbnail === true,
) ?? []
return (
<Fragment>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment