Skip to content

Commit 66090a2

Browse files
fix: correct app action names [] (#10253)
* change action names * change app action names when called * logs * test logs * remove logs * remove logs
1 parent f4f87c0 commit 66090a2

3 files changed

Lines changed: 6 additions & 18 deletions

File tree

apps/google-docs/functions/completeOauth.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,8 @@ interface CompleteOAuthParams {
1111
state: string;
1212
}
1313

14-
/*
15-
* INTEG-3271: Double check the imported types and make sure they work for Google Docs (use Klaviyo as a reference)
16-
* Additionally, understand the implementation detail for the Google Docs OAuth flow (copied from Klaviyo)
17-
*/
1814
export async function completeOauth(sdk: OAuthSDK, params: CompleteOAuthParams): Promise<void> {
1915
try {
20-
// Complete the OAuth flow using the SDK
2116
await sdk.exchange({ code: params.code, state: params.state });
2217
} catch (error) {
2318
console.error('Failed to complete OAuth flow:', error);

apps/google-docs/functions/initiateOauth.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export type OAuthSDK = {
2121

2222
export async function initiateOauth(sdk: OAuthSDK): Promise<OAuthResponseUrl> {
2323
try {
24-
// Initialize OAuth flow using the SDK
2524
const oauthResponse = await sdk.init();
2625

2726
return {
@@ -37,7 +36,6 @@ export const handler = async (
3736
event: AppEventHandlerRequest,
3837
context: AppEventContext
3938
): Promise<AppEventHandlerResponse> => {
40-
// Use the oauth sdk to initiate the oauth flow, use initiateOauth.ts from Klaviyo as a reference
4139
const sdk = (context as any).oauthSdk;
4240
if (!sdk) {
4341
console.error('No SDK available in context');

apps/google-docs/src/locations/ConfigScreen.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const ConfigScreen = () => {
5252
});
5353

5454
const checkStatusAppAction = appActions.items.find(
55-
(action) => action.name === 'Check Status'
55+
(action) => action.name === 'checkGdocOauthTokenStatus'
5656
);
5757
if (!checkStatusAppAction) {
5858
console.warn('Check Status app action not found');
@@ -122,16 +122,14 @@ const ConfigScreen = () => {
122122

123123
const messageHandler = async (event: MessageEvent) => {
124124
if (event.data.type === 'oauth:complete') {
125-
console.log('oauth:complete');
126125
const appDefinitionId = sdk.ids.app;
127126
// call app action to complete oauth
128127
const appActions = await sdk.cma.appAction.getManyForEnvironment({
129128
environmentId: sdk.ids.environment,
130129
spaceId: sdk.ids.space,
131130
});
132-
console.log('appActions', appActions);
133131
const completeOauthAppAction = appActions.items.find(
134-
(action) => action.name === 'Complete Oauth'
132+
(action) => action.name === 'completeGdocOauth'
135133
);
136134
await sdk.cma.appActionCall.create(
137135
{ appDefinitionId, appActionId: completeOauthAppAction?.sys.id || '' },
@@ -142,7 +140,6 @@ const ConfigScreen = () => {
142140
},
143141
}
144142
);
145-
console.log('completeOauthAppAction', completeOauthAppAction);
146143
// Check the updated status after OAuth completion - expect it to be connected
147144
await checkGoogleStatus(true);
148145

@@ -153,8 +150,6 @@ const ConfigScreen = () => {
153150
};
154151

155152
const cleanup = () => {
156-
console.log('cleanup called');
157-
// Clear the interval
158153
if (checkWindowIntervalRef.current) {
159154
window.clearInterval(checkWindowIntervalRef.current);
160155
checkWindowIntervalRef.current = null;
@@ -184,7 +179,7 @@ const ConfigScreen = () => {
184179
});
185180

186181
const initiateOauthAppAction = appActions.items.find(
187-
(action) => action.name === 'Initiate Oauth'
182+
(action) => action.name === 'initiateGdocOauth'
188183
);
189184

190185
const response = await sdk.cma.appActionCall.createWithResponse(
@@ -223,7 +218,9 @@ const ConfigScreen = () => {
223218
environmentId: sdk.ids.environment,
224219
spaceId: sdk.ids.space,
225220
});
226-
const disconnectAppAction = appActions.items.find((action) => action.name === 'Disconnect');
221+
const disconnectAppAction = appActions.items.find(
222+
(action) => action.name === 'revokeGdocOauthToken'
223+
);
227224
await sdk.cma.appActionCall.create(
228225
{
229226
appActionId: disconnectAppAction?.sys.id || '',
@@ -422,8 +419,6 @@ const ConfigScreen = () => {
422419
parameters: {},
423420
}
424421
);
425-
426-
console.log(JSON.parse(response.response.body));
427422
}}>
428423
Create entries from document
429424
</Button>

0 commit comments

Comments
 (0)