From f3ce27d404b5380bff50b1621ba3811ce67062ae Mon Sep 17 00:00:00 2001 From: Timofey Boyko Date: Tue, 21 Nov 2023 09:57:18 +0300 Subject: [PATCH] Client:OAuth2: add errors for client form create --- packages/client/public/locales/en/OAuth.json | 3 + .../ClientForm/components/BasicBlock.tsx | 20 ++- .../ClientForm/components/InputGroup.tsx | 85 ++++++------ .../ClientForm/components/MultiInputGroup.tsx | 94 +++++++++----- .../ClientForm/components/OAuthBlock.tsx | 1 + .../ClientForm/components/SupportBlock.tsx | 15 ++- .../ClientForm/components/TextAreaGroup.tsx | 4 - .../OAuth/sub-components/ClientForm/index.tsx | 122 ++++++++++++++++++ 8 files changed, 249 insertions(+), 95 deletions(-) diff --git a/packages/client/public/locales/en/OAuth.json b/packages/client/public/locales/en/OAuth.json index 211f834a8b..397bd345ee 100644 --- a/packages/client/public/locales/en/OAuth.json +++ b/packages/client/public/locales/en/OAuth.json @@ -12,6 +12,8 @@ "ClientHelpButton": "Credentials for using OAth 2.0 as your Authentication type. Note: Any enterprise admin who knows the app's client ID will be able to retrieve information about the app including app name, authentication type, app scopes and redirect URI.", "EditApp": "Edit application", "EnterDescription": "Enter description", + "ErrorName": "Minimal name length:", + "ErrorWrongURL": "Wrong URL", "EnterURL": "Enter URL", "IconDescription": "JPG, PNG or SVG, 32x32", "ID": "ID", @@ -37,6 +39,7 @@ "RevokeConsentLogin": "If you want to renew an automatic login into {{name}} using ONLYOFFICE DocSpace, you will be asked to grant access to your DocSpace account data.", "RevokeConsentLoginGroup": "If you want to renew an automatic login using ONLYOFFICE DocSpace, you will be asked to grant access to your DocSpace account data.", "Secret": "Secret", + "SelectNewImage": "Select new image", "Scopes": "Scopes", "SignIn": "Sign in with DocSpace", "SupportAndLegalInfo": "Support & Legal info", diff --git a/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/ClientForm/components/BasicBlock.tsx b/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/ClientForm/components/BasicBlock.tsx index 00478cdb92..1069bacbc2 100644 --- a/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/ClientForm/components/BasicBlock.tsx +++ b/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/ClientForm/components/BasicBlock.tsx @@ -17,6 +17,7 @@ interface BasicBlockProps { changeValue: (name: string, value: string) => void; isEdit: boolean; + errorFields: string[]; } const BasicBlock = ({ @@ -28,14 +29,8 @@ const BasicBlock = ({ changeValue, isEdit, + errorFields, }: BasicBlockProps) => { - const [error, setError] = React.useState({ - name: "", - websiteUrl: "", - logo: "", - description: "", - }); - const onChange = (e: React.ChangeEvent) => { const target = e.target; @@ -67,22 +62,26 @@ const BasicBlock = ({ name={"name"} placeholder={t("Common:EnterName")} value={nameValue} - error={error.name} + error={`${t("ErrorName")} 3`} onChange={onChange} + isRequired + isError={errorFields.includes("name")} /> @@ -91,7 +90,6 @@ const BasicBlock = ({ name={"description"} placeholder={t("EnterDescription")} value={descriptionValue} - error={error.description} onChange={onChange} /> diff --git a/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/ClientForm/components/InputGroup.tsx b/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/ClientForm/components/InputGroup.tsx index e9432f8256..5a4498d191 100644 --- a/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/ClientForm/components/InputGroup.tsx +++ b/packages/client/src/pages/PortalSettings/categories/developer-tools/OAuth/sub-components/ClientForm/components/InputGroup.tsx @@ -5,6 +5,8 @@ import InputBlock from "@docspace/components/input-block"; import Button from "@docspace/components/button"; //@ts-ignore import HelpButton from "@docspace/components/help-button"; +//@ts-ignore +import FieldContainer from "@docspace/components/field-container"; import CopyReactSvgUrl from "PUBLIC_DIR/images/copy.react.svg?url"; @@ -35,6 +37,9 @@ interface InputGroupProps { isPassword?: boolean; disabled?: boolean; + isRequired?: boolean; + isError?: boolean; + children?: React.ReactNode; } const InputGroup = ({ @@ -57,48 +62,52 @@ const InputGroup = ({ onCopyClick, isPassword, disabled, + isRequired, + isError, + children, }: InputGroupProps) => { return ( - - - {label} - - {helpButtonText && } - - - - {buttonLabel && ( -