Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pin widget flow #312

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions src/GitHubExtension/Widgets/GitHubAssignedWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public override void OnActionInvoked(WidgetActionInvokedArgs actionInvokedArgs)
}
}

public new void UpdateActivityState()
public override void UpdateActivityState()
{
// State logic for the Widget:
// Signed in -> Configure -> Active / Inactive per widget host.
Expand Down Expand Up @@ -235,7 +235,7 @@ public override void LoadContentData()

public void LoadContentData(IEnumerable<Octokit.Issue> items)
{
Log.Logger()?.ReportDebug(Name, ShortId, "Getting Data for Assigned in Widget");
Log.Logger()?.ReportDebug(Name, ShortId, "Getting Data for Assigned to Widget");

try
{
Expand Down Expand Up @@ -328,7 +328,6 @@ public string GetConfigurationData()
{
{ "showCategory", EnumHelper.SearchCategoryToString(ShowCategory == SearchCategory.Unknown ? SearchCategory.IssuesAndPullRequests : ShowCategory) },
{ "savedShowCategory", savedShowCategory != null ? "savedShowCategory" : string.Empty },
{ "configuring", true },
};
return configurationData.ToJsonString();
}
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/Widgets/GitHubIssuesWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public override string GetData(WidgetPageState page)
WidgetPageState.SignIn => GetSignIn(),
WidgetPageState.Configure => GetConfiguration(RepositoryUrl),
WidgetPageState.Content => ContentData,
WidgetPageState.Loading => new JsonObject { { "configuring", true } }.ToJsonString(),
WidgetPageState.Loading => EmptyJson,
_ => throw new NotImplementedException(Page.GetType().Name),
};
}
Expand Down
3 changes: 1 addition & 2 deletions src/GitHubExtension/Widgets/GitHubMentionedInWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public override void OnWidgetContextChanged(WidgetContextChangedArgs contextChan
UpdateActivityState();
}

public new void UpdateActivityState()
public override void UpdateActivityState()
{
// State logic for the Widget:
// Signed in -> Configure -> Active / Inactive per widget host.
Expand Down Expand Up @@ -304,7 +304,6 @@ public string GetConfigurationData()
{
{ "showCategory", EnumHelper.SearchCategoryToString(ShowCategory == SearchCategory.Unknown ? SearchCategory.IssuesAndPullRequests : ShowCategory) },
{ "savedShowCategory", savedShowCategory != null ? "savedShowCategory" : string.Empty },
{ "configuring", true },
};
return configurationData.ToJsonString();
}
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubExtension/Widgets/GitHubPullsWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public override string GetData(WidgetPageState page)
WidgetPageState.SignIn => GetSignIn(),
WidgetPageState.Configure => GetConfiguration(RepositoryUrl),
WidgetPageState.Content => ContentData,
WidgetPageState.Loading => new JsonObject { { "configuring", true } }.ToJsonString(),
WidgetPageState.Loading => EmptyJson,
_ => throw new NotImplementedException(Page.GetType().Name),
};
}
Expand Down
10 changes: 4 additions & 6 deletions src/GitHubExtension/Widgets/GitHubReviewWidget.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using GitHubExtension.DataManager;
using GitHubExtension.Helpers;
using GitHubExtension.Widgets.Enums;
using GitHubExtension.Widgets.Enums;
using Microsoft.Windows.Widgets.Providers;
using Octokit;

Expand Down Expand Up @@ -73,7 +71,7 @@ public override void OnWidgetContextChanged(WidgetContextChangedArgs contextChan
UpdateActivityState();
}

