Skip to content

Commit

Permalink
Add Redirection to SPA UI
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed May 6, 2024
1 parent 8e7ece7 commit 57c0a31
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/dotnet/APIView/APIViewWeb/Helpers/PageModelHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,13 @@ public static async Task<ReviewContentModel> GetReviewContentAsync(

var activeRevisionRenderableCodeFile = await codeFileRepository.GetCodeFileAsync(activeRevision.Id, activeRevision.Files[0].FileId);
var activeRevisionReviewCodeFile = activeRevisionRenderableCodeFile.CodeFile;

if (activeRevisionReviewCodeFile.CodeFileVersion.Equals("v2"))
{
reviewPageContent.Directive = ReviewContentModelDirective.RedirectToSPAUI;
return reviewPageContent;
}

var fileDiagnostics = activeRevisionReviewCodeFile.Diagnostics ?? Array.Empty<CodeDiagnostic>();

var activeRevisionHtmlLines = activeRevisionRenderableCodeFile.Render(showDocumentation: showDocumentation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public enum ReviewContentModelDirective
ProceedWithPageLoad = 0,
TryGetlegacyReview,
ErrorDueToInvalidAPIRevisonProceedWithPageLoad,
ErrorDueToInvalidAPIRevisonRedirectToIndexPage

ErrorDueToInvalidAPIRevisonRedirectToIndexPage,
RedirectToSPAUI
}

public class ReviewContentModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ public async Task<IActionResult> OnGetAsync(string id, string revisionId = null)
showDocumentation: (ShowDocumentation ?? false), showDiffOnly: ShowDiffOnly, diffContextSize: REVIEW_DIFF_CONTEXT_SIZE,
diffContextSeperator: DIFF_CONTEXT_SEPERATOR);

if (ReviewContent.Directive == ReviewContentModelDirective.RedirectToSPAUI)
{
var uri = $"https://spa.{Request.Host}/review/{id}?activeApiRevisionId={revisionId}";
return Redirect(uri);
}

if (ReviewContent.Directive == ReviewContentModelDirective.TryGetlegacyReview)
{
// Check if you can get review from legacy data
Expand Down
2 changes: 1 addition & 1 deletion src/dotnet/APIView/ClientSPA/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "2mb"
"maximumError": "3mb"
},
{
"type": "anyComponentStyle",
Expand Down

0 comments on commit 57c0a31

Please sign in to comment.