Skip to content

Commit 06e97c1

Browse files
committed
chore(credentials): cleanup pass on the batch-2 changes
1 parent 6b0feef commit 06e97c1

4 files changed

Lines changed: 21 additions & 23 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/integrations/[block]/integration-block-detail.tsx‎

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { type ReactNode, useEffect, useMemo, useRef, useState } from 'react'
3+
import { type ReactNode, useEffect, useRef, useState } from 'react'
44
import { Chip, ChipDropdown, ChipLink, cn } from '@sim/emcn'
55
import { ArrowLeft, Plus } from '@sim/emcn/icons'
66
import { useRouter } from 'next/navigation'
@@ -174,9 +174,9 @@ function IntegrationBlockDetailContent({ integration, workspaceId }: Integration
174174
const oauthAvailable = Boolean(oauthService) && (availability?.oauthAvailable ?? true)
175175
const [oauthOpen, setOAuthOpen] = useState(false)
176176
const [personalTokenOpen, setPersonalTokenOpen] = useState(false)
177+
const isGitLab = integration.slug === 'gitlab'
177178
const personalTokenAvailable =
178-
integration.slug === 'gitlab' &&
179-
(availability?.state === 'ready' || availability?.state === 'limited')
179+
isGitLab && (availability?.state === 'ready' || availability?.state === 'limited')
180180

181181
const { data: credentials = [], isPending: credentialsLoading } = useWorkspaceCredentials({
182182
workspaceId,
@@ -190,22 +190,21 @@ function IntegrationBlockDetailContent({ integration, workspaceId }: Integration
190190
* credential lists on every product it powers. Comparing resolved
191191
* `providerId`s instead hides it from all of them.
192192
*/
193-
const connectedCredentials = useMemo(() => {
194-
const serviceCredentials = oauthService
195-
? credentials.filter(
196-
(c) =>
197-
(c.type === 'oauth' || c.type === 'service_account') &&
198-
c.providerId &&
199-
credentialProviderMatchesService(c.providerId, oauthService)
200-
)
201-
: []
202-
if (integration.slug !== 'gitlab') return serviceCredentials
203-
// GitLab also has personal tokens, which Copilot acts with on the person's behalf.
204-
return [
205-
...credentials.filter((c) => c.type === 'personal_token' && c.providerId === 'gitlab'),
206-
...serviceCredentials,
207-
]
208-
}, [credentials, oauthService, integration.slug])
193+
const serviceCredentials = oauthService
194+
? credentials.filter(
195+
(c) =>
196+
(c.type === 'oauth' || c.type === 'service_account') &&
197+
c.providerId &&
198+
credentialProviderMatchesService(c.providerId, oauthService)
199+
)
200+
: []
201+
// GitLab also has personal tokens, which Copilot acts with on the person's behalf.
202+
const connectedCredentials = isGitLab
203+
? [
204+
...credentials.filter((c) => c.type === 'personal_token' && c.providerId === 'gitlab'),
205+
...serviceCredentials,
206+
]
207+
: serviceCredentials
209208
const [serviceAccountOpen, setServiceAccountOpen] = useState(false)
210209
const serviceAccountTarget = useServiceAccountConnectTarget({
211210
serviceAccountProviderId: oauthService?.serviceAccountProviderId,

‎apps/sim/blocks/utils.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ export function withSavedCredential(
147147
`Block "${legacy.type}": unused selector twins ${unusedSelectorKeys.join(', ')}`
148148
)
149149
}
150-
// The picker sits right under the operation picker, the first thing a user
151-
// sets; a block without one keeps it where its secret was.
150+
// Under the operation picker because that is the first field a user sets.
152151
const operationAt = subBlocks.findIndex(
153152
(subBlock) => subBlock.id === 'operation' && !isTriggerModeSubBlock(subBlock)
154153
)

‎apps/sim/tools/whatsapp/utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function buildMessagesUrl(phoneNumberId: string | undefined): string {
1515

1616
/** Build the media upload endpoint for a given business phone number ID. */
1717
export function buildMediaUploadUrl(phoneNumberId: string): string {
18-
return `https://graph.facebook.com/${WHATSAPP_GRAPH_VERSION}/${encodeURIComponent(phoneNumberId.trim())}/media`
18+
return `https://graph.facebook.com/${WHATSAPP_GRAPH_VERSION}/${safeUrlPathSegment(phoneNumberId.trim(), 'phoneNumberId')}/media`
1919
}
2020

2121
/** Build the media metadata endpoint for a media ID, optionally scoped to a phone number. */

‎apps/sim/tools/whatsapp/whatsapp.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('WhatsApp request URL and headers', () => {
2626
it.each(['../../999/register#', '..', '123/subscribed_apps?'])(
2727
'refuses a phone number ID that would leave its path segment (%s)',
2828
(phoneNumberId) => {
29-
expect(() => sendMessageTool.request.url({ ...auth, phoneNumberId })).toThrow()
29+
expect(() => sendMessageTool.request.url({ ...auth, phoneNumberId })).toThrow(/phoneNumberId/)
3030
}
3131
)
3232
})

0 commit comments

Comments
 (0)