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

Hide/Show (Un)Deprecate Button for package owner only #10091

Merged
merged 6 commits into from
Oct 31, 2019
Merged
Changes from 4 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
24 changes: 21 additions & 3 deletions src/DynamoCoreWpf/ViewModels/PackageManager/PackageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,16 @@ private void Deprecate()

private bool CanDeprecate()
{
return dynamoViewModel.Model.AuthenticationManager.HasAuthProvider;
PackageInfo pkg = new PackageInfo(Model.Name, new Version(Model.VersionName));
bool isAuthor = false;
var header = packageManagerClient.GetPackageHeader(pkg);
if (header != null) {
if (header.maintainers.First().username.Equals(dynamoViewModel.Model.AuthenticationManager.Username))
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
{
isAuthor = true;
}
}
return dynamoViewModel.Model.AuthenticationManager.HasAuthProvider && isAuthor;
zeusongit marked this conversation as resolved.
Show resolved Hide resolved
}

private void Undeprecate()
Expand All @@ -203,13 +212,22 @@ private void Undeprecate()
Resources.UndeprecatingPackageMessageBoxTitle,
MessageBoxButton.YesNo, MessageBoxImage.Question);
if (res == MessageBoxResult.No) return;

packageManagerClient.Undeprecate(Model.Name);
}

private bool CanUndeprecate()
{
return dynamoViewModel.Model.AuthenticationManager.HasAuthProvider;
PackageInfo pkg = new PackageInfo(Model.Name, new Version(Model.VersionName));
zeusongit marked this conversation as resolved.
Show resolved Hide resolved
bool isAuthor = false;
var header = packageManagerClient.GetPackageHeader(pkg);
if (header != null)
{
if (header.maintainers.First().username.Equals(dynamoViewModel.Model.AuthenticationManager.Username))
{
isAuthor = true;
}
}
return dynamoViewModel.Model.AuthenticationManager.HasAuthProvider && isAuthor;
zeusongit marked this conversation as resolved.
Show resolved Hide resolved
}

private void PublishNewPackageVersion()
Expand Down