Thanks @sg-code it works for me
Using Strapi V4
in my code, there is src/admin/app.example.js, I renamed src/admin/app.js
after that it start works.
if there is no file inside src/admin, just create app.js and use this reference
const config = {
locales: [],
};
import { Button } from '@strapi/design-system'
import React from 'react';
const bootstrap = (app) => {
app.injectContentManagerComponent("listView", "actions", {
name: "CustomCreateButton",
Component: () => (
<Button
variant='secondary'>
Rebuild Website
</Button>
),
});
app.injectContentManagerComponent("listView", "actions", {
name: "CustomCreateButton",
Component: () => {
// Use useEffect to remove the original button
React.useEffect(() => {
const defaultButton = document.querySelector('[href$="/create"]'); // Find the default button
if (defaultButton) {
defaultButton.style.display = "none"; // Hide it
}
}, []); // Run this once when the component mounts
return (
<Button
variant="success"
onClick={() => {
// Custom action for creating a new entry
alert("Custom Create Entry Clicked!");
}}
>
Custom Create Entry
</Button>
);
},
});
app.injectContentManagerComponent("editView", "right-links", {
name: "TweetButton",
Component: () => (
<Button
variant='secondary'
>
Rebuild Website
</Button>
),
});
};
export default {
config,
bootstrap,
};