Skip to content

Commit

Permalink
fixed issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeriaMaltseva committed Dec 2, 2024
1 parent 7e6b13a commit cbb764c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
* @license https://github.com/pimcore/studio-ui-bundle/blob/1.x/LICENSE.md POCL and PCL
*/

import { api, type AssetGetGridApiResponse, type AssetPatchByIdApiArg, useAssetGetGridMutation, useAssetPatchByIdMutation } from '@Pimcore/modules/asset/asset-api-slice-enhanced'
import React, { useContext, useEffect, useMemo, useState } from 'react'
import { type FetchBaseQueryError } from '@reduxjs/toolkit/query'
import { isUndefined } from 'lodash'
import { api, type AssetGetGridApiResponse, type Column, type AssetPatchByIdApiArg, useAssetGetGridMutation, useAssetPatchByIdMutation } from '@Pimcore/modules/asset/asset-api-slice-enhanced'
import { type GridColumnConfiguration } from '@Pimcore/modules/data-object/data-object-api-slice.gen'
import { encodeColumnIdentifier, GridContainer } from './grid-container'
import { GridToolbarContainer } from './toolbar/grid-toolbar-container'
import { AssetContext } from '@Pimcore/modules/asset/asset-provider'
Expand Down Expand Up @@ -84,6 +85,18 @@ export const ListContainerInner = (): React.JSX.Element => {
}
}, [columns, filterOptions, page, pageSize, sorting])

const getInitialColumns = ({ initialGridConfigData, availableGridConfigData }): GridColumnConfiguration[] => {
return initialGridConfigData!.columns.map((column: Column) => {
const availableColumn = availableGridConfigData?.columns?.find((availableColumn: GridColumnConfiguration) => availableColumn.key === column.key)

if (isUndefined(availableColumn)) {
trackError(new GeneralError(`Column with key ${column.key} is not available`))
}

return availableColumn
}).filter((column: GridColumnConfiguration | undefined) => !isUndefined(column))
}

useEffect(() => {
async function fetchGridConfiguration (): Promise<void> {
const availableGridConfigPromise = dispatch(api.endpoints.assetGetAvailableGridColumns.initiate())
Expand All @@ -93,15 +106,10 @@ export const ListContainerInner = (): React.JSX.Element => {
setAvailableColumns(availableGridConfig.data?.columns)
setGridConfig(initialGridConfig.data)

const initialColumns = initialGridConfig.data!.columns.map((column) => {
const availableColumn = availableGridConfig.data?.columns?.find((availableColumn) => availableColumn.key === column.key)

if (isUndefined(availableColumn)) {
trackError(new GeneralError(`Column with key ${column.key} is not available`))
}

return availableColumn
}).filter((column) => !isUndefined(column))
const initialColumns = getInitialColumns({
initialGridConfigData: initialGridConfig.data,
availableGridConfigData: availableGridConfig.data
})

setGridColumns(initialColumns)
availableGridConfigPromise.unsubscribe()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1876,5 +1876,7 @@
"build/b78fb8ab-874d-4fff-a928-4ae4370624c3/../../../assets/dist/build/types/js/src/core/app/config/services/index.d.ts.map": "http://localhost:3030/build/b78fb8ab-874d-4fff-a928-4ae4370624c3/../../../assets/dist/build/types/js/src/core/app/config/services/index.d.ts.map",
"build/b78fb8ab-874d-4fff-a928-4ae4370624c3/../../../assets/dist/build/types/js/test-utils/jest-setup.d.ts.map": "http://localhost:3030/build/b78fb8ab-874d-4fff-a928-4ae4370624c3/../../../assets/dist/build/types/js/test-utils/jest-setup.d.ts.map",
"build/b78fb8ab-874d-4fff-a928-4ae4370624c3/../../../assets/dist/build/types/js/src/core/modules/asset/tree/index.d.ts.map": "http://localhost:3030/build/b78fb8ab-874d-4fff-a928-4ae4370624c3/../../../assets/dist/build/types/js/src/core/modules/asset/tree/index.d.ts.map",
"build/b78fb8ab-874d-4fff-a928-4ae4370624c3/../../../assets/dist/build/types/js/src/core/modules/icon-library/index.d.ts.map": "http://localhost:3030/build/b78fb8ab-874d-4fff-a928-4ae4370624c3/../../../assets/dist/build/types/js/src/core/modules/icon-library/index.d.ts.map"
"build/b78fb8ab-874d-4fff-a928-4ae4370624c3/../../../assets/dist/build/types/js/src/core/modules/icon-library/index.d.ts.map": "http://localhost:3030/build/b78fb8ab-874d-4fff-a928-4ae4370624c3/../../../assets/dist/build/types/js/src/core/modules/icon-library/index.d.ts.map",
"build/b78fb8ab-874d-4fff-a928-4ae4370624c3/vendors-node_modules_dnd-kit_modifiers_dist_modifiers_esm_js-node_modules_dnd-kit_sortable_di-f1de11.css": "http://localhost:3030/build/b78fb8ab-874d-4fff-a928-4ae4370624c3/vendors-node_modules_dnd-kit_modifiers_dist_modifiers_esm_js-node_modules_dnd-kit_sortable_di-f1de11.css",
"build/b78fb8ab-874d-4fff-a928-4ae4370624c3/vendors-node_modules_dnd-kit_modifiers_dist_modifiers_esm_js-node_modules_dnd-kit_sortable_di-f1de11.js": "http://localhost:3030/build/b78fb8ab-874d-4fff-a928-4ae4370624c3/vendors-node_modules_dnd-kit_modifiers_dist_modifiers_esm_js-node_modules_dnd-kit_sortable_di-f1de11.js"
}

0 comments on commit cbb764c

Please sign in to comment.