feat: add project key support for Jira analytics
- Introduced `projectKey` and `ignoredProjects` fields in Jira configuration to enhance analytics capabilities. - Implemented project validation logic in `JiraConfigClient` and integrated it into the `JiraConfigForm` for user input. - Updated `IntegrationsSettingsPageClient` to display analytics dashboard link based on the configured project key. - Enhanced API routes to handle project key in Jira sync and user preferences. - Marked related tasks as complete in `TODO.md`.
This commit is contained in:
59
src/actions/jira-analytics.ts
Normal file
59
src/actions/jira-analytics.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
'use server';
|
||||
|
||||
import { JiraAnalyticsService } from '@/services/jira-analytics';
|
||||
import { userPreferencesService } from '@/services/user-preferences';
|
||||
import { JiraAnalytics } from '@/lib/types';
|
||||
|
||||
export type JiraAnalyticsResult = {
|
||||
success: boolean;
|
||||
data?: JiraAnalytics;
|
||||
error?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Server Action pour récupérer les analytics Jira du projet configuré
|
||||
*/
|
||||
export async function getJiraAnalytics(): Promise<JiraAnalyticsResult> {
|
||||
try {
|
||||
// Récupérer la config Jira depuis la base de données
|
||||
const jiraConfig = await userPreferencesService.getJiraConfig();
|
||||
|
||||
if (!jiraConfig.enabled || !jiraConfig.baseUrl || !jiraConfig.email || !jiraConfig.apiToken) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'Configuration Jira manquante. Configurez Jira dans les paramètres.'
|
||||
};
|
||||
}
|
||||
|
||||
if (!jiraConfig.projectKey) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'Aucun projet configuré pour les analytics. Configurez un projet dans les paramètres Jira.'
|
||||
};
|
||||
}
|
||||
|
||||
// Créer le service d'analytics
|
||||
const analyticsService = new JiraAnalyticsService({
|
||||
baseUrl: jiraConfig.baseUrl,
|
||||
email: jiraConfig.email,
|
||||
apiToken: jiraConfig.apiToken,
|
||||
projectKey: jiraConfig.projectKey
|
||||
});
|
||||
|
||||
// Récupérer les analytics
|
||||
const analytics = await analyticsService.getProjectAnalytics();
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: analytics
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Erreur lors du calcul des analytics Jira:', error);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Erreur lors du calcul des analytics'
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user