Force users to provide access token before creating connector for Github/Confluence

This commit is contained in:
Weves
2023-06-19 11:55:57 -06:00
committed by Chris Weaver
parent 1d9a9a60c8
commit 3863ee3ce1
2 changed files with 151 additions and 119 deletions

View File

@ -65,7 +65,7 @@ const Main = () => {
return ( return (
<> <>
<h2 className="font-bold mb-2 mt-6 ml-auto mr-auto"> <h2 className="font-bold mb-2 mt-6 ml-auto mr-auto">
Step 1: Provide your Credentials Step 1: Provide your access token
</h2> </h2>
{confluenceCredential ? ( {confluenceCredential ? (
@ -139,10 +139,11 @@ const Main = () => {
</> </>
)} )}
{/* TODO: make this periodic */}
<h2 className="font-bold mb-2 mt-6 ml-auto mr-auto"> <h2 className="font-bold mb-2 mt-6 ml-auto mr-auto">
Step 2: Which spaces do you want to make searchable? Step 2: Which spaces do you want to make searchable?
</h2> </h2>
{confluenceCredential ? (
<>
<p className="text-sm mb-4"> <p className="text-sm mb-4">
To use the Confluence connector, you must first follow the guide To use the Confluence connector, you must first follow the guide
described{" "} described{" "}
@ -152,35 +153,45 @@ const Main = () => {
> >
here here
</a>{" "} </a>{" "}
to give the Danswer backend read access to your documents. Once that is to give the Danswer backend read access to your documents. Once that
setup, specify any link to a Confluence page below and click is setup, specify any link to a Confluence page below and click
&quot;Index&quot; to Index. Based on the provided link, we will index &quot;Index&quot; to Index. Based on the provided link, we will
the ENTIRE SPACE, not just the specified page. For example, entering{" "} index the ENTIRE SPACE, not just the specified page. For example,
<i>https://danswer.atlassian.net/wiki/spaces/Engineering/overview</i>{" "} entering{" "}
and clicking the Index button will index the whole <i>Engineering</i>{" "} <i>
Confluence space. https://danswer.atlassian.net/wiki/spaces/Engineering/overview
</i>{" "}
and clicking the Index button will index the whole{" "}
<i>Engineering</i> Confluence space.
</p> </p>
{confluenceConnectorIndexingStatuses.length > 0 && ( {confluenceConnectorIndexingStatuses.length > 0 && (
<> <>
<p className="text-sm mb-2"> <p className="text-sm mb-2">
We pull the latest pages and comments from each space listed below We pull the latest pages and comments from each space listed
every <b>10</b> minutes. below every <b>10</b> minutes.
</p> </p>
<div className="mb-2"> <div className="mb-2">
<ConnectorsTable<ConfluenceConfig, ConfluenceCredentialJson> <ConnectorsTable<ConfluenceConfig, ConfluenceCredentialJson>
connectorIndexingStatuses={confluenceConnectorIndexingStatuses} connectorIndexingStatuses={
confluenceConnectorIndexingStatuses
}
liveCredential={confluenceCredential} liveCredential={confluenceCredential}
getCredential={(credential) => { getCredential={(credential) => {
return ( return (
<div> <div>
<p>{credential.credential_json.confluence_access_token}</p> <p>
{credential.credential_json.confluence_access_token}
</p>
</div> </div>
); );
}} }}
onCredentialLink={async (connectorId) => { onCredentialLink={async (connectorId) => {
if (confluenceCredential) { if (confluenceCredential) {
await linkCredential(connectorId, confluenceCredential.id); await linkCredential(
connectorId,
confluenceCredential.id
);
mutate("/api/manage/admin/connector/indexing-status"); mutate("/api/manage/admin/connector/indexing-status");
} }
}} }}
@ -191,7 +202,9 @@ const Main = () => {
getValue: (connector) => ( getValue: (connector) => (
<a <a
className="text-blue-500" className="text-blue-500"
href={connector.connector_specific_config.wiki_page_url} href={
connector.connector_specific_config.wiki_page_url
}
> >
{connector.connector_specific_config.wiki_page_url} {connector.connector_specific_config.wiki_page_url}
</a> </a>
@ -230,13 +243,24 @@ const Main = () => {
refreshFreq={10 * 60} // 10 minutes refreshFreq={10 * 60} // 10 minutes
onSubmit={async (isSuccess, responseJson) => { onSubmit={async (isSuccess, responseJson) => {
if (isSuccess && responseJson) { if (isSuccess && responseJson) {
await linkCredential(responseJson.id, confluenceCredential.id); await linkCredential(
responseJson.id,
confluenceCredential.id
);
mutate("/api/manage/admin/connector/indexing-status"); mutate("/api/manage/admin/connector/indexing-status");
} }
}} }}
/> />
</div> </div>
</> </>
) : (
<p className="text-sm">
Please provide your access token in Step 1 first! Once done with that,
you can then specify which Confluence spaces you want to make
searchable.
</p>
)}
</>
); );
}; };

View File

@ -168,6 +168,7 @@ const Main = () => {
</> </>
)} )}
{githubCredential ? (
<div className="border-solid border-gray-600 border rounded-md p-6 mt-4"> <div className="border-solid border-gray-600 border rounded-md p-6 mt-4">
<h2 className="font-bold mb-3">Connect to a New Repository</h2> <h2 className="font-bold mb-3">Connect to a New Repository</h2>
<ConnectorForm<GithubConfig> <ConnectorForm<GithubConfig>
@ -203,6 +204,13 @@ const Main = () => {
}} }}
/> />
</div> </div>
) : (
<p className="text-sm">
Please provide your access token in Step 1 first! Once done with that,
you can then specify which Github repositories you want to make
searchable.
</p>
)}
</> </>
); );
}; };