database ctx menu fixed

This commit is contained in:
Jan Prochazka 2020-05-16 08:01:13 +02:00
parent 96e160f122
commit 952dbbf50c

View File

@ -2,26 +2,33 @@ import React from 'react';
import _ from 'lodash'; import _ from 'lodash';
import { DatabaseIcon } from '../icons'; import { DatabaseIcon } from '../icons';
import { DropDownMenuItem } from '../modals/DropDownMenu'; import { DropDownMenuItem } from '../modals/DropDownMenu';
import showModal from '../modals/showModal'; import { openNewTab } from '../utility/common';
import ConnectionModal from '../modals/ConnectionModal';
import axios from '../utility/axios';
function Menu({ data, makeAppObj }) { function Menu({ data, setOpenedTabs }) {
const handleEdit = () => { const { connection, name } = data;
showModal(modalState => <ConnectionModal modalState={modalState} connection={data} />); const tooltip = `${connection.displayName || connection.server}\n${name}`;
};
const handleDelete = () => { const handleNewQuery = () => {
axios.post('connections/delete', data); openNewTab(setOpenedTabs, {
title: 'Query',
icon: 'sql.svg',
tooltip,
tabComponent: 'QueryTab',
props: {
conid: connection._id,
database: name,
},
});
}; };
return ( return (
<> <>
<DropDownMenuItem onClick={handleEdit}>Edit</DropDownMenuItem> <DropDownMenuItem onClick={handleNewQuery}>New query</DropDownMenuItem>
<DropDownMenuItem onClick={handleDelete}>Delete</DropDownMenuItem>
</> </>
); );
} }
const databaseAppObject = flags => ({ name, connection }) => { const databaseAppObject = (flags) => ({ name, connection }) => {
const { boldCurrentDatabase } = flags || {}; const { boldCurrentDatabase } = flags || {};
const title = name; const title = name;
const key = name; const key = name;