mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2025-06-15 13:36:35 +02:00
Replace RebootButton with ActionButtonWithModal component and update documentation
This commit is contained in:
39
src/common/ActionButtonWithModal/ActionButtonWithModal.md
Normal file
39
src/common/ActionButtonWithModal/ActionButtonWithModal.md
Normal file
@ -0,0 +1,39 @@
|
||||
RebootButton component is a button that opens a modal dialog to confirm the
|
||||
reboot of the device.
|
||||
|
||||
## Usage
|
||||
|
||||
```jsx
|
||||
import React, { useEffect, createContext } from "react";
|
||||
|
||||
import Button from "../../bootstrap/Button";
|
||||
import { AlertContextProvider } from "../../context/alertContext/AlertContext";
|
||||
import ActionButtonWithModal from "./ActionButtonWithModal";
|
||||
|
||||
window.AlertContext = React.createContext();
|
||||
|
||||
const RebootButtonExample = () => {
|
||||
const ActionButton = (props) => {
|
||||
return <Button {...props}>Action</Button>;
|
||||
};
|
||||
|
||||
return (
|
||||
<AlertContextProvider>
|
||||
<div id="modal-container" />
|
||||
<div id="alert-container" />
|
||||
<ActionButtonWithModal
|
||||
actionTrigger={ActionButton}
|
||||
actionUrl="/reforis/api/action"
|
||||
modalTitle="Warning!"
|
||||
modalMessage="Are you sure you want to perform this action?"
|
||||
modalActionText="Confirm action"
|
||||
modalActionProps={{ className: "btn-danger" }}
|
||||
successMessage="Action request succeeded."
|
||||
errorMessage="Action request failed."
|
||||
/>
|
||||
</AlertContextProvider>
|
||||
);
|
||||
};
|
||||
|
||||
<RebootButtonExample />;
|
||||
```
|
Reference in New Issue
Block a user