Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Implement Shortcut Settings Page #1830

Merged
merged 75 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
44e0328
Refactor: Use react-hotkeys-hook lib to handle shortcuts usability
igorrCarvalho Apr 11, 2024
23bcdce
Merge remote-tracking branch 'origin/dev' into node-shortcuts-refactor
ogabrielluiz Apr 12, 2024
489fc0d
Refactor: Use mod key instead of ctrl key to enable shortcuts to mac …
igorrCarvalho Apr 12, 2024
53f0388
Feat: add API Modal shortcut (ctrl+r)
igorrCarvalho Apr 17, 2024
58f78c3
Feat: make space open node code modal
igorrCarvalho Apr 19, 2024
a0a01ae
Feat: make possible to open node advanced settings by double clicking…
igorrCarvalho Apr 19, 2024
2818909
remove console.log
igorrCarvalho Apr 19, 2024
c550a1d
Refactor: Add all toolbar options into more
igorrCarvalho Apr 22, 2024
8ac6cdb
Feat: add shortcut to open flow share modal (ctrl+alt+s)
igorrCarvalho Apr 23, 2024
113b478
Feat: Add validation to avoid error when user doesnt have access to t…
igorrCarvalho Apr 23, 2024
cfff4e3
Fixed double click on description opening Settings modal
lucaseduoli Apr 29, 2024
1b3d62c
Merge remote-tracking branch 'origin/dev' into node-shortcuts-refactor
lucaseduoli Apr 29, 2024
dc5eebe
Fixed Code shortcut
lucaseduoli Apr 29, 2024
1497e86
Fixed PageComponent shortcuts not considering shift
lucaseduoli Apr 29, 2024
604e579
Feat: User can edit his keys combination for each shortcut
igorrCarvalho Apr 30, 2024
bc3d32b
Merge node-shortcuts-refactor into shortcuts_settings
igorrCarvalho Apr 30, 2024
edb2ff4
Fix: resolve merge conflicts
igorrCarvalho Apr 30, 2024
86fe906
Feat: User can change the node shortcuts
igorrCarvalho Apr 30, 2024
c37c782
Merge feature/ui_table into shortcuts_settings
igorrCarvalho May 1, 2024
c146a0c
Fix merge
igorrCarvalho May 1, 2024
76f3b82
Feat: User can customize all shortcuts
igorrCarvalho May 1, 2024
5bd9aba
Feat: Save user config in localStorage
igorrCarvalho May 2, 2024
61b894c
Feat: Add restore button to shortcuts settings
igorrCarvalho May 2, 2024
8967a26
Format code
igorrCarvalho May 2, 2024
2901580
Merge dev into shortcuts_settings
igorrCarvalho May 3, 2024
58cd138
Merge dev into shortcuts_settings
igorrCarvalho May 3, 2024
c6869c2
Refactor: Visual shortcut update with the settings configuration
igorrCarvalho May 3, 2024
b698ca3
Merge dev into shortcuts_settings
igorrCarvalho May 3, 2024
c2ae5e8
Refactor: Add the possibility to don't use ctrl/cmd
igorrCarvalho May 6, 2024
60dba48
Feat: make possible to change all nodes shortcuts
igorrCarvalho May 6, 2024
9466e06
Fix: Ctrl displaying as Control
igorrCarvalho May 6, 2024
5c6edc9
Merge dev into shortcuts_settings
igorrCarvalho May 8, 2024
ca30b11
Install react-hotkeys-hook
igorrCarvalho May 23, 2024
ec5d5f2
Merge dev into shortcuts_settings
igorrCarvalho May 23, 2024
0eb6f6b
Merge dev
igorrCarvalho May 29, 2024
126d4e1
Merge dev into shortcuts_settings
igorrCarvalho Jun 5, 2024
e531e36
Merge cz/mergeAll into shortcuts_settings
igorrCarvalho Jun 7, 2024
8c5f74e
Merge branch 'cz/mergeAll' into shortcuts_settings
igorrCarvalho Jun 7, 2024
5218e92
Refactor: add max page size
igorrCarvalho Jun 7, 2024
0d09ca2
Remove consolelog
igorrCarvalho Jun 7, 2024
1cfc3f4
Fix: Change Meta key to command for mac users
igorrCarvalho Jun 7, 2024
f2a8e0f
Refactor: Update destructive color in CSS
rodrigosnader Jun 8, 2024
9c88ed3
Refactor: retrieve shortcuts data directly in the store
igorrCarvalho Jun 8, 2024
a53180e
Refactor: Enable editing on double click and make changes in initial …
igorrCarvalho Jun 8, 2024
4b090d6
Refactor: add a name to shortcuts column
igorrCarvalho Jun 8, 2024
f5f5147
Refactor: Remove checkbox and pagination
igorrCarvalho Jun 8, 2024
6b10879
Refactor: change command for cmd
igorrCarvalho Jun 8, 2024
f4a8b31
Remove console.log
igorrCarvalho Jun 8, 2024
ce4550d
Refactor: put freeze inside more
igorrCarvalho Jun 8, 2024
04f6f33
Refactor: remove save and freeze from toolbar
igorrCarvalho Jun 8, 2024
a58f0b0
Refactor: Remove openWDoubleClick
igorrCarvalho Jun 8, 2024
a7187ff
Fix: using space in shortcuts table break the app
igorrCarvalho Jun 8, 2024
f970271
Refactor: Change button variant to default
igorrCarvalho Jun 8, 2024
fc47915
Refactor: add freeze to nodetoolbar
igorrCarvalho Jun 8, 2024
40e977c
Refactor: Improve code check to prevent bugs
igorrCarvalho Jun 9, 2024
90a8adc
Merge branch 'cz/mergeAll' into shortcuts_settings
ogabrielluiz Jun 9, 2024
e614787
Refactor: Remove unnecessary isMac prop from toolbarSelectItem compon…
ogabrielluiz Jun 9, 2024
b99a82e
Fix: shortcuts not saving properly
igorrCarvalho Jun 9, 2024
d372a8e
Fix: add panActivationKeyCode to reactFLow to prevent pan bugs
igorrCarvalho Jun 9, 2024
93ba523
Merge branch 'shortcuts_settings' of github.com:langflow-ai/langflow …
igorrCarvalho Jun 9, 2024
9d73489
Refactor: remove cache before saving shortcuts
igorrCarvalho Jun 9, 2024
3541101
Refactor: Use a single array of shortcuts to prevent bugs on MACOS
igorrCarvalho Jun 9, 2024
81a29da
Fix: API modal not opening with shortcut
igorrCarvalho Jun 9, 2024
71525cf
Remove console.log
igorrCarvalho Jun 9, 2024
4fd9677
Feat: add shortcut to open flow Share modal
igorrCarvalho Jun 9, 2024
a335bb7
Fix: place toolbar icons in the center of the toolbarItem
igorrCarvalho Jun 9, 2024
2bbf01d
Feat: add visual shortcuts to nodeToolbar tooltips
igorrCarvalho Jun 9, 2024
d14e13d
Feat: Add shortcut to open flow share modal
igorrCarvalho Jun 9, 2024
c59542d
Feat: add colorful padding to visual shortcut on toolbar
igorrCarvalho Jun 9, 2024
d07dec9
Add preventDefault to every shortcut call
igorrCarvalho Jun 9, 2024
4f80346
Feat: create isThereModal validate function to prevent modals from op…
igorrCarvalho Jun 9, 2024
63dec53
Refactor: Create modal_classes constant
igorrCarvalho Jun 9, 2024
5028f80
Refactor: Simplify isThereModal function
igorrCarvalho Jun 9, 2024
983e03d
Fix: modal leaving screen
igorrCarvalho Jun 10, 2024
75fa7c1
Fix: state not reseting properly
igorrCarvalho Jun 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/backend/base/langflow/base/memory/memory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from typing import Optional

