diff --git a/src/dotnet/APIView/ClientSPA/src/app/_components/api-revision-options/api-revision-options.component.html b/src/dotnet/APIView/ClientSPA/src/app/_components/api-revision-options/api-revision-options.component.html index 22cf31dc5e8..06876b0393a 100644 --- a/src/dotnet/APIView/ClientSPA/src/app/_components/api-revision-options/api-revision-options.component.html +++ b/src/dotnet/APIView/ClientSPA/src/app/_components/api-revision-options/api-revision-options.component.html @@ -5,7 +5,7 @@ [(ngModel)]="selectedActiveAPIRevision" optionLabel="label" inputId="active-api-revision-select" - [panelStyle]="{'width':'30dvw'}" + [panelStyle]="{'width':'40dvw'}" [filter]="true" [resetFilterOnHide]="true" (onHide)="resetDropDownFilter('active')" @@ -73,7 +73,7 @@ [(ngModel)]="selectedDiffAPIRevision" optionLabel="label" inputId="diff-api-revision-select" - [panelStyle]="{'width':'30dvw'}" + [panelStyle]="{'width':'40dvw'}" [filter]="true" [resetFilterOnHide]="true" (onHide)="resetDropDownFilter('diff')" diff --git a/src/dotnet/APIView/ClientSPA/src/app/_components/api-revision-options/api-revision-options.component.ts b/src/dotnet/APIView/ClientSPA/src/app/_components/api-revision-options/api-revision-options.component.ts index c7aed8906f2..d76cfe8dc38 100644 --- a/src/dotnet/APIView/ClientSPA/src/app/_components/api-revision-options/api-revision-options.component.ts +++ b/src/dotnet/APIView/ClientSPA/src/app/_components/api-revision-options/api-revision-options.component.ts @@ -124,15 +124,14 @@ export class ApiRevisionOptionsComponent implements OnChanges { }); if (dropDownMenu === "active") { - this.activeApiRevisionsMenu = filtered; + this.activeApiRevisionsMenu = filtered.filter((apiRevision: APIRevision) => apiRevision.id !== this.diffApiRevisionId); if (this.selectedActiveAPIRevision && !this.activeApiRevisionsMenu.includes(this.selectedActiveAPIRevision)) { this.activeApiRevisionsMenu.unshift(this.selectedActiveAPIRevision); } } if (dropDownMenu === "diff") { - filtered = filtered.filter((apiRevision: APIRevision) => apiRevision.id !== this.activeApiRevisionId); - this.diffApiRevisionsMenu = filtered + this.diffApiRevisionsMenu = filtered.filter((apiRevision: APIRevision) => apiRevision.id !== this.activeApiRevisionId); if (this.selectedDiffAPIRevision && !this.diffApiRevisionsMenu.includes(this.selectedDiffAPIRevision)) { this.diffApiRevisionsMenu.unshift(this.selectedDiffAPIRevision); } diff --git a/src/dotnet/APIView/ClientSPA/src/app/_components/review-page-options/review-page-options.component.ts b/src/dotnet/APIView/ClientSPA/src/app/_components/review-page-options/review-page-options.component.ts index b88edc44778..d8730b70e6c 100644 --- a/src/dotnet/APIView/ClientSPA/src/app/_components/review-page-options/review-page-options.component.ts +++ b/src/dotnet/APIView/ClientSPA/src/app/_components/review-page-options/review-page-options.component.ts @@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChange import { ActivatedRoute, Router } from '@angular/router'; import { InputSwitchOnChangeEvent } from 'primeng/inputswitch'; import { getQueryParams } from 'src/app/_helpers/router-helpers'; -import { mapLanguageAliases } from 'src/app/_helpers/common-helpers'; +import { FULL_DIFF_STYLE, mapLanguageAliases, NODE_DIFF_STYLE, TREE_DIFF_STYLE } from 'src/app/_helpers/common-helpers'; import { Review } from 'src/app/_models/review'; import { APIRevision } from 'src/app/_models/revision'; import { ConfigService } from 'src/app/_services/config/config.service'; @@ -66,9 +66,9 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges{ selectedApprovers: string[] = []; diffStyleOptions : any[] = [ - { label: 'Full Diff', value: "full" }, - { label: 'Only Trees', value: "trees"}, - { label: 'Only Nodes', value: "nodes" } + { label: 'Full Diff', value: FULL_DIFF_STYLE }, + { label: 'Only Trees', value: TREE_DIFF_STYLE }, + { label: 'Only Nodes', value: NODE_DIFF_STYLE } ]; selectedDiffStyle : string = this.diffStyleOptions[0]; diff --git a/src/dotnet/APIView/ClientSPA/src/app/_components/review-page/review-page.component.ts b/src/dotnet/APIView/ClientSPA/src/app/_components/review-page/review-page.component.ts index 45972bc884e..20a017ad612 100644 --- a/src/dotnet/APIView/ClientSPA/src/app/_components/review-page/review-page.component.ts +++ b/src/dotnet/APIView/ClientSPA/src/app/_components/review-page/review-page.component.ts @@ -68,7 +68,7 @@ export class ReviewPageComponent implements OnInit { constructor(private route: ActivatedRoute, private router: Router, private apiRevisionsService: RevisionsService, private reviewsService: ReviewsService, private workerService: WorkerService, private changeDetectorRef: ChangeDetectorRef, - private userProfileService: UserProfileService, private commentsService: CommentsService) {} + private userProfileService: UserProfileService) {} ngOnInit() { this.userProfileService.getUserProfile().subscribe( @@ -88,7 +88,6 @@ export class ReviewPageComponent implements OnInit { this.showLineNumbers = false; } }); - this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe(params => { const navigationState = this.router.getCurrentNavigation()?.extras.state; if (!navigationState || !navigationState['skipStateUpdate']) { diff --git a/src/dotnet/APIView/ClientSPA/src/app/_helpers/common-helpers.ts b/src/dotnet/APIView/ClientSPA/src/app/_helpers/common-helpers.ts index 581503a5dee..b9abf5b92e3 100644 --- a/src/dotnet/APIView/ClientSPA/src/app/_helpers/common-helpers.ts +++ b/src/dotnet/APIView/ClientSPA/src/app/_helpers/common-helpers.ts @@ -3,6 +3,9 @@ export const ACTIVE_API_REVISION_ID_QUERY_PARAM = "activeApiRevisionId"; export const DIFF_API_REVISION_ID_QUERY_PARAM = "diffApiRevisionId"; export const DIFF_STYLE_QUERY_PARAM = "diffStyle"; export const SCROLL_TO_NODE_QUERY_PARAM = "nId"; +export const FULL_DIFF_STYLE = "full"; +export const TREE_DIFF_STYLE = "trees"; +export const NODE_DIFF_STYLE = "nodes"; export function getLanguageCssSafeName(language: string): string { switch (language.toLowerCase()) { diff --git a/src/dotnet/APIView/ClientSPA/src/app/_workers/apitree-builder.worker.ts b/src/dotnet/APIView/ClientSPA/src/app/_workers/apitree-builder.worker.ts index 590d8b2eb3d..5ca6abba75a 100644 --- a/src/dotnet/APIView/ClientSPA/src/app/_workers/apitree-builder.worker.ts +++ b/src/dotnet/APIView/ClientSPA/src/app/_workers/apitree-builder.worker.ts @@ -4,6 +4,7 @@ import { ApiTreeBuilderData } from "../_models/revision"; import { CodePanelData, CodePanelNodeMetaData, CodePanelRowData, CodePanelRowDatatype } from '../_models/codePanelModels'; import { InsertCodePanelRowDataMessage, ReviewPageWorkerMessageDirective } from '../_models/insertCodePanelRowDataMessage'; import { NavigationTreeNode } from '../_models/navigationTreeModels'; +import { FULL_DIFF_STYLE, NODE_DIFF_STYLE, TREE_DIFF_STYLE } from '../_helpers/common-helpers'; let codePanelData: CodePanelData | null = null; let codePanelRowData: CodePanelRowData[] = []; @@ -20,6 +21,9 @@ addEventListener('message', ({ data }) => { let jsonString = new TextDecoder().decode(new Uint8Array(data)); codePanelData = JSON.parse(jsonString); + if (!codePanelData?.hasDiff) { + apiTreeBuilderData!.diffStyle = FULL_DIFF_STYLE; // If there is no diff nodes and tree diff will not work + } buildCodePanelRows("root", navigationTree); const codePanelRowDataMessage : InsertCodePanelRowDataMessage = { @@ -68,18 +72,18 @@ function buildCodePanelRows(nodeIdHashed: string, navigationTree: NavigationTree let buildChildren = true; let addNodeToBuffer = false - if (nodeIdHashed !== "root" && (apiTreeBuilderData?.diffStyle === "trees" || apiTreeBuilderData?.diffStyle === "nodes") && + if (nodeIdHashed !== "root" && (apiTreeBuilderData?.diffStyle === TREE_DIFF_STYLE || apiTreeBuilderData?.diffStyle === NODE_DIFF_STYLE) && (!node.isNodeWithDiffInDescendants || (!apiTreeBuilderData?.showDocumentation && !node.isNodeWithNoneDocDiffInDescendants))) { buildNode = false; buildChildren = false; } if (!buildNode && (!node.childrenNodeIdsInOrder || Object.keys(node.childrenNodeIdsInOrder).length === 0) && - (apiTreeBuilderData?.diffStyle !== "nodes" || node.isNodeWithDiff)) { + (apiTreeBuilderData?.diffStyle !== NODE_DIFF_STYLE || node.isNodeWithDiff)) { buildNode = true; } - if (!node.isNodeWithDiff && apiTreeBuilderData?.diffStyle === "nodes" && (!node.childrenNodeIdsInOrder || Object.keys(node.childrenNodeIdsInOrder).length === 0)) { + if (!node.isNodeWithDiff && apiTreeBuilderData?.diffStyle === NODE_DIFF_STYLE && (!node.childrenNodeIdsInOrder || Object.keys(node.childrenNodeIdsInOrder).length === 0)) { addNodeToBuffer = true; }