Files
payloadcms/test/access-control/TestButton.tsx
Paul 9c7e7ed8d4 fix(ui): custom buttons and e2e refresh permissions test (#5458)
* moved refresh permissions test suite to access control

* support for custom Save, SaveDraft and Publish buttons in admin config for collections and globals

* moved navigation content to client side so that permissions can be refreshed from active state
2024-03-26 11:48:00 -03:00

28 lines
635 B
TypeScript

'use client'
import { useForm } from '@payloadcms/ui/forms/Form'
import { useAuth } from '@payloadcms/ui/providers/Auth'
import { useTranslation } from '@payloadcms/ui/providers/Translation'
import React from 'react'
export const TestButton: React.FC = () => {
const { refreshPermissions } = useAuth()
const { submit } = useForm()
const { t } = useTranslation()
const label = t('general:save')
return (
<button
id="action-save"
onClick={(e) => {
e.preventDefault()
void refreshPermissions()
void submit()
}}
type="submit"
>
Custom: {label}
</button>
)
}