1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 06:44:21 +00:00
This commit is contained in:
Steffo 2021-10-17 01:27:35 +02:00 committed by Stefano Pigozzi
parent 97d795b175
commit df89faad26
4 changed files with 62 additions and 51 deletions

View file

@ -40,13 +40,6 @@
<inspection_tool class="PyRelativeImportInspection" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PyReturnFromInitInspection" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="PySetFunctionToLiteralInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PyShadowingBuiltinsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredNames">
<list>
<option value="format" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyStringFormatInspection" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="PyTrailingSemicolonInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="PyUnnecessaryBackslashInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />

View file

@ -24,6 +24,8 @@ export function ViewSetRouter<Resource extends DjangoResource>({viewSet, unselec
const path = useSophonPath()
const pk = path?.[pathSegment]
return React.useMemo(
() => {
if(viewSet === undefined) {
return (
<Box>
@ -57,4 +59,9 @@ export function ViewSetRouter<Resource extends DjangoResource>({viewSet, unselec
selectedRoute={(props) => <SelectedRoute {...props}/>}
/>
)
},
[viewSet, UnselectedRoute, SelectedRoute, pk, pkKey],
)
}

View file

@ -617,6 +617,8 @@ export function useManagedViewSet<Resource extends DjangoResource>(baseRoute: st
[refresh, state, refreshOnMount, viewset, baseRoute],
)
return React.useMemo(
() => {
if(!viewset) {
return undefined
}
@ -630,4 +632,7 @@ export function useManagedViewSet<Resource extends DjangoResource>(baseRoute: st
create,
command,
}
},
[state, resources, refresh, create, command]
)
}

View file

@ -149,9 +149,15 @@ export function useViewSet<Resource>(baseRoute: string): ViewSet<Resource> | und
[action, baseRoute],
)
return React.useMemo(
() => {
if(!api) {
return undefined
}
return {command, action, list, retrieve, create, update, destroy}
},
[command, action, list, retrieve, create, update, destroy],
)
}