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

feature: update flowToolbar under feature flag #5895

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
07d2f82
feat: Add ENABLE_PUBLISH feature flag
anovazzi1 Jan 23, 2025
99d8163
feat: Add Columns2 icon to nodeIconsLucide
anovazzi1 Jan 23, 2025
8abd14c
style: Add styles for deploy dropdown items
anovazzi1 Jan 23, 2025
a70a54b
feat: Add ENABLE_PUBLISH feature flag to constants.ts
anovazzi1 Jan 23, 2025
bf5ba25
refactor: Update playground button in flowToolbarComponent
anovazzi1 Jan 23, 2025
e7ac7d9
feat: Add deploy dropdown component to flowToolbarComponent
anovazzi1 Jan 23, 2025
8b318a8
feat: Add FlowToolbarOptions component
anovazzi1 Jan 23, 2025
e82424c
refactor: Update flowToolbarComponent with FlowToolbarOptions compone…
anovazzi1 Jan 23, 2025
b4620e5
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 23, 2025
578dc67
refactor: Update ENABLE_PUBLISH feature flag in feature-flags.ts
anovazzi1 Jan 23, 2025
55bea23
add external link for hover state
anovazzi1 Jan 23, 2025
4a60dae
Refactor deploy-dropdown.tsx to add ShadTooltipComponent and handle c…
anovazzi1 Jan 23, 2025
11d2718
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 23, 2025
1af59bf
Merge remote-tracking branch 'origin/main' into NewPublishMenu
anovazzi1 Jan 24, 2025
5070339
fix: remove feature flag for playground button name
anovazzi1 Jan 28, 2025
5769ed1
fix: rename DeployDropdown to PublishDropdown in FlowToolbarOptions
anovazzi1 Jan 28, 2025
482ab81
fix: rename DeployDropdown to PublishDropdown and update related func…
anovazzi1 Jan 28, 2025
4bf0a2c
fix: update classNames utility import and refactor class assignment i…
anovazzi1 Jan 28, 2025
b2be365
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 28, 2025
e1615ce
fix: enhance hover effects and accessibility in PublishDropdown compo…
anovazzi1 Jan 28, 2025
56fdd3e
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 28, 2025
1c44395
feat: add switch for publishing state in PublishDropdown component an…
anovazzi1 Feb 3, 2025
9528901
[autofix.ci] apply automated fixes
autofix-ci[bot] Feb 3, 2025
004f4a2
Merge branch 'main' into NewPublishMenu
ogabrielluiz Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import IconComponent from "@/components/common/genericIconComponent";
import ShadTooltipComponent from "@/components/common/shadTooltipComponent";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import useFlowsManagerStore from "@/stores/flowsManagerStore";
import useFlowStore from "@/stores/flowStore";

