-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathbitbucketDataCenterConnectionCreationForm.tsx
More file actions
48 lines (41 loc) · 1.73 KB
/
bitbucketDataCenterConnectionCreationForm.tsx
File metadata and controls
48 lines (41 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use client';
import SharedConnectionCreationForm from "./sharedConnectionCreationForm";
import { BitbucketConnectionConfig } from "@sourcebot/schemas/v3/connection.type";
import { bitbucketSchema } from "@sourcebot/schemas/v3/bitbucket.schema";
import { bitbucketDataCenterQuickActions } from "../../connections/quickActions";
interface BitbucketDataCenterConnectionCreationFormProps {
onCreated?: (id: number) => void;
}
const additionalConfigValidation = (config: BitbucketConnectionConfig): { message: string, isValid: boolean } => {
const hasProjects = config.projects && config.projects.length > 0 && config.projects.some(p => p.trim().length > 0);
const hasRepos = config.repos && config.repos.length > 0 && config.repos.some(r => r.trim().length > 0);
if (!hasProjects && !hasRepos) {
return {
message: "At least one project or repository must be specified",
isValid: false,
}
}
return {
message: "Valid",
isValid: true,
}
};
export const BitbucketDataCenterConnectionCreationForm = ({ onCreated }: BitbucketDataCenterConnectionCreationFormProps) => {
const defaultConfig: BitbucketConnectionConfig = {
type: 'bitbucket',
deploymentType: 'server',
}
return (
<SharedConnectionCreationForm<BitbucketConnectionConfig>
type="bitbucket-server"
title="Create a Bitbucket Data Center connection"
defaultValues={{
config: JSON.stringify(defaultConfig, null, 2),
}}
schema={bitbucketSchema}
additionalConfigValidation={additionalConfigValidation}
quickActions={bitbucketDataCenterQuickActions}
onCreated={onCreated}
/>
)
}