Skip to content

Commit

Permalink
Merge pull request activepieces#6100 from activepieces/fix/connection…
Browse files Browse the repository at this point in the history
…s-minor-bugs

fix: disable connect button until all oauth2 props are filled + use correct zoho api urls
  • Loading branch information
AbdulTheActivePiecer authored Nov 21, 2024
2 parents b669436 + 1777ff8 commit 93e61e1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/pieces/community/zoho-books/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-zoho-books",
"version": "0.0.1"
"version": "0.0.2"
}
7 changes: 5 additions & 2 deletions packages/pieces/community/zoho-books/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ export const zohoBooks = createPiece({
actions: [
createCustomApiCallAction({
baseUrl: (auth) =>
`https://${(auth as OAuth2PropertyValue).data['location']}/books/v3`,
{
const data = (auth as OAuth2PropertyValue).data;
return data && data['api_domain']? `${data['api_domain']}/books/v3` : ''
},
auth: zohoBooksAuth,
authMapping: async (auth) => ({
Authorization: `Bearer ${(auth as OAuth2PropertyValue).access_token}`,
Authorization: `Zoho-oauthtoken ${(auth as OAuth2PropertyValue).access_token}`,
}),
}),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/pieces/community/zoho-crm/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-zoho-crm",
"version": "0.1.7"
"version": "0.1.8"
}
8 changes: 6 additions & 2 deletions packages/pieces/community/zoho-crm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ export const zohoCrm = createPiece({
readFile,
createCustomApiCallAction({
baseUrl: (auth) =>
`https://${(auth as OAuth2PropertyValue).data.location}/crm/v4`,
{
const data = (auth as OAuth2PropertyValue).data;
return data && data['api_domain']? `${data['api_domain']}/crm/v3` : ''
},

auth: zohoCrmAuth,
authMapping: async (auth) => ({
Authorization: `Bearer ${(auth as OAuth2PropertyValue).access_token}`,
Authorization: `Zoho-oauthtoken ${(auth as OAuth2PropertyValue).access_token}`,
}),
}),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const CreateOrEditConnectionDialog = React.memo(
},
onError: (err) => {
if (err instanceof ConnectionNameAlreadyExists) {
form.setError('request.externalId', {
form.setError('request.displayName', {
message: t('Name is already used'),
});
} else if (api.isError(err)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,17 @@ const OAuth2ConnectionSettings = ({
const clientSecret = (form.getValues().request as UpsertOAuth2Request)
?.value?.client_secret;
const hasClientSecret = !isNil(clientSecret);
const propsValues = form.getValues('request.value.props') ?? {};
const arePropsValid = authProperty.props
? Object.keys(authProperty.props).reduce((acc, key) => {
return acc && !isNil(propsValues[key]) && propsValues[key] !== '';
}, true)
: true;

setReadyToConnect(
baseCriteria &&
(currentOAuth2Type !== AppConnectionType.OAUTH2 || hasClientSecret),
(currentOAuth2Type !== AppConnectionType.OAUTH2 || hasClientSecret) &&
arePropsValid,
);
}, [watchedForm]);

Expand Down

0 comments on commit 93e61e1

Please sign in to comment.