mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
rename files => tabs
This commit is contained in:
parent
82592bc565
commit
1059c1cbf2
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import './index.css';
|
||||
import Screen from './Screen';
|
||||
import { CurrentWidgetProvider, CurrentDatabaseProvider, OpenedFilesProvider } from './utility/globalState';
|
||||
import { CurrentWidgetProvider, CurrentDatabaseProvider, OpenedTabsProvider } from './utility/globalState';
|
||||
import { SocketProvider } from './utility/SocketProvider';
|
||||
|
||||
function App() {
|
||||
@ -9,9 +9,9 @@ function App() {
|
||||
<CurrentWidgetProvider>
|
||||
<CurrentDatabaseProvider>
|
||||
<SocketProvider>
|
||||
<OpenedFilesProvider>
|
||||
<OpenedTabsProvider>
|
||||
<Screen />
|
||||
</OpenedFilesProvider>
|
||||
</OpenedTabsProvider>
|
||||
</SocketProvider>
|
||||
</CurrentDatabaseProvider>
|
||||
</CurrentWidgetProvider>
|
||||
|
@ -3,7 +3,7 @@ import styled from 'styled-components';
|
||||
import theme from './theme';
|
||||
|
||||
import { TableIcon } from './icons';
|
||||
import { useOpenedFiles, useSetOpenedFiles } from './utility/globalState';
|
||||
import { useOpenedTabs, useSetOpenedTabs } from './utility/globalState';
|
||||
|
||||
// const files = [
|
||||
// { name: 'app.js' },
|
||||
@ -31,11 +31,11 @@ const FileNameWrapper = styled.span`
|
||||
`;
|
||||
|
||||
export default function FilesTabsPanel() {
|
||||
const files = useOpenedFiles();
|
||||
const setOpenedFiles = useSetOpenedFiles();
|
||||
const files = useOpenedTabs();
|
||||
const setOpenedTabs = useSetOpenedTabs();
|
||||
|
||||
const handleTabClick = id => {
|
||||
setOpenedFiles(files =>
|
||||
setOpenedTabs(files =>
|
||||
files.map(x => ({
|
||||
...x,
|
||||
selected: x.id == id,
|
||||
@ -44,7 +44,7 @@ export default function FilesTabsPanel() {
|
||||
};
|
||||
const handleMouseUp = (e, id) => {
|
||||
if (e.button == 1) {
|
||||
setOpenedFiles(files => files.filter(x => x.id != id));
|
||||
setOpenedTabs(files => files.filter(x => x.id != id));
|
||||
}
|
||||
};
|
||||
return (
|
||||
|
@ -2,12 +2,12 @@ import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { showMenu } from '../modals/DropDownMenu';
|
||||
import { AppObjectCore } from './AppObjects';
|
||||
import { useSetOpenedFiles } from '../utility/globalState';
|
||||
import { useSetOpenedTabs } from '../utility/globalState';
|
||||
|
||||
export function AppObjectList({ list, makeAppObj, SubItems = undefined, onObjectClick = undefined }) {
|
||||
const setOpenedFiles = useSetOpenedFiles();
|
||||
const setOpenedTabs = useSetOpenedTabs();
|
||||
return (list || []).map(x => {
|
||||
const appobj = makeAppObj(x, { setOpenedFiles });
|
||||
const appobj = makeAppObj(x, { setOpenedTabs });
|
||||
if (onObjectClick) appobj.onClick = onObjectClick;
|
||||
let res = <AppObjectCore key={appobj.key} data={x} makeAppObj={makeAppObj} {...appobj} />;
|
||||
if (SubItems) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { showMenu } from '../modals/DropDownMenu';
|
||||
import { useSetOpenedFiles } from '../utility/globalState';
|
||||
import { useSetOpenedTabs } from '../utility/globalState';
|
||||
|
||||
const AppObjectDiv = styled.div`
|
||||
padding: 5px;
|
||||
@ -35,7 +35,7 @@ export function AppObjectCore({ title, Icon, Menu, data, makeAppObj, onClick })
|
||||
}
|
||||
|
||||
export function AppObjectControl({ data, makeAppObj }) {
|
||||
const setOpenedFiles = useSetOpenedFiles();
|
||||
const appobj = makeAppObj(data, { setOpenedFiles });
|
||||
const setOpenedTabs = useSetOpenedTabs();
|
||||
const appobj = makeAppObj(data, { setOpenedTabs });
|
||||
return <AppObjectCore {...appobj} data={data} makeAppObj={makeAppObj} />;
|
||||
}
|
||||
|
@ -21,13 +21,13 @@ function Menu({ data, makeAppObj }) {
|
||||
);
|
||||
}
|
||||
|
||||
export default function tableAppObject({ pureName, schemaName }, { setOpenedFiles }) {
|
||||
export default function tableAppObject({ pureName, schemaName }, { setOpenedTabs }) {
|
||||
const title = schemaName ? `${schemaName}.${pureName}` : pureName;
|
||||
const key = title;
|
||||
const Icon = TableIcon;
|
||||
const onClick = ({ schemaName, pureName }) => {
|
||||
const id = uuidv1();
|
||||
setOpenedFiles(files => [...files, { id, name: pureName }]);
|
||||
setOpenedTabs(files => [...files, { id, name: pureName }]);
|
||||
};
|
||||
|
||||
return { title, key, Icon, Menu, onClick };
|
||||
|
@ -45,5 +45,5 @@ export { CurrentWidgetProvider, useCurrentWidget, useSetCurrentWidget };
|
||||
const [CurrentDatabaseProvider, useCurrentDatabase, useSetCurrentDatabase] = createGlobalState(null);
|
||||
export { CurrentDatabaseProvider, useCurrentDatabase, useSetCurrentDatabase };
|
||||
|
||||
const [OpenedFilesProvider, useOpenedFiles, useSetOpenedFiles] = createStorageState('openedFiles', []);
|
||||
export { OpenedFilesProvider, useOpenedFiles, useSetOpenedFiles };
|
||||
const [OpenedTabsProvider, useOpenedTabs, useSetOpenedTabs] = createStorageState('openedTabs', []);
|
||||
export { OpenedTabsProvider, useOpenedTabs, useSetOpenedTabs };
|
||||
|
Loading…
Reference in New Issue
Block a user