mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 00:16:00 +00:00
improved save file experience
This commit is contained in:
22
packages/web/src/utility/SaveFileToolbarButton.js
Normal file
22
packages/web/src/utility/SaveFileToolbarButton.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import React from 'react';
|
||||
import { DropDownMenuItem } from '../modals/DropDownMenu';
|
||||
import ToolbarButton, { ToolbarDropDownButton } from '../widgets/ToolbarButton';
|
||||
|
||||
export default function SaveFileToolbarButton({ tabid, save, saveAs }) {
|
||||
if (!saveAs) return null;
|
||||
|
||||
if (save) {
|
||||
return (
|
||||
<ToolbarDropDownButton icon="icon save" text="Save">
|
||||
<DropDownMenuItem onClick={save}>Save</DropDownMenuItem>
|
||||
<DropDownMenuItem onClick={saveAs}>Save As</DropDownMenuItem>
|
||||
</ToolbarDropDownButton>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ToolbarButton onClick={saveAs} icon="icon save">
|
||||
Save As
|
||||
</ToolbarButton>
|
||||
);
|
||||
}
|
||||
13
packages/web/src/utility/ToolbarPortal.js
Normal file
13
packages/web/src/utility/ToolbarPortal.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
export default function ToolbarPortal({ toolbarPortalRef, tabVisible, children }) {
|
||||
return (
|
||||
(toolbarPortalRef &&
|
||||
toolbarPortalRef.current &&
|
||||
tabVisible &&
|
||||
children &&
|
||||
ReactDOM.createPortal(children, toolbarPortalRef.current)) ||
|
||||
null
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user