mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 10:46:00 +00:00
opened tabs widget
This commit is contained in:
22
packages/web/src/appobj/openedTabAppObject.js
Normal file
22
packages/web/src/appobj/openedTabAppObject.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import React from 'react';
|
||||
import _ from 'lodash';
|
||||
import { getIconImage } from '../icons';
|
||||
|
||||
const openedTabAppObject = () => ({ tabid, props, selected, icon, title }, { setOpenedTabs }) => {
|
||||
const key = tabid;
|
||||
const Icon = (props) => getIconImage(icon, props);
|
||||
const isBold = !!selected;
|
||||
|
||||
const onClick = () => {
|
||||
setOpenedTabs((files) =>
|
||||
files.map((x) => ({
|
||||
...x,
|
||||
selected: x.tabid == tabid,
|
||||
}))
|
||||
);
|
||||
};
|
||||
|
||||
return { title, key, Icon, isBold, onClick };
|
||||
};
|
||||
|
||||
export default openedTabAppObject;
|
||||
Reference in New Issue
Block a user