7.7 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 | 01 | execute | 1 |
|
true |
|
|
Purpose: Foundation contract — every other plan in this phase builds on this message class and base class extension. Output: GlobalSitesChangedMessage.cs, updated FeatureViewModelBase.cs
<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 From SharepointToolbox/Core/Messages/TenantSwitchedMessage.cs: ```csharp using CommunityToolkit.Mvvm.Messaging.Messages; using SharepointToolbox.Core.Models;namespace SharepointToolbox.Core.Messages;
public sealed class TenantSwitchedMessage : ValueChangedMessage { public TenantSwitchedMessage(TenantProfile profile) : base(profile) { } }
From SharepointToolbox/Core/Models/SiteInfo.cs:
```csharp
namespace SharepointToolbox.Core.Models;
public record SiteInfo(string Url, string Title);
From SharepointToolbox/ViewModels/FeatureViewModelBase.cs (OnActivated — extend this):
protected override void OnActivated()
{
Messenger.Register<TenantSwitchedMessage>(this, (r, m) => ((FeatureViewModelBase)r).OnTenantSwitched(m.Value));
}
protected virtual void OnTenantSwitched(TenantProfile profile)
{
// Derived classes override to reset their state
}
File: `SharepointToolbox/Core/Messages/GlobalSitesChangedMessage.cs`
```csharp
using CommunityToolkit.Mvvm.Messaging.Messages;
using SharepointToolbox.Core.Models;
namespace SharepointToolbox.Core.Messages;
public sealed class GlobalSitesChangedMessage : ValueChangedMessage<IReadOnlyList<SiteInfo>>
{
public GlobalSitesChangedMessage(IReadOnlyList<SiteInfo> sites) : base(sites) { }
}
```
The value type is `IReadOnlyList<SiteInfo>` (not ObservableCollection) because the message carries a snapshot of the current selection — receivers should not mutate the sender's collection.
cd "C:\Users\dev\Documents\projets\Sharepoint" && dotnet build SharepointToolbox/SharepointToolbox.csproj --no-incremental 2>&1 | tail -5
GlobalSitesChangedMessage.cs exists in Core/Messages/, compiles without errors, follows the ValueChangedMessage pattern.
Task 2: Extend FeatureViewModelBase with GlobalSites support
SharepointToolbox/ViewModels/FeatureViewModelBase.cs
Modify FeatureViewModelBase to register for GlobalSitesChangedMessage and store the global sites.
1. Add using directive: `using SharepointToolbox.Core.Models;` (SiteInfo is in Core.Models).
2. Add a protected property to store the global sites (after the existing fields, before RunCommand):
```csharp
/// <summary>
/// Sites selected in the global toolbar picker. Updated via GlobalSitesChangedMessage.
/// Derived VMs check this in RunOperationAsync before falling back to per-tab SiteUrl.
/// </summary>
protected IReadOnlyList<SiteInfo> GlobalSites { get; private set; } = Array.Empty<SiteInfo>();
```
3. In `OnActivated()`, add a second Messenger.Register call for GlobalSitesChangedMessage, right after the existing TenantSwitchedMessage registration:
```csharp
protected override void OnActivated()
{
Messenger.Register<TenantSwitchedMessage>(this, (r, m) => ((FeatureViewModelBase)r).OnTenantSwitched(m.Value));
Messenger.Register<GlobalSitesChangedMessage>(this, (r, m) => ((FeatureViewModelBase)r).OnGlobalSitesReceived(m.Value));
}
```
4. Add a private method that updates the property and calls the virtual hook:
```csharp
private void OnGlobalSitesReceived(IReadOnlyList<SiteInfo> sites)
{
GlobalSites = sites;
OnGlobalSitesChanged(sites);
}
```
5. Add a protected virtual method for derived classes to override:
```csharp
/// <summary>
/// Called when the global site selection changes. Override in derived VMs
/// to update UI state (e.g., pre-fill SiteUrl from first global site).
/// </summary>
protected virtual void OnGlobalSitesChanged(IReadOnlyList<SiteInfo> sites)
{
// Derived classes override to react to global site changes
}
```
Do NOT modify anything in the ExecuteAsync, RunCommand, CancelCommand, or OnTenantSwitched areas. Only add the new GlobalSites infrastructure.
cd "C:\Users\dev\Documents\projets\Sharepoint" && dotnet build SharepointToolbox/SharepointToolbox.csproj --no-incremental 2>&1 | tail -5 && dotnet test SharepointToolbox.Tests/SharepointToolbox.Tests.csproj --no-build 2>&1 | tail -5
FeatureViewModelBase compiles with GlobalSites property, OnGlobalSitesChanged virtual method, and GlobalSitesChangedMessage registration in OnActivated. All existing tests still pass (no regression).
- `dotnet build SharepointToolbox/SharepointToolbox.csproj` succeeds with 0 errors
- `dotnet test` shows no new failures (existing tests unaffected)
- GlobalSitesChangedMessage.cs exists in Core/Messages/
- FeatureViewModelBase.cs contains `GlobalSites` property and `OnGlobalSitesChanged` virtual method
- OnActivated registers for both TenantSwitchedMessage and GlobalSitesChangedMessage
<success_criteria> The messaging contract is established: GlobalSitesChangedMessage can be sent by any publisher and received by all FeatureViewModelBase subclasses. The protected GlobalSites property and virtual OnGlobalSitesChanged hook are available for tab VMs to override in plan 06-04. </success_criteria>
After completion, create `.planning/phases/06-global-site-selection/06-01-SUMMARY.md`