export default function DeployDropdown() {
const domain = window.location.origin;
const flowName = useFlowsManagerStore((state) => state.currentFlow?.name);
const hasIO = useFlowStore((state) => state.hasIO);
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="default" className="font-medium">
Deploy
<IconComponent name="ChevronDown" className="icon-size font-medium" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent
sideOffset={10}
alignOffset={-10}
align="end"
className="min-w-[300px] max-w-[400px]"
>
<ShadTooltipComponent
styleClasses="truncate"
side="left"
content={
hasIO
? `${domain}/${flowName}`
: "Add a Chat Input or Chat Output to deploy the playground"
}
>
<DropdownMenuItem className="deploy-dropdown-item text-nowrap">
<div
className={`group ${!hasIO ? "!important cursor-not-allowed text-muted-foreground" : ""}`}
>
<IconComponent name="Globe" className="icon-size mr-2" />
<a
className={`max-w-[80%] truncate ${!hasIO ? "cursor-not-allowed" : ""}`}
href={`${domain}/${flowName}`}
target="_blank"
rel="noreferrer"
onClick={(event) => {
if (!hasIO) {
event.preventDefault();
}
}}
>
{domain.replace(/^https?:\/\//, "")}/{flowName}
</a>
<div className="ml-auto w-[5%]">
<IconComponent
name="ExternalLink"
className="icon-size ml-auto opacity-0 group-hover:opacity-100"
/>
</div>
</div>
</DropdownMenuItem>
</ShadTooltipComponent>
<DropdownMenuItem className="deploy-dropdown-item group">
<div>
<IconComponent name="Code2" className="icon-size mr-2" />
<span>API access</span>
</div>
</DropdownMenuItem>
<DropdownMenuItem className="deploy-dropdown-item group">
<div>
<IconComponent name="Columns2" className="icon-size mr-2" />
<span>Embed into site</span>
</div>
</DropdownMenuItem>
<DropdownMenuItem className="deploy-dropdown-item group">
<div className="group">
<IconComponent name="FileCode2" className="icon-size mr-2" />
<span>Langflow SDK</span>
<IconComponent
name="ExternalLink"
className="icon-size ml-auto hidden group-hover:block"
/>
</div>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import useFlowStore from "@/stores/flowStore";
import { useState } from "react";
import DeployDropdown from "./deploy-dropdown";
import PlaygroundButton from "./playground-button";

export default function FlowToolbarOptions() {
const [open, setOpen] = useState<boolean>(false);
const hasIO = useFlowStore((state) => state.hasIO);

return (
<div className="flex items-center gap-1.5">
<div className="flex h-full w-full gap-1.5 rounded-sm transition-all">
<PlaygroundButton
hasIO={hasIO}
open={open}
setOpen={setOpen}
canvasOpen
/>
</div>
<DeployDropdown />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import ForwardedIconComponent from "@/components/common/genericIconComponent";
import ShadTooltip from "@/components/common/shadTooltipComponent";
import { PLAYGROUND_BUTTON_NAME } from "@/constants/constants";
import { ENABLE_PUBLISH } from "@/customization/feature-flags";
import IOModal from "@/modals/IOModal/new-modal";

const PlaygroundButton = ({ hasIO, open, setOpen, canvasOpen }) => {
const PlayIcon = () => (
<ForwardedIconComponent name="Play" className="h-4 w-4 transition-all" />
<ForwardedIconComponent
name="Play"
className="h-4 w-4 transition-all"
strokeWidth={ENABLE_PUBLISH ? 2 : 1.5}
/>
);

const ButtonLabel = () => <span className="hidden md:block">Playground</span>;
const ButtonLabel = () => (
<span className="hidden md:block">{PLAYGROUND_BUTTON_NAME}</span>
);

const ActiveButton = () => (
<div
Expand Down
106 changes: 56 additions & 50 deletions src/frontend/src/components/core/flowToolbarComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PlaygroundButton from "@/components/core/flowToolbarComponent/components/
import {
ENABLE_API,
ENABLE_LANGFLOW_STORE,
ENABLE_PUBLISH,
} from "@/customization/feature-flags";
import { track } from "@/customization/utils/analytics";
import { Panel } from "@xyflow/react";
Expand All @@ -15,6 +16,7 @@ import { useShortcutsStore } from "../../../stores/shortcuts";
import { useStoreStore } from "../../../stores/storeStore";
import { classNames, isThereModal } from "../../../utils/utils";
import ForwardedIconComponent from "../../common/genericIconComponent";
import FlowToolbarOptions from "./components/flow-toolbar-options";

export default function FlowToolbar(): JSX.Element {
const preventDefault = true;
Expand Down Expand Up @@ -123,58 +125,62 @@ export default function FlowToolbar(): JSX.Element {
"hover:shadow-round-btn-shadow flex items-center justify-center gap-7 rounded-md border bg-background p-1.5 shadow transition-all"
}
>
<div className="flex gap-1.5">
<div className="flex h-full w-full gap-1.5 rounded-sm transition-all">
<PlaygroundButton
hasIO={hasIO}
open={open}
setOpen={setOpen}
canvasOpen
/>
</div>
{ENABLE_API && (
<>
<div
className="flex cursor-pointer items-center gap-2"
data-testid="api_button_modal"
id="api_button_modal"
>
{currentFlow && currentFlow.data && (
<ApiModal
flow={currentFlow}
open={openCodeModal}
setOpen={setOpenCodeModal}
>
<div
className={classNames(
"relative inline-flex h-8 w-full items-center justify-center gap-1.5 rounded px-3 py-1.5 text-sm font-semibold text-foreground transition-all duration-150 ease-in-out hover:bg-accent",
)}
{ENABLE_PUBLISH ? (
<FlowToolbarOptions />
) : (
<div className="flex gap-1.5">
<div className="flex h-full w-full gap-1.5 rounded-sm transition-all">
<PlaygroundButton
hasIO={hasIO}
open={open}
setOpen={setOpen}
canvasOpen
/>
</div>
{ENABLE_API && (
<>
<div
className="flex cursor-pointer items-center gap-2"
data-testid="api_button_modal"
id="api_button_modal"
>
{currentFlow && currentFlow.data && (
<ApiModal
flow={currentFlow}
open={openCodeModal}
setOpen={setOpenCodeModal}
>
<ForwardedIconComponent
name="Code2"
className={"h-4 w-4"}
/>
<span className="hidden md:block">API</span>
</div>
</ApiModal>
)}
</div>
</>
)}
{ENABLE_LANGFLOW_STORE && (
<div className="flex items-center gap-2">
<div
className={`side-bar-button ${
!hasApiKey || !validApiKey || !hasStore
? "cursor-not-allowed"
: "cursor-pointer"
}`}
>
{ModalMemo}
<div
className={classNames(
"relative inline-flex h-8 w-full items-center justify-center gap-1.5 rounded px-3 py-1.5 text-sm font-semibold text-foreground transition-all duration-150 ease-in-out hover:bg-accent",
)}
>
<ForwardedIconComponent
name="Code2"
className={"h-4 w-4"}
/>
<span className="hidden md:block">API</span>
</div>
</ApiModal>
)}
</div>
</>
)}
{ENABLE_LANGFLOW_STORE && (
<div className="flex items-center gap-2">
<div
className={`side-bar-button ${
!hasApiKey || !validApiKey || !hasStore
? "cursor-not-allowed"
: "cursor-pointer"
}`}
>
{ModalMemo}
</div>
</div>
</div>
)}
</div>
)}
</div>
)}
</div>
</Panel>
</>
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/src/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// src/constants/constants.ts

import { ENABLE_PUBLISH } from "@/customization/feature-flags";
import custom from "../customization/config-constants";
import { languageMap } from "../types/components";

Expand Down Expand Up @@ -1005,3 +1006,5 @@ export const ICON_STROKE_WIDTH = 1.5;
export const DEFAULT_PLACEHOLDER = "Type something...";

export const DEFAULT_TOOLSET_PLACEHOLDER = "Used as a tool";

export const PLAYGROUND_BUTTON_NAME = ENABLE_PUBLISH ? "Test" : "Playground";
1 change: 1 addition & 0 deletions src/frontend/src/customization/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export const ENABLE_INTEGRATIONS = false;
export const ENABLE_NEW_LOGO = true;
export const ENABLE_DATASTAX_LANGFLOW = false;
export const ENABLE_HOMEPAGE = true;
export const ENABLE_PUBLISH = true;
8 changes: 8 additions & 0 deletions src/frontend/src/style/applies.css
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,14 @@
align-items: center;
}

.deploy-dropdown-item {
@apply px-2.5 py-2 hover:bg-background cursor-pointer font-normal text-[14px] !important;
}

.deploy-dropdown-item > :first-child {
@apply flex items-center hover:bg-accent w-full px-2 py-1.5 rounded-md !important;
}

:root {
--color-bg1: rgb(255, 255, 255);
--color1: 255, 50, 118;
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/src/utils/styleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
Code2,
CodeXml,
Cog,
Columns2,
Combine,
Command,
Compass,
Expand All @@ -80,6 +81,7 @@ import {
EyeOff,
File,
FileClock,
FileCode2,
FileDown,
FileQuestion,
FileSearch,
Expand Down Expand Up @@ -953,6 +955,8 @@ export const nodeIconsLucide: iconsType = {
ThumbDownIconCustom,
ThumbUpIconCustom,
Serper: SerperIcon,
FileCode2,
Columns2,
ScrapeGraphAI: ScrapeGraph,
ScrapeGraph: ScrapeGraph,
ScrapeGraphSmartScraperApi: ScrapeGraph,
Expand Down
Loading