mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
database ctx menu fixed
This commit is contained in:
parent
96e160f122
commit
952dbbf50c
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user