Skip to content

Commit

Permalink
oauth integrations
Browse files Browse the repository at this point in the history
shell

Revert "shell"

This reverts commit 852eca9.
  • Loading branch information
maciaszczykm committed Oct 30, 2024
1 parent d6939fe commit 739aa25
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { useQuery } from '@apollo/client'
import { Box, Text } from 'grommet'
import { Check as Checkmark } from 'forge-core'

import { ZOOM_ICON, ZOOM_INSTALL_URL } from './constants'
import { OAUTH_Q } from './queries'
import { OAuthService } from './types'
import { useOauthIntegrationsQuery } from '../../../generated/graphql'

function redirectUrl(format, service) {
const location = `${
Expand Down Expand Up @@ -66,7 +65,9 @@ function Integration({
}

export function OAuthIntegrations() {
const { data } = useQuery(OAUTH_Q, { fetchPolicy: 'cache-and-network' })
const { data } = useOauthIntegrationsQuery({
fetchPolicy: 'cache-and-network',
})

if (!data) return null

Expand Down
14 changes: 7 additions & 7 deletions www/src/_deprecated/components/integrations/OauthCreator.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { useEffect, useMemo } from 'react'
import { Errors } from 'forge-core'
import { useLocation, useNavigate, useParams } from 'react-router-dom'
import { useMutation } from '@apollo/client'

import { Box, Text } from 'grommet'

import { LoopingLogo } from '../../../components/utils/AnimatedLogo'

import { CREATE_OAUTH } from './queries'
import { ParamToService } from './types'
import { useCreateOauthIntegrationMutation } from '../../../generated/graphql'

function OauthError({ error, service }: any) {
return (
Expand Down Expand Up @@ -40,11 +39,12 @@ export function OauthCreator() {
redirectUri: `${window.location.origin}${window.location.pathname}`,
}
}, [location])
const [mutation, { loading, data, error }] = useMutation(CREATE_OAUTH, {
variables: {
attributes: { code, redirectUri, service: ParamToService[service] },
},
})
const [mutation, { loading, data, error }] =
useCreateOauthIntegrationMutation({
variables: {
attributes: { code, redirectUri, service: ParamToService[service] },
},
})

useEffect(() => {
mutation()
Expand Down
18 changes: 0 additions & 18 deletions www/src/_deprecated/components/integrations/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,3 @@ export const DELETE_WEBHOOK = gql`
}
${IntegrationWebhookFragment}
`

export const OAUTH_Q = gql`
query {
oauthIntegrations {
...OauthIntegration
}
}
${OauthIntegration}
`

export const CREATE_OAUTH = gql`
mutation Create($attributes: OauthIntegrationAttributes!) {
createOauthIntegration(attributes: $attributes) {
...OauthIntegration
}
}
${OauthIntegration}
`
86 changes: 86 additions & 0 deletions www/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5521,6 +5521,18 @@ export type OauthIntegrationFragment = { __typename?: 'OauthIntegration', id: st

export type ZoomMeetingFragment = { __typename?: 'ZoomMeeting', joinUrl: string, password?: string | null };

export type OauthIntegrationsQueryVariables = Exact<{ [key: string]: never; }>;


export type OauthIntegrationsQuery = { __typename?: 'RootQueryType', oauthIntegrations?: Array<{ __typename?: 'OauthIntegration', id: string, service: OauthService, insertedAt?: Date | null } | null> | null };

export type CreateOauthIntegrationMutationVariables = Exact<{
attributes: OauthAttributes;
}>;


export type CreateOauthIntegrationMutation = { __typename?: 'RootMutationType', createOauthIntegration?: { __typename?: 'OauthIntegration', id: string, service: OauthService, insertedAt?: Date | null } | null };

export type SignupInviteMutationVariables = Exact<{
attributes: UserAttributes;
inviteId: Scalars['String']['input'];
Expand Down Expand Up @@ -8610,6 +8622,78 @@ export type GroupsQueryHookResult = ReturnType<typeof useGroupsQuery>;
export type GroupsLazyQueryHookResult = ReturnType<typeof useGroupsLazyQuery>;
export type GroupsSuspenseQueryHookResult = ReturnType<typeof useGroupsSuspenseQuery>;
export type GroupsQueryResult = Apollo.QueryResult<GroupsQuery, GroupsQueryVariables>;
export const OauthIntegrationsDocument = gql`
query OauthIntegrations {
oauthIntegrations {
...OauthIntegration
}
}
${OauthIntegrationFragmentDoc}`;

/**
* __useOauthIntegrationsQuery__
*
* To run a query within a React component, call `useOauthIntegrationsQuery` and pass it any options that fit your needs.
* When your component renders, `useOauthIntegrationsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useOauthIntegrationsQuery({
* variables: {
* },
* });
*/
export function useOauthIntegrationsQuery(baseOptions?: Apollo.QueryHookOptions<OauthIntegrationsQuery, OauthIntegrationsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<OauthIntegrationsQuery, OauthIntegrationsQueryVariables>(OauthIntegrationsDocument, options);
}
export function useOauthIntegrationsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<OauthIntegrationsQuery, OauthIntegrationsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<OauthIntegrationsQuery, OauthIntegrationsQueryVariables>(OauthIntegrationsDocument, options);
}
export function useOauthIntegrationsSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions<OauthIntegrationsQuery, OauthIntegrationsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useSuspenseQuery<OauthIntegrationsQuery, OauthIntegrationsQueryVariables>(OauthIntegrationsDocument, options);
}
export type OauthIntegrationsQueryHookResult = ReturnType<typeof useOauthIntegrationsQuery>;
export type OauthIntegrationsLazyQueryHookResult = ReturnType<typeof useOauthIntegrationsLazyQuery>;
export type OauthIntegrationsSuspenseQueryHookResult = ReturnType<typeof useOauthIntegrationsSuspenseQuery>;
export type OauthIntegrationsQueryResult = Apollo.QueryResult<OauthIntegrationsQuery, OauthIntegrationsQueryVariables>;
export const CreateOauthIntegrationDocument = gql`
mutation CreateOauthIntegration($attributes: OauthAttributes!) {
createOauthIntegration(attributes: $attributes) {
...OauthIntegration
}
}
${OauthIntegrationFragmentDoc}`;
export type CreateOauthIntegrationMutationFn = Apollo.MutationFunction<CreateOauthIntegrationMutation, CreateOauthIntegrationMutationVariables>;

