Files
Sharepoint-Toolbox/.planning/phases/06-global-site-selection/06-03-PLAN.md
2026-04-07 09:57:15 +02:00

11 KiB

phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, must_haves
phase plan type wave depends_on files_modified autonomous requirements must_haves
06-global-site-selection 03 execute 2
06-02
SharepointToolbox/MainWindow.xaml
SharepointToolbox/MainWindow.xaml.cs
SharepointToolbox/Localization/Strings.resx
SharepointToolbox/Localization/Strings.fr.resx
SharepointToolbox/ViewModels/MainWindowViewModel.cs
true
SITE-01
truths artifacts key_links
A 'Select Sites' button is visible in the toolbar after the Clear Session button
A label next to the button shows the count of selected sites (e.g., '3 site(s) selected') or 'No sites selected'
Clicking the button opens SitePickerDialog and updates the global selection
The button is disabled when no tenant profile is connected
The button and label use localized strings (EN + FR)
The global site selection persists across tab switches (lives on MainWindowViewModel)
path provides contains
SharepointToolbox/MainWindow.xaml Toolbar with global site picker button and count label OpenGlobalSitePickerCommand
path provides contains
SharepointToolbox/MainWindow.xaml.cs SitePickerDialog factory wiring for toolbar OpenGlobalSitePickerDialog
path provides contains
SharepointToolbox/Localization/Strings.resx EN localization keys for global site picker toolbar.selectSites
path provides contains
SharepointToolbox/Localization/Strings.fr.resx FR localization keys for global site picker toolbar.selectSites
from to via pattern
SharepointToolbox/MainWindow.xaml SharepointToolbox/ViewModels/MainWindowViewModel.cs Command binding for OpenGlobalSitePickerCommand OpenGlobalSitePickerCommand
from to via pattern
SharepointToolbox/MainWindow.xaml.cs SharepointToolbox/Views/Dialogs/SitePickerDialog.xaml.cs Dialog factory lambda using DI OpenGlobalSitePickerDialog
Add the global site picker button and count label to the main toolbar, wire the SitePickerDialog factory from code-behind, add localization keys for all new toolbar strings, and update MainWindowViewModel to use localized label text.

Purpose: Makes the global site selection visible and interactive in the UI. Users see the button at all times regardless of active tab. Output: Updated MainWindow.xaml with toolbar controls, MainWindow.xaml.cs with dialog wiring, localization files with new EN/FR keys, MainWindowViewModel using localized label.

<execution_context> @C:/Users/SebastienQUEROL/.claude/get-shit-done/workflows/execute-plan.md @C:/Users/SebastienQUEROL/.claude/get-shit-done/templates/summary.md </execution_context>

@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md @.planning/phases/06-global-site-selection/06-CONTEXT.md @.planning/phases/06-global-site-selection/06-02-SUMMARY.md ```csharp public ObservableCollection GlobalSelectedSites { get; } public string GlobalSitesSelectedLabel { get; } // "3 site(s) selected" or "No sites selected" public RelayCommand OpenGlobalSitePickerCommand { get; } public Func? OpenGlobalSitePickerDialog { get; set; } // Factory set by code-behind ```

From SharepointToolbox/MainWindow.xaml (ToolBar section):

<ToolBar DockPanel.Dock="Top">
  <ComboBox Width="220" ... />
  <Button Content="..." Command="{Binding ConnectCommand}" />
  <Button Content="..." Command="{Binding ManageProfilesCommand}" />
  <Separator />
  <Button Content="..." Command="{Binding ClearSessionCommand}" />
  <!-- NEW: Separator + Select Sites button + count label go HERE -->
</ToolBar>

From SharepointToolbox/Views/Tabs/PermissionsView.xaml.cs:

vm.OpenSitePickerDialog = () =>
{
    var factory = serviceProvider.GetRequiredService<Func<TenantProfile, SitePickerDialog>>();
    return factory(vm.CurrentProfile ?? new TenantProfile());
};
Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[toolbar.connect]}"
Localization.TranslationSource.Instance["key"]
Task 1: Add localization keys for global site picker (EN + FR) SharepointToolbox/Localization/Strings.resx, SharepointToolbox/Localization/Strings.fr.resx Add the following localization keys to both resource files.
In `Strings.resx` (English), add these data entries (maintain alphabetical ordering with existing keys if the file is sorted, otherwise append at the end before the closing `</root>` tag):

```xml
<data name="toolbar.selectSites" xml:space="preserve">
  <value>Select Sites</value>
</data>
<data name="toolbar.selectSites.tooltip" xml:space="preserve">
  <value>Select target sites for all tabs</value>
</data>
<data name="toolbar.selectSites.tooltipDisabled" xml:space="preserve">
  <value>Connect to a tenant first</value>
</data>
<data name="toolbar.globalSites.count" xml:space="preserve">
  <value>{0} site(s) selected</value>
</data>
<data name="toolbar.globalSites.none" xml:space="preserve">
  <value>No sites selected</value>
</data>
```

In `Strings.fr.resx` (French), add the matching entries:

