From 61e208ec6325f55b8ac76589ece7bae1e9881431 Mon Sep 17 00:00:00 2001 From: Daniel Karski Date: Mon, 2 Dec 2024 10:24:47 +0100 Subject: [PATCH] [CP-3322] Handle entitiesTypes ordering --- .../mc-file-manager-view/file-category-list.ts | 15 ++++++--------- .../generated/mc-file-manager-view/file-list.ts | 17 ++++++++--------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/libs/generic-view/ui/src/lib/generated/mc-file-manager-view/file-category-list.ts b/libs/generic-view/ui/src/lib/generated/mc-file-manager-view/file-category-list.ts index fb5240fef8..2ea4ada533 100644 --- a/libs/generic-view/ui/src/lib/generated/mc-file-manager-view/file-category-list.ts +++ b/libs/generic-view/ui/src/lib/generated/mc-file-manager-view/file-category-list.ts @@ -13,30 +13,26 @@ interface CategoryListItemConfig { icon: IconType } -const CONFIG_MAP: Record = { +const CONFIG_MAP: Record> = { audioFiles: { - id: "0", name: "Music", icon: IconType.MusicNote, markerColor: "#E38577", entitiesType: "audioFiles", }, imageFiles: { - id: "1", name: "Photos", icon: IconType.PhotoCatalog, markerColor: "#0E7490", entitiesType: "imageFiles", }, ebookFiles: { - id: "2", name: "Ebooks", icon: IconType.Book, markerColor: "#A8DADC", entitiesType: "ebookFiles", }, applicationFiles: { - id: "3", name: "Apps", icon: IconType.Grid, markerColor: "#AEBEC9", @@ -45,9 +41,10 @@ const CONFIG_MAP: Record = { } function getConfigByEntityType( - entityType: string + entityType: string, + id: string ): CategoryListItemConfig | undefined { - return CONFIG_MAP[entityType] || undefined + return { ...CONFIG_MAP[entityType], id } || undefined } const generateFileCategoryListItem = ({ @@ -212,8 +209,8 @@ export const generateFileCategoryList = (entitiesTypes: string[]): Subview => { }, } - return entitiesTypes.reduce((previousValue, entitiesType) => { - const config = getConfigByEntityType(entitiesType) + return entitiesTypes.reduce((previousValue, entitiesType, index) => { + const config = getConfigByEntityType(entitiesType, String(index)) if (!config) { return previousValue } diff --git a/libs/generic-view/ui/src/lib/generated/mc-file-manager-view/file-list.ts b/libs/generic-view/ui/src/lib/generated/mc-file-manager-view/file-list.ts index e6a44922a4..b3f0b0a407 100644 --- a/libs/generic-view/ui/src/lib/generated/mc-file-manager-view/file-list.ts +++ b/libs/generic-view/ui/src/lib/generated/mc-file-manager-view/file-list.ts @@ -11,31 +11,30 @@ interface FileListConfig { entitiesType: string } -const CONFIG_MAP: Record = { +const CONFIG_MAP: Record> = { audioFiles: { - id: "0", name: "Music", entitiesType: "audioFiles", }, imageFiles: { - id: "1", name: "Photos", entitiesType: "imageFiles", }, ebookFiles: { - id: "2", name: "Ebooks", entitiesType: "ebookFiles", }, applicationFiles: { - id: "3", name: "Apps", entitiesType: "applicationFiles", }, } -function getConfigByEntityType(entityType: string): FileListConfig | undefined { - return CONFIG_MAP[entityType] || undefined +function getConfigByEntityType( + entityType: string, + id: string +): FileListConfig | undefined { + return { ...CONFIG_MAP[entityType], id } || undefined } const generateFileList = ({ @@ -479,8 +478,8 @@ export const generateFileListWrapper = (entitiesTypes: string[]): Subview => { }, } - return entitiesTypes.reduce((previousValue, entitiesType) => { - const config = getConfigByEntityType(entitiesType) + return entitiesTypes.reduce((previousValue, entitiesType, index) => { + const config = getConfigByEntityType(entitiesType, String(index)) if (!config) { return previousValue }