Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

Changes proposed in this pull request

  • Extends policy system from PR Add system-wide policy configuration for centralized update control #3313 to support custom settings folder location
  • Adds SettingsFolderLocation nullable string property to PolicyInfo for path override
  • Modifies SettingsManager.GetSettingsFolderLocation() to check policy before falling back to portable/non-portable defaults
  • Validates policy paths are absolute, contain no invalid characters, and are directories (not files), with graceful fallback on failure
  • Updates documentation in settings.md with System-Wide Policy info box matching existing pattern from update.md
  • Removes "Available Policies" section from system-wide-policies.md to avoid duplication (policies documented in respective setting pages)
  • Adds UI indicator (IsLocationManagedByPolicy property and admin shield icon) in Settings view to show when location is managed by policy

Implementation:

public static string GetSettingsFolderLocation()
{
    // Policy override takes precedence with validation
    if (!string.IsNullOrWhiteSpace(PolicyManager.Current?.SettingsFolderLocation))
    {
        var policyPath = PolicyManager.Current.SettingsFolderLocation;
        if (!Path.IsPathRooted(policyPath)) { /* log error, fallback */ }
        try { 
            var fullPath = Path.GetFullPath(policyPath);
            if (File.Exists(fullPath)) { /* log error (is file not directory), fallback */ }
            else { return fullPath; }
        }
        catch (ArgumentException | NotSupportedException | SecurityException) { /* log error, fallback */ }
    }
    
    // Fall back to existing logic
    return ConfigurationManager.Current.IsPortable ? /* ... */;
}

config.json example:

{
  "Update_CheckForUpdatesAtStartup": false,
  "SettingsFolderLocation": "C:\\CustomPath\\NETworkManager\\Settings"
}

UI Enhancement:
The Settings view now displays a shield icon with "This setting is managed by your administrator" message when the location is controlled by policy, matching the existing pattern in the Update settings view.

Related issue(s)

Based on PR #3313 - System-wide policy infrastructure

Copilot generated summary

Copilot summary

This PR adds SettingsFolderLocation policy to enable administrators to centrally control settings storage location across all users. The implementation validates policy-provided paths (absolute, valid characters, directory not file) and falls back to defaults on validation failure. Documentation restructured to follow existing pattern with System-Wide Policy info boxes in setting pages. UI enhanced with admin indicator (shield icon + message) when location is managed by policy, matching the Update view pattern.

To-Do

Contributing

By submitting this pull request, I confirm the following:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 6 commits February 9, 2026 20:11
Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Copilot AI changed the title [WIP] Add policy to override SettingsFolder location in SettingsManager Add SettingsFolderLocation policy for centralized settings path control Feb 9, 2026
Copilot AI requested a review from BornToBeRoot February 9, 2026 20:19
@BornToBeRoot
Copy link
Owner

@copilot

  1. In GetSettingsFolderLocation() you should check it the path is a directory
  2. Add a note to the settings.md similar to what exists in the update.md and remove the "Available Policies" in the system-wide-policies.md
  3. Add also the is managed by admin icon/message to the property in the settings view similar to the update view

…ndicator

Co-authored-by: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 9, 2026

@copilot

  1. In GetSettingsFolderLocation() you should check it the path is a directory
    ...

All three items addressed in commit a58b7e0:

  1. Directory validation: Added File.Exists() check in GetSettingsFolderLocation() to ensure the policy path is not a file
  2. Documentation updated: Added System-Wide Policy info box to settings.md matching the format in update.md, and removed the "Available Policies" section from system-wide-policies.md
  3. Admin indicator added: Added IsLocationManagedByPolicy property to SettingsSettingsViewModel and added the shield icon with "This setting is managed by your administrator" message to SettingsSettingsView.xaml

The UI now shows the admin indicator below the Location field when SettingsFolderLocation is set in config.json, matching the behavior of the Update settings:

image

The Location field will display the policy-controlled path with the shield icon and accent-colored message when managed by policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants