1 回答
TA贡献1898条经验 获得超8个赞
您需要使用 listManageActions
ui hook。这就是你如何做到这一点
// ./admin-ui/index.js // this file is automatically imported into admin-ui for hooks
import { UpdateItems, DeleteItems, useList } '@keystonejs/admin-ui/components'
import { useQuery, useMutation, useApolloClient } '@apollo/react-hooks'
const ExportCsvButton = () => {
const { list, selectedItems } = useList();
// your logic and react state hooks etc
// selectedItems contains array of item Ids which are selected, list is the list you are in.
const exportCsv = () => {
// your logic to retrieve the items and data for exporting or doing custom work
// you can use graphql to get
}
return (<Button onClick={() => exportCSV()}> Export CSV </Button>
}
export default {
// re-implement the default delete many and update many items buttons + custom Button
listManageActions: () => (<div><UpdateItems /><DeleteItems /><ExportCsvButton /></div>),
};
添加回答
举报