mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: added validation to cloud hostname field (#3523)
This commit is contained in:
parent
70172f8e3d
commit
f7803dab56
@ -7,6 +7,8 @@ import { Plus } from "lucide-react";
|
|||||||
import { useApplication, useProject } from "hooks/store";
|
import { useApplication, useProject } from "hooks/store";
|
||||||
// components
|
// components
|
||||||
import { CustomSelect, Input } from "@plane/ui";
|
import { CustomSelect, Input } from "@plane/ui";
|
||||||
|
// helpers
|
||||||
|
import { checkEmailValidity } from "helpers/string.helper";
|
||||||
// types
|
// types
|
||||||
import { IJiraImporterForm } from "@plane/types";
|
import { IJiraImporterForm } from "@plane/types";
|
||||||
|
|
||||||
@ -46,17 +48,18 @@ export const JiraGetImportDetail: React.FC = observer(() => {
|
|||||||
render={({ field: { value, onChange, ref } }) => (
|
render={({ field: { value, onChange, ref } }) => (
|
||||||
<Input
|
<Input
|
||||||
id="metadata.api_token"
|
id="metadata.api_token"
|
||||||
name="metadata.api_token"
|
|
||||||
type="text"
|
type="text"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
hasError={Boolean(errors.metadata?.api_token)}
|
||||||
placeholder="XXXXXXXX"
|
placeholder="XXXXXXXX"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
{errors.metadata?.api_token && <p className="text-red-500 text-xs">{errors.metadata.api_token.message}</p>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -75,7 +78,6 @@ export const JiraGetImportDetail: React.FC = observer(() => {
|
|||||||
render={({ field: { value, onChange, ref } }) => (
|
render={({ field: { value, onChange, ref } }) => (
|
||||||
<Input
|
<Input
|
||||||
id="metadata.project_key"
|
id="metadata.project_key"
|
||||||
name="metadata.project_key"
|
|
||||||
type="text"
|
type="text"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
@ -86,6 +88,9 @@ export const JiraGetImportDetail: React.FC = observer(() => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
{errors.metadata?.project_key && (
|
||||||
|
<p className="text-red-500 text-xs">{errors.metadata.project_key.message}</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -100,11 +105,11 @@ export const JiraGetImportDetail: React.FC = observer(() => {
|
|||||||
name="metadata.email"
|
name="metadata.email"
|
||||||
rules={{
|
rules={{
|
||||||
required: "Please enter email address.",
|
required: "Please enter email address.",
|
||||||
|
validate: (value) => checkEmailValidity(value) || "Please enter a valid email address",
|
||||||
}}
|
}}
|
||||||
render={({ field: { value, onChange, ref } }) => (
|
render={({ field: { value, onChange, ref } }) => (
|
||||||
<Input
|
<Input
|
||||||
id="metadata.email"
|
id="metadata.email"
|
||||||
name="metadata.email"
|
|
||||||
type="email"
|
type="email"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
@ -115,6 +120,7 @@ export const JiraGetImportDetail: React.FC = observer(() => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
{errors.metadata?.email && <p className="text-red-500 text-xs">{errors.metadata.email.message}</p>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -129,12 +135,11 @@ export const JiraGetImportDetail: React.FC = observer(() => {
|
|||||||
name="metadata.cloud_hostname"
|
name="metadata.cloud_hostname"
|
||||||
rules={{
|
rules={{
|
||||||
required: "Please enter your cloud host name.",
|
required: "Please enter your cloud host name.",
|
||||||
|
validate: (value) => !/^https?:\/\//.test(value) || "Hostname should not begin with http:// or https://",
|
||||||
}}
|
}}
|
||||||
render={({ field: { value, onChange, ref } }) => (
|
render={({ field: { value, onChange, ref } }) => (
|
||||||
<Input
|
<Input
|
||||||
id="metadata.cloud_hostname"
|
id="metadata.cloud_hostname"
|
||||||
name="metadata.cloud_hostname"
|
|
||||||
type="email"
|
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
@ -144,6 +149,9 @@ export const JiraGetImportDetail: React.FC = observer(() => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
{errors.metadata?.cloud_hostname && (
|
||||||
|
<p className="text-red-500 text-xs">{errors.metadata.cloud_hostname.message}</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user