Skip to content

Commit 55a284c

Browse files
author
Marosvölgyi Zoltán
committed
Fix old functions
1 parent 724a2f4 commit 55a284c

File tree

6 files changed

+561
-9907
lines changed

6 files changed

+561
-9907
lines changed

apps/sensenet/src/components/IconFromPath.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const IconFromPath = ({
8787
const resizedsvg = svg
8888
.replace('width=', 'width="100%" oldwidth=')
8989
.replace('height=', 'height="100%" oldheight=')
90-
options.repo.iconCache.set(path, resizedsvg)
90+
options.repo.iconCache.set(svgPath, resizedsvg)
9191
setIcon(resizedsvg)
9292
return
9393
}

apps/sensenet/src/components/content/Explore.tsx

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ export function Explore({
101101
const pathFromUrl = useQuery().get('path')
102102
const snRoute = useSnRoute()
103103
const activeAction = snRoute.match!.params.action
104-
104+
const isNewGrid =
105+
window.location.pathname === '/content/explorer/' || window.location.pathname === '/custom/explorer/root/'
105106
const onActivateItemOverride = async (activeItem: GenericContent) => {
106107
const expandedItem = await repository.load({
107108
idOrPath: activeItem.Id,
@@ -174,8 +175,6 @@ export function Explore({
174175
return <FullScreenLoader />
175176
}
176177

177-
const isNewGrid =
178-
window.location.pathname === '/content/explorer/' || window.location.pathname === '/custom/explorer/root/'
179178
if (isNewGrid) {
180179
return (
181180
<>
@@ -218,7 +217,6 @@ export function Explore({
218217
)
219218
}
220219
}
221-
console.log('theme:', theme)
222220
return (
223221
<LoadSettingsContextProvider>
224222
<CurrentContentProvider idOrPath={currentPath}>
@@ -235,19 +233,35 @@ export function Explore({
235233

236234
<div className={`${classes.treeAndDatagridWrapper} leftTree theme-${theme.palette.type} `}>
237235
{hasTree && (
238-
<div className="simpletree">
239-
<SimpleTree
240-
onItemClick={(item) => {
241-
onNavigate(item)
242-
}}
243-
parentPath={PathHelper.isAncestorOf(rootPath, currentPath) ? rootPath : currentPath}
244-
activeItemPath={currentPath}
245-
onTreeLoadingChange={onTreeLoadingChange}
246-
loadSettings={loadTreeSettings}
247-
onNavigate={onNavigate}
248-
rootLoaded={false}
249-
/>
250-
</div>
236+
//
237+
<>
238+
{!isNewGrid ? (
239+
<TreeWithData
240+
onItemClick={(item) => {
241+
onNavigate(item)
242+
}}
243+
parentPath={PathHelper.isAncestorOf(rootPath, currentPath) ? rootPath : currentPath}
244+
activeItemPath={currentPath}
245+
onTreeLoadingChange={onTreeLoadingChange}
246+
loadSettings={loadTreeSettings}
247+
/>
248+
) : (
249+
<div className="simpletree">
250+
<SimpleTree
251+
onItemClick={(item) => {
252+
onNavigate(item)
253+
}}
254+
parentPath={PathHelper.isAncestorOf(rootPath, currentPath) ? rootPath : currentPath}
255+
activeItemPath={currentPath}
256+
onTreeLoadingChange={onTreeLoadingChange}
257+
loadSettings={loadTreeSettings}
258+
onNavigate={onNavigate}
259+
rootLoaded={false}
260+
/>
261+
</div>
262+
)}
263+
{/* */}
264+
</>
251265
)}
252266
<div className={classes.exploreContainer}>{renderContent()}</div>
253267
</div>

apps/sensenet/src/components/tree/StyledTreeItem.tsx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ODataCollectionResponse } from '@sensenet/client-core'
77
import { GenericContent } from '@sensenet/default-content-types'
88
import { useRepository } from '@sensenet/hooks-react'
99
import React, { useCallback, useEffect, useState } from 'react'
10+
import { useQuery } from '../../hooks'
1011
import { Icon } from '../Icon'
1112
import StyledTreeItemProps from './Props/StyledTreeItemProps'
1213
function isOpen(prop: any) {
@@ -36,21 +37,31 @@ export const StyledTreeItem = withStyles((theme: Theme) =>
3637
)((props: StyledTreeItemProps) => {
3738
const repo = useRepository()
3839
const [innerElements, setInnerElements] = useState<[]>()
39-
// const [elementsLoaded, setElemetnsLoaded] = useState<boolean>()
4040
const loadCollectionCB = useCallback(() => {
4141
function loadCollection(): Promise<ODataCollectionResponse<GenericContent>> {
42-
return repo.loadCollection<GenericContent>({
43-
path: props.contentValue.Path,
44-
oDataOptions: { select: ['Path', 'Name', 'DisplayName', 'Type', 'Actions'] },
45-
})
42+
const cacheKey = `collection_${props.contentValue.Path}`
43+
const cachedData = sessionStorage.getItem(cacheKey)
44+
const cacheTimestamp = sessionStorage.getItem(`${cacheKey}_timestamp`)
45+
const now = new Date().getTime()
46+
47+
if (cachedData && cacheTimestamp && now - parseInt(cacheTimestamp, 10) < 30 * 1000) {
48+
return Promise.resolve(JSON.parse(cachedData))
49+
}
50+
51+
return repo
52+
.loadCollection<GenericContent>({
53+
path: props.contentValue.Path,
54+
oDataOptions: { select: ['Path', 'Name', 'DisplayName', 'Type', 'Actions'] },
55+
})
56+
.then((result) => {
57+
sessionStorage.setItem(cacheKey, JSON.stringify(result))
58+
sessionStorage.setItem(`${cacheKey}_timestamp`, now.toString())
59+
return result
60+
})
4661
}
62+
4763
const respRequest = loadCollection()
4864
respRequest.then((result: any) => {
49-
//console.log('#tree: loadCollectionCB')
50-
//const piso = isOpen(props['aria-expanded'])
51-
//if (!elementsLoaded || (elementsLoaded && piso)) {
52-
// setElemetnsLoaded(true)
53-
//console.log('#tree:amottan piso:', piso, props.contentValue.Name)
5465
const elements = result?.d.results.map((innerChild: GenericContent) => {
5566
props.addItemToExpanded(innerChild)
5667
return (

apps/sensenet/src/style.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ SimpleTree
181181
.buttonPanel .MuiButton-label {
182182
flex-direction: column;
183183
}
184+
.MuiListItemIcon-root .svgicon {
185+
width: 24px;
186+
height: 24px;
187+
}
184188
/*.leftTree .MuiListItemIcon-root {
185189
border-left: 2px dotted #ccc;
186190
padding-left: 5px;

packages/sn-client-core/src/Repository/Repository.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export class Repository implements Disposable {
9696
if (this.configuration.token) {
9797
request.headers.append('Authorization', `Bearer ${this.configuration.token}`)
9898
}
99-
console.log('load from cache')
10099
return await this.fetchMethod(request)
101100
}
102101

0 commit comments

Comments
 (0)