Skip to content

Commit

Permalink
Attempt to update extension to work with version in main
Browse files Browse the repository at this point in the history
Seems like list isn't updating itself
  • Loading branch information
michael-hawker committed Jan 31, 2025
1 parent 531e836 commit a14a9d9
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 37 deletions.
23 changes: 22 additions & 1 deletion PowerToys.sln
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZoomItModuleInterface", "sr
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZoomItSettingsInterop", "src\modules\ZoomIt\ZoomItSettingsInterop\ZoomItSettingsInterop.vcxproj", "{CA7D8106-30B9-4AEC-9D05-B69B31B8C461}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicrosoftLearnExtension", "src\modules\cmdpal\Exts\MicrosoftLearnExtension\MicrosoftLearnExtension.csproj", "{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Expand Down Expand Up @@ -3412,6 +3414,24 @@ Global
{CA7D8106-30B9-4AEC-9D05-B69B31B8C461}.Release|x64.Build.0 = Release|x64
{CA7D8106-30B9-4AEC-9D05-B69B31B8C461}.Release|x86.ActiveCfg = Release|x64
{CA7D8106-30B9-4AEC-9D05-B69B31B8C461}.Release|x86.Build.0 = Release|x64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|ARM64.ActiveCfg = Debug|ARM64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|ARM64.Build.0 = Debug|ARM64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|ARM64.Deploy.0 = Debug|ARM64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|x64.ActiveCfg = Debug|x64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|x64.Build.0 = Debug|x64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|x64.Deploy.0 = Debug|x64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|x86.ActiveCfg = Debug|x64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|x86.Build.0 = Debug|x64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Debug|x86.Deploy.0 = Debug|x64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|ARM64.ActiveCfg = Release|ARM64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|ARM64.Build.0 = Release|ARM64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|ARM64.Deploy.0 = Release|ARM64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|x64.ActiveCfg = Release|x64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|x64.Build.0 = Release|x64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|x64.Deploy.0 = Release|x64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|x86.ActiveCfg = Release|x64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|x86.Build.0 = Release|x64
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775}.Release|x86.Deploy.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -3679,14 +3699,15 @@ Global
{453CBB73-A3CB-4D0B-8D24-6940B86FE21D} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2}
{C0CE3B5E-16D3-495D-B335-CA791B660162} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2}
{3A9A7297-92C4-4F16-B6F9-8D4AB652C86C} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2}
{605E914B-7232-4789-AF46-BF5D3DDFC14E} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2}
{D5E5F5EA-1B6C-4A73-88BE-304F36C9E4EE} = {9873BA05-4C41-4819-9283-CF45D795431B}
{605E914B-7232-4789-AF46-BF5D3DDFC14E} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2}
{7F5B9557-5878-4438-A721-3E28296BA193} = {9873BA05-4C41-4819-9283-CF45D795431B}
{E81A7D20-9862-ABDB-0AAE-9BC5B517A9F9} = {ECB8E0D1-7603-4E5C-AB10-D1E545E6F8E2}
{DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC}
{0A84F764-3A88-44CD-AA96-41BDBD48627B} = {DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C}
{E4585179-2AC1-4D5F-A3FF-CFC5392F694C} = {DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C}
{CA7D8106-30B9-4AEC-9D05-B69B31B8C461} = {DD6E12FE-5509-4ABC-ACC2-3D6DC98A238C}
{1C58495C-6C10-4EB5-AE6B-CBE8DE8B9775} = {071E18A4-A530-46B8-AB7D-B862EE55E24E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\Common.Dotnet.CsWinRT.props" />
<PropertyGroup>
<OutputType>WinExe</OutputType>
Expand All @@ -7,6 +7,9 @@
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<UseWinUI>false</UseWinUI>
<EnableMsixTooling>true</EnableMsixTooling>
<OutputPath>$(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPalExtensions\$(RootNamespace)</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>

<ItemGroup>
Expand All @@ -26,6 +29,7 @@

<ItemGroup>
<ProjectReference Include="..\..\extensionsdk\Microsoft.CmdPal.Extensions.Helpers\Microsoft.CmdPal.Extensions.Helpers.csproj" />
<ProjectReference Include="..\..\..\..\common\Common.UI\Common.UI.csproj" />
</ItemGroup>

<!--
Expand All @@ -36,11 +40,6 @@
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<ProjectCapability Include="Msix" />
</ItemGroup>
<ItemGroup>
<Folder Include="Data\" />
<Folder Include="Forms\" />
<Folder Include="Commands\" />
</ItemGroup>

<!--
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,20 @@
using System.Threading.Tasks;
using Microsoft.CmdPal.Extensions;
using Microsoft.CmdPal.Extensions.Helpers;
using Windows.Foundation;

namespace MicrosoftLearnExtension;

public partial class MicrosoftLearnExtensionActionsProvider : ICommandProvider
public partial class MicrosoftLearnExtensionActionsProvider : CommandProvider
{
public string DisplayName => $"Microsoft Learn Doc Search Extension for cmdpal Commands";

public IconDataType Icon => new(string.Empty);
public MicrosoftLearnExtensionActionsProvider()
{
DisplayName = $"Microsoft Learn Doc Search Extension for cmdpal Commands";
}

private readonly IListItem[] _commands = [
new ListItem(new MicrosoftLearnExtensionPage()),
private readonly ICommandItem[] _actions = [
new CommandItem(new MicrosoftLearnExtensionPage()),
];

#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
public void Dispose() => throw new NotImplementedException();
#pragma warning restore CA1816 // Dispose methods should call SuppressFinalize

public IListItem[] TopLevelCommands()
{
return _commands;
}
public override ICommandItem[] TopLevelCommands() => _actions;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ public MicrosoftLearnExtensionPage()
{
Icon = new("https://learn.microsoft.com/favicon.ico");
Name = "Microsoft Learn Doc Search";
PlaceholderText = "Search Windows App SDK docs";
IsLoading = true;

// #091f2c
AccentColor = ColorHelpers.FromRgb(9, 31, 44);
}

private static async Task<List<SearchResult>> SearchMicrosoftLearn(string query)
{
if (string.IsNullOrWhiteSpace(query))
{
return new(); // TODO: Should have a hint of 'type query' item...
return new();
}

//// TODO: Sanitize input?
Expand All @@ -49,26 +54,27 @@ private static async Task<List<SearchResult>> SearchMicrosoftLearn(string query)
return JsonSerializer.Deserialize<SearchResultList>(response, JsonOptions).Results.ToList();
}

public override ISection[] GetItems(string query)
public override IListItem[] GetItems()
{
var t = DoGetItems(query);
var t = DoGetItems(SearchText);
t.ConfigureAwait(false);
return t.Result;
}

private async Task<ISection[]> DoGetItems(string query)
public override void UpdateSearchText(string oldSearch, string newSearch)
{
IsLoading = true;
GetItems();
}

private async Task<IListItem[]> DoGetItems(string query)
{
List<SearchResult> items = await SearchMicrosoftLearn(query);
this.Loading = false;
var s = new ListSection()
this.IsLoading = false;
return items.Select((post) => new ListItem(new LinkAction(post))
{
Title = "Posts",
Items = items.Select((post) => new ListItem(new LinkAction(post))
{
Title = post.Title,
Subtitle = post.Description,
}).ToArray(),
};
return [s];
Title = post.Title,
Subtitle = post.Description,
}).ToArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ namespace MicrosoftLearnExtension;
[ComVisible(true)]
[Guid("11771f22-a54a-400c-8c3d-5c9c31b4429c")]
[ComDefaultInterface(typeof(IExtension))]
public sealed partial class SampleExtension : IExtension
public sealed partial class SampleExtension : IExtension, IDisposable
{
private readonly ManualResetEvent _extensionDisposedEvent;

private readonly MicrosoftLearnExtensionActionsProvider _provider = new();

public SampleExtension(ManualResetEvent extensionDisposedEvent)
{
this._extensionDisposedEvent = extensionDisposedEvent;
Expand All @@ -26,7 +28,7 @@ public object GetProvider(ProviderType providerType)
switch (providerType)
{
case ProviderType.Commands:
return new MicrosoftLearnExtensionActionsProvider();
return _provider;
default:
return null;
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/cmdpal/terminate_extensions.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ taskkill /f /im MediaControlsExtension.exe
taskkill /f /im EverythingExtension.exe
taskkill /f /im MastodonExtension.exe
taskkill /f /im MenusExtension.exe
taskkill /f /im MicrosoftLearnExtension.exe
taskkill /f /im PokedexExtension.exe
taskkill /f /im SamplePagesExtension.exe
taskkill /f /im SSHKeychainExtension.exe
Expand Down

1 comment on commit a14a9d9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

🔴 Please review

See the 📜action log or 📝 job summary for details.

Unrecognized words (2)

devrel
sooon

To accept these unrecognized words as correct, you could run the following commands

... in a clone of the [email protected]:zadjii-msft/PowerToys.git repository
on the llama/docsext branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.24/apply.pl' |
perl - 'https://github.com/zadjii-msft/PowerToys/actions/runs/13063978389/attempts/1'
Errors (1)

See the 📜action log or 📝 job summary for details.

❌ Errors Count
❌ ignored-expect-variant 5

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Please sign in to comment.