Skip to content

Commit

Permalink
add open tab menu item to DB right click menu (#571)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
  • Loading branch information
MasterOdin authored Feb 23, 2021
1 parent e8744d3 commit bf73124
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/renderer/components/database-list-item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default class DatabaseListItem extends Component {
onSelectDatabase: PropTypes.func.isRequired,
onGetSQLScript: PropTypes.func.isRequired,
onRefreshDatabase: PropTypes.func.isRequired,
onOpenTab: PropTypes.func.isRequired,
onShowDiagramModal: PropTypes.func.isRequired,
}

Expand All @@ -67,6 +68,10 @@ export default class DatabaseListItem extends Component {
label: 'Refresh Database',
click: this.props.onRefreshDatabase.bind(this, nextProps.database),
}));
this.contextMenu.append(new MenuItem({
label: 'Open Tab',
click: this.props.onOpenTab.bind(this, nextProps.database),
}));
this.contextMenu.append(new MenuItem({
label: 'Show Database Diagram',
click: this.props.onShowDiagramModal.bind(this, nextProps.database),
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/components/database-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class DatabaseList extends Component {
onSelectTable: PropTypes.func.isRequired,
onGetSQLScript: PropTypes.func.isRequired,
onRefreshDatabase: PropTypes.func.isRequired,
onOpenTab: PropTypes.func.isRequired,
onShowDiagramModal: PropTypes.func.isRequired,
}

Expand Down Expand Up @@ -49,6 +50,7 @@ export default class DatabaseList extends Component {
onSelectDatabase,
onGetSQLScript,
onRefreshDatabase,
onOpenTab,
onShowDiagramModal,
currentDB,
} = this.props;
Expand Down Expand Up @@ -87,6 +89,7 @@ export default class DatabaseList extends Component {
onSelectDatabase={onSelectDatabase}
onGetSQLScript={onGetSQLScript}
onRefreshDatabase={onRefreshDatabase}
onOpenTab={onOpenTab}
onShowDiagramModal={onShowDiagramModal} />
))
}
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/containers/query-browser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class QueryBrowserContainer extends Component {
this.onSelectTable = this.onSelectTable.bind(this);
this.onGetSQLScript = this.onGetSQLScript.bind(this);
this.onRefreshDatabase = this.onRefreshDatabase.bind(this);
this.onOpenTab = this.onOpenTab.bind(this);
this.onShowDiagramModal = this.onShowDiagramModal.bind(this);
}

Expand Down Expand Up @@ -274,6 +275,11 @@ class QueryBrowserContainer extends Component {
dispatch(DbAction.refreshDatabase(database));
}

onOpenTab(database) {
const { dispatch } = this.props;
dispatch(QueryActions.newQuery(database.name));
}

onShowDiagramModal(database) {
const { dispatch } = this.props;
dispatch(DbAction.showDatabaseDiagram(database.name));
Expand Down Expand Up @@ -701,6 +707,7 @@ class QueryBrowserContainer extends Component {
onSelectTable={this.onSelectTable}
onGetSQLScript={this.onGetSQLScript}
onRefreshDatabase={this.onRefreshDatabase}
onOpenTab={this.onOpenTab}
onShowDiagramModal={this.onShowDiagramModal} />
</div>
</ResizableBox>
Expand Down

0 comments on commit bf73124

Please sign in to comment.