Skip to content

Commit 5bcadd4

Browse files
mario99logicRonenMars
authored andcommitted
feat: azure bot connector
1 parent b84d6f4 commit 5bcadd4

File tree

16 files changed

+253
-1
lines changed

16 files changed

+253
-1
lines changed
Lines changed: 1 addition & 0 deletions
Loading

src/assets/image/icons/connections/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ export { default as LinearIcon } from "@assets/image/icons/connections/linear.sv
3737
export { default as SalesforceIcon } from "@assets/image/icons/connections/Salesforce.svg?react";
3838
// Taken from: https://www.svgrepo.com/svg/452111/teams
3939
export { default as MicrosoftTeamsIcon } from "@assets/image/icons/connections/MicrosoftTeams.svg?react";
40+
export { default as AzureBotIcon } from "@assets/image/icons/connections/AzureBot.svg?react";
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import React, { useEffect, useState } from "react";
2+
3+
import { useTranslation } from "react-i18next";
4+
5+
import { ConnectionAuthType } from "@enums";
6+
import { Integrations } from "@src/enums/components";
7+
import { useConnectionForm } from "@src/hooks";
8+
import { azureBotIntegrationSchema } from "@validations";
9+
10+
import { Button, ErrorMessage, Input, SecretInput, Spinner } from "@components/atoms";
11+
12+
export const AzureBotIntegrationAddForm = ({
13+
connectionId,
14+
triggerParentFormSubmit,
15+
type,
16+
}: {
17+
connectionId?: string;
18+
triggerParentFormSubmit: () => void;
19+
type: string;
20+
}) => {
21+
const { createConnection, errors, handleSubmit, isLoading, register, setValue } = useConnectionForm(
22+
azureBotIntegrationSchema,
23+
"create"
24+
);
25+
26+
const [lockState, setLockState] = useState({
27+
app_password: true,
28+
tenant_id: true,
29+
});
30+
31+
const handleLockAction = (fieldName: string, newLockState: boolean) => {
32+
setLockState((prev) => ({ ...prev, [fieldName]: newLockState }));
33+
};
34+
35+
const configureConnection = async (connectionId: string) => {
36+
await createConnection(connectionId, ConnectionAuthType.Initialized, Integrations.azurebot);
37+
};
38+
39+
useEffect(() => {
40+
setValue("auth_scopes", type);
41+
// eslint-disable-next-line react-hooks/exhaustive-deps
42+
}, [type]);
43+
44+
useEffect(() => {
45+
if (connectionId) {
46+
configureConnection(connectionId);
47+
}
48+
// eslint-disable-next-line react-hooks/exhaustive-deps
49+
}, [connectionId]);
50+
51+
const { t } = useTranslation("integrations");
52+
53+
return (
54+
<form className="mt-6 flex flex-col gap-6" onSubmit={handleSubmit(triggerParentFormSubmit)}>
55+
<div className="relative">
56+
<Input
57+
{...register("app_id")}
58+
aria-label={t("azurebot.placeholders.appId")}
59+
disabled={isLoading}
60+
isError={!!errors.app_id}
61+
isRequired
62+
label={t("azurebot.placeholders.appId")}
63+
/>
64+
<ErrorMessage>{errors.app_id?.message as string}</ErrorMessage>
65+
</div>
66+
67+
<div className="relative">
68+
<SecretInput
69+
{...register("app_password")}
70+
aria-label={t("azurebot.placeholders.appPassword")}
71+
disabled={isLoading}
72+
handleInputChange={(newValue) => setValue("app_password", newValue)}
73+
handleLockAction={(newLockState) => handleLockAction("app_password", newLockState)}
74+
isError={!!errors.app_password}
75+
isLocked={lockState.app_password}
76+
isRequired
77+
label={t("azurebot.placeholders.appPassword")}
78+
type="password"
79+
/>
80+
<ErrorMessage>{errors.app_password?.message as string}</ErrorMessage>
81+
</div>
82+
83+
<div className="relative">
84+
<SecretInput
85+
type="password"
86+
{...register("tenant_id")}
87+
aria-label={t("azurebot.placeholders.tenantId")}
88+
disabled={isLoading}
89+
handleInputChange={(newValue) => setValue("tenant_id", newValue)}
90+
handleLockAction={(newLockState) => handleLockAction("tenant_id", newLockState)}
91+
isError={!!errors.tenant_id}
92+
isLocked={lockState.tenant_id}
93+
isRequired
94+
label={t("azurebot.placeholders.tenantId")}
95+
/>
96+
<ErrorMessage>{errors.tenant_id?.message as string}</ErrorMessage>
97+
</div>
98+
99+
<Button
100+
aria-label={t("buttons.saveConnection")}
101+
className="ml-auto w-fit border-black bg-white px-3 font-medium hover:bg-gray-950 hover:text-white"
102+
type="submit"
103+
variant="outline"
104+
>
105+
{isLoading ? <Spinner /> : null}
106+
{t("buttons.saveConnection")}
107+
</Button>
108+
</form>
109+
);
110+
};
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import React, { useState } from "react";
2+
3+
import { useTranslation } from "react-i18next";
4+
5+
import { useConnectionForm } from "@src/hooks";
6+
import { azureBotIntegrationSchema } from "@validations";
7+
8+
import { Button, ErrorMessage, Input, SecretInput, Spinner } from "@components/atoms";
9+
10+
import { FloppyDiskIcon } from "@assets/image/icons";
11+
12+
const initialLockState: Record<string, boolean> = {
13+
app_password: true,
14+
tenant_id: true,
15+
};
16+
17+
export const AzureBotIntegrationEditForm = () => {
18+
const { t } = useTranslation("integrations");
19+
const [lockState, setLockState] = useState(initialLockState);
20+
21+
const { errors, handleSubmit, isLoading, onSubmitEdit, register, setValue } = useConnectionForm(
22+
azureBotIntegrationSchema,
23+
"edit"
24+
);
25+
26+
const handleLockAction = (fieldName: string, newLockState: boolean) => {
27+
setLockState((prev) => ({ ...prev, [fieldName]: newLockState }));
28+
};
29+
30+
// Removed useEffect to not pre-populate values - just show clean form with labels
31+
32+
return (
33+
<form className="flex flex-col gap-4" onSubmit={handleSubmit(onSubmitEdit)}>
34+
<div className="relative">
35+
<Input
36+
{...register("app_id")}
37+
aria-label={t("azurebot.placeholders.appId")}
38+
disabled={isLoading}
39+
isError={!!errors.app_id}
40+
isRequired
41+
label={t("azurebot.placeholders.appId")}
42+
/>
43+
<ErrorMessage>{errors.app_id?.message as string}</ErrorMessage>
44+
</div>
45+
46+
<div className="relative">
47+
<SecretInput
48+
type="password"
49+
{...register("app_password")}
50+
aria-label={t("azurebot.placeholders.appPassword")}
51+
disabled={isLoading}
52+
handleInputChange={(newValue) => setValue("app_password", newValue)}
53+
handleLockAction={(newLockState) => handleLockAction("app_password", newLockState)}
54+
isError={!!errors.app_password}
55+
isLocked={lockState.app_password}
56+
isRequired
57+
label={t("azurebot.placeholders.appPassword")}
58+
/>
59+
<ErrorMessage>{errors.app_password?.message as string}</ErrorMessage>
60+
</div>
61+
62+
<div className="relative">
63+
<SecretInput
64+
type="password"
65+
{...register("tenant_id")}
66+
aria-label={t("azurebot.placeholders.tenantId")}
67+
disabled={isLoading}
68+
handleInputChange={(newValue) => setValue("tenant_id", newValue)}
69+
handleLockAction={(newLockState) => handleLockAction("tenant_id", newLockState)}
70+
isError={!!errors.tenant_id}
71+
isLocked={lockState.tenant_id}
72+
isRequired
73+
label={t("azurebot.placeholders.tenantId")}
74+
/>
75+
<ErrorMessage>{errors.tenant_id?.message as string}</ErrorMessage>
76+
</div>
77+
78+
<Button
79+
aria-label={t("buttons.saveConnection")}
80+
className="ml-auto w-fit border-white px-3 font-medium text-white hover:bg-black"
81+
disabled={isLoading}
82+
type="submit"
83+
variant="outline"
84+
>
85+
{isLoading ? <Spinner /> : <FloppyDiskIcon className="size-5 fill-white transition" />}
86+
{t("buttons.saveConnection")}
87+
</Button>
88+
</form>
89+
);
90+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { AzureBotIntegrationAddForm } from "@components/organisms/connections/integrations/azurebot/add";
2+
export { AzureBotIntegrationEditForm } from "@components/organisms/connections/integrations/azurebot/edit";

src/components/organisms/connections/integrations/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,7 @@ export {
5858
SalesforceIntegrationAddForm,
5959
SalesforceIntegrationEditForm,
6060
} from "@components/organisms/connections/integrations/salesforce";
61+
export {
62+
AzureBotIntegrationAddForm,
63+
AzureBotIntegrationEditForm,
64+
} from "@components/organisms/connections/integrations/azurebot";

src/constants/connections/addComponentsMapping.constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
HeightIntegrationAddForm,
2323
ZoomIntegrationAddForm,
2424
SalesforceIntegrationAddForm,
25+
AzureBotIntegrationAddForm,
2526
} from "@components/organisms/connections/integrations";
2627
import { MicrosoftTeamsIntegrationAddForm } from "@components/organisms/connections/integrations/microsoft/teams";
2728

