Skip to content

Commit

Permalink
fix: add missing data-css attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
dziraf committed Jul 10, 2024
1 parent 4c2a87a commit 4cefcd0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
12 changes: 8 additions & 4 deletions src/frontend/components/routes/bulk-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
} from '../app/index.js'
import { useTranslation, useNotice, useResource } from '../../hooks/index.js'
import allowOverride from '../../hoc/allow-override.js'
import { getDataCss } from '../../index.js'

type MatchParams = Pick<BulkActionParams, 'actionName' | 'resourceId'>

Expand Down Expand Up @@ -97,10 +98,13 @@ const BulkAction: React.FC = () => {
return <NoActionError resourceId={resourceId!} actionName={actionName!} />
}

const routeWrapperCss = getDataCss(resource.id, action.actionType, action.name, 'route-wrapper')
const routeActionCss = getDataCss(resource.id, action.actionType, action.name, 'route')

if (action.showInDrawer) {
if (!listAction) {
return (
<DrawerPortal width={action.containerWidth}>
<DrawerPortal width={action.containerWidth} data-css={routeActionCss}>
<BaseActionComponent
action={action as ActionJSON}
resource={resource}
Expand All @@ -116,15 +120,15 @@ const BulkAction: React.FC = () => {

return (
<>
<DrawerPortal width={action.containerWidth}>
<DrawerPortal width={action.containerWidth} data-css={routeActionCss}>
<BaseActionComponent
action={action as ActionJSON}
resource={resource}
records={records}
setTag={setTag}
/>
</DrawerPortal>
<Wrapper width={listAction.containerWidth}>
<Wrapper width={listAction.containerWidth} data-css={routeWrapperCss}>
<ActionHeader
resource={resource}
action={listAction}
Expand All @@ -138,7 +142,7 @@ const BulkAction: React.FC = () => {
}

return (
<Wrapper width={action.containerWidth}>
<Wrapper width={action.containerWidth} data-css={routeWrapperCss}>
{!action?.showInDrawer ? <ActionHeader resource={resource} action={action} tag={tag} /> : ''}
<BaseActionComponent
action={action as ActionJSON}
Expand Down
12 changes: 8 additions & 4 deletions src/frontend/components/routes/record-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import DrawerPortal from '../app/drawer-portal.js'
import { ActionResponse, RecordActionResponse } from '../../../backend/actions/action.interface.js'
import mergeRecordResponse from '../../hooks/use-record/merge-record-response.js'
import allowOverride from '../../hoc/allow-override.js'
import { getDataCss } from '../../index.js'

const api = new ApiClient()

Expand Down Expand Up @@ -116,10 +117,13 @@ const RecordAction: React.FC = () => {
return <NoRecordError resourceId={resourceId!} recordId={recordId!} />
}

const routeWrapperCss = getDataCss(resource.id, action.actionType, action.name, 'route-wrapper')
const routeActionCss = getDataCss(resource.id, action.actionType, action.name, 'route')

if (action.showInDrawer) {
if (!listAction) {
return (
<DrawerPortal width={action.containerWidth}>
<DrawerPortal width={action.containerWidth} data-css={routeActionCss}>
<BaseActionComponent action={action as ActionJSON} resource={resource} record={record} />
</DrawerPortal>
)
Expand All @@ -131,10 +135,10 @@ const RecordAction: React.FC = () => {

return (
<>
<DrawerPortal width={action.containerWidth}>
<DrawerPortal width={action.containerWidth} data-css={routeActionCss}>
<BaseActionComponent action={action as ActionJSON} resource={resource} record={record} />
</DrawerPortal>
<Wrapper width={listAction.containerWidth}>
<Wrapper width={listAction.containerWidth} data-css={routeWrapperCss}>
<ActionHeader
resource={resource}
action={listAction}
Expand All @@ -148,7 +152,7 @@ const RecordAction: React.FC = () => {
}

return (
<Wrapper width={action.containerWidth}>
<Wrapper width={action.containerWidth} data-css={routeWrapperCss}>
<ActionHeader
resource={resource}
action={action}
Expand Down
9 changes: 5 additions & 4 deletions src/frontend/components/routes/resource-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { NoActionError, NoResourceError } from '../app/error-message.js'
import FilterDrawer from '../app/filter-drawer.js'
import { ActionHeader } from '../app/index.js'
import Wrapper from './utils/wrapper.js'
import { getResourceElementCss } from '../../utils/data-css-name.js'
import { getDataCss, getResourceElementCss } from '../../utils/data-css-name.js'

type PropsFromState = {
resources: Array<ResourceJSON>
Expand Down Expand Up @@ -42,11 +42,12 @@ const ResourceAction: React.FC<Props> = (props) => {
const listAction = resource.resourceActions.find((r) => r.name === listActionName)

const contentTag = getResourceElementCss(resource.id, action.name)
const routeActionCss = getDataCss(resource.id, action.actionType, action.name, 'route')

if (action.showInDrawer) {
if (!listAction) {
return (
<DrawerPortal width={action.containerWidth}>
<DrawerPortal width={action.containerWidth} data-css={routeActionCss}>
<BaseActionComponent action={action} resource={resource} />
</DrawerPortal>
)
Expand All @@ -58,14 +59,14 @@ const ResourceAction: React.FC<Props> = (props) => {

return (
<>
<DrawerPortal width={action.containerWidth}>
<DrawerPortal width={action.containerWidth} data-css={routeActionCss}>
<BaseActionComponent
action={action}
resource={resource}
setTag={setTag}
/>
</DrawerPortal>
<Wrapper width={listAction.containerWidth}>
<Wrapper width={listAction.containerWidth} data-css={contentTag}>
<ActionHeader
resource={resource}
action={listAction}
Expand Down

0 comments on commit 4cefcd0

Please sign in to comment.