/**
* __useCreateOauthIntegrationMutation__
*
* To run a mutation, you first call `useCreateOauthIntegrationMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useCreateOauthIntegrationMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [createOauthIntegrationMutation, { data, loading, error }] = useCreateOauthIntegrationMutation({
* variables: {
* attributes: // value for 'attributes'
* },
* });
*/
export function useCreateOauthIntegrationMutation(baseOptions?: Apollo.MutationHookOptions<CreateOauthIntegrationMutation, CreateOauthIntegrationMutationVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useMutation<CreateOauthIntegrationMutation, CreateOauthIntegrationMutationVariables>(CreateOauthIntegrationDocument, options);
}
export type CreateOauthIntegrationMutationHookResult = ReturnType<typeof useCreateOauthIntegrationMutation>;
export type CreateOauthIntegrationMutationResult = Apollo.MutationResult<CreateOauthIntegrationMutation>;
export type CreateOauthIntegrationMutationOptions = Apollo.BaseMutationOptions<CreateOauthIntegrationMutation, CreateOauthIntegrationMutationVariables>;
export const SignupInviteDocument = gql`
mutation SignupInvite($attributes: UserAttributes!, $inviteId: String!) {
signup(attributes: $attributes, inviteId: $inviteId) {
Expand Down Expand Up @@ -11973,6 +12057,7 @@ export const namedOperations = {
GetDnsRecords: 'GetDnsRecords',
GroupMembers: 'GroupMembers',
Groups: 'Groups',
OauthIntegrations: 'OauthIntegrations',
Invite: 'Invite',
KeyBackups: 'KeyBackups',
KeyBackup: 'KeyBackup',
Expand Down Expand Up @@ -12020,6 +12105,7 @@ export const namedOperations = {
CreateGroup: 'CreateGroup',
UpdateGroup: 'UpdateGroup',
DeleteGroup: 'DeleteGroup',
CreateOauthIntegration: 'CreateOauthIntegration',
SignupInvite: 'SignupInvite',
RealizeInvite: 'RealizeInvite',
CreateInvite: 'CreateInvite',
Expand Down
12 changes: 12 additions & 0 deletions www/src/graph/integrations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,15 @@ fragment ZoomMeeting on ZoomMeeting {
joinUrl
password
}

query OauthIntegrations {
oauthIntegrations {
...OauthIntegration
}
}

mutation CreateOauthIntegration($attributes: OauthAttributes!) {
createOauthIntegration(attributes: $attributes) {
...OauthIntegration
}
}

0 comments on commit 739aa25

Please sign in to comment.