11'use client'
22
3- import { type ReactNode , useEffect , useMemo , useRef , useState } from 'react'
3+ import { type ReactNode , useEffect , useRef , useState } from 'react'
44import { Chip , ChipDropdown , ChipLink , cn } from '@sim/emcn'
55import { ArrowLeft , Plus } from '@sim/emcn/icons'
66import { 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 ,
0 commit comments