diff --git a/web-server/pages/api/internal/[org_id]/git_provider_org.ts b/web-server/pages/api/internal/[org_id]/git_provider_org.ts index 312cd7a12..d0837a055 100644 --- a/web-server/pages/api/internal/[org_id]/git_provider_org.ts +++ b/web-server/pages/api/internal/[org_id]/git_provider_org.ts @@ -61,6 +61,8 @@ const providerOrgBrandingMap = { gitlab: 'groups' }; +const THRESHOLD = 300; + export const getProviderOrgs = ( org_id: ID, provider: CodeSourceProvidersIntegration @@ -101,6 +103,9 @@ async function getRepos( let response: Response; do { + if (allRepos.length >= THRESHOLD) { + break; + } response = await fetch(url, { headers: { Authorization: `token ${token}` @@ -116,9 +121,10 @@ async function getRepos( const nextLink = response.headers.get('Link'); if (nextLink) { - // @ts-ignore - const nextUrl = nextLink.split(',').find((link) => link?.rel === 'next'); - url = nextUrl ? nextUrl.slice(1, -1) : ''; // Extract URL from link header + const nextUrl = nextLink + .split(',') + .find((link) => link.includes('rel="next"')); + url = nextUrl ? nextUrl.trim().split(';')[0].slice(1, -1) : ''; } else { url = ''; } diff --git a/web-server/src/content/Dashboards/useIntegrationHandlers.tsx b/web-server/src/content/Dashboards/useIntegrationHandlers.tsx index 78f21818c..19edd46fb 100644 --- a/web-server/src/content/Dashboards/useIntegrationHandlers.tsx +++ b/web-server/src/content/Dashboards/useIntegrationHandlers.tsx @@ -70,12 +70,11 @@ const ConfigureGithubModalBody: FC<{ }; const handleSubmission = useCallback(async () => { - if (!token.value) { setError('Please enter a valid token'); return; } - isLoading.true(); + depFn(isLoading.true); checkGitHubValidity(token.value) .then(async (isValid) => { if (!isValid) throw new Error('Invalid token'); @@ -84,9 +83,7 @@ const ConfigureGithubModalBody: FC<{ try { const res = await getMissingPATScopes(token.value); if (res.length) { - throw new Error( - `Token is missing scopes: ${res.join(', ')}` - ); + throw new Error(`Token is missing scopes: ${res.join(', ')}`); } } catch (e) { // @ts-ignore @@ -95,16 +92,10 @@ const ConfigureGithubModalBody: FC<{ }) .then(async () => { try { - return await linkProvider( - token.value, - orgId, - Integration.GITHUB - ); + return await linkProvider(token.value, orgId, Integration.GITHUB); } catch (e: any) { throw new Error( - `Failed to link Github${ - e?.message ? `: ${e?.message}` : '' - }`, + `Failed to link Github${e?.message ? `: ${e?.message}` : ''}`, e ); } @@ -127,9 +118,7 @@ const ConfigureGithubModalBody: FC<{ setError(e.message); console.error(`Error while linking token: ${e.message}`, e); }) - .finally(() => { - isLoading.false(); - }); + .finally(isLoading.false); }, [ dispatch, enqueueSnackbar, @@ -219,14 +208,15 @@ const TokenPermissions = () => { }, [position, positionArray.length]); const expand = useBoolState(false); - const isLoading = useBoolState(false); + const imageLoaded = useBoolState(false); // change position every second useEffect(() => { + if (!imageLoaded.value) return; if (expand.value) return depFn(position.set, 0); const interval = setInterval(changePosition, 2000); return () => clearInterval(interval); - }, [changePosition, expand.value, position.set]); + }, [changePosition, expand.value, imageLoaded.value, position.set]); const styles: SxProps[] = useMemo(() => { const baseStyles = { @@ -297,7 +287,7 @@ const TokenPermissions = () => { return (
{ height: expand.value ? '1257px' : '240px', transition: 'all 0.8s ease', position: 'relative', - maxWidth: '100%' + maxWidth: '100%', + background: '#0D1017' }} > { alt="PAT_permissions" /> - + {imageLoaded.value && } - {expandedStyles.map((style, index) => ( - - ))} + {imageLoaded.value && + expandedStyles.map((style, index) => ( + + ))} - {isLoading.value && ( + {!imageLoaded.value && ( { transform: 'translate(-50%, -50%)' }} > - Loading... + Loading... )}
- + Hover to expand