-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/validation in add new prompt studio (#60)
* Add validation in add new tool from prompt studio * Handle error validation for update API deployment
- Loading branch information
1 parent
22a0c58
commit 28f7e20
Showing
12 changed files
with
308 additions
and
181 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,54 @@ | ||
import { Image } from "antd"; | ||
import emojiRegex from "emoji-regex"; | ||
import PropTypes from "prop-types"; | ||
|
||
import "./ToolIcon.css"; | ||
import { useEffect, useState } from "react"; | ||
|
||
function ToolIcon({ iconSrc }) { | ||
const [svgDataUri, setSvgDataUri] = useState(""); | ||
useEffect(() => { | ||
if (!iconSrc) { | ||
setSvgDataUri(""); | ||
return; | ||
} | ||
function ToolIcon({ iconSrc, showBorder }) { | ||
const emojiregex = emojiRegex(); | ||
const isSVG = | ||
iconSrc && typeof iconSrc === "string" && iconSrc.includes("<svg"); | ||
|
||
if (isSVG) { | ||
// If it's an SVG, render it as an image | ||
const uri = `data:image/svg+xml,${encodeURIComponent(iconSrc)}`; | ||
setSvgDataUri(uri); | ||
}, [iconSrc]); | ||
return ( | ||
<div className="tool-icon-border display-flex-center"> | ||
<Image src={svgDataUri} preview={false} height={30} width={30} /> | ||
</div> | ||
); | ||
return ( | ||
<div | ||
className={`display-flex-center ${ | ||
showBorder ? "tool-icon-border" : "" | ||
}`} | ||
> | ||
<Image src={uri} preview={false} height={30} width={30} /> | ||
</div> | ||
); | ||
} else if (typeof iconSrc === "string" && emojiregex.test(iconSrc)) { | ||
// If it's a string, render it using Typography | ||
return ( | ||
<div | ||
className={`display-flex-center ${ | ||
showBorder ? "tool-icon-border" : "" | ||
}`} | ||
> | ||
{iconSrc} | ||
</div> | ||
); | ||
} else { | ||
// Handle other cases if needed | ||
return ( | ||
<div | ||
className={`display-flex-center ${ | ||
showBorder ? "tool-icon-border" : "" | ||
}`} | ||
> | ||
{"🧰"} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
ToolIcon.propTypes = { | ||
iconSrc: PropTypes.string, | ||
showBorder: PropTypes.bool, | ||
}; | ||
|
||
export { ToolIcon }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,9 @@ | |
|
||
.add-cus-tool-gap { | ||
margin-bottom: 16px; | ||
} | ||
} | ||
|
||
.emoji-modal .ant-modal-content { | ||
padding: 0; | ||
width: fit-content; | ||
} |
Oops, something went wrong.