Skip to content

Commit 1558826

Browse files
authored
feat: Optimize canvas menu organization (#3145)
1 parent 244a343 commit 1558826

File tree

1 file changed

+48
-60
lines changed

1 file changed

+48
-60
lines changed

src/dashboard/Data/CustomDashboard/CustomDashboard.react.js

Lines changed: 48 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import DashboardView from 'dashboard/DashboardView.react';
1111
import EmptyState from 'components/EmptyState/EmptyState.react';
1212
import Icon from 'components/Icon/Icon.react';
1313
import Toolbar from 'components/Toolbar/Toolbar.react';
14+
import BrowserMenu from 'components/BrowserMenu/BrowserMenu.react';
15+
import MenuItem from 'components/BrowserMenu/MenuItem.react';
16+
import Separator from 'components/BrowserMenu/Separator.react';
1417
import CanvasElement from './CanvasElement.react';
1518
import AddElementDialog from './AddElementDialog.react';
1619
import SaveCanvasDialog from './SaveCanvasDialog.react';
@@ -1275,69 +1278,54 @@ class CustomDashboard extends DashboardView {
12751278

12761279
return (
12771280
<Toolbar section="Canvas" subsection={subsection}>
1278-
<a
1279-
className={styles.toolbarButton}
1280-
onClick={this.handleNewCanvas}
1281+
<BrowserMenu
1282+
title="Canvas"
1283+
icon="canvas-outline"
1284+
setCurrent={() => {}}
12811285
>
1282-
<Icon name="files-outline" width={14} height={14} />
1283-
<span>New</span>
1284-
</a>
1285-
<div className={styles.toolbarSeparator} />
1286-
<a
1287-
className={styles.toolbarButton}
1288-
onClick={() => this.setState({ showLoadDialog: true })}
1289-
>
1290-
<Icon name="folder-outline" width={14} height={14} />
1291-
<span>Load</span>
1292-
</a>
1293-
{hasElements && (
1294-
<>
1295-
<div className={styles.toolbarSeparator} />
1296-
<a
1297-
className={styles.toolbarButton}
1298-
onClick={() => this.setState({ showSaveDialog: true })}
1299-
>
1300-
<Icon name="download" width={14} height={14} />
1301-
<span>Save</span>
1302-
</a>
1303-
</>
1304-
)}
1286+
<MenuItem
1287+
text="New"
1288+
onClick={this.handleNewCanvas}
1289+
/>
1290+
<MenuItem
1291+
text="Load"
1292+
onClick={() => this.setState({ showLoadDialog: true })}
1293+
/>
1294+
<MenuItem
1295+
text="Save"
1296+
disabled={!hasElements}
1297+
onClick={() => this.setState({ showSaveDialog: true })}
1298+
/>
1299+
</BrowserMenu>
13051300
<div className={styles.toolbarSeparator} />
1306-
<a
1307-
className={styles.toolbarButton}
1308-
onClick={() => this.setState({ showAddDialog: true })}
1301+
<BrowserMenu
1302+
title="Element"
1303+
icon="files-outline"
1304+
setCurrent={() => {}}
13091305
>
1310-
<Icon name="plus-outline" width={14} height={14} />
1311-
<span>Add Element</span>
1312-
</a>
1313-
{selectedElement && (
1314-
<>
1315-
<div className={styles.toolbarSeparator} />
1316-
<a
1317-
className={styles.toolbarButton}
1318-
onClick={this.handleEditElement}
1319-
>
1320-
<Icon name="edit-solid" width={14} height={14} />
1321-
<span>Edit</span>
1322-
</a>
1323-
<div className={styles.toolbarSeparator} />
1324-
<a
1325-
className={styles.toolbarButton}
1326-
onClick={() => this.handleDuplicateElement(selectedElement)}
1327-
>
1328-
<Icon name="clone-icon" width={14} height={14} />
1329-
<span>Duplicate</span>
1330-
</a>
1331-
<div className={styles.toolbarSeparator} />
1332-
<a
1333-
className={styles.toolbarButton}
1334-
onClick={() => this.handleDeleteElement(selectedElement)}
1335-
>
1336-
<Icon name="trash-solid" width={14} height={14} />
1337-
<span>Delete</span>
1338-
</a>
1339-
</>
1340-
)}
1306+
<MenuItem
1307+
text="Add"
1308+
onClick={() => this.setState({ showAddDialog: true })}
1309+
/>
1310+
<MenuItem
1311+
text="Duplicate"
1312+
shortcut="⌘D"
1313+
disabled={!selectedElement}
1314+
onClick={() => this.handleDuplicateElement(selectedElement)}
1315+
/>
1316+
<MenuItem
1317+
text="Edit"
1318+
disabled={!selectedElement}
1319+
onClick={this.handleEditElement}
1320+
/>
1321+
<Separator />
1322+
<MenuItem
1323+
text="Delete"
1324+
shortcut="⌫"
1325+
disabled={!selectedElement}
1326+
onClick={() => this.handleDeleteElement(selectedElement)}
1327+
/>
1328+
</BrowserMenu>
13411329
{hasDataElements && (
13421330
<>
13431331
<div className={styles.toolbarSeparator} />

0 commit comments

Comments
 (0)