-
Notifications
You must be signed in to change notification settings - Fork 558
/
Copy pathAddIntegrationModal.tsx
82 lines (73 loc) · 2.36 KB
/
AddIntegrationModal.tsx
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import React, { useState, useEffect } from "react";
import Modal from "components/Modal";
// @ts-ignore
import Dropdown from "components/forms/fields/Dropdown";
import CustomLink from "components/CustomLink";
import { IIntegration, IZendeskJiraIntegrations } from "interfaces/integration";
import IntegrationForm from "../IntegrationForm";
const baseClass = "add-integration-modal";
interface IAddIntegrationModalProps {
onCancel: () => void;
onSubmit: (
integrationSubmitData: IIntegration[],
integrationDestination: string
) => void;
serverErrors?: { base: string; email: string };
backendValidators: { [key: string]: string };
integrations: IZendeskJiraIntegrations;
testingConnection: boolean;
}
const destinationOptions = [
{ label: "Jira", value: "jira" },
{ label: "Zendesk", value: "zendesk" },
];
const AddIntegrationModal = ({
onCancel,
onSubmit,
backendValidators,
integrations,
testingConnection,
}: IAddIntegrationModalProps): JSX.Element => {
const [errors, setErrors] = useState<{ [key: string]: string }>(
backendValidators
);
const [destination, setDestination] = useState("jira");
const onDestinationChange = (value: string) => {
setDestination(value);
};
useEffect(() => {
setErrors(backendValidators);
}, [backendValidators]);
return (
<Modal title="Add integration" onExit={onCancel} className={baseClass}>
<div className="form">
{!testingConnection && (
<>
<Dropdown
label="Ticket destination"
name="destination"
onChange={onDestinationChange}
value={destination}
options={destinationOptions}
classname={`${baseClass}__destination-dropdown`}
wrapperClassName={`${baseClass}__form-field ${baseClass}__form-field--platform`}
/>
<CustomLink
url="https://github.com/fleetdm/fleet/issues/new?assignees=&labels=idea&template=feature-request.md&title="
text="Suggest a new destination"
newTab
/>
</>
)}
<IntegrationForm
onCancel={onCancel}
onSubmit={onSubmit}
integrations={integrations}
destination={destination}
testingConnection={testingConnection}
/>
</div>
</Modal>
);
};
export default AddIntegrationModal;