Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix records list not visible when resource action is open in drawer #1628

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions src/frontend/components/routes/resource-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const ResourceAction: React.FC<Props> = (props) => {
const { resources } = props
const { resourceId, actionName } = params
const [tag, setTag] = useState('')
const [filterVisible, setFilterVisible] = useState(false)

const resource = resources.find((r) => r.id === resourceId)
if (!resource) {
Expand All @@ -37,13 +38,43 @@ const ResourceAction: React.FC<Props> = (props) => {
return <NoActionError resourceId={resourceId!} actionName={actionName!} />
}

const listActionName = 'list'
const listAction = resource.resourceActions.find((r) => r.name === listActionName)

const contentTag = getResourceElementCss(resource.id, action.name)

if (action.showInDrawer) {
if (!listAction) {
return (
<DrawerPortal width={action.containerWidth}>
<BaseActionComponent action={action} resource={resource} />
</DrawerPortal>
)
}

const toggleFilter = listAction.showFilter
? (): void => setFilterVisible(!filterVisible)
: undefined

return (
<DrawerPortal width={action.containerWidth}>
<BaseActionComponent action={action} resource={resource} />
</DrawerPortal>
<>
<DrawerPortal width={action.containerWidth}>
<BaseActionComponent
action={action}
resource={resource}
setTag={setTag}
/>
</DrawerPortal>
<Wrapper width={listAction.containerWidth}>
<ActionHeader
resource={resource}
action={listAction}
tag={tag}
toggleFilter={toggleFilter}
/>
<BaseActionComponent action={listAction} resource={resource} setTag={setTag} />
</Wrapper>
</>
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/hooks/use-navigation-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function useNavigationResources(
memo[key] = enrichResource(resource, resource.navigation?.icon)
} else if (memo[key] && memo[key].elements && resource.navigation?.name) {
memo[key].label = translateLabel(resource.navigation?.name)
memo[key].elements.push(enrichResource(resource))
memo[key].elements?.push?.(enrichResource(resource))
} else {
memo[key] = {
elements: [enrichResource(resource)],
Expand Down
Loading