* Add GitLab integration components Introduced PushToGitLabDialog and GitlabConnection components to handle GitLab project connections and push functionality. Includes user authentication, project handling, and UI for seamless integration with GitLab. * Add components for GitLab connection and push dialog Introduce `GitlabConnection` and `PushToGitLabDialog` components to handle GitLab integration. These components allow users to connect their GitLab account, manage recent projects, and push code to a GitLab repository with detailed configurations and feedback. * Fix GitLab personal access tokens link to use correct URL * Update GitHub push call to use new pushToRepository method * Enhance GitLab integration with performance improvements - Add comprehensive caching system for repositories and user data - Implement pagination and search/filter functionality with debouncing - Add skeleton loaders and improved loading states - Implement retry logic for API calls with exponential backoff - Add background refresh capabilities - Improve error handling and user feedback - Optimize API calls to reduce loading times * feat: implement GitLab integration with connection management and repository handling - Add GitLab connection UI components - Implement GitLab API service for repository operations - Add GitLab connection store for state management - Update existing connection components (Vercel, Netlify) - Add repository listing and statistics display - Refactor GitLab components into organized folder structure * fix: resolve GitLab deployment issues and improve user experience - Fix DialogTitle accessibility warnings for screen readers - Remove CORS-problematic attributes from avatar images to prevent loading errors - Enhance GitLab API error handling with detailed error messages - Fix project creation settings to prevent initial commit conflicts - Add automatic GitLab connection state initialization on app startup - Improve deployment dialog UI with better error handling and user feedback - Add GitLab deployment source type to action runner system - Clean up deprecated push dialog files and consolidate deployment components 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: implement GitHub clone repository dialog functionality This commit fixes the missing GitHub repository selection dialog in the "Clone a repo" feature by implementing the same elegant interface pattern used by GitLab. Key Changes: - Added onCloneRepository prop support to GitHubConnection component - Updated RepositoryCard to generate proper GitHub clone URLs (https://github.com/{full_name}.git) - Implemented full GitHub repository selection dialog in GitCloneButton.tsx - Added proper dialog close handling after successful clone operations - Maintained existing GitHub connection settings page functionality Technical Details: - Follows same component patterns as GitLab implementation - Uses proper TypeScript interfaces for clone URL handling - Includes professional dialog styling with loading states - Supports repository search, pagination, and authentication flow The GitHub clone experience now matches GitLab's functionality, providing users with a unified and intuitive repository selection interface across both providers. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Clean up unused connection components - Remove ConnectionForm.tsx (unused GitHub form component) - Remove CreateBranchDialog.tsx (unused branch creation dialog) - Remove RepositoryDialogContext.tsx (unused context provider) - Remove empty components/ directory These files were not referenced anywhere in the codebase and were leftover from development. * Remove environment variables info section from ConnectionsTab - Remove collapsible environment variables section - Clean up unused state and imports - Simplify the connections tab UI * Reorganize connections folder structure - Create netlify/ folder and move NetlifyConnection.tsx - Create vercel/ folder and move VercelConnection.tsx - Add index.ts files for both netlify and vercel folders - Update imports in ConnectionsTab.tsx to use new folder structure - All connection components now follow consistent folder organization --------- Co-authored-by: Hayat Bourgi <hayat.bourgi@montyholding.com> Co-authored-by: Hayat55 <53140162+Hayat55@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
117 lines
3.6 KiB
TypeScript
117 lines
3.6 KiB
TypeScript
import { atom } from 'nanostores';
|
|
import type { NetlifyConnection, NetlifyUser } from '~/types/netlify';
|
|
import { logStore } from './logs';
|
|
import { toast } from 'react-toastify';
|
|
|
|
// Initialize with stored connection or environment variable
|
|
const storedConnection = typeof window !== 'undefined' ? localStorage.getItem('netlify_connection') : null;
|
|
const envToken = import.meta.env.VITE_NETLIFY_ACCESS_TOKEN;
|
|
console.log('Netlify store: envToken loaded:', envToken ? '[TOKEN_EXISTS]' : '[NO_TOKEN]');
|
|
|
|
// If we have an environment token but no stored connection, initialize with the env token
|
|
const initialConnection: NetlifyConnection = storedConnection
|
|
? JSON.parse(storedConnection)
|
|
: {
|
|
user: null,
|
|
token: envToken || '',
|
|
stats: undefined,
|
|
};
|
|
|
|
export const netlifyConnection = atom<NetlifyConnection>(initialConnection);
|
|
export const isConnecting = atom<boolean>(false);
|
|
export const isFetchingStats = atom<boolean>(false);
|
|
|
|
// Function to initialize Netlify connection with environment token
|
|
export async function initializeNetlifyConnection() {
|
|
const currentState = netlifyConnection.get();
|
|
|
|
// If we already have a connection or no token, don't try to connect
|
|
if (currentState.user || !envToken) {
|
|
console.log('Netlify: Skipping auto-connect - user exists or no env token');
|
|
return;
|
|
}
|
|
|
|
console.log('Netlify: Attempting auto-connection with env token');
|
|
|
|
try {
|
|
isConnecting.set(true);
|
|
|
|
const response = await fetch('https://api.netlify.com/api/v1/user', {
|
|
headers: {
|
|
Authorization: `Bearer ${envToken}`,
|
|
},
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`Failed to connect to Netlify: ${response.statusText}`);
|
|
}
|
|
|
|
const userData = await response.json();
|
|
|
|
// Update the connection state
|
|
const connectionData: Partial<NetlifyConnection> = {
|
|
user: userData as NetlifyUser,
|
|
token: envToken,
|
|
};
|
|
|
|
// Store in localStorage for persistence
|
|
localStorage.setItem('netlify_connection', JSON.stringify(connectionData));
|
|
|
|
// Update the store
|
|
updateNetlifyConnection(connectionData);
|
|
|
|
// Fetch initial stats
|
|
await fetchNetlifyStats(envToken);
|
|
} catch (error) {
|
|
console.error('Error initializing Netlify connection:', error);
|
|
logStore.logError('Failed to initialize Netlify connection', { error });
|
|
} finally {
|
|
isConnecting.set(false);
|
|
}
|
|
}
|
|
|
|
export const updateNetlifyConnection = (updates: Partial<NetlifyConnection>) => {
|
|
const currentState = netlifyConnection.get();
|
|
const newState = { ...currentState, ...updates };
|
|
netlifyConnection.set(newState);
|
|
|
|
// Persist to localStorage
|
|
if (typeof window !== 'undefined') {
|
|
localStorage.setItem('netlify_connection', JSON.stringify(newState));
|
|
}
|
|
};
|
|
|
|
export async function fetchNetlifyStats(token: string) {
|
|
try {
|
|
isFetchingStats.set(true);
|
|
|
|
const sitesResponse = await fetch('https://api.netlify.com/api/v1/sites', {
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
if (!sitesResponse.ok) {
|
|
throw new Error(`Failed to fetch sites: ${sitesResponse.status}`);
|
|
}
|
|
|
|
const sites = (await sitesResponse.json()) as any;
|
|
|
|
const currentState = netlifyConnection.get();
|
|
updateNetlifyConnection({
|
|
...currentState,
|
|
stats: {
|
|
sites,
|
|
totalSites: sites.length,
|
|
},
|
|
});
|
|
} catch (error) {
|
|
console.error('Netlify API Error:', error);
|
|
logStore.logError('Failed to fetch Netlify stats', { error });
|
|
toast.error('Failed to fetch Netlify statistics');
|
|
} finally {
|
|
isFetchingStats.set(false);
|
|
}
|
|
}
|