-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* upgrade React Admin to v5 * fix post-upgrade type errors, prepare client-side search and filter, create Accept constant * post-upgrade: account for new rowClick defaults * refactor My(Show/Edit)Actions * fix crash on PostCreate
- Loading branch information
1 parent
e5f8001
commit b0c972d
Showing
31 changed files
with
200 additions
and
624 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import {FC} from 'react' | ||
import {ListButton, ShowButton, TopToolbar, useRecordContext, useResourceContext} from 'react-admin' | ||
import {ListButton, ShowButton, TopToolbar, useCreatePath, useRecordContext, useResourceContext} from 'react-admin' | ||
// eslint-disable-next-line node/no-extraneous-import | ||
import {useLocation} from 'react-router-dom' | ||
|
||
|
@@ -8,19 +8,20 @@ export const MyEditActions: FC = () => { | |
|
||
const resource = useResourceContext() | ||
const record = useRecordContext() | ||
const createPath = useCreatePath() | ||
|
||
// needed, undefined on first load | ||
if (!record) return null | ||
|
||
const currentPathWithoutTab = `/${resource}/${record.id}` // '/cms/post/123' | ||
let to = `${currentPathWithoutTab}/show` // '/cms/post/123/show' | ||
const currentPathWithoutTab = createPath({type: 'edit', resource, id: record.id}) // '/cms/post/123' | ||
const tabPart = pathname.slice(currentPathWithoutTab.length) // bud '' alebo '/1' | ||
if (tabPart) to = `${to}${tabPart}` // '/cms/post/123/show' alebo '/cms/post/123/show/1' | ||
const path = createPath({type: 'show', resource, id: record.id}) // '/cms/post/123/show' | ||
const to = `${path}${tabPart}` // '/cms/post/123/show' alebo '/cms/post/123/show/1' | ||
|
||
return ( | ||
<TopToolbar> | ||
{/* the `to` prop was omitted from ShowButton in recent RA version, but it's still working | ||
and RA doesn't provide better way to do this | ||
TODO: try again after RA upgrade */} | ||
{/* the `to` prop is omitted from ShowButtonProps, but it's still being spread to underlying button. | ||
we want to link to the specific show tab, not just resource show */} | ||
{/* @ts-ignore */} | ||
Check warning on line 25 in src/components/Admin/custom/MyEditActions.tsx GitHub Actions / branch-test
|
||
<ShowButton to={to} /> | ||
<ListButton label="Back to list" /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.