@@ -49,5 +50,6 @@ export const integrationAddFormComponents: Partial<Record<keyof typeof Integrati
4950
linear: LinearIntegrationAddForm,
5051
salesforce: SalesforceIntegrationAddForm,
5152
microsoft_teams: MicrosoftTeamsIntegrationAddForm,
53+
azurebot: AzureBotIntegrationAddForm,
5254
youtube: GoogleYoutubeIntegrationAddForm,
5355
};

src/constants/connections/editComponentsMapping.constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
ZoomIntegrationEditForm,
2222
LinearIntegrationEditForm,
2323
SalesforceIntegrationEditForm,
24+
AzureBotIntegrationEditForm,
2425
} from "@components/organisms/connections/integrations";
2526
import { MicrosoftTeamsIntegrationEditForm } from "@components/organisms/connections/integrations/microsoft/teams";
2627

@@ -48,4 +49,5 @@ export const integrationToEditComponent: Partial<Record<keyof typeof Integration
4849
[Integrations.linear]: LinearIntegrationEditForm,
4950
[Integrations.salesforce]: SalesforceIntegrationEditForm,
5051
[Integrations.microsoft_teams]: MicrosoftTeamsIntegrationEditForm,
52+
[Integrations.azurebot]: AzureBotIntegrationEditForm,
5153
};

src/constants/connections/integrationVariablesMapping.constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,9 @@ export const integrationVariablesMapping = {
102102
client_secret: "client_secret",
103103
tenant_id: "tenant_id",
104104
},
105+
[Integrations.azurebot]: {
106+
app_id: "app_id",
107+
app_password: "app_password",
108+
tenant_id: "tenant_id",
109+
},
105110
};

0 commit comments

Comments
 (0)