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

071824.01/conversation #8834

Merged
merged 7 commits into from
Aug 15, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Show Comment Threads on Conversation Page
chidozieononiwu committed Aug 8, 2024

Verified

This commit was signed with the committer’s verified signature.
filipw Filip W
commit 07ec4eb9f4c1b492a220cef0f30f23efb10be7f9

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p-timeline [value]="apiRevisions">
<p-timeline [value]="getAPIRevisionWithComments()">
<ng-template pTemplate="marker" let-apiRevision>
<i class="bi bi-clock-history"></i>
</ng-template>
@@ -13,7 +13,10 @@
<span class="emphasis-badge secondary ms-2">lastUpdated: {{ apiRevision | lastUpdatedOn | timeago }}</span>
<span class="ms-2" *ngIf="apiRevision.label">{{ apiRevision.label }}</span>
</span>
<div *ngFor="let comment of getFilteredComments(apiRevision)">
<div *ngFor="let commentThread of commentThreads.get(apiRevision.id); let isLast = last">
<p-divider />
<a class="small">{{ commentThread!.comments[0].elementId }}</a>
<app-comment-thread [codePanelRowData]="commentThread"></app-comment-thread>
</div>
</ng-template>
</p-timeline>
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ConversationComponent } from './conversation.component';
import { ConversationsComponent } from './conversations.component';

describe('ConversationComponent', () => {
let component: ConversationComponent;
let fixture: ComponentFixture<ConversationComponent>;
let component: ConversationsComponent;
let fixture: ComponentFixture<ConversationsComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ConversationComponent]
declarations: [ConversationsComponent]
});
fixture = TestBed.createComponent(ConversationComponent);
fixture = TestBed.createComponent(ConversationsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { CodePanelRowData, CodePanelRowDatatype } from 'src/app/_models/codePanelModels';
import { CommentItemModel } from 'src/app/_models/commentItemModel';
import { APIRevision } from 'src/app/_models/revision';

@Component({
selector: 'app-conversations',
templateUrl: './conversations.component.html',
styleUrls: ['./conversations.component.scss']
})
export class ConversationsComponent implements OnChanges {
@Input() apiRevisions: APIRevision[] = [];
@Input() comments: CommentItemModel[] = [];

commentThreads: Map<string, CodePanelRowData[]> = new Map<string, CodePanelRowData[]>();

ngOnChanges(changes: SimpleChanges) {
if (changes['apiRevisions'] || changes['comments']) {
if (this.apiRevisions.length > 0 && this.comments.length > 0) {
this.createCommentThreads();
}
}
}

createCommentThreads() {
for (const apiRevision of this.apiRevisions) {
const groupedCommentsForAPIRevision = this.comments
.filter(c => c.apiRevisionId === apiRevision.id)
.reduce((acc: { [key: string]: CommentItemModel[] }, comment) => {
const key = comment.elementId;
if (!acc[key]) {
acc[key] = [];
}
acc[key].push(comment);
return acc;
}, {});

if (Object.keys(groupedCommentsForAPIRevision).length > 0) {
this.commentThreads.set(apiRevision.id, []);
}

for (const elementId in groupedCommentsForAPIRevision) {
if (groupedCommentsForAPIRevision.hasOwnProperty(elementId)) {
const comments = groupedCommentsForAPIRevision[elementId];
const codePanelRowData = new CodePanelRowData();
codePanelRowData.type = CodePanelRowDatatype.CommentThread;
codePanelRowData.comments = comments;
codePanelRowData.isResolvedCommentThread = comments.some(c => c.isResolved);
this.commentThreads.get(apiRevision.id)?.push(codePanelRowData);
}
}
}
}

getAPIRevisionWithComments() {
return this.apiRevisions.filter(apiRevision => this.commentThreads.has(apiRevision.id));
}
}
Original file line number Diff line number Diff line change
@@ -73,8 +73,8 @@
[revisionSidePanel]="revisionSidePanel!"></app-revisions-list>
</p-sidebar>
<p-sidebar [(visible)]="conversationSidePanel!" position="right" [modal]="true" styleClass="conversation-sidebar">
<app-conversation
<app-conversations
[apiRevisions]="apiRevisions"
[comments]="comments"></app-conversation >
[comments]="comments"></app-conversations >
</p-sidebar>
<app-footer></app-footer>
Original file line number Diff line number Diff line change
@@ -45,6 +45,6 @@
}

.conversation-sidebar {
width: 50dvw;
width: 60dvw;
}
}
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ export enum CommentType {
export class CommentItemModel {
id: string = '';
reviewId: string = '';
aPIRevisionId: string = '';
apiRevisionId: string = '';
elementId: string = '';
sectionClass: string = '';
commentText: string = '';
@@ -28,7 +28,7 @@ export class CommentItemModel {
constructor() {
this.id = '';
this.reviewId = '';
this.aPIRevisionId = '';
this.apiRevisionId = '';
this.elementId = '';
this.sectionClass = '';
this.commentText = '';
Original file line number Diff line number Diff line change
@@ -14,14 +14,15 @@ import { MenuModule } from 'primeng/menu';
import { TimelineModule } from 'primeng/timeline';
import { SharedAppModule } from '../shared/shared-app.module';
import { ButtonModule } from 'primeng/button';
import { DividerModule } from 'primeng/divider';
import { UiScrollModule } from 'ngx-ui-scroll' ;
import { PageOptionsSectionComponent } from 'src/app/_components/shared/page-options-section/page-options-section.component';
import { ApiRevisionOptionsComponent } from 'src/app/_components/api-revision-options/api-revision-options.component';
import { MarkdownToHtmlPipe } from 'src/app/_pipes/markdown-to-html.pipe';
import { EditorComponent } from 'src/app/_components/shared/editor/editor.component';
import { ReviewPageOptionsComponent } from 'src/app/_components/review-page-options/review-page-options.component';
import { InputSwitchModule } from 'primeng/inputswitch';
import { ConversationComponent } from 'src/app/_components/conversation/conversation.component';
import { ConversationsComponent } from 'src/app/_components/conversations/conversations.component';

const routes: Routes = [
{ path: '', component: ReviewPageComponent }
@@ -34,12 +35,12 @@ const routes: Routes = [
ReviewInfoComponent,
CodePanelComponent,
CommentThreadComponent,
ConversationComponent,
ConversationsComponent,
PageOptionsSectionComponent,
ReviewPageOptionsComponent,
ApiRevisionOptionsComponent,
MarkdownToHtmlPipe,
EditorComponent
EditorComponent,
],
imports: [
SharedAppModule,
@@ -53,6 +54,7 @@ const routes: Routes = [
ButtonModule,
InputSwitchModule,
UiScrollModule,
DividerModule,
RouterModule.forChild(routes),
]
})
4 changes: 4 additions & 0 deletions src/dotnet/APIView/ClientSPA/src/ng-prime-overrides.scss
Original file line number Diff line number Diff line change
@@ -163,6 +163,10 @@ p-contextmenusub {
outline-offset: 0.15rem;
}

.p-divider.p-divider-horizontal:before {
border-top: 1px solid var(--border-color);
}

.p-editor-container .p-editor-toolbar {
background: var(--base-bg-color);
}