|
| 1 | +# Add extra checkboxes when publishing or submitting to community |
| 2 | + |
| 3 | +InvenioRDM allows you to customize the publish modal by adding extra checkboxes for user confirmation (e.g., terms of service, data policy). This is useful for compliance and custom workflows. |
| 4 | + |
| 5 | +## Define parameters to override |
| 6 | + |
| 7 | +You can override the default behavior of modals by customizing their parameters or injecting additional elements. |
| 8 | + |
| 9 | +### Define the extra checkbox fields (a list) using the extraCheckboxes parameter |
| 10 | + |
| 11 | +```javascript |
| 12 | +import { i18next } from "@translations/invenio_rdm_records/i18next"; |
| 13 | +import { PublishModal } from "@js/invenio_rdm_records"; |
| 14 | +import { parametrize } from "react-overridable"; |
| 15 | + |
| 16 | +export const parameters = { |
| 17 | + extraCheckboxes: [ |
| 18 | + { |
| 19 | + fieldPath: "acceptTermsOfService", |
| 20 | + text: i18next.t( |
| 21 | + "I confirm that this record complies with the data policy and terms of service." |
| 22 | + ), |
| 23 | + }, |
| 24 | + ], |
| 25 | +}; |
| 26 | + |
| 27 | +export const PublishModalComponent = parametrize(PublishModal, parameters); |
| 28 | +``` |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +### You can also inject extra UI elements before or after the checkboxes |
| 33 | + |
| 34 | +```javascript |
| 35 | +import { i18next } from "@translations/invenio_rdm_records/i18next"; |
| 36 | +import { SubmitReviewModal } from "@js/invenio_rdm_records"; |
| 37 | +import { parametrize } from "react-overridable"; |
| 38 | + |
| 39 | +const LegalDisclaimer = () => ( |
| 40 | + <> |
| 41 | + <p className="text-xs"> |
| 42 | + By publishing, you agree to our <a href="/terms" className="underline">terms of service</a>. |
| 43 | + </p> |
| 44 | + <p className="text-xs mt-1">This action is irreversible.</p> |
| 45 | + </> |
| 46 | +); |
| 47 | + |
| 48 | +export const parameters = { |
| 49 | + beforeContent: <p className="text-sm mb-2">Please review before continuing:</p>, |
| 50 | + afterContent: <LegalDisclaimer />, |
| 51 | +}; |
| 52 | + |
| 53 | +export const SubmitReviewModalComponent = parametrize(SubmitReviewModal, parameters); |
| 54 | +``` |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +#### Override the components in the overridableRegistry mapping |
| 59 | + |
| 60 | +```javascript |
| 61 | +export const overriddenComponents = { |
| 62 | + "InvenioRdmRecords.PublishModal.container": PublishModalComponent, |
| 63 | + "InvenioRdmRecords.SubmitReviewModal.container": SubmitReviewModalComponent, |
| 64 | +}; |
| 65 | +``` |
| 66 | + |
| 67 | +And then re-build the assets for the changes to take effect. |
| 68 | + |
| 69 | +```sh |
| 70 | +invenio-cli assets build |
| 71 | +``` |
| 72 | + |
0 commit comments