Skip to content

Commit

Permalink
Merge branch 'main' into feat/outline
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala authored Sep 15, 2023
2 parents cea0936 + 767716e commit 3822eda
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/@dcl/inspector/src/components/Assets/Assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { FolderOpen } from '../Icons/Folder'
import { MdImageSearch } from 'react-icons/md'
import { HiOutlinePlus } from 'react-icons/hi'
import { AssetsCatalog } from '../AssetsCatalog'
import { catalog } from '../../lib/logic/catalog'
import { AssetPack, catalog, isSmart } from '../../lib/logic/catalog'
import { getConfig } from '../../lib/logic/config'
import { getSelectedAssetsTab, selectAssetsTab } from '../../redux/ui'
import { useAppDispatch, useAppSelector } from '../../redux/hooks'
import { AssetsTab } from '../../redux/ui/types'
Expand All @@ -14,6 +15,13 @@ import ImportAsset from '../ImportAsset'

import './Assets.css'

function removeSmartItems(assetPack: AssetPack) {
return {
...assetPack,
assets: assetPack.assets.filter((asset) => !isSmart(asset))
}
}

function Assets() {
const dispatch = useAppDispatch()
const tab = useAppSelector(getSelectedAssetsTab)
Expand All @@ -25,6 +33,11 @@ function Assets() {
[]
)

const config = getConfig()
const filteredCatalog = config.disableSmartItems
? catalog.map(removeSmartItems).filter((assetPack) => assetPack.assets.length > 0)
: catalog

return (
<div className="Assets">
<div className="Assets-buttons">
Expand All @@ -47,7 +60,7 @@ function Assets() {
</div>
</div>
<div className="Assets-content">
{tab === AssetsTab.AssetsPack && <AssetsCatalog catalog={catalog} />}
{tab === AssetsTab.AssetsPack && <AssetsCatalog catalog={filteredCatalog} />}
{tab === AssetsTab.FileSystem && <ProjectAssetExplorer />}
{tab === AssetsTab.Import && <ImportAsset onSave={handleTabClick(AssetsTab.FileSystem)} />}
</div>
Expand Down
5 changes: 5 additions & 0 deletions packages/@dcl/inspector/src/lib/logic/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ export function getAssetsByCategory(assets: Asset[]) {

return categories
}

export function isSmart(asset: Asset) {
const components = Object.keys(asset.components)
return components.length > 1 || (components.length === 1 && components[0] !== 'core::GltfContainer')
}

0 comments on commit 3822eda

Please sign in to comment.