-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { FormItem } from '@altinn/ux-editor/types/FormItem'; | ||
import type { ComponentType } from 'app-shared/types/ComponentType'; | ||
import { WWWROOT_FILE_PATH } from './EditImage'; | ||
|
||
export const updateComponentWithImage = ( | ||
component: FormItem<ComponentType.Image>, | ||
imageSource: string, | ||
) => { | ||
return { | ||
Check warning on line 9 in frontend/packages/ux-editor/src/components/config/editModal/EditImage/EditImageUtils.ts Codecov / codecov/patchfrontend/packages/ux-editor/src/components/config/editModal/EditImage/EditImageUtils.ts#L9
|
||
...component, | ||
image: { | ||
...component.image, | ||
src: { | ||
...component.image?.src, | ||
nb: imageSource, // How to handle different images for different languages? | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
export const updateComponentWithDeletedImageReference = ( | ||
component: FormItem<ComponentType.Image>, | ||
) => { | ||
component.image.src = {}; | ||
return component; | ||
Check warning on line 25 in frontend/packages/ux-editor/src/components/config/editModal/EditImage/EditImageUtils.ts Codecov / codecov/patchfrontend/packages/ux-editor/src/components/config/editModal/EditImage/EditImageUtils.ts#L24-L25
|
||
}; | ||
|
||
export const extractFileNameFromImageSrc = (imageSrc: string, org: string, app: string) => { | ||
if (!imageSrc) return ''; | ||
const relativeFilePath = `/${org}/${app}/`; | ||
const indexOfRelativePathInImageSource: number = imageSrc.indexOf(relativeFilePath); | ||
const indexOfWwwrootInImageSource: number = imageSrc.indexOf(WWWROOT_FILE_PATH); | ||
Check warning on line 32 in frontend/packages/ux-editor/src/components/config/editModal/EditImage/EditImageUtils.ts Codecov / codecov/patchfrontend/packages/ux-editor/src/components/config/editModal/EditImage/EditImageUtils.ts#L30-L32
|
||
if (indexOfRelativePathInImageSource > -1) | ||
return imageSrc.slice(indexOfRelativePathInImageSource + relativeFilePath.length); | ||
Check warning on line 34 in frontend/packages/ux-editor/src/components/config/editModal/EditImage/EditImageUtils.ts Codecov / codecov/patchfrontend/packages/ux-editor/src/components/config/editModal/EditImage/EditImageUtils.ts#L34
|
||
if (indexOfWwwrootInImageSource > -1) | ||
return imageSrc.slice(indexOfWwwrootInImageSource + WWWROOT_FILE_PATH.length); | ||
return imageSrc; // What to return? | ||
Check warning on line 37 in frontend/packages/ux-editor/src/components/config/editModal/EditImage/EditImageUtils.ts Codecov / codecov/patchfrontend/packages/ux-editor/src/components/config/editModal/EditImage/EditImageUtils.ts#L36-L37
|
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.fileDescription, | ||
.fileName { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.fileName { | ||
font-weight: bold; | ||
} | ||
|
||
.missingFileDescription { | ||
font-style: italic; | ||
} | ||
|
||
.fileInfoContainer { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import classes from './PreviewFileInfo.module.css'; | ||
import { StudioParagraph } from '@studio/components'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
interface PreviewFileInfoProps { | ||
existingImageUrl: string; | ||
existingImageDescription?: string; | ||
} | ||
|
||
export const PreviewFileInfo = ({ | ||
existingImageUrl, | ||
existingImageDescription, | ||
}: PreviewFileInfoProps) => { | ||
const { t } = useTranslation(); | ||
Check warning on line 15 in frontend/packages/ux-editor/src/components/config/editModal/EditImage/LocalImage/PreviewImageSummary/PreviewFileInfo.tsx Codecov / codecov/patchfrontend/packages/ux-editor/src/components/config/editModal/EditImage/LocalImage/PreviewImageSummary/PreviewFileInfo.tsx#L15
|
||
|
||
return ( | ||
Check warning on line 17 in frontend/packages/ux-editor/src/components/config/editModal/EditImage/LocalImage/PreviewImageSummary/PreviewFileInfo.tsx Codecov / codecov/patchfrontend/packages/ux-editor/src/components/config/editModal/EditImage/LocalImage/PreviewImageSummary/PreviewFileInfo.tsx#L17
|
||
<div className={classes.fileInfoContainer}> | ||
<StudioParagraph size='small' className={classes.fileName}> | ||
{existingImageUrl} | ||
</StudioParagraph> | ||
{existingImageDescription ? ( | ||
<StudioParagraph size='small' className={classes.fileDescription}> | ||
{existingImageDescription} | ||
</StudioParagraph> | ||
) : ( | ||
<StudioParagraph size='small' className={classes.missingFileDescription}> | ||
{t('ux_editor.properties_panel.images.description_missing')} | ||
</StudioParagraph> | ||
)} | ||
</div> | ||
); | ||
}; |