Feat: add shortcut to open flow Share modal
This commit is contained in:
parent
71525cfe47
commit
4fd9677fb6
1 changed files with 15 additions and 6 deletions
|
|
@ -13,25 +13,32 @@ import ForwardedIconComponent from "../genericIconComponent";
|
||||||
import { Separator } from "../ui/separator";
|
import { Separator } from "../ui/separator";
|
||||||
|
|
||||||
export default function FlowToolbar(): JSX.Element {
|
export default function FlowToolbar(): JSX.Element {
|
||||||
|
const preventDefault = true;
|
||||||
function handleAPIWShortcut(e: KeyboardEvent) {
|
function handleAPIWShortcut(e: KeyboardEvent) {
|
||||||
e.preventDefault();
|
|
||||||
setOpenCodeModal((oldOpen) => !oldOpen);
|
setOpenCodeModal((oldOpen) => !oldOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleChatWShortcut(e: KeyboardEvent) {
|
function handleChatWShortcut(e: KeyboardEvent) {
|
||||||
if (useFlowStore.getState().hasIO) {
|
if (useFlowStore.getState().hasIO) {
|
||||||
e.preventDefault();
|
|
||||||
setOpen((oldState) => !oldState);
|
setOpen((oldState) => !oldState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleShareWShortcut(e: KeyboardEvent) {
|
||||||
|
setOpenShareModal((oldState) => !oldState);
|
||||||
|
}
|
||||||
|
|
||||||
const openPlayground = useShortcutsStore((state) => state.open);
|
const openPlayground = useShortcutsStore((state) => state.open);
|
||||||
const api = useShortcutsStore((state) => state.api);
|
const api = useShortcutsStore((state) => state.api);
|
||||||
|
const share = useShortcutsStore((state) => state.share);
|
||||||
|
|
||||||
useHotkeys(openPlayground, handleChatWShortcut);
|
useHotkeys(openPlayground, handleChatWShortcut, { preventDefault });
|
||||||
useHotkeys(api, handleAPIWShortcut);
|
useHotkeys(api, handleAPIWShortcut, { preventDefault });
|
||||||
const [open, setOpen] = useState(false);
|
useHotkeys(share, handleShareWShortcut, { preventDefault });
|
||||||
|
|
||||||
|
const [open, setOpen] = useState<boolean>(false);
|
||||||
const [openCodeModal, setOpenCodeModal] = useState<boolean>(false);
|
const [openCodeModal, setOpenCodeModal] = useState<boolean>(false);
|
||||||
|
const [openShareModal, setOpenShareModal] = useState<boolean>(false);
|
||||||
|
|
||||||
const hasIO = useFlowStore((state) => state.hasIO);
|
const hasIO = useFlowStore((state) => state.hasIO);
|
||||||
const hasStore = useStoreStore((state) => state.hasStore);
|
const hasStore = useStoreStore((state) => state.hasStore);
|
||||||
|
|
@ -47,6 +54,8 @@ export default function FlowToolbar(): JSX.Element {
|
||||||
is_component={false}
|
is_component={false}
|
||||||
component={currentFlow!}
|
component={currentFlow!}
|
||||||
disabled={!hasApiKey || !validApiKey || !hasStore}
|
disabled={!hasApiKey || !validApiKey || !hasStore}
|
||||||
|
open={openShareModal}
|
||||||
|
setOpen={setOpen}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
disabled={!hasApiKey || !validApiKey || !hasStore}
|
disabled={!hasApiKey || !validApiKey || !hasStore}
|
||||||
|
|
@ -70,7 +79,7 @@ export default function FlowToolbar(): JSX.Element {
|
||||||
</button>
|
</button>
|
||||||
</ShareModal>
|
</ShareModal>
|
||||||
),
|
),
|
||||||
[hasApiKey, validApiKey, currentFlow, hasStore],
|
[hasApiKey, validApiKey, currentFlow, hasStore, openShareModal, setOpen],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue