-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add PlaygroundButton component to flow toolbar (#4712)
* ✨ (playground-button.tsx): Add a new PlaygroundButton component to the flowToolbarComponent to handle the display of the Playground button based on the presence of Chat Input or Chat Output components. 📝 (index.tsx): Import and use the PlaygroundButton component in the FlowToolbar component to replace the previous implementation of the Playground button display. 🔧 (applies.css): Add styling for the playground-btn-flow-toolbar class to ensure consistent styling for the Playground button in the toolbar. * 📝 (playground-button.tsx): update import path for IOModal to point to the newModal file instead of the old one
- Loading branch information
1 parent
e208776
commit 5ed32cb
Showing
3 changed files
with
61 additions
and
32 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/frontend/src/components/flowToolbarComponent/components/playground-button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import ForwardedIconComponent from "@/components/genericIconComponent"; | ||
import ShadTooltip from "@/components/shadTooltipComponent"; | ||
import IOModal from "@/modals/IOModal/newModal"; | ||
|
||
const PlaygroundButton = ({ hasIO, open, setOpen, canvasOpen }) => { | ||
const PlayIcon = () => ( | ||
<ForwardedIconComponent name="Play" className="h-4 w-4 transition-all" /> | ||
); | ||
|
||
const ButtonLabel = () => <span className="hidden md:block">Playground</span>; | ||
|
||
const ActiveButton = () => ( | ||
<div | ||
data-testid="playground-btn-flow-io" | ||
className="playground-btn-flow-toolbar hover:bg-accent" | ||
> | ||
<PlayIcon /> | ||
<ButtonLabel /> | ||
</div> | ||
); | ||
|
||
const DisabledButton = () => ( | ||
<div | ||
className="playground-btn-flow-toolbar cursor-not-allowed text-muted-foreground duration-150" | ||
data-testid="playground-btn-flow" | ||
> | ||
<PlayIcon /> | ||
<ButtonLabel /> | ||
</div> | ||
); | ||
|
||
return hasIO ? ( | ||
<IOModal | ||
open={open} | ||
setOpen={setOpen} | ||
disable={!hasIO} | ||
canvasOpen={canvasOpen} | ||
> | ||
<ActiveButton /> | ||
</IOModal> | ||
) : ( | ||
<ShadTooltip content="Add a Chat Input or Chat Output to use the playground"> | ||
<div> | ||
<DisabledButton /> | ||
</div> | ||
</ShadTooltip> | ||
); | ||
}; | ||
|
||
export default PlaygroundButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters