({
queryKey: [QueryKey.LayoutNames, owner, app],
queryFn: () =>
- getLayoutNames(owner, app).then((layoutNames) => layoutNames.map(removeExtension)),
+ getLayoutNames(owner, app).then((layoutNames) =>
+ layoutNames.map(FileNameUtils.removeExtension),
+ ),
});
};
diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditImage/LocalImage/ImportImage/AddImageFromLibrary/ChooseFromLibrary/ImageLibraryPreview.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditImage/LocalImage/ImportImage/AddImageFromLibrary/ChooseFromLibrary/ImageLibraryPreview.tsx
index 128e770e336..9f6e6391824 100644
--- a/frontend/packages/ux-editor/src/components/config/editModal/EditImage/LocalImage/ImportImage/AddImageFromLibrary/ChooseFromLibrary/ImageLibraryPreview.tsx
+++ b/frontend/packages/ux-editor/src/components/config/editModal/EditImage/LocalImage/ImportImage/AddImageFromLibrary/ChooseFromLibrary/ImageLibraryPreview.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import classes from './ChooseFromLibrary.module.css';
import { imagePath } from 'app-shared/api/paths';
-import { extractFilename } from 'app-shared/utils/filenameUtils';
+import { FileNameUtils } from '@studio/pure-functions';
import { useStudioEnvironmentParams } from 'app-shared/hooks/useStudioEnvironmentParams';
import { WWWROOT_FILE_PATH } from '../../../../../EditImage/constants';
import { StudioCard, StudioHeading } from '@studio/components';
@@ -42,6 +42,7 @@ const ImageFromLibrary = ({
onAddImageReference,
imageSource,
}: ImageFromLibraryProps) => {
+ const fileName = FileNameUtils.extractFilename(imageFilePath);
// The img component requires an alt which we can set to be the descriptions from the metadata in the library when this is available.
// TODO: Add description when we know how to store them. See analysis issue: https://github.com/Altinn/altinn-studio/issues/13346
return (
@@ -51,12 +52,8 @@ const ImageFromLibrary = ({
-
- {extractFilename(imageFilePath)}
+
+ {fileName}
diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditImage/LocalImage/PreviewImageSummary/PreviewFileInfo.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditImage/LocalImage/PreviewImageSummary/PreviewFileInfo.tsx
index 36be4f85699..5b7bf2ae8ca 100644
--- a/frontend/packages/ux-editor/src/components/config/editModal/EditImage/LocalImage/PreviewImageSummary/PreviewFileInfo.tsx
+++ b/frontend/packages/ux-editor/src/components/config/editModal/EditImage/LocalImage/PreviewImageSummary/PreviewFileInfo.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import classes from './PreviewFileInfo.module.css';
import { StudioParagraph } from '@studio/components';
-import { extractFilename } from 'app-shared/utils/filenameUtils';
+import { FileNameUtils } from '@studio/pure-functions';
interface PreviewFileInfoProps {
existingImageUrl: string;
@@ -11,7 +11,7 @@ export const PreviewFileInfo = ({ existingImageUrl }: PreviewFileInfoProps) => {
return (
- {extractFilename(existingImageUrl)}
+ {FileNameUtils.extractFilename(existingImageUrl)}
);
diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/EditOptionList.tsx b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/EditOptionList.tsx
index 79dbde88e34..101659260be 100644
--- a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/EditOptionList.tsx
+++ b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/EditOptionList.tsx
@@ -9,7 +9,7 @@ import { altinnDocsUrl } from 'app-shared/ext-urls';
import { FormField } from '../../../../../FormField';
import { useStudioEnvironmentParams } from 'app-shared/hooks/useStudioEnvironmentParams';
import type { SelectionComponentType } from '../../../../../../types/FormComponent';
-import { removeExtension } from 'app-shared/utils/filenameUtils';
+import { FileNameUtils } from '@studio/pure-functions';
import { findFileNameError } from './utils/findFileNameError';
import type { FileNameError } from './utils/findFileNameError';
import type { AxiosError } from 'axios';
@@ -53,7 +53,7 @@ export function EditOptionList({
const handleUpload = (file: File) => {
uploadOptionList(file, {
onSuccess: () => {
- handleOptionsIdChange(removeExtension(file.name));
+ handleOptionsIdChange(FileNameUtils.removeExtension(file.name));
toast.success(t('ux_editor.modal_properties_code_list_upload_success'));
},
onError: (error: AxiosError) => {
diff --git a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/utils/findFileNameError.ts b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/utils/findFileNameError.ts
index 307307991a0..f13182f7336 100644
--- a/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/utils/findFileNameError.ts
+++ b/frontend/packages/ux-editor/src/components/config/editModal/EditOptions/OptionTabs/EditOptionList/utils/findFileNameError.ts
@@ -1,4 +1,4 @@
-import { removeExtension } from 'app-shared/utils/filenameUtils';
+import { FileNameUtils } from '@studio/pure-functions';
export type FileNameError = 'invalidFileName' | 'fileExists';
@@ -6,7 +6,7 @@ export const findFileNameError = (
optionListIds: string[],
fileName: string,
): FileNameError | null => {
- const fileNameWithoutExtension = removeExtension(fileName);
+ const fileNameWithoutExtension = FileNameUtils.removeExtension(fileName);
if (!isFilenameValid(fileNameWithoutExtension)) {
return 'invalidFileName';