public new void UpdateActivityState()
public override void UpdateActivityState()
{
// State logic for the Widget: (no configuration is needed)
// Signed in -> Active / Inactive per widget host.
Expand Down Expand Up @@ -156,7 +154,7 @@ public override void LoadContentData()

public void LoadContentData(IEnumerable<Octokit.Issue> items)
{
Log.Logger()?.ReportDebug(Name, ShortId, "Getting Data for Mentioned in Widget");
Log.Logger()?.ReportDebug(Name, ShortId, "Getting Data for Review requested Widget");

try
{
Expand Down Expand Up @@ -232,7 +230,7 @@ public override string GetData(WidgetPageState page)
return page switch
{
WidgetPageState.SignIn => new JsonObject { { "message", Resources.GetResource(@"Widget_Template/SignInRequired", Log.Logger()) } }.ToJsonString(),
WidgetPageState.Configure => EmptyJson,
WidgetPageState.Configure => throw new NotImplementedException(Page.GetType().Name),
WidgetPageState.Content => ContentData,
WidgetPageState.Loading => EmptyJson,
_ => throw new NotImplementedException(Page.GetType().Name),
Expand Down
5 changes: 1 addition & 4 deletions src/GitHubExtension/Widgets/GitHubWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ public string GetConfiguration(string data)
if (data == string.Empty)
{
configurationData.Add("hasConfiguration", false);
configurationData.Add("configuring", true);
var repositoryData = new JsonObject
{
{ "url", string.Empty },
Expand Down Expand Up @@ -279,7 +278,6 @@ public string GetConfiguration(string data)
{
Log.Logger()?.ReportError(Name, ShortId, $"Failed getting configuration information for input url: {data}", ex);
configurationData.Add("hasConfiguration", false);
configurationData.Add("configuring", true);

var repositoryData = new JsonObject
{
Expand All @@ -302,7 +300,6 @@ public string GetSignIn()
var signInData = new JsonObject
{
{ "message", Resources.GetResource(@"Widget_Template/SignInRequired", Log.Logger()) },
{ "configuring", true },
};

return signInData.ToString();
Expand All @@ -314,7 +311,7 @@ public bool IsUserLoggedIn()
return authProvider.GetLoggedInDeveloperIds().DeveloperIds.Any();
}

public void UpdateActivityState()
public override void UpdateActivityState()
{
// State logic for the Widget:
// Signed in -> Valid Repository Url -> Active / Inactive per widget host.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,6 @@
"weight": "bolder",
"spacing": "None"
},
{
"type": "TextBlock",
"text": "%Widget_Template/Label%",
"wrap": true,
"size": "Small"
},
{
"type": "TextBlock",
"text": "${label}",
"wrap": true,
"weight": "bolder",
"spacing": "None"
},
{
"type": "TextBlock",
"text": "%Widget_Template/Author%",
Expand All @@ -91,19 +78,6 @@
"wrap": true,
"weight": "bolder",
"spacing": "None"
},
{
"type": "TextBlock",
"text": "%Widget_Template/Project%",
"wrap": true,
"size": "Small"
},
{
"type": "TextBlock",
"text": "${Project}",
"wrap": true,
"weight": "bolder",
"spacing": "None"
}
],
"spacing": "Medium",
Expand All @@ -115,7 +89,6 @@
{
"type": "ColumnSet",
"spacing": "Medium",
"$when": "${$root.savedRepositoryUrl != \"\"}",
"columns": [
{
"type": "Column",
Expand All @@ -142,7 +115,8 @@
"type": "Action.Execute",
"title": "%Widget_Template_Button/Cancel%",
"verb": "Cancel",
"tooltip": "%Widget_Template_Tooltip/Cancel%"
"tooltip": "%Widget_Template_Tooltip/Cancel%",
"isEnabled": "${$root.savedRepositoryUrl != \"\"}"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,6 @@
"weight": "bolder",
"spacing": "None"
},
{
"type": "TextBlock",
"text": "%Widget_Template/Label%",
"wrap": true,
"size": "Small"
},
{
"type": "TextBlock",
"text": "${label}",
"wrap": true,
"weight": "bolder",
"spacing": "None"
},
{
"type": "TextBlock",
"text": "%Widget_Template/Author%",
Expand All @@ -76,19 +63,6 @@
"wrap": true,
"weight": "bolder",
"spacing": "None"
},
{
"type": "TextBlock",
"text": "%Widget_Template/Project%",
"wrap": true,
"size": "Small"
},
{
"type": "TextBlock",
"text": "${Project}",
"wrap": true,
"weight": "bolder",
"spacing": "None"
}
],
"spacing": "Medium",
Expand All @@ -100,7 +74,6 @@
{
"type": "ColumnSet",
"spacing": "Medium",
"$when": "${$root.savedRepositoryUrl != \"\"}",
"columns": [
{
"type": "Column",
Expand All @@ -127,7 +100,8 @@
"type": "Action.Execute",
"title": "%Widget_Template_Button/Cancel%",
"verb": "Cancel",
"tooltip": "%Widget_Template_Tooltip/Cancel%"
"tooltip": "%Widget_Template_Tooltip/Cancel%",
"isEnabled": "${$root.savedRepositoryUrl != \"\"}"
}
]
}
Expand Down
2 changes: 2 additions & 0 deletions src/GitHubExtension/Widgets/WidgetImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ public void SetState(string state)
public abstract void OnCustomizationRequested(WidgetCustomizationRequestedArgs customizationRequestedArgs);

public abstract void OnWidgetContextChanged(WidgetContextChangedArgs contextChangedArgs);

public abstract void UpdateActivityState();
}