From 952dbbf50ce3200b45b62a39247fc5f43c7b4439 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sat, 16 May 2020 08:01:13 +0200 Subject: [PATCH] database ctx menu fixed --- packages/web/src/appobj/databaseAppObject.js | 31 ++++++++++++-------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/web/src/appobj/databaseAppObject.js b/packages/web/src/appobj/databaseAppObject.js index ba099cf3..1652810b 100644 --- a/packages/web/src/appobj/databaseAppObject.js +++ b/packages/web/src/appobj/databaseAppObject.js @@ -2,26 +2,33 @@ import React from 'react'; import _ from 'lodash'; import { DatabaseIcon } from '../icons'; import { DropDownMenuItem } from '../modals/DropDownMenu'; -import showModal from '../modals/showModal'; -import ConnectionModal from '../modals/ConnectionModal'; -import axios from '../utility/axios'; +import { openNewTab } from '../utility/common'; -function Menu({ data, makeAppObj }) { - const handleEdit = () => { - showModal(modalState => ); - }; - const handleDelete = () => { - axios.post('connections/delete', data); +function Menu({ data, setOpenedTabs }) { + const { connection, name } = data; + const tooltip = `${connection.displayName || connection.server}\n${name}`; + + const handleNewQuery = () => { + openNewTab(setOpenedTabs, { + title: 'Query', + icon: 'sql.svg', + tooltip, + tabComponent: 'QueryTab', + props: { + conid: connection._id, + database: name, + }, + }); }; + return ( <> - Edit - Delete + New query ); } -const databaseAppObject = flags => ({ name, connection }) => { +const databaseAppObject = (flags) => ({ name, connection }) => { const { boldCurrentDatabase } = flags || {}; const title = name; const key = name;