-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP: GitHub Integration * WIP: Github Integration * WIP: Github integration * Refactore Code * WIP: Github Integration * WIP: Github integration * WIP: Github Integration * WIP: Github Integration * fix: Updated GitHub Integration UI * fix: undefined error * fix: Lint error and added repository * Updated State * fix: Updated install API body as per updated API * fix: Github Repo fetching * Update constants.ts --------- Co-authored-by: Ruslan K <[email protected]>
- Loading branch information
1 parent
9e55d58
commit 99b292f
Showing
43 changed files
with
1,329 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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 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,94 @@ | ||
import { | ||
getGithubIntegrationMetadataAPI, | ||
getGithubIntegrationRepositoriesAPI, | ||
installGitHubIntegrationAPI, | ||
oAuthEndpointAuthorizationAPI, | ||
} from '@app/services/client/api/integrations/github'; | ||
import { | ||
integrationGithubMetadataState, | ||
integrationGithubRepositoriesState, | ||
userState, | ||
} from '@app/stores'; | ||
import { useCallback } from 'react'; | ||
import { useRecoilState } from 'recoil'; | ||
import { useQuery } from '../useQuery'; | ||
|
||
export function useGitHubIntegration() { | ||
const [user] = useRecoilState(userState); | ||
|
||
const [integrationGithubMetadata, setIntegrationGithubMetadata] = | ||
useRecoilState(integrationGithubMetadataState); | ||
const [integrationGithubRepositories, setIntegrationGithubRepositories] = | ||
useRecoilState(integrationGithubRepositoriesState); | ||
|
||
const { loading: installLoading, queryCall: installQueryCall } = useQuery( | ||
installGitHubIntegrationAPI | ||
); | ||
const { loading: oAuthLoading, queryCall: oAuthQueryCall } = useQuery( | ||
oAuthEndpointAuthorizationAPI | ||
); | ||
const { loading: metadataLoading, queryCall: metadataQueryCall } = useQuery( | ||
getGithubIntegrationMetadataAPI | ||
); | ||
const { loading: repositoriesLoading, queryCall: repositoriesQueryCall } = | ||
useQuery(getGithubIntegrationRepositoriesAPI); | ||
|
||
const installGitHub = useCallback( | ||
(installation_id: string, setup_action: string) => { | ||
return installQueryCall({ | ||
tenantId: user?.tenantId as string, | ||
organizationId: user?.employee?.organizationId as string, | ||
installation_id, | ||
setup_action, | ||
}); | ||
}, | ||
[installQueryCall, user] | ||
); | ||
const oAuthGitHub = useCallback( | ||
(installation_id: string, setup_action: string, code: string) => { | ||
return oAuthQueryCall({ | ||
tenantId: user?.tenantId as string, | ||
organizationId: user?.employee?.organizationId as string, | ||
installation_id, | ||
setup_action, | ||
code, | ||
}); | ||
}, | ||
[oAuthQueryCall, user] | ||
); | ||
const metaData = useCallback( | ||
(integrationId: string) => { | ||
return metadataQueryCall(integrationId).then((response) => { | ||
setIntegrationGithubMetadata(response.data.data); | ||
|
||
return response.data.data; | ||
}); | ||
}, | ||
[metadataQueryCall, setIntegrationGithubMetadata] | ||
); | ||
const getRepositories = useCallback( | ||
(integrationId: string) => { | ||
return repositoriesQueryCall(integrationId).then((response) => { | ||
setIntegrationGithubRepositories(response.data.data); | ||
|
||
return response.data.data; | ||
}); | ||
}, | ||
[repositoriesQueryCall, setIntegrationGithubRepositories] | ||
); | ||
|
||
return { | ||
installLoading, | ||
installQueryCall, | ||
installGitHub, | ||
oAuthLoading, | ||
oAuthQueryCall, | ||
oAuthGitHub, | ||
metaData, | ||
metadataLoading, | ||
getRepositories, | ||
repositoriesLoading, | ||
integrationGithubMetadata, | ||
integrationGithubRepositories, | ||
}; | ||
} |
This file contains 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,29 @@ | ||
import { getIntegrationAPI } from '@app/services/client/api'; | ||
import { integrationState } from '@app/stores'; | ||
import { useCallback } from 'react'; | ||
import { useRecoilState } from 'recoil'; | ||
import { useQuery } from '../useQuery'; | ||
|
||
export function useIntegration() { | ||
const [integration, setIntegration] = useRecoilState(integrationState); | ||
|
||
const { loading: loading, queryCall: queryCall } = | ||
useQuery(getIntegrationAPI); | ||
|
||
const getIntegration = useCallback( | ||
(name: string) => { | ||
return queryCall(name).then((response) => { | ||
setIntegration(response.data.data); | ||
|
||
return response.data.data; | ||
}); | ||
}, | ||
[queryCall, setIntegration] | ||
); | ||
|
||
return { | ||
loading, | ||
getIntegration, | ||
integration, | ||
}; | ||
} |
This file contains 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,32 @@ | ||
import { getIntegrationTenantAPI } from '@app/services/client/api'; | ||
import { integrationTenantState } from '@app/stores'; | ||
import { useCallback } from 'react'; | ||
import { useRecoilState } from 'recoil'; | ||
import { useQuery } from '../useQuery'; | ||
|
||
export function useIntegrationTenant() { | ||
const [integrationTenant, setIntegrationTenant] = useRecoilState( | ||
integrationTenantState | ||
); | ||
|
||
const { loading: loading, queryCall: queryCall } = useQuery( | ||
getIntegrationTenantAPI | ||
); | ||
|
||
const getIntegrationTenant = useCallback( | ||
(name: string) => { | ||
return queryCall(name).then((response) => { | ||
setIntegrationTenant(response.data.data); | ||
|
||
return response.data.data; | ||
}); | ||
}, | ||
[queryCall, setIntegrationTenant] | ||
); | ||
|
||
return { | ||
loading, | ||
getIntegrationTenant, | ||
integrationTenant, | ||
}; | ||
} |
This file contains 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,29 @@ | ||
import { getIntegrationTypesAPI } from '@app/services/client/api'; | ||
import { integrationTypesState } from '@app/stores'; | ||
import { useCallback } from 'react'; | ||
import { useRecoilState } from 'recoil'; | ||
import { useQuery } from '../useQuery'; | ||
|
||
export function useIntegrationTypes() { | ||
const [integrationTypes, setIntegrationTypes] = useRecoilState( | ||
integrationTypesState | ||
); | ||
|
||
const { loading: loading, queryCall: queryCall } = useQuery( | ||
getIntegrationTypesAPI | ||
); | ||
|
||
const getIntegrationTypes = useCallback(() => { | ||
return queryCall().then((response) => { | ||
setIntegrationTypes(response.data.data); | ||
|
||
return response.data.data; | ||
}); | ||
}, [queryCall, setIntegrationTypes]); | ||
|
||
return { | ||
loading, | ||
getIntegrationTypes, | ||
integrationTypes, | ||
}; | ||
} |
This file contains 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 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,43 @@ | ||
export interface IGithubMetadata { | ||
id: number; | ||
account: { | ||
login: string; | ||
id: number; | ||
node_id: string; | ||
avatar_url: string; | ||
gravatar_id: string; | ||
url: string; | ||
html_url: string; | ||
followers_url: string; | ||
following_url: string; | ||
gists_url: string; | ||
starred_url: string; | ||
subscriptions_url: string; | ||
organizations_url: string; | ||
repos_url: string; | ||
events_url: string; | ||
received_events_url: string; | ||
type: string; | ||
site_admin: boolean; | ||
}; | ||
repository_selection: string; | ||
access_tokens_url: string; | ||
repositories_url: string; | ||
html_url: string; | ||
app_id: number; | ||
app_slug: string; | ||
target_id: number; | ||
target_type: string; | ||
permissions: { | ||
issues: string; | ||
metadata: string; | ||
}; | ||
events: string[]; | ||
created_at: string | Date; | ||
updated_at: string | Date; | ||
single_file_name: string | null; | ||
has_multiple_single_files: boolean; | ||
single_file_paths: string[]; | ||
suspended_by: string | number | null; | ||
suspended_at: string | number | null; | ||
} |
Oops, something went wrong.