feat(domain,application,infrastructure,backend,web-server,app-tauri,frontend): lot utilisateur #325 #326 — icônes projet avec watermark CLI custom et localisation FR/EN (QA verte)
Lot en un seul commit: les deux features partagent les mêmes contrats (domain/settings.rs, DTO, commandes Tauri/HTTP, web-server) et les mêmes surfaces UI — la séparation par fichiers était impossible sans chirurgie de hunks risquant des états intermédiaires non compilables (convention lot des batches #310-#313 et #315). #325 — icône configurable par projet, watermark CLI custom: - domaine: ProjectIconSet (devicon, simple-icons, lucide, idea), ProjectIconRef validé (nom ASCII 1..=64, -_. internes), champ icon optionnel sur ProjectSettings; sérialisation camelCase et try_from strict - application: UpdateProjectSettings.execute accepte un patch theme_color OU icon (absent = inchangé, null = défaut produit), tests in-dependants avec store mémoire - backend/app-tauri/web-server: ProjectIconRefDto, UpdateProjectSettingsRequestDto avec icon optionnel (désérialisation additive), commandes update_project_settings alignées Tauri/HTTP, tests DTO et HTTP (défaut null, set, clear, nom invalide rejeté) - frontend: catalogue projectIcons (recherche EN), ProjectIconPicker en grille multi-lignes dans Paramètres projet, affichage de l'icône dans ProjectTabs et watermark grand format à faible opacité en fond de CLI custom; ports ProjectSettings.icon, Partial<ProjectSettings>, adapters tauri/mock/http et tests alignés #326 — localisation FR/EN et traduction des textes IdeA: - domaine: IdeaLanguage (fr | en), champ language optionnel sur IdeaUserSettings (absence = défaut produit, série additive validée) - backend/web-server: UserSettingsDto.language, update_user_settings accepte language, tests HTTP alignés; fixtures structured_launch_d3 mises à jour - frontend: i18n/ (catalogue FR/EN, I18nProvider, scan anti-régression des sources visibles), GeneralSettings avec sélecteur de langue dans les paramètres, setupI18n dans vitest; migration de l'ensemble des textes hardcodés vers le catalogue sur toutes les surfaces (agents, layout, projets, tickets, sprints, web, plugins, permissions, git, templates, skills, mémoire, model servers, embedder, first-run, devices, scheduled tasks, workstate, dialogs), FR conservé par défaut; recherche d'icônes #325 en anglais conformément au ticket QA verte sur feature/batch-325-326-project-icons-localisation. Aucun push.
This commit is contained in:
@ -2,7 +2,8 @@
|
||||
|
||||
use crate::AppError;
|
||||
use domain::{
|
||||
IdeaUserSettings, Project, ProjectSettings, ProjectSettingsStore, ThemeColor, UserSettingsStore,
|
||||
IdeaUserSettings, Project, ProjectIconRef, ProjectSettings, ProjectSettingsStore, ThemeColor,
|
||||
UserSettingsStore,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
@ -64,18 +65,109 @@ impl UpdateProjectSettings {
|
||||
}
|
||||
/// Applies the supplied fields and returns the accepted project settings.
|
||||
///
|
||||
/// An absent outer option leaves the colour unchanged; an explicit inner
|
||||
/// `None` restores the product fallback.
|
||||
/// An absent outer option leaves a field unchanged; an explicit inner
|
||||
/// `None` restores that field's product fallback.
|
||||
pub async fn execute(
|
||||
&self,
|
||||
project: &Project,
|
||||
theme_color: Option<Option<ThemeColor>>,
|
||||
icon: Option<Option<ProjectIconRef>>,
|
||||
) -> Result<ProjectSettings, AppError> {
|
||||
let mut settings = self.store.load(&project.root).await?;
|
||||
let mut changed = false;
|
||||
if let Some(theme_color) = theme_color {
|
||||
settings.theme_color = theme_color;
|
||||
changed = true;
|
||||
}
|
||||
if let Some(icon) = icon {
|
||||
settings.icon = icon;
|
||||
changed = true;
|
||||
}
|
||||
if changed {
|
||||
self.store.save(&project.root, &settings).await?;
|
||||
}
|
||||
Ok(settings)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use async_trait::async_trait;
|
||||
use domain::{ProjectIconSet, ProjectPath, RemoteRef, StoreError};
|
||||
use std::sync::Mutex;
|
||||
|
||||
struct MemoryProjectSettings(Mutex<ProjectSettings>);
|
||||
|
||||
#[async_trait]
|
||||
impl ProjectSettingsStore for MemoryProjectSettings {
|
||||
async fn load(&self, _root: &ProjectPath) -> Result<ProjectSettings, StoreError> {
|
||||
Ok(self.0.lock().unwrap().clone())
|
||||
}
|
||||
|
||||
async fn save(
|
||||
&self,
|
||||
_root: &ProjectPath,
|
||||
settings: &ProjectSettings,
|
||||
) -> Result<(), StoreError> {
|
||||
*self.0.lock().unwrap() = settings.clone();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn project() -> Project {
|
||||
Project::new(
|
||||
domain::ProjectId::new_random(),
|
||||
"Settings",
|
||||
ProjectPath::new("/settings-project").unwrap(),
|
||||
RemoteRef::Local,
|
||||
0,
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn project_settings_patch_updates_fields_independently_and_supports_clear() {
|
||||
let store = Arc::new(MemoryProjectSettings(Mutex::new(ProjectSettings {
|
||||
theme_color: Some(ThemeColor::new("#123456").unwrap()),
|
||||
icon: Some(ProjectIconRef::new(ProjectIconSet::Devicon, "rust").unwrap()),
|
||||
})));
|
||||
let update = UpdateProjectSettings::new(store);
|
||||
let project = project();
|
||||
|
||||
let icon = ProjectIconRef::new(ProjectIconSet::Lucide, "star").unwrap();
|
||||
let after_icon = update
|
||||
.execute(&project, None, Some(Some(icon.clone())))
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
after_icon.theme_color.as_ref().map(ThemeColor::as_str),
|
||||
Some("#123456")
|
||||
);
|
||||
assert_eq!(after_icon.icon, Some(icon));
|
||||
|
||||
let after_theme = update
|
||||
.execute(
|
||||
&project,
|
||||
Some(Some(ThemeColor::new("#ABCDEF").unwrap())),
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
after_theme.theme_color.as_ref().map(ThemeColor::as_str),
|
||||
Some("#ABCDEF")
|
||||
);
|
||||
assert_eq!(
|
||||
after_theme.icon.as_ref().map(ProjectIconRef::name),
|
||||
Some("star")
|
||||
);
|
||||
|
||||
let cleared = update.execute(&project, None, Some(None)).await.unwrap();
|
||||
assert!(cleared.icon.is_none());
|
||||
assert_eq!(
|
||||
cleared.theme_color.as_ref().map(ThemeColor::as_str),
|
||||
Some("#ABCDEF")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -899,6 +899,7 @@ fn launch_fixture_with_preference(interface: DefaultAgentTerminalInterface) -> L
|
||||
.expect("fixture owns its launcher")
|
||||
.with_user_settings(Arc::new(FixedUserSettings(IdeaUserSettings {
|
||||
default_agent_terminal_interface: Some(interface),
|
||||
language: None,
|
||||
})));
|
||||
fixture.launch = Arc::new(launch);
|
||||
fixture
|
||||
@ -949,6 +950,7 @@ async fn changing_global_preference_does_not_replace_an_existing_terminal() {
|
||||
settings
|
||||
.save(&IdeaUserSettings {
|
||||
default_agent_terminal_interface: Some(DefaultAgentTerminalInterface::IdeaCli),
|
||||
language: None,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user