Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 2 additions & 46 deletions src/GitHubExtension/Widgets/GitHubReviewWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ namespace GitHubExtension.Widgets;

internal sealed class GitHubReviewWidget : GitHubUserWidget
{
public GitHubReviewWidget()
: base()
protected override string GetTitleIconData()
{
// This widget does not allow customization, so this value will not change.
ShowCategory = SearchCategory.PullRequests;
return IconLoader.GetIconAsBase64("pulls.png");
}

public override void RequestContentData()
Expand All @@ -25,48 +23,6 @@ public override void RequestContentData()
RequestContentData(request);
}

protected override string GetTitleIconData()
{
return IconLoader.GetIconAsBase64("pulls.png");
}

// This widget does not have "ShowCategory" as a variable.
// So we override this method to not care about this data.
protected override void ResetWidgetInfoFromState()
{
base.ResetWidgetInfoFromState();
ShowCategory = SearchCategory.PullRequests;
}

// Overriding this method because this widget only cares about the account.
public override void OnActionInvoked(WidgetActionInvokedArgs actionInvokedArgs)
{
if (actionInvokedArgs.Verb == "Submit")
{
var data = actionInvokedArgs.Data;
var dataObject = JsonNode.Parse(data);

if (dataObject == null)
{
return;
}

DeveloperLoginId = dataObject["account"]?.GetValue<string>() ?? string.Empty;
UpdateTitle(dataObject);

ConfigurationData = data;

// If we got here during the customization flow, we need to LoadContentData again
// so we can show the loading page rather than stale data.
LoadContentData();
UpdateActivityState();
}
else
{
base.OnActionInvoked(actionInvokedArgs);
}
}

public override string GetTemplatePath(WidgetPageState page)
{
return page switch
Expand Down
37 changes: 21 additions & 16 deletions src/GitHubExtension/Widgets/GitHubUserWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,28 +135,33 @@ public override void OnCustomizationRequested(WidgetCustomizationRequestedArgs c
base.OnCustomizationRequested(customizationRequestedArgs);
}

public override void OnActionInvoked(WidgetActionInvokedArgs actionInvokedArgs)
protected void SubmitAction(string data)
{
if (actionInvokedArgs.Verb == "Submit")
var dataObject = JsonNode.Parse(data);

if (dataObject == null)
{
var data = actionInvokedArgs.Data;
var dataObject = JsonNode.Parse(data);
return;
}

if (dataObject == null)
{
return;
}
ShowCategory = EnumHelper.StringToSearchCategory(dataObject["showCategory"]?.GetValue<string>() ?? string.Empty);
DeveloperLoginId = dataObject["account"]?.GetValue<string>() ?? string.Empty;
UpdateTitle(dataObject);

ShowCategory = EnumHelper.StringToSearchCategory(dataObject["showCategory"]?.GetValue<string>() ?? string.Empty);
DeveloperLoginId = dataObject["account"]?.GetValue<string>() ?? string.Empty;
UpdateTitle(dataObject);
ConfigurationData = data;

ConfigurationData = data;
// If we got here during the customization flow, we need to LoadContentData again
// so we can show the loading page rather than stale data.
LoadContentData();
UpdateActivityState();
}

// If we got here during the customization flow, we need to LoadContentData again
// so we can show the loading page rather than stale data.
LoadContentData();
UpdateActivityState();
public override void OnActionInvoked(WidgetActionInvokedArgs actionInvokedArgs)
{
if (actionInvokedArgs.Verb == "Submit")
{
var data = actionInvokedArgs.Data;
SubmitAction(data);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@
"label": "%Widget_Template/WidgetTitleLabel%",
"value": "${widgetTitle}"
},
{
"type": "Input.ChoiceSet",
"id": "showCategory",
"isMultiSelect": false,
"isVisible": false,
"value": "PullRequests",
"choices": [
{
"title": "%Widget_Template/PullRequests%",
"value": "PullRequests"
}
]
},
Comment thread
guimafelipe marked this conversation as resolved.
Resolved
{
"type": "ColumnSet",
"columns": [
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtensionServer/Package-Can.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
</LightMode>
</ThemeResources>
</Definition>
<Definition Id="GitHub_Reviews" DisplayName="ms-resource:Widget_DisplayName_Reviews" Description="ms-resource:Widget_Description_Reviews" IsCustomizable="false">
<Definition Id="GitHub_Reviews" DisplayName="ms-resource:Widget_DisplayName_Reviews" Description="ms-resource:Widget_Description_Reviews" IsCustomizable="true">
<Capabilities>
<Capability>
<Size Name="medium" />
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtensionServer/Package-Dev.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
</LightMode>
</ThemeResources>
</Definition>
<Definition Id="GitHub_Reviews" DisplayName="ms-resource:Widget_DisplayName_Reviews" Description="ms-resource:Widget_Description_Reviews" IsCustomizable="false">
<Definition Id="GitHub_Reviews" DisplayName="ms-resource:Widget_DisplayName_Reviews" Description="ms-resource:Widget_Description_Reviews" IsCustomizable="true">
<Capabilities>
<Capability>
<Size Name="medium" />
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtensionServer/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
</LightMode>
</ThemeResources>
</Definition>
<Definition Id="GitHub_Reviews" DisplayName="ms-resource:Widget_DisplayName_Reviews" Description="ms-resource:Widget_Description_Reviews" IsCustomizable="false">
<Definition Id="GitHub_Reviews" DisplayName="ms-resource:Widget_DisplayName_Reviews" Description="ms-resource:Widget_Description_Reviews" IsCustomizable="true">
<Capabilities>
<Capability>
<Size Name="medium" />
Expand Down