Pages publishing Button interaction #2788
Replies: 1 comment 5 replies
-
Hey @hoangtran74! This is definitely possible. For this type of customization I recommend creating a custom publish button. You can see the basics of how these are structured here. Here is an example that might point you in the right direction: import { useAuth } from 'payload/components/utilities';
import { CustomPublishButtonProps } from 'payload/types';
import * as React from 'react';
export const CustomPublishButton: CustomPublishButtonProps = ({ publish, label, disabled, DefaultButton }) => {
const { user } = useAuth();
const userRoles = Array.isArray(user?.role) ? user?.role : [user?.role];
if (userRoles.includes('admin')) {
return (
<DefaultButton
publish={publish}
label={label}
disabled={disabled}
/>
);
}
return null;
}; While this is a bit different than your use-case, I think the foundation is the same. I would imagine you using the |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I couldn't find any solutions or documentation anywhere, hoping someone can point me to the right direction.
Option 1: For example, in the Page component, I have an approver field with ties to a selection of drop-down options. At the page creation, it will be drafted, and would like the publishing button to be disabled unless the approver option is selected as "approved.
Options 2: Fetching the approving processed info from an external API, then using that info to enable or disable the publishing button.
Beta Was this translation helpful? Give feedback.
All reactions