From 1f45d295a07ce961372f0de44c8b0780f615394f Mon Sep 17 00:00:00 2001 From: Ilango Date: Tue, 16 Apr 2024 17:06:11 +0530 Subject: [PATCH 1/4] Add a field for custom error message in allowed domains configuration --- .../ui-component/extended/AllowedDomains.jsx | 47 ++++++++++++++----- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/packages/ui/src/ui-component/extended/AllowedDomains.jsx b/packages/ui/src/ui-component/extended/AllowedDomains.jsx index 0f37785f9b7..04dcdab99ae 100644 --- a/packages/ui/src/ui-component/extended/AllowedDomains.jsx +++ b/packages/ui/src/ui-component/extended/AllowedDomains.jsx @@ -4,7 +4,7 @@ import PropTypes from 'prop-types' import { enqueueSnackbar as enqueueSnackbarAction, closeSnackbar as closeSnackbarAction, SET_CHATFLOW } from '@/store/actions' // material-ui -import { Button, IconButton, OutlinedInput, Box, List, InputAdornment } from '@mui/material' +import { Button, IconButton, OutlinedInput, Box, List, InputAdornment, Typography } from '@mui/material' import { IconX, IconTrash, IconPlus } from '@tabler/icons' // Project import @@ -25,6 +25,7 @@ const AllowedDomains = ({ dialogProps }) => { const closeSnackbar = (...args) => dispatch(closeSnackbarAction(...args)) const [inputFields, setInputFields] = useState(['']) + const [errorMessage, setErrorMessage] = useState('') const [chatbotConfig, setChatbotConfig] = useState({}) @@ -47,9 +48,12 @@ const AllowedDomains = ({ dialogProps }) => { const onSave = async () => { try { let value = { - allowedOrigins: [...inputFields] + allowedOrigins: [...inputFields], + allowedOriginsError: errorMessage } chatbotConfig.allowedOrigins = value.allowedOrigins + chatbotConfig.allowedOriginsError = value.allowedOriginsError + const saveResp = await chatflowsApi.updateChatflow(dialogProps.chatflow.id, { chatbotConfig: JSON.stringify(chatbotConfig) }) @@ -96,8 +100,14 @@ const AllowedDomains = ({ dialogProps }) => { } else { setInputFields(['']) } + if (chatbotConfig.allowedOriginsError) { + setErrorMessage(chatbotConfig.allowedOriginsError) + } else { + setErrorMessage('') + } } catch (e) { setInputFields(['']) + setErrorMessage('') } } @@ -106,15 +116,30 @@ const AllowedDomains = ({ dialogProps }) => { return ( <> -
- Your chatbot will only work when used from the following domains. -
- :not(style)': { m: 1 }, pt: 2 }}> + +
+ Error Message + { + setErrorMessage(e.target.value) + }} + /> +
+
+ + + Allowed Domains + Your chatbot will only work when used from the following domains. + {inputFields.map((origin, index) => { return ( From 582c2cdb9b34f871dd8c7dfb550d4bcdd7267412 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 19 Apr 2024 02:49:53 +0100 Subject: [PATCH 2/4] enhance UI for more consistency --- .../ui-component/extended/AllowedDomains.jsx | 49 ++++++++++++------- .../src/ui-component/extended/RateLimit.jsx | 9 ++-- .../ui-component/extended/SpeechToText.jsx | 4 +- .../ui/src/views/chatflows/ShareChatbot.jsx | 6 +++ 4 files changed, 45 insertions(+), 23 deletions(-) diff --git a/packages/ui/src/ui-component/extended/AllowedDomains.jsx b/packages/ui/src/ui-component/extended/AllowedDomains.jsx index 179738fca2a..4930623d2fe 100644 --- a/packages/ui/src/ui-component/extended/AllowedDomains.jsx +++ b/packages/ui/src/ui-component/extended/AllowedDomains.jsx @@ -9,6 +9,7 @@ import { IconX, IconTrash, IconPlus } from '@tabler/icons' // Project import import { StyledButton } from '@/ui-component/button/StyledButton' +import { TooltipWithParser } from '@/ui-component/tooltip/TooltipWithParser' // store import useNotifier from '@/utils/useNotifier' @@ -118,29 +119,20 @@ const AllowedDomains = ({ dialogProps }) => { return ( <> - -
- Error Message - { - setErrorMessage(e.target.value) - }} - /> -
-
- Allowed Domains - Your chatbot will only work when used from the following domains. + + Allowed Domains + + {inputFields.map((origin, index) => { @@ -155,6 +147,7 @@ const AllowedDomains = ({ dialogProps }) => { size='small' value={origin} name='origin' + placeholder='https://example.com' endAdornment={ {inputFields.length > 1 && ( @@ -185,6 +178,28 @@ const AllowedDomains = ({ dialogProps }) => { })} + +
+ + Error Message + + + { + setErrorMessage(e.target.value) + }} + /> +
+
Save diff --git a/packages/ui/src/ui-component/extended/RateLimit.jsx b/packages/ui/src/ui-component/extended/RateLimit.jsx index 3f47667c711..36e1a7b9099 100644 --- a/packages/ui/src/ui-component/extended/RateLimit.jsx +++ b/packages/ui/src/ui-component/extended/RateLimit.jsx @@ -7,6 +7,7 @@ import { Box, Typography, Button, OutlinedInput } from '@mui/material' // Project import import { StyledButton } from '@/ui-component/button/StyledButton' +import { TooltipWithParser } from '@/ui-component/tooltip/TooltipWithParser' // Icons import { IconX } from '@tabler/icons' @@ -16,7 +17,6 @@ import chatflowsApi from '@/api/chatflows' // utils import useNotifier from '@/utils/useNotifier' -import { TooltipWithParser } from '@/ui-component/tooltip/TooltipWithParser' const RateLimit = () => { const dispatch = useDispatch() @@ -117,6 +117,7 @@ const RateLimit = () => { value={message} placeholder={placeholder} name={fieldName} + size='small' onChange={(e) => { onTextChanged(e.target.value, fieldName) }} @@ -138,9 +139,9 @@ const RateLimit = () => { } /> - {textField(limitMax, 'limitMax', 'Message Limit per Duration', 'number')} - {textField(limitDuration, 'limitDuration', 'Duration in Second', 'number')} - {textField(limitMsg, 'limitMsg', 'Limit Message', 'string')} + {textField(limitMax, 'limitMax', 'Message Limit per Duration', 'number', '5')} + {textField(limitDuration, 'limitDuration', 'Duration in Second', 'number', '60')} + {textField(limitMsg, 'limitMsg', 'Limit Message', 'string', 'You have reached the quota')} onSave()}> Save Changes diff --git a/packages/ui/src/ui-component/extended/SpeechToText.jsx b/packages/ui/src/ui-component/extended/SpeechToText.jsx index 234840ff351..3c8fb674e0e 100644 --- a/packages/ui/src/ui-component/extended/SpeechToText.jsx +++ b/packages/ui/src/ui-component/extended/SpeechToText.jsx @@ -189,7 +189,7 @@ const SpeechToText = ({ dialogProps }) => { Providers - None OpenAI Whisper Assembly AI @@ -198,7 +198,7 @@ const SpeechToText = ({ dialogProps }) => {
{selectedProvider !== 'none' && ( <> - +
{ const [titleAvatarSrc, setTitleAvatarSrc] = useState(chatbotConfig?.titleAvatarSrc ?? '') const [welcomeMessage, setWelcomeMessage] = useState(chatbotConfig?.welcomeMessage ?? '') + const [errorMessage, setErrorMessage] = useState(chatbotConfig?.errorMessage ?? '') const [backgroundColor, setBackgroundColor] = useState(chatbotConfig?.backgroundColor ?? defaultConfig.backgroundColor) const [fontSize, setFontSize] = useState(chatbotConfig?.fontSize ?? defaultConfig.fontSize) const [poweredByTextColor, setPoweredByTextColor] = useState(chatbotConfig?.poweredByTextColor ?? defaultConfig.poweredByTextColor) @@ -114,6 +115,7 @@ const ShareChatbot = ({ isSessionMemory }) => { if (title) obj.title = title if (titleAvatarSrc) obj.titleAvatarSrc = titleAvatarSrc if (welcomeMessage) obj.welcomeMessage = welcomeMessage + if (errorMessage) obj.errorMessage = errorMessage if (backgroundColor) obj.backgroundColor = backgroundColor if (fontSize) obj.fontSize = fontSize if (poweredByTextColor) obj.poweredByTextColor = poweredByTextColor @@ -268,6 +270,9 @@ const ShareChatbot = ({ isSessionMemory }) => { case 'welcomeMessage': setWelcomeMessage(value) break + case 'errorMessage': + setErrorMessage(value) + break case 'fontSize': setFontSize(value) break @@ -417,6 +422,7 @@ const ShareChatbot = ({ isSessionMemory }) => { `https://raw.githubusercontent.com/FlowiseAI/Flowise/main/assets/FloWiseAI_dark.png` )} {textField(welcomeMessage, 'welcomeMessage', 'Welcome Message', 'string', 'Hello! This is custom welcome message')} + {textField(errorMessage, 'errorMessage', 'Error Message', 'string', 'This is custom error message')} {colorField(backgroundColor, 'backgroundColor', 'Background Color')} {textField(fontSize, 'fontSize', 'Font Size', 'number')} {colorField(poweredByTextColor, 'poweredByTextColor', 'PoweredBy TextColor')} From 88647f621395ef89bf5d8fee62b67c53cf5213d1 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 19 Apr 2024 02:57:58 +0100 Subject: [PATCH 3/4] update pnpm version --- .github/workflows/main.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6b6b6f48981..9333fe1f029 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v3 with: - version: 9.0.3 + version: ^9.0.3 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: diff --git a/package.json b/package.json index 238eb3b31ba..9c70f2b1901 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "turbo": "1.10.16", "typescript": "^4.8.4" }, - "packageManager": "pnpm@9.0.3", + "packageManager": "^pnpm@9.0.3", "pnpm": { "onlyBuiltDependencies": [ "faiss-node", From 91c5a51034cf81798b145964977c43a39f6c97cb Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 19 Apr 2024 03:02:25 +0100 Subject: [PATCH 4/4] update pnpm version --- .github/workflows/main.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9333fe1f029..485f5c2eb6c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v3 with: - version: ^9.0.3 + version: 9.0.4 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: diff --git a/package.json b/package.json index 9c70f2b1901..33471e385cf 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "turbo": "1.10.16", "typescript": "^4.8.4" }, - "packageManager": "^pnpm@9.0.3", + "packageManager": "pnpm@9.0.4", "pnpm": { "onlyBuiltDependencies": [ "faiss-node",