- 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`.
62 lines
1.5 KiB
TypeScript
62 lines
1.5 KiB
TypeScript
import { httpClient } from './base/http-client';
|
|
import { JiraConfig } from '@/lib/types';
|
|
|
|
export interface JiraConfigResponse {
|
|
jiraConfig: JiraConfig;
|
|
}
|
|
|
|
export interface SaveJiraConfigRequest {
|
|
baseUrl: string;
|
|
email: string;
|
|
apiToken: string;
|
|
projectKey?: string;
|
|
ignoredProjects?: string[];
|
|
}
|
|
|
|
export interface SaveJiraConfigResponse {
|
|
success: boolean;
|
|
message: string;
|
|
jiraConfig: JiraConfig;
|
|
}
|
|
|
|
class JiraConfigClient {
|
|
private readonly basePath = '/user-preferences/jira-config';
|
|
|
|
/**
|
|
* Récupère la configuration Jira actuelle
|
|
*/
|
|
async getJiraConfig(): Promise<JiraConfig> {
|
|
const response = await httpClient.get<JiraConfigResponse>(this.basePath);
|
|
return response.jiraConfig;
|
|
}
|
|
|
|
/**
|
|
* Sauvegarde la configuration Jira
|
|
*/
|
|
async saveJiraConfig(config: SaveJiraConfigRequest): Promise<SaveJiraConfigResponse> {
|
|
return httpClient.put<SaveJiraConfigResponse>(this.basePath, config);
|
|
}
|
|
|
|
/**
|
|
* Supprime la configuration Jira (remet à zéro)
|
|
*/
|
|
async deleteJiraConfig(): Promise<{ success: boolean; message: string }> {
|
|
return httpClient.delete(this.basePath);
|
|
}
|
|
|
|
/**
|
|
* Valide l'existence d'un projet Jira
|
|
*/
|
|
async validateProject(projectKey: string): Promise<{
|
|
success: boolean;
|
|
exists: boolean;
|
|
projectName?: string;
|
|
error?: string;
|
|
message: string;
|
|
}> {
|
|
return httpClient.post('/jira/validate-project', { projectKey });
|
|
}
|
|
}
|
|
|
|
export const jiraConfigClient = new JiraConfigClient();
|