General UI Fixes (#624)

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-07-07 00:03:28 -03:00 • committed by GitHub
commit 961c3d94c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 68 additions and 65 deletions

View file

@ -222,7 +222,7 @@ export default function ParameterComponent({
/> />
) : data.node.template[name].multiline ? ( ) : data.node.template[name].multiline ? (
<TextAreaComponent <TextAreaComponent
disabled={disabled} disabled={false}
value={data.node.template[name].value ?? ""} value={data.node.template[name].value ?? ""}
onChange={handleOnNewValue} onChange={handleOnNewValue}
/> />

View file

@ -16,6 +16,7 @@ import { NodeToolbar } from "reactflow";
import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent"; import NodeToolbarComponent from "../../pages/FlowPage/components/nodeToolbarComponent";
import ShadTooltip from "../../components/ShadTooltipComponent"; import ShadTooltip from "../../components/ShadTooltipComponent";
import { useSSE } from "../../contexts/SSEContext"; import { useSSE } from "../../contexts/SSEContext";
import { Zap } from "lucide-react";
export default function GenericNode({ export default function GenericNode({
data, data,
@ -117,7 +118,8 @@ export default function GenericNode({
<Tooltip <Tooltip
title={ title={
!validationStatus ? ( !validationStatus ? (
"Validating..." <span className="flex">Build <Zap className="mx-0.5 h-5 fill-build-trigger stroke-build-trigger stroke-1" strokeWidth={1.5} /> flow to validate status.</span>
) : ( ) : (
<div className="max-h-96 overflow-auto"> <div className="max-h-96 overflow-auto">
{validationStatus.params {validationStatus.params

View file

@ -2,7 +2,7 @@ import { useContext, useEffect, useState } from "react";
import { PopUpContext } from "../../contexts/popUpContext"; import { PopUpContext } from "../../contexts/popUpContext";
import { TextAreaComponentType } from "../../types/components"; import { TextAreaComponentType } from "../../types/components";
import GenericModal from "../../modals/genericModal"; import GenericModal from "../../modals/genericModal";
import { TypeModal } from "../../utils"; import { TypeModal, classNames } from "../../utils";
import { ExternalLink } from "lucide-react"; import { ExternalLink } from "lucide-react";
@ -30,34 +30,24 @@ export default function TextAreaComponent({
<div className={disabled ? "cursor-not-allowed" : ""}> <div className={disabled ? "cursor-not-allowed" : ""}>
<div <div
className={ className={
(editNode ? "w-full items-center" : "flex w-full items-center") + (editNode ? "w-full relative top-2" : "flex w-full items-center") +
(disabled ? " pointer-events-none" : "") (disabled ? " pointer-events-none" : "")
} }
> >
<span
onClick={() => { <input
openPopUp( value={myValue}
<GenericModal className={
type={TypeModal.TEXT} editNode
buttonText="Finishing Editing" ? "input-edit-node"
modalTitle="Edit Text" : "input-primary" + (disabled ? " input-disable " : "")
value={myValue} }
setValue={(t: string) => { placeholder={"Type something..."}
setMyValue(t); onChange={(e) => {
onChange(t); setMyValue(e.target.value);
}} onChange(e.target.value);
/> }}
); />
}}
className={
editNode
? "input-edit-node input-dialog "
: "input-dialog input-primary " +
(disabled ? "input-disable" : "")
}
>
{myValue !== "" ? myValue : "Type something..."}
</span>
<button <button
onClick={() => { onClick={() => {

View file

@ -529,4 +529,4 @@ export const USER_PROJECTS_HEADER = "My Collection";
* *
*/ */
export const HIGHLIGH_CSS = export const HIGHLIGH_CSS =
"block pl-3 pr-14 py-2 w-full h-full text-sm outline-0 border-0 break-all"; "block pl-3 pr-14 py-2 w-full h-full text-sm outline-0 border-0 break-all overflow-y-hidden max-w-[75vw]";

View file

@ -111,7 +111,9 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
startTweaks(); startTweaks();
} }
} else { } else {
startTweaks(); if(tweak?.current){
startTweaks();
}
} }
}, [closeEdit]); }, [closeEdit]);
@ -313,7 +315,7 @@ export default function ApiModal({ flow }: { flow: FlowType }) {
> >
{index < 3 ? ( {index < 3 ? (
<SyntaxHighlighter <SyntaxHighlighter
className="h-[60vh] w-full overflow-auto" className="h-[60vh] w-full overflow-auto custom-scroll"
language={tab.mode} language={tab.mode}
style={oneDark} style={oneDark}
> >

View file

@ -32,6 +32,7 @@ import {
import { Badge } from "../../components/ui/badge"; import { Badge } from "../../components/ui/badge";
import ShadTooltip from "../../components/ShadTooltipComponent"; import ShadTooltip from "../../components/ShadTooltipComponent";
import DOMPurify from "dompurify"; import DOMPurify from "dompurify";
import { Variable } from "lucide-react";
export default function GenericModal({ export default function GenericModal({
field_name = "", field_name = "",
@ -196,39 +197,6 @@ export default function GenericModal({
</DialogDescription> </DialogDescription>
</DialogHeader> </DialogHeader>
{type == TypeModal.PROMPT &&
inputValue &&
inputValue != "" &&
wordsHighlight.length > 0 && (
<>
<div>
<span className="">Variables: </span>
{wordsHighlight.map((word, index) => (
<ShadTooltip
key={getRandomKeyByssmm() + index}
content={word.replace(/[{}]/g, "")}
asChild={false}
delayDuration={1500}
>
<Badge
key={index}
size="lg"
className="m-1 max-w-[40vw] cursor-default truncate p-2.5 text-sm"
>
<div className="relative bottom-[1px]">
<span>
{word.replace(/[{}]/g, "").length > 59
? word.replace(/[{}]/g, "").slice(0, 56) + "..."
: word.replace(/[{}]/g, "")}
</span>
</div>
</Badge>
</ShadTooltip>
))}
</div>
</>
)}
<div <div
className={classNames( className={classNames(
!isEdit ? "rounded-lg border" : "", !isEdit ? "rounded-lg border" : "",
@ -238,7 +206,7 @@ export default function GenericModal({
{type == TypeModal.PROMPT && isEdit ? ( {type == TypeModal.PROMPT && isEdit ? (
<Textarea <Textarea
ref={ref} ref={ref}
className="form-input h-full w-full rounded-lg border-gray-300 focus-visible:ring-1 dark:border-gray-700 dark:bg-gray-900 dark:text-white" className="form-input h-full w-full rounded-lg border-gray-300 focus-visible:ring-1 dark:border-gray-700 dark:bg-gray-900 dark:text-white custom-scroll"
value={inputValue} value={inputValue}
onBlur={() => { onBlur={() => {
blur(); blur();
@ -268,6 +236,45 @@ export default function GenericModal({
)} )}
</div> </div>
{type == TypeModal.PROMPT && (
<>
<div className="">
<div className="items-center flex flex-wrap">
<Variable className=" -ml-px mr-1 h-4 w-4 text-primary flex"></Variable>
<span className="text-md font-semibold text-primary">
Input Variables: {wordsHighlight &&
wordsHighlight.length == 0 ? '-' : ''}
</span>
{wordsHighlight.map((word, index) => (
<ShadTooltip
key={getRandomKeyByssmm() + index}
content={word.replace(/[{}]/g, "")}
asChild={false}
delayDuration={1500}
>
<Badge
key={index}
variant="gray" size="md"
className="m-1 max-w-[40vw] cursor-default truncate p-2.5 text-sm"
>
<div className="relative bottom-[1px]">
<span>
{word.replace(/[{}]/g, "").length > 59
? word.replace(/[{}]/g, "").slice(0, 56) + "..."
: word.replace(/[{}]/g, "")}
</span>
</div>
</Badge>
</ShadTooltip>
))}
</div>
</div>
</>
)}
<DialogFooter> <DialogFooter>
<Button <Button
className="mt-3" className="mt-3"

View file

@ -1022,6 +1022,7 @@ export const INVALID_CHARACTERS = [
")", ")",
"[", "[",
"]", "]",
"\n"
]; ];
export const regexHighlight = /\{([^}]+)\}/g; export const regexHighlight = /\{([^}]+)\}/g;

View file

@ -199,6 +199,7 @@ module.exports = {
".custom-scroll": { ".custom-scroll": {
"&::-webkit-scrollbar": { "&::-webkit-scrollbar": {
width: "8px", width: "8px",
height: "8px"
}, },
"&::-webkit-scrollbar-track": { "&::-webkit-scrollbar-track": {
backgroundColor: "#f1f1f1", backgroundColor: "#f1f1f1",