Skip to content

Commit

Permalink
Add Package version details and approval fields (#1186)
Browse files Browse the repository at this point in the history
* Add Package version details
  • Loading branch information
praveenkuttappan authored and benbp committed Dec 1, 2020
1 parent 77d9784 commit 7120e10
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/dotnet/APIView/APIView/Languages/CodeFileBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class CodeFileBuilder

public ICodeFileBuilderSymbolOrderProvider SymbolOrderProvider { get; set; } = new CodeFileBuilderSymbolOrderProvider();

public const string CurrentVersion = "18";
public const string CurrentVersion = "19";

private IEnumerable<INamespaceSymbol> EnumerateNamespaces(IAssemblySymbol assemblySymbol)
{
Expand Down Expand Up @@ -109,7 +109,8 @@ public CodeFile Build(IAssemblySymbol assemblySymbol, bool runAnalysis)
Tokens = builder.Tokens.ToArray(),
VersionString = CurrentVersion,
Navigation = new[] { assemblyNavigationItem },
Diagnostics = analyzer.Results.ToArray()
Diagnostics = analyzer.Results.ToArray(),
PackageName = assemblySymbol.Name
};

return node;
Expand Down
2 changes: 2 additions & 0 deletions src/dotnet/APIView/APIView/Model/CodeFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public string VersionString

public string Language { get; set; }

public string PackageName { get; set; }

public CodeFileToken[] Tokens { get; set; } = Array.Empty<CodeFileToken>();

public NavigationItem[] Navigation { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions src/dotnet/APIView/APIViewWeb/Models/ReviewCodeFileModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ public string Language

[Obsolete("Back compat don't use directly")]
public bool RunAnalysis { get; set; }

public string PackageName { get; set; }
}
}
14 changes: 12 additions & 2 deletions src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,19 @@
<input type="text" class="form-control" id="searchBox" placeholder="Filter by review name" autofocus>
</div>

<div class="btn-group float-left pl-5">
<a class="btn btn-primary" active-if='@Model.Language != "All"' asp-route-language="All">All</a>
<a class="btn btn-primary" active-if='@Model.Language != "C"' asp-route-language="C">C</a>
<a class="btn btn-primary" active-if='@Model.Language != "C#"' asp-route-language="C#">C#</a>
<a class="btn btn-primary" active-if='@Model.Language != "C++"' asp-route-language="C++">C++</a>
<a class="btn btn-primary" active-if='@Model.Language != "Java"' asp-route-language="Java">Java</a>
<a class="btn btn-primary" active-if='@Model.Language != "JS/TS"' asp-route-language="JavaScript">JS/TS</a>
<a class="btn btn-primary" active-if='@Model.Language != "Python"' asp-route-language="Python">Python</a>
</div>

<div class="btn-group float-right">
<a class="btn btn-secondary" active-if="!@Model.Closed" asp-route-closed="false">Open</a>
<a class="btn btn-secondary" active-if="@Model.Closed" asp-route-closed="true">Closed</a>
<a class="btn btn-secondary" active-if="!@Model.Closed" asp-route-closed="false" asp-route-language=@Model.Language>Open</a>
<a class="btn btn-secondary" active-if="@Model.Closed" asp-route-closed="true" asp-route-language=@Model.Language>Closed</a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ public IndexPageModel(ReviewManager manager)
[BindProperty(SupportsGet = true)]
public bool Closed { get; set; }

[BindProperty(SupportsGet = true)]
public string Language { get; set; } = "All";

public IEnumerable<ReviewModel> Assemblies { get; set; }

public async Task OnGetAsync()
{
Assemblies = await _manager.GetReviewsAsync(Closed);
Assemblies = await _manager.GetReviewsAsync(Closed, Language);
}

public async Task<IActionResult> OnPostUploadAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ public CosmosReviewRepository(IConfiguration configuration)
_reviewsContainer = client.GetContainer("APIView", "Reviews");
}

public async Task<IEnumerable<ReviewModel>> GetReviewsAsync(bool closed)
public async Task<IEnumerable<ReviewModel>> GetReviewsAsync(bool closed, string language)
{
var allReviews = new List<ReviewModel>();
var queryDefinition = new QueryDefinition("SELECT * FROM Reviews r WHERE" +
"(IS_DEFINED(r.IsClosed) ? r.IsClosed : false) = @isClosed")
.WithParameter("@isClosed", closed);
"(IS_DEFINED(r.IsClosed) ? r.IsClosed : false) = @isClosed AND " +
"('All' = @language OR EXISTS (SELECT VALUE revision FROM revision in r.Revisions WHERE " +
"EXISTS (SELECT VALUE files from files in revision.Files WHERE files.Language = @language)))")
.WithParameter("@isClosed", closed)
.WithParameter("@language", language);

var itemQueryIterator = _reviewsContainer.GetItemQueryIterator<ReviewModel>(queryDefinition);
while (itemQueryIterator.HasMoreResults)
Expand Down
5 changes: 3 additions & 2 deletions src/dotnet/APIView/APIViewWeb/Repositories/ReviewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public async Task<ReviewModel> CreateReviewAsync(ClaimsPrincipal user, string or
return review;
}

public Task<IEnumerable<ReviewModel>> GetReviewsAsync(bool closed)
public Task<IEnumerable<ReviewModel>> GetReviewsAsync(bool closed, string language)
{
return _reviewsRepository.GetReviewsAsync(closed);
return _reviewsRepository.GetReviewsAsync(closed, language);
}

public async Task DeleteReviewAsync(ClaimsPrincipal user, string id)
Expand Down Expand Up @@ -255,6 +255,7 @@ private void InitializeFromCodeFile(ReviewCodeFileModel file, CodeFile codeFile)
file.Language = codeFile.Language;
file.VersionString = codeFile.VersionString;
file.Name = codeFile.Name;
file.PackageName = codeFile.PackageName;
}

private LanguageService GetLanguageService(string language)
Expand Down

0 comments on commit 7120e10

Please sign in to comment.