from langflow.field_typing import Text
from langflow.helpers.record import records_to_text
from langflow.interface.custom.custom_component import CustomComponent
from langflow.schema.schema import Record

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from langchain_community.vectorstores import (
FAISS,
Chroma,
ElasticsearchStore,
MongoDBAtlasVectorSearch,
Pinecone,
Qdrant,
Expand Down
10 changes: 10 additions & 0 deletions src/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"react-cookie": "^4.1.1",
"react-dom": "^18.2.21",
"react-error-boundary": "^4.0.11",
"react-hotkeys-hook": "^4.5.0",
"react-icons": "^5.0.1",
"react-laag": "^2.0.5",
"react-markdown": "^8.0.7",
Expand Down
277 changes: 149 additions & 128 deletions src/frontend/src/components/ImageViewer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,141 +1,162 @@
import { saveAs } from "file-saver";
import OpenSeadragon from "openseadragon";
import { useEffect, useRef, useState } from "react";
import { IMGViewErrorMSG, IMGViewErrorTitle } from "../../constants/constants";
import useAlertStore from "../../stores/alertStore";
import ForwardedIconComponent from "../genericIconComponent";
import useFlowStore from "../../stores/flowStore";
import OpenSeadragon from 'openseadragon';
import { Separator } from "../ui/separator";
import { saveAs } from 'file-saver'
import useAlertStore from "../../stores/alertStore";
import { IMGViewErrorMSG, IMGViewErrorTitle } from "../../constants/constants";

export default function ImageViewer({image }) {
export default function ImageViewer({ image }) {
const viewerRef = useRef(null);
const [errorDownloading, setErrordownloading] = useState(false)
const setErrorList = useAlertStore(state => state.setErrorData);
const [errorDownloading, setErrordownloading] = useState(false);
const setErrorList = useAlertStore((state) => state.setErrorData);
const [initialMsg, setInicialMsg] = useState("Please build your flow");

useEffect(() => {
try {
if (viewerRef.current) {
// Initialize OpenSeadragon viewer
const viewer = OpenSeadragon({
element: viewerRef.current,
prefixUrl:
"https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.2/images/", // Optional: Set the path to OpenSeadragon images
tileSources: { type: "image", url: image },
defaultZoomLevel: 1,
maxZoomPixelRatio: 4,
showNavigationControl: false,
});
const zoomInButton = document.getElementById("zoom-in-button");
const zoomOutButton = document.getElementById("zoom-out-button");
const homeButton = document.getElementById("home-button");
const fullPageButton = document.getElementById("full-page-button");

zoomInButton!.addEventListener("click", () =>
viewer.viewport.zoomBy(1.2)
);
zoomOutButton!.addEventListener("click", () =>
viewer.viewport.zoomBy(0.8)
);
homeButton!.addEventListener("click", () => viewer.viewport.goHome());
fullPageButton!.addEventListener("click", () =>
viewer.setFullScreen(true)
);

useEffect(() => {
try {
if (viewerRef.current) {
// Initialize OpenSeadragon viewer
const viewer = OpenSeadragon({
element: viewerRef.current,
prefixUrl: 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.2/images/', // Optional: Set the path to OpenSeadragon images
tileSources: {type: 'image', url: image},
defaultZoomLevel: 1,
maxZoomPixelRatio: 4,
showNavigationControl: false,
});
const zoomInButton = document.getElementById('zoom-in-button');
const zoomOutButton = document.getElementById('zoom-out-button');
const homeButton = document.getElementById('home-button');
const fullPageButton = document.getElementById('full-page-button');

zoomInButton!.addEventListener('click', () => viewer.viewport.zoomBy(1.2));
zoomOutButton!.addEventListener('click', () => viewer.viewport.zoomBy(0.8));
homeButton!.addEventListener('click', () => viewer.viewport.goHome());
fullPageButton!.addEventListener('click', () => viewer.setFullScreen(true));

// Optionally, you can set additional viewer options here

// Cleanup function
return () => {
viewer.destroy();
zoomInButton!.removeEventListener('click', () => viewer.viewport.zoomBy(1.2));
zoomOutButton!.removeEventListener('click', () => viewer.viewport.zoomBy(0.8));
homeButton!.removeEventListener('click', () => viewer.viewport.goHome());
fullPageButton!.removeEventListener('click', () => viewer.setFullScreen(true));
};
}
} catch (error) {
console.error('Error initializing OpenSeadragon:', error);
}
}, [image]);
// Optionally, you can set additional viewer options here

function download() {
const imageUrl = image;
// Fetch the image data
fetch(imageUrl)
.then(response => response.blob())
.then(blob => {
// Save the image using FileSaver.js
saveAs(blob, 'image.jpg');
})
.catch(error => {
setErrorList({title: "There was an error downloading your image"})
console.error('Error downloading image:', error)
});
// Cleanup function
return () => {
viewer.destroy();
zoomInButton!.removeEventListener("click", () =>
viewer.viewport.zoomBy(1.2)
);
zoomOutButton!.removeEventListener("click", () =>
viewer.viewport.zoomBy(0.8)
);
homeButton!.removeEventListener("click", () =>
viewer.viewport.goHome()
);
fullPageButton!.removeEventListener("click", () =>
viewer.setFullScreen(true)
);
};
}
} catch (error) {
console.error("Error initializing OpenSeadragon:", error);
}
}, [image]);

return (
image === "" ? (
<div className="w-full h-full bg-muted rounded-md flex align-center justify-center flex-col gap-5 border border-border">
<div className="flex gap-2 align-center justify-center ">
<ForwardedIconComponent
name="Image"
/>
{IMGViewErrorTitle}
</div>
<div className="flex align-center justify-center">
<div className="langflow-chat-desc flex align-center justify-center">
<div className="langflow-chat-desc-span">
{IMGViewErrorMSG}
</div>
</div>
</div>
function download() {
const imageUrl = image;
// Fetch the image data
fetch(imageUrl)
.then((response) => response.blob())
.then((blob) => {
// Save the image using FileSaver.js
saveAs(blob, "image.jpg");
})
.catch((error) => {
setErrorList({ title: "There was an error downloading your image" });
console.error("Error downloading image:", error);
});
}

return image === "" ? (
<div className="align-center flex h-full w-full flex-col justify-center gap-5 rounded-md border border-border bg-muted">
<div className="align-center flex justify-center gap-2 ">
<ForwardedIconComponent name="Image" />
{IMGViewErrorTitle}
</div>
<div className="align-center flex justify-center">
<div className="langflow-chat-desc align-center flex justify-center">
<div className="langflow-chat-desc-span">{IMGViewErrorMSG}</div>
</div>
</div>
</div>
) : (
<>
<div className="align-center my-2 mb-4 flex w-full justify-center">
<div className="shadow-round-btn-shadow hover:shadow-round-btn-shadow flex w-[50%] items-center justify-center rounded-sm border bg-muted shadow-md transition-all">
<button
id="zoom-in-button"
className="relative inline-flex w-full w-full items-center justify-center px-3 py-3 text-sm font-semibold transition-all transition-all duration-500 ease-in-out ease-in-out hover:bg-hover"
>
<ForwardedIconComponent
name="ZoomIn"
className={"h-5 w-5 text-secondary-foreground"}
/>
</button>
<div>
<Separator orientation="vertical" />
</div>
<button
id="zoom-out-button"
className="relative inline-flex w-full items-center justify-center px-3 py-3 text-sm font-semibold transition-all transition-all duration-500 ease-in-out ease-in-out hover:bg-hover"
>
<ForwardedIconComponent
name="ZoomOut"
className={"h-5 w-5 text-secondary-foreground"}
/>
</button>
<div>
<Separator orientation="vertical" />
</div>
) : (
<>
<div className="w-full flex align-center justify-center my-2 mb-4">
<div className="shadow-round-btn-shadow hover:shadow-round-btn-shadow flex items-center justify-center rounded-sm border bg-muted shadow-md transition-all w-[50%]">
<button id="zoom-in-button" className="relative inline-flex w-full items-center justify-center px-3 py-3 text-sm font-semibold transition-all w-full transition-all duration-500 ease-in-out ease-in-out hover:bg-hover">
<ForwardedIconComponent
name="ZoomIn"
className={"text-secondary-foreground w-5 h-5"}
/>
</button>
<div>
<Separator orientation="vertical" />
</div>
<button id="zoom-out-button" className="relative inline-flex w-full items-center justify-center px-3 py-3 text-sm font-semibold transition-all transition-all duration-500 ease-in-out ease-in-out hover:bg-hover">
<ForwardedIconComponent
name="ZoomOut"
className={"text-secondary-foreground w-5 h-5"}
/>
</button>
<div>
<Separator orientation="vertical" />
</div>
<button id="home-button" className="relative inline-flex w-full items-center justify-center px-3 py-3 text-sm font-semibold transition-all transition-all duration-500 ease-in-out ease-in-out hover:bg-hover">
<ForwardedIconComponent
name="RotateCcw"
className={"text-secondary-foreground w-5 h-5"}
/>
</button>
<div>
<Separator orientation="vertical" />
</div>
<button id="full-page-button" className="relative inline-flex w-full items-center justify-center px-3 py-3 text-sm font-semibold transition-all transition-all duration-500 ease-in-out ease-in-out hover:bg-hover">
<ForwardedIconComponent
name="Maximize2"
className={"text-secondary-foreground w-5 h-5"}
/>
</button>
<div>
<Separator orientation="vertical" />
</div>

<button onClick={download} className="relative inline-flex w-full items-center justify-center px-3 py-3 text-sm font-semibold transition-all transition-all duration-500 ease-in-out ease-in-out hover:bg-hover">
<ForwardedIconComponent
name="ArrowDownToLine"
className={"text-secondary-foreground w-5 h-5"}
/>
</button>

</div>
<button
id="home-button"
className="relative inline-flex w-full items-center justify-center px-3 py-3 text-sm font-semibold transition-all transition-all duration-500 ease-in-out ease-in-out hover:bg-hover"
>
<ForwardedIconComponent
name="RotateCcw"
className={"h-5 w-5 text-secondary-foreground"}
/>
</button>
<div>
<Separator orientation="vertical" />
</div>
<div id="canvas" ref={viewerRef} className={`w-full h-[90%] `} />
</>
)
);
}
<button
id="full-page-button"
className="relative inline-flex w-full items-center justify-center px-3 py-3 text-sm font-semibold transition-all transition-all duration-500 ease-in-out ease-in-out hover:bg-hover"
>
<ForwardedIconComponent
name="Maximize2"
className={"h-5 w-5 text-secondary-foreground"}
/>
</button>
<div>
<Separator orientation="vertical" />
</div>

<button
onClick={download}
className="relative inline-flex w-full items-center justify-center px-3 py-3 text-sm font-semibold transition-all transition-all duration-500 ease-in-out ease-in-out hover:bg-hover"
>
<ForwardedIconComponent
name="ArrowDownToLine"
className={"h-5 w-5 text-secondary-foreground"}
/>
</button>
</div>
</div>
<div id="canvas" ref={viewerRef} className={`h-[90%] w-full `} />
</>
);
}