mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 01:33:59 +00:00
numbering tabs
This commit is contained in:
@@ -20,7 +20,7 @@ function Menu({ data }) {
|
|||||||
|
|
||||||
const handleNewQuery = () => {
|
const handleNewQuery = () => {
|
||||||
openNewTab({
|
openNewTab({
|
||||||
title: 'Query',
|
title: 'Query #',
|
||||||
icon: 'img sql-file',
|
icon: 'img sql-file',
|
||||||
tooltip,
|
tooltip,
|
||||||
tabComponent: 'QueryTab',
|
tabComponent: 'QueryTab',
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export function SavedSqlFileAppObject({ data, commonProps }) {
|
|||||||
|
|
||||||
openNewTab(
|
openNewTab(
|
||||||
{
|
{
|
||||||
title: 'Shell',
|
title: 'Shell #',
|
||||||
icon: 'img shell',
|
icon: 'img shell',
|
||||||
tabComponent: 'ShellTab',
|
tabComponent: 'ShellTab',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ export default function DataGridCore(props) {
|
|||||||
const handleOpenFreeTable = () => {
|
const handleOpenFreeTable = () => {
|
||||||
openNewTab(
|
openNewTab(
|
||||||
{
|
{
|
||||||
title: 'selection',
|
title: 'Data #',
|
||||||
icon: 'img free-table',
|
icon: 'img free-table',
|
||||||
tabComponent: 'FreeTableTab',
|
tabComponent: 'FreeTableTab',
|
||||||
props: {},
|
props: {},
|
||||||
@@ -365,7 +365,7 @@ export default function DataGridCore(props) {
|
|||||||
const handleOpenChart = () => {
|
const handleOpenChart = () => {
|
||||||
openNewTab(
|
openNewTab(
|
||||||
{
|
{
|
||||||
title: 'Chart',
|
title: 'Chart #',
|
||||||
icon: 'img chart',
|
icon: 'img chart',
|
||||||
tabComponent: 'ChartTab',
|
tabComponent: 'ChartTab',
|
||||||
props: {},
|
props: {},
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export default function SqlDataGridCore(props) {
|
|||||||
function openActiveChart() {
|
function openActiveChart() {
|
||||||
openNewTab(
|
openNewTab(
|
||||||
{
|
{
|
||||||
title: 'Chart',
|
title: 'Chart #',
|
||||||
icon: 'img chart',
|
icon: 'img chart',
|
||||||
tabComponent: 'ChartTab',
|
tabComponent: 'ChartTab',
|
||||||
props: {
|
props: {
|
||||||
@@ -104,7 +104,7 @@ export default function SqlDataGridCore(props) {
|
|||||||
function openQuery() {
|
function openQuery() {
|
||||||
openNewTab(
|
openNewTab(
|
||||||
{
|
{
|
||||||
title: 'Query',
|
title: 'Query #',
|
||||||
icon: 'img sql-file',
|
icon: 'img sql-file',
|
||||||
tabComponent: 'QueryTab',
|
tabComponent: 'QueryTab',
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export default function useNewFreeTable() {
|
|||||||
|
|
||||||
return ({ title = undefined, ...props } = {}) =>
|
return ({ title = undefined, ...props } = {}) =>
|
||||||
openNewTab({
|
openNewTab({
|
||||||
title: title || 'Table',
|
title: title || 'Data #',
|
||||||
icon: 'img free-table',
|
icon: 'img free-table',
|
||||||
tabComponent: 'FreeTableTab',
|
tabComponent: 'FreeTableTab',
|
||||||
props,
|
props,
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ function GenerateSctriptButton({ modalState }) {
|
|||||||
const code = await createImpExpScript(extensions, values);
|
const code = await createImpExpScript(extensions, values);
|
||||||
openNewTab(
|
openNewTab(
|
||||||
{
|
{
|
||||||
title: 'Shell',
|
title: 'Shell #',
|
||||||
icon: 'img shell',
|
icon: 'img shell',
|
||||||
tabComponent: 'ShellTab',
|
tabComponent: 'ShellTab',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default function useNewQuery() {
|
|||||||
return ({ title = undefined, initialData = undefined, ...props } = {}) =>
|
return ({ title = undefined, initialData = undefined, ...props } = {}) =>
|
||||||
openNewTab(
|
openNewTab(
|
||||||
{
|
{
|
||||||
title: title || 'Query',
|
title: title || 'Query #',
|
||||||
icon: 'img sql-file',
|
icon: 'img sql-file',
|
||||||
tooltip,
|
tooltip,
|
||||||
tabComponent: 'QueryTab',
|
tabComponent: 'QueryTab',
|
||||||
@@ -40,7 +40,7 @@ export function useNewQueryDesign() {
|
|||||||
return ({ title = undefined, initialData = undefined, ...props } = {}) =>
|
return ({ title = undefined, initialData = undefined, ...props } = {}) =>
|
||||||
openNewTab(
|
openNewTab(
|
||||||
{
|
{
|
||||||
title: title || 'Query',
|
title: title || 'Query #',
|
||||||
icon: 'img query-design',
|
icon: 'img query-design',
|
||||||
tooltip,
|
tooltip,
|
||||||
tabComponent: 'QueryDesignTab',
|
tabComponent: 'QueryDesignTab',
|
||||||
|
|||||||
@@ -42,6 +42,15 @@ export default function useOpenNewTab() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// new tab will be created
|
||||||
|
if (newTab.title.endsWith('#')) {
|
||||||
|
const numbers = openedTabs
|
||||||
|
.filter(x => x.title && x.title.startsWith(newTab.title))
|
||||||
|
.map(x => parseInt(x.title.substring(newTab.title.length)));
|
||||||
|
|
||||||
|
newTab.title = `${newTab.title}${numbers.length > 0 ? _.max(numbers) + 1 : 1}`;
|
||||||
|
}
|
||||||
|
|
||||||
const tabid = uuidv1();
|
const tabid = uuidv1();
|
||||||
if (initialData) {
|
if (initialData) {
|
||||||
for (const key of _.keys(initialData)) {
|
for (const key of _.keys(initialData)) {
|
||||||
@@ -61,7 +70,7 @@ export default function useOpenNewTab() {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
[setOpenedTabs]
|
[setOpenedTabs, openedTabs]
|
||||||
);
|
);
|
||||||
|
|
||||||
return openNewTab;
|
return openNewTab;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export default function ToolBar({ toolbarPortalRef }) {
|
|||||||
|
|
||||||
const newMarkdown = () => {
|
const newMarkdown = () => {
|
||||||
openNewTab({
|
openNewTab({
|
||||||
title: 'Page',
|
title: 'Page #',
|
||||||
tabComponent: 'MarkdownEditorTab',
|
tabComponent: 'MarkdownEditorTab',
|
||||||
icon: 'img markdown',
|
icon: 'img markdown',
|
||||||
});
|
});
|
||||||
@@ -103,7 +103,7 @@ export default function ToolBar({ toolbarPortalRef }) {
|
|||||||
|
|
||||||
const newShell = () => {
|
const newShell = () => {
|
||||||
openNewTab({
|
openNewTab({
|
||||||
title: 'Shell',
|
title: 'Shell #',
|
||||||
icon: 'img shell',
|
icon: 'img shell',
|
||||||
tabComponent: 'ShellTab',
|
tabComponent: 'ShellTab',
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user