-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathMenuDangerousExample.js
More file actions
58 lines (53 loc) · 1.36 KB
/
MenuDangerousExample.js
File metadata and controls
58 lines (53 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import PropTypes from 'prop-types';
import { Notification } from 'grommet';
import { useState } from 'react';
import { DestructiveConfirmation } from '../../templates';
import { MenuMock } from './MenuMock';
export const MenuDangerousExample = ({ bestPractice = true }) => {
const [showModal, setShowModal] = useState(false);
const [toast, setToast] = useState(false);
const items = [
{ label: 'Edit' },
{ label: 'View servers' },
{
label: 'Delete',
onClick: () => {
if (bestPractice) setShowModal(true);
else setToast(true);
},
},
];
return (
<>
<MenuMock
label="Actions"
items={
bestPractice
? [items.slice(0, items.length - 1), items.slice(-1)]
: items
}
/>
{showModal && (
<DestructiveConfirmation
title="Delete server"
message={`This will permanently delete this server,
including all history, located at:`}
path="/servers/KCHDvfcByKvvjymNheg"
setShowModal={setShowModal}
setToast={setToast}
/>
)}
{toast && (
<Notification
toast
status="normal"
message="Server deleted."
onClose={() => setToast(false)}
/>
)}
</>
);
};
MenuDangerousExample.propTypes = {
bestPractice: PropTypes.bool,
};