forked from cerc-io/snowballtools-base
Implement Github authentication to show repositories list (#45)
* Use react-oauth-popup for github authentication popup * Fetch auth token and use in app to fetch list of repositories * Get client id and secret from config * Use GitHub search API for fetching repos * Use debounce for searching repos and projects
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { ApolloClient, DefaultOptions, InMemoryCache, NormalizedCacheObject } from '@apollo/client';
|
||||
|
||||
import { getUser, getOrganizations, getDeployments, getProjectMembers, searchProjects, getEnvironmentVariables, getProject, getDomains, getProjectsInOrganization } from './queries';
|
||||
import { AddEnvironmentVariableInput, AddEnvironmentVariablesResponse, GetDeploymentsResponse, GetEnvironmentVariablesResponse, GetOrganizationsResponse, GetProjectMembersResponse, SearchProjectsResponse, GetUserResponse, RemoveMemberResponse, UpdateDeploymentToProdResponse, GetProjectResponse, UpdateProjectResponse, UpdateProjectInput, RedeployToProdResponse, DeleteProjectResponse, GetProjectsInOrganizationResponse, RollbackDeploymentResponse, AddDomainInput, AddDomainResponse, GetDomainsResponse, UpdateDomainInput, UpdateDomainResponse } from './types';
|
||||
import { removeMember, addEnvironmentVariables, updateDeploymentToProd, updateProjectMutation, redeployToProd, deleteProject, addDomain, rollbackDeployment, updateDomainMutation } from './mutations';
|
||||
import { AddEnvironmentVariableInput, AddEnvironmentVariablesResponse, GetDeploymentsResponse, GetEnvironmentVariablesResponse, GetOrganizationsResponse, GetProjectMembersResponse, SearchProjectsResponse, GetUserResponse, RemoveMemberResponse, UpdateDeploymentToProdResponse, GetProjectResponse, UpdateProjectResponse, UpdateProjectInput, RedeployToProdResponse, DeleteProjectResponse, GetProjectsInOrganizationResponse, RollbackDeploymentResponse, AddDomainInput, AddDomainResponse, GetDomainsResponse, UpdateDomainInput, UpdateDomainResponse, AuthenticateGithubResponse } from './types';
|
||||
import { removeMember, addEnvironmentVariables, updateDeploymentToProd, updateProjectMutation, redeployToProd, deleteProject, addDomain, rollbackDeployment, updateDomainMutation, authenticateGithub } from './mutations';
|
||||
|
||||
export interface GraphQLConfig {
|
||||
gqlEndpoint: string;
|
||||
@@ -227,4 +227,15 @@ export class GQLClient {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
async authenticateGithub (code: string): Promise<AuthenticateGithubResponse> {
|
||||
const { data } = await this.client.mutate({
|
||||
mutation: authenticateGithub,
|
||||
variables: {
|
||||
code
|
||||
}
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,3 +51,10 @@ mutation ($projectId: String!, $domainDetails: AddDomainInput!) {
|
||||
addDomain(projectId: $projectId, domainDetails: $domainDetails)
|
||||
}
|
||||
`;
|
||||
|
||||
export const authenticateGithub = gql`
|
||||
mutation ($code: String!) {
|
||||
authenticateGithub(code: $code) {
|
||||
token
|
||||
}
|
||||
}`;
|
||||
|
||||
@@ -222,3 +222,9 @@ export type AddDomainInput = {
|
||||
export type AddDomainResponse = {
|
||||
addDomain: true
|
||||
}
|
||||
|
||||
export type AuthenticateGithubResponse = {
|
||||
authenticateGithub: {
|
||||
token: string
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user