```xml
<data name="toolbar.selectSites" xml:space="preserve">
  <value>Choisir les sites</value>
</data>
<data name="toolbar.selectSites.tooltip" xml:space="preserve">
  <value>Choisir les sites cibles pour tous les onglets</value>
</data>
<data name="toolbar.selectSites.tooltipDisabled" xml:space="preserve">
  <value>Connectez-vous d'abord</value>
</data>
<data name="toolbar.globalSites.count" xml:space="preserve">
  <value>{0} site(s) selectionne(s)</value>
</data>
<data name="toolbar.globalSites.none" xml:space="preserve">
  <value>Aucun site selectionne</value>
</data>
```

Verify the resx files are well-formed XML after editing.
cd "C:\Users\dev\Documents\projets\Sharepoint" && dotnet build SharepointToolbox/SharepointToolbox.csproj --no-incremental 2>&1 | tail -5 Both Strings.resx and Strings.fr.resx contain the 5 new keys each. Build succeeds (resx compiles). Task 2: Update MainWindowViewModel label to use localized strings SharepointToolbox/ViewModels/MainWindowViewModel.cs Update the GlobalSitesSelectedLabel property (added in plan 06-02) to use the new localization keys instead of hardcoded strings.
Replace the GlobalSitesSelectedLabel property with:
```csharp
public string GlobalSitesSelectedLabel =>
    GlobalSelectedSites.Count > 0
        ? string.Format(Localization.TranslationSource.Instance["toolbar.globalSites.count"], GlobalSelectedSites.Count)
        : Localization.TranslationSource.Instance["toolbar.globalSites.none"];
```

This follows the same pattern used by PermissionsViewModel.SitesSelectedLabel.
cd "C:\Users\dev\Documents\projets\Sharepoint" && dotnet build SharepointToolbox/SharepointToolbox.csproj --no-incremental 2>&1 | tail -5 GlobalSitesSelectedLabel uses TranslationSource localized keys instead of hardcoded strings. Task 3: Add toolbar UI controls and wire SitePickerDialog factory SharepointToolbox/MainWindow.xaml, SharepointToolbox/MainWindow.xaml.cs **MainWindow.xaml** — Add a Separator, "Select Sites" button, and count label to the ToolBar, after the existing Clear Session button:
```xml
<Separator />
<Button Content="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[toolbar.selectSites]}"
        Command="{Binding OpenGlobalSitePickerCommand}"
        ToolTip="{Binding Source={x:Static loc:TranslationSource.Instance}, Path=[toolbar.selectSites.tooltip]}" />
<TextBlock Text="{Binding GlobalSitesSelectedLabel}"
           VerticalAlignment="Center" Margin="6,0,0,0"
           Foreground="Gray" />
```

Place these three elements immediately after the existing `<Button Content="..." Command="{Binding ClearSessionCommand}" />` line, before the closing `</ToolBar>` tag.

Note: The button is automatically disabled when SelectedProfile is null because OpenGlobalSitePickerCommand's CanExecute checks `SelectedProfile != null`. A disabled tooltip would require a style trigger — defer that (per context, it's Claude's discretion for exact XAML layout).

**MainWindow.xaml.cs** — Wire the SitePickerDialog factory for the global site picker. In the constructor, after the existing line that wires `OpenProfileManagementDialog`, add:

```csharp
// Wire global site picker dialog factory (same pattern as PermissionsView)
viewModel.OpenGlobalSitePickerDialog = () =>
{
    var factory = serviceProvider.GetRequiredService<Func<TenantProfile, SitePickerDialog>>();
    return factory(viewModel.SelectedProfile ?? new TenantProfile());
};
```

This requires adding a using directive for SitePickerDialog if not already present:
```csharp
using SharepointToolbox.Views.Dialogs;  // already imported for ProfileManagementDialog
```

Also add using for TenantProfile if not already present:
```csharp
using SharepointToolbox.Core.Models;  // already imported
```
cd "C:\Users\dev\Documents\projets\Sharepoint" && dotnet build SharepointToolbox/SharepointToolbox.csproj --no-incremental 2>&1 | tail -5 MainWindow.xaml shows "Select Sites" button + count label in toolbar. MainWindow.xaml.cs wires the SitePickerDialog factory to MainWindowViewModel.OpenGlobalSitePickerDialog. Build succeeds. - `dotnet build SharepointToolbox/SharepointToolbox.csproj` succeeds with 0 errors - MainWindow.xaml ToolBar contains the Select Sites button bound to OpenGlobalSitePickerCommand - MainWindow.xaml ToolBar contains a TextBlock bound to GlobalSitesSelectedLabel - MainWindow.xaml.cs sets viewModel.OpenGlobalSitePickerDialog factory - Strings.resx contains 5 new toolbar.* keys - Strings.fr.resx contains 5 matching FR translations - MainWindowViewModel.GlobalSitesSelectedLabel uses localized strings

<success_criteria> The toolbar displays a "Select Sites" button and a site count label. Clicking the button opens SitePickerDialog (when connected to a tenant). The label updates to show the count of selected sites. All strings are localized in EN and FR. </success_criteria>

After completion, create `.planning/phases/06-global-site-selection/06-03-SUMMARY.md`