1.0.0 • Published 6 months ago

@dslab/ra-delete-dialog-button v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

React-Admin `Delete with confirm dialog

Version Documentation Maintenance License: MIT

Delete with confirm dialog for React-Admin, to render a nested field in the record to match as confirmation before performing deletion. Supports validation on user input match against resource id. Uses MUIv5 as ui library.

Install

yarn install @dslab/ra-delete-confirm

Usage

To use in an show/edit context, where the record is available, include the component as any other button in list or toolbar actions.

The list of optional parameters are

 confirmTitle="Resource title"
 mutationOptions="optional API query parameters"
 redirect="url to redirect after deletion"

The list could be implemented like the following.

export const AppList = () => {
    const params = useParams();
    const options = { meta: { realmId: params.realmId } };
    useListContext<any>();
    return (
        <>
            <List>
                <Datagrid bulkActionButtons={false}>
                    <DeleteButtonDialog
                        mutationOptions={options}
                        confirmTitle="Resource Deletion"
                        redirect={`/apps/r/${params.id}`}
                    />
                </Datagrid>
            </List>
        </>
    );
};

Screenshot for the resulting form

Form screenshot

Author

SmartCommunityLab

Show your support

Give a ⭐️ if this project helped you!

License

Copyright © 2023 SmartCommunityLab. This project is MIT licensed.

1.0.0

6 months ago