Skip to content

Commit

Permalink
Remove Down Vote Button and Obsolete UI command (#9950)
Browse files Browse the repository at this point in the history
* Remove Down Vote Button and Obsolete UI command

* Remove Downvote tests
  • Loading branch information
QilongTang authored Sep 4, 2019
1 parent fb26e4e commit 2d265ed
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 71 deletions.
11 changes: 1 addition & 10 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1667,9 +1667,6 @@ Next assemblies were loaded several times:
<value>Description</value>
<comment>Package description</comment>
</data>
<data name="PackageSearchViewDownvoteButtonTooltip" xml:space="preserve">
<value>Downvote to voice lack of support for this package</value>
</data>
<data name="PackageSearchViewInstallButton" xml:space="preserve">
<value>⇓ Install</value>
<comment>To install package</comment>
Expand Down
3 changes: 0 additions & 3 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1308,9 +1308,6 @@ You will get a chance to save your work.</value>
<value>Description</value>
<comment>Package description</comment>
</data>
<data name="PackageSearchViewDownvoteButtonTooltip" xml:space="preserve">
<value>Downvote to voice lack of support for this package</value>
</data>
<data name="PackageSearchViewInstallButton" xml:space="preserve">
<value>⇓ Install</value>
<comment>To install package</comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,6 @@ public List<PackageManagerSearchElement> ListAll()
var ele = new PackageManagerSearchElement(header);

ele.UpvoteRequested += this.Model.Upvote;
ele.DownvoteRequested += this.Model.Downvote;

CachedPackageList.Add( ele );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class PackageManagerSearchElementViewModel : BrowserItemViewModel, IEquat
{
public ICommand DownloadLatestCommand { get; set; }
public ICommand UpvoteCommand { get; set; }

[Obsolete("This UI command will no longer decrease package votes and will be removed in Dynamo 3.0")]
public ICommand DownvoteCommand { get; set; }
public ICommand VisitSiteCommand { get; set; }
public ICommand VisitRepositoryCommand { get; set; }
Expand All @@ -31,6 +33,8 @@ public PackageManagerSearchElementViewModel(PackageManagerSearchElement element,
this.DownloadLatestToCustomPathCommand = new DelegateCommand(() => OnRequestDownload(Model.Header.versions.Last(), true));

this.UpvoteCommand = new DelegateCommand(Model.Upvote, () => canLogin);

// TODO: Remove the initialization of the UI command in Dynamo 3.0
this.DownvoteCommand = new DelegateCommand(Model.Downvote, () => canLogin);

this.VisitSiteCommand =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,25 +323,18 @@
</StackPanel>
</Button>

<StackPanel Width="55" Orientation="Vertical" Margin="3,0,0,0">
<StackPanel Orientation="Horizontal">
<StackPanel Width="80" Orientation="Vertical" Margin="3,0,0,0">
<StackPanel Orientation="Vertical">
<Button Name="UpvoteButton"
FontSize="15"
ToolTip="{x:Static p:Resources.PackageSearchViewUpvoteButtonTooltip}"
Content="👍"
Margin="0,0,8,0"
Margin="0,0,0,0"
Foreground="Gray"
Command="{Binding Path=UpvoteCommand}"
Style="{StaticResource FlatButton}" />
<Button Name="DownvoteButton"
FontSize="15"
ToolTip="{x:Static p:Resources.PackageSearchViewDownvoteButtonTooltip}"
Foreground="Gray"
Content="👎"
Command="{Binding Path=DownvoteCommand}"
Style="{StaticResource FlatButton}" />
<TextBlock FontSize="10" TextAlignment="Center" Margin="0,0,0,0" Text="{Binding Path=Model.Votes}" Foreground="Gray" />
</StackPanel>
<TextBlock FontSize="10" TextAlignment="Center" Margin="0,0,0,0" Text="{Binding Path=Model.Votes}" Foreground="Gray" />
</StackPanel>
</StackPanel>

Expand Down
9 changes: 0 additions & 9 deletions src/DynamoPackages/PackageManagerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ internal bool Upvote(string packageId)
}, false);
}

internal bool Downvote(string packageId)
{
return FailFunc.TryExecute(() =>
{
var pkgResponse = this.client.ExecuteAndDeserialize(new Downvote(packageId));
return pkgResponse.success;
}, false);
}

internal PackageManagerResult DownloadPackage(string packageId, string version, out string pathToPackage)
{
try
Expand Down
2 changes: 2 additions & 0 deletions src/DynamoPackages/PackageManagerSearchElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class PackageManagerSearchElement : SearchElementBase
/// An event that's invoked when the user has attempted to downvote this
/// package.
/// </summary>
[Obsolete("This event will be removed in Dynamo 3.0")]
public event Func<string, bool> DownvoteRequested;

public string Maintainers { get { return String.Join(", ", this.Header.maintainers.Select(x => x.username)); } }
Expand Down Expand Up @@ -155,6 +156,7 @@ public void Upvote()
, TaskScheduler.FromCurrentSynchronizationContext());
}

[Obsolete("This API will no longer decrease package votes and will be removed in Dynamo 3.0")]
public void Downvote()
{
Task<bool>.Factory.StartNew(() => DownvoteRequested(this.Id))
Expand Down
33 changes: 0 additions & 33 deletions test/Libraries/PackageManagerTests/PackageManagerClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,39 +173,6 @@ public void Upvote_ReturnsFalseWhenRequestThrowsException()

#endregion

#region Downvote

[Test]
public void Downvote_ReturnsTrueWhenRequestSucceeds()
{
var gc = new Mock<IGregClient>();
gc.Setup(x => x.ExecuteAndDeserialize(It.IsAny<Downvote>())).Returns(new ResponseBody()
{
success = true
});

var pc = new PackageManagerClient(gc.Object, MockMaker.Empty<IPackageUploadBuilder>(), "");

var res = pc.Downvote("id");

Assert.IsTrue(res);
}

[Test]
public void Downvote_ReturnsFalseWhenRequestThrowsException()
{
var gc = new Mock<IGregClient>();
gc.Setup(x => x.ExecuteAndDeserialize(It.IsAny<Downvote>())).Throws<Exception>();

var pc = new PackageManagerClient(gc.Object, MockMaker.Empty<IPackageUploadBuilder>(), "");

var res = pc.Downvote("id");

Assert.IsFalse(res);
}

#endregion

#region GetTermsOfUseAcceptanceStatus

[Test]
Expand Down

0 comments on commit 2d265ed

Please sign in to comment.