Skip to content

Commit

Permalink
Add Jira Server connector form (onyx-dot-app#1046)
Browse files Browse the repository at this point in the history
  • Loading branch information
useruid authored Feb 19, 2024
1 parent c1d1651 commit 54fb779
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
10 changes: 8 additions & 2 deletions backend/danswer/connectors/danswer_jira/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,15 @@ def __init__(
self.jira_client: JIRA | None = None

def load_credentials(self, credentials: dict[str, Any]) -> dict[str, Any] | None:
email = credentials["jira_user_email"]
api_token = credentials["jira_api_token"]
self.jira_client = JIRA(basic_auth=(email, api_token), server=self.jira_base)
# if user provide an email we assume it's cloud
if "jira_user_email" in credentials:
email = credentials["jira_user_email"]
self.jira_client = JIRA(
basic_auth=(email, api_token), server=self.jira_base
)
else:
self.jira_client = JIRA(token_auth=api_token, server=self.jira_base)
return None

def load_from_state(self) -> GenerateDocumentsOutput:
Expand Down
45 changes: 36 additions & 9 deletions web/src/app/admin/connectors/jira/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CredentialForm } from "@/components/admin/connectors/CredentialForm";
import {
JiraConfig,
JiraCredentialJson,
JiraServerCredentialJson,
ConnectorIndexingStatus,
} from "@/lib/types";
import useSWR, { useSWRConfig } from "swr";
Expand Down Expand Up @@ -71,7 +72,7 @@ const Main = () => {

const jiraConnectorIndexingStatuses: ConnectorIndexingStatus<
JiraConfig,
JiraCredentialJson
JiraCredentialJson | JiraServerCredentialJson
>[] = connectorIndexingStatuses.filter(
(connectorIndexingStatus) =>
connectorIndexingStatus.connector.source === "jira"
Expand All @@ -90,12 +91,6 @@ const Main = () => {
{jiraCredential ? (
<>
<div className="flex mb-1 text-sm">
{/* <div className="flex">
<p className="my-auto">Existing Username: </p>
<p className="ml-1 italic my-auto max-w-md truncate">
{confluenceCredential.credential_json?.confluence_username}
</p>{" "}
</div> */}
<p className="my-auto">Existing Access Token: </p>
<p className="ml-1 italic my-auto max-w-md truncate">
{jiraCredential.credential_json?.jira_api_token}
Expand Down Expand Up @@ -142,8 +137,10 @@ const Main = () => {
>
here
</a>{" "}
to generate an Access Token.
to generate an Access Token (for cloud) or Personal Access Token
(for server). Submit only one form.
</Text>
<Title className="mb-2 mt-6 ml-auto mr-auto">Cloud</Title>
<Card className="mt-4">
<CredentialForm<JiraCredentialJson>
formBody={
Expand Down Expand Up @@ -175,6 +172,33 @@ const Main = () => {
}}
/>
</Card>
<Title className="mb-2 mt-6 ml-auto mr-auto">Server</Title>
<Card className="mt-4">
<CredentialForm<JiraServerCredentialJson>
formBody={
<>
<TextFormField
name="jira_api_token"
label="Personal Access Token:"
type="password"
/>
</>
}
validationSchema={Yup.object().shape({
jira_api_token: Yup.string().required(
"Please enter your Jira personal access token"
),
})}
initialValues={{
jira_api_token: "",
}}
onSubmit={(isSuccess) => {
if (isSuccess) {
refreshCredentials();
}
}}
/>
</Card>
</>
)}

Expand Down Expand Up @@ -202,7 +226,10 @@ const Main = () => {
below every <b>10</b> minutes.
</Text>
<div className="mb-2">
<ConnectorsTable<JiraConfig, JiraCredentialJson>
<ConnectorsTable<
JiraConfig,
JiraCredentialJson | JiraServerCredentialJson
>
connectorIndexingStatuses={jiraConnectorIndexingStatuses}
liveCredential={jiraCredential}
getCredential={(credential) => {
Expand Down
4 changes: 4 additions & 0 deletions web/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ export interface JiraCredentialJson {
jira_api_token: string;
}

export interface JiraServerCredentialJson {
jira_api_token: string;
}

export interface ProductboardCredentialJson {
productboard_access_token: string;
}
Expand Down

0 comments on commit 54fb779

Please sign in to comment.