-
Notifications
You must be signed in to change notification settings - Fork 2
feat: azure bot connector #1285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mario99logic
wants to merge
1
commit into
main
Choose a base branch
from
mario/ui-1760_azure_bot
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule autokitteh
updated
31 files
110 changes: 110 additions & 0 deletions
110
src/components/organisms/connections/integrations/azurebot/add.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| import React, { useEffect, useState } from "react"; | ||
|
|
||
| import { useTranslation } from "react-i18next"; | ||
|
|
||
| import { ConnectionAuthType } from "@enums"; | ||
| import { Integrations } from "@src/enums/components"; | ||
| import { useConnectionForm } from "@src/hooks"; | ||
| import { azureBotIntegrationSchema } from "@validations"; | ||
|
|
||
| import { Button, ErrorMessage, Input, SecretInput, Spinner } from "@components/atoms"; | ||
|
|
||
| export const AzureBotIntegrationAddForm = ({ | ||
| connectionId, | ||
| triggerParentFormSubmit, | ||
| type, | ||
| }: { | ||
| connectionId?: string; | ||
| triggerParentFormSubmit: () => void; | ||
| type: string; | ||
| }) => { | ||
| const { createConnection, errors, handleSubmit, isLoading, register, setValue } = useConnectionForm( | ||
| azureBotIntegrationSchema, | ||
| "create" | ||
| ); | ||
|
|
||
| const [lockState, setLockState] = useState({ | ||
| app_password: true, | ||
| tenant_id: true, | ||
| }); | ||
|
|
||
| const handleLockAction = (fieldName: string, newLockState: boolean) => { | ||
| setLockState((prev) => ({ ...prev, [fieldName]: newLockState })); | ||
| }; | ||
|
|
||
| const configureConnection = async (connectionId: string) => { | ||
| await createConnection(connectionId, ConnectionAuthType.Initialized, Integrations.azurebot); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| setValue("auth_scopes", type); | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, [type]); | ||
|
|
||
| useEffect(() => { | ||
| if (connectionId) { | ||
| configureConnection(connectionId); | ||
| } | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, [connectionId]); | ||
|
|
||
| const { t } = useTranslation("integrations"); | ||
|
|
||
| return ( | ||
| <form className="mt-6 flex flex-col gap-6" onSubmit={handleSubmit(triggerParentFormSubmit)}> | ||
| <div className="relative"> | ||
| <Input | ||
| {...register("app_id")} | ||
| aria-label={t("azurebot.placeholders.appId")} | ||
| disabled={isLoading} | ||
| isError={!!errors.app_id} | ||
| isRequired | ||
| label={t("azurebot.placeholders.appId")} | ||
| /> | ||
| <ErrorMessage>{errors.app_id?.message as string}</ErrorMessage> | ||
| </div> | ||
|
|
||
| <div className="relative"> | ||
| <SecretInput | ||
| {...register("app_password")} | ||
| aria-label={t("azurebot.placeholders.appPassword")} | ||
| disabled={isLoading} | ||
| handleInputChange={(newValue) => setValue("app_password", newValue)} | ||
| handleLockAction={(newLockState) => handleLockAction("app_password", newLockState)} | ||
| isError={!!errors.app_password} | ||
| isLocked={lockState.app_password} | ||
| isRequired | ||
| label={t("azurebot.placeholders.appPassword")} | ||
| type="password" | ||
| /> | ||
| <ErrorMessage>{errors.app_password?.message as string}</ErrorMessage> | ||
| </div> | ||
|
|
||
| <div className="relative"> | ||
| <SecretInput | ||
| type="password" | ||
| {...register("tenant_id")} | ||
| aria-label={t("azurebot.placeholders.tenantId")} | ||
| disabled={isLoading} | ||
| handleInputChange={(newValue) => setValue("tenant_id", newValue)} | ||
| handleLockAction={(newLockState) => handleLockAction("tenant_id", newLockState)} | ||
| isError={!!errors.tenant_id} | ||
| isLocked={lockState.tenant_id} | ||
| isRequired | ||
| label={t("azurebot.placeholders.tenantId")} | ||
| /> | ||
| <ErrorMessage>{errors.tenant_id?.message as string}</ErrorMessage> | ||
| </div> | ||
|
|
||
| <Button | ||
| aria-label={t("buttons.saveConnection")} | ||
| className="ml-auto w-fit border-black bg-white px-3 font-medium hover:bg-gray-950 hover:text-white" | ||
| type="submit" | ||
| variant="outline" | ||
| > | ||
| {isLoading ? <Spinner /> : null} | ||
| {t("buttons.saveConnection")} | ||
| </Button> | ||
| </form> | ||
| ); | ||
| }; | ||
90 changes: 90 additions & 0 deletions
90
src/components/organisms/connections/integrations/azurebot/edit.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import React, { useState } from "react"; | ||
|
|
||
| import { useTranslation } from "react-i18next"; | ||
|
|
||
| import { useConnectionForm } from "@src/hooks"; | ||
| import { azureBotIntegrationSchema } from "@validations"; | ||
|
|
||
| import { Button, ErrorMessage, Input, SecretInput, Spinner } from "@components/atoms"; | ||
|
|
||
| import { FloppyDiskIcon } from "@assets/image/icons"; | ||
|
|
||
| const initialLockState: Record<string, boolean> = { | ||
| app_password: true, | ||
| tenant_id: true, | ||
| }; | ||
|
|
||
| export const AzureBotIntegrationEditForm = () => { | ||
| const { t } = useTranslation("integrations"); | ||
| const [lockState, setLockState] = useState(initialLockState); | ||
|
|
||
| const { errors, handleSubmit, isLoading, onSubmitEdit, register, setValue } = useConnectionForm( | ||
| azureBotIntegrationSchema, | ||
| "edit" | ||
| ); | ||
|
|
||
| const handleLockAction = (fieldName: string, newLockState: boolean) => { | ||
| setLockState((prev) => ({ ...prev, [fieldName]: newLockState })); | ||
| }; | ||
|
|
||
| // Removed useEffect to not pre-populate values - just show clean form with labels | ||
|
|
||
| return ( | ||
| <form className="flex flex-col gap-4" onSubmit={handleSubmit(onSubmitEdit)}> | ||
| <div className="relative"> | ||
| <Input | ||
| {...register("app_id")} | ||
| aria-label={t("azurebot.placeholders.appId")} | ||
| disabled={isLoading} | ||
| isError={!!errors.app_id} | ||
| isRequired | ||
| label={t("azurebot.placeholders.appId")} | ||
| /> | ||
| <ErrorMessage>{errors.app_id?.message as string}</ErrorMessage> | ||
| </div> | ||
|
|
||
| <div className="relative"> | ||
| <SecretInput | ||
| type="password" | ||
| {...register("app_password")} | ||
| aria-label={t("azurebot.placeholders.appPassword")} | ||
| disabled={isLoading} | ||
| handleInputChange={(newValue) => setValue("app_password", newValue)} | ||
| handleLockAction={(newLockState) => handleLockAction("app_password", newLockState)} | ||
| isError={!!errors.app_password} | ||
| isLocked={lockState.app_password} | ||
| isRequired | ||
| label={t("azurebot.placeholders.appPassword")} | ||
| /> | ||
| <ErrorMessage>{errors.app_password?.message as string}</ErrorMessage> | ||
| </div> | ||
|
|
||
| <div className="relative"> | ||
| <SecretInput | ||
| type="password" | ||
| {...register("tenant_id")} | ||
| aria-label={t("azurebot.placeholders.tenantId")} | ||
| disabled={isLoading} | ||
| handleInputChange={(newValue) => setValue("tenant_id", newValue)} | ||
| handleLockAction={(newLockState) => handleLockAction("tenant_id", newLockState)} | ||
| isError={!!errors.tenant_id} | ||
| isLocked={lockState.tenant_id} | ||
| isRequired | ||
| label={t("azurebot.placeholders.tenantId")} | ||
| /> | ||
| <ErrorMessage>{errors.tenant_id?.message as string}</ErrorMessage> | ||
| </div> | ||
|
|
||
| <Button | ||
| aria-label={t("buttons.saveConnection")} | ||
| className="ml-auto w-fit border-white px-3 font-medium text-white hover:bg-black" | ||
| disabled={isLoading} | ||
| type="submit" | ||
| variant="outline" | ||
| > | ||
| {isLoading ? <Spinner /> : <FloppyDiskIcon className="size-5 fill-white transition" />} | ||
| {t("buttons.saveConnection")} | ||
| </Button> | ||
| </form> | ||
| ); | ||
| }; |
2 changes: 2 additions & 0 deletions
2
src/components/organisms/connections/integrations/azurebot/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export { AzureBotIntegrationAddForm } from "@components/organisms/connections/integrations/azurebot/add"; | ||
| export { AzureBotIntegrationEditForm } from "@components/organisms/connections/integrations/azurebot/edit"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think this is a secret