Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 6c7e13e

Browse files
committed
Add component project-thread
1 parent 7a525af commit 6c7e13e

File tree

5 files changed

+84
-1
lines changed

5 files changed

+84
-1
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { Router, ActivatedRoute } from '@angular/router';
3+
import { Observable, forkJoin, combineLatest } from 'rxjs';
4+
import { switchMap, map, take } from 'rxjs/operators';
5+
import { Insight } from 'models/entities/insights/insight.model';
6+
import { Project } from 'models/entities/project.model';
7+
import { AuthService } from 'components/auth/auth.service';
8+
import { InsightService } from 'components/insight/insight.service';
9+
import { ProjectAuthorizationService } from '../project-authorization.service';
10+
import { ProjectDataService } from '../project-data.service';
11+
import { Thread } from 'models/messaging/thread.model';
12+
import { MessagingService } from 'components/messaging/messaging.service';
13+
14+
@Component({
15+
selector: 'project-thread',
16+
template: require('./project-thread.html'),
17+
styles: [require('./project-thread.scss')],
18+
})
19+
export class ProjectThreadComponent implements OnInit {
20+
private project$: Observable<Project>;
21+
private thread$: Observable<Thread>;
22+
23+
private canEdit = false; // used in html
24+
private canDelete = false; // used in html
25+
26+
static parameters = [
27+
Router,
28+
ActivatedRoute,
29+
ProjectDataService,
30+
MessagingService,
31+
// ProjectAuthorizationService,
32+
// InsightService,
33+
// AuthService,
34+
];
35+
constructor(
36+
private router: Router,
37+
private route: ActivatedRoute,
38+
private projectDataService: ProjectDataService,
39+
private messagingService: MessagingService
40+
) // private projectAuthorizationService: ProjectAuthorizationService,
41+
// private insightService: InsightService,
42+
// private authService: AuthService
43+
{
44+
this.project$ = this.projectDataService.project();
45+
46+
this.router.routeReuseStrategy.shouldReuseRoute = function() {
47+
return false;
48+
};
49+
}
50+
51+
ngOnInit() {
52+
this.thread$ = this.route.params.pipe(
53+
switchMap(params => this.messagingService.getThread(params.threadId)),
54+
take(1)
55+
);
56+
57+
// const canAdminProject$ = this.project$.pipe(
58+
// switchMap(project => this.projectAuthorizationService.canAdmin(project._id))
59+
// );
60+
61+
// // TODO Check that the author has Write access
62+
// const isAuthor$ = forkJoin({
63+
// authInfo: this.authService.authInfo().pipe(take(1)),
64+
// insight: this.insight$,
65+
// }).pipe(
66+
// map(res => {
67+
// return res.authInfo.user._id.toString() === res.insight.createdBy._id.toString();
68+
// })
69+
// );
70+
71+
// combineLatest(canAdminProject$, isAuthor$).subscribe(([canAdminProject, isAuthor]) => {
72+
// this.canEdit = canAdminProject || isAuthor;
73+
// this.canDelete = canAdminProject || isAuthor;
74+
// });
75+
}
76+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<ng-container *ngIf="thread$ | async as thread">
2+
<thread [threadId]="thread._id"></thread>
3+
</ng-container>

client/app/project/project-thread/project-thread.scss

Whitespace-only changes.

client/app/project/project.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import { ProjectGuard } from './project-guard.service';
5151
import { EntityAuthorizationTypes } from 'components/authorization/entity-guard.service';
5252
import { ProjectResourceComponent } from './project-resource/project-resource.component';
5353
import { ProjectInsightComponent } from './project-insight/project-insight.component';
54+
import { ProjectThreadComponent } from './project-thread/project-thread.component';
5455

5556
export const ROUTES: Routes = [
5657
{
@@ -91,7 +92,7 @@ export const ROUTES: Routes = [
9192
{ path: 'activity', component: ProjectActivityComponent },
9293
{ path: 'discussion', component: ProjectDiscussionComponent },
9394
{ path: 'discussion/new', component: ProjectThreadNewComponent },
94-
{ path: 'discussion/:threadId', component: EntityThreadComponent },
95+
{ path: 'discussion/:threadId', component: ProjectThreadComponent },
9596
{
9697
path: 'settings',
9798
component: ProjectSettingsComponent,
@@ -152,6 +153,7 @@ export const ROUTES: Routes = [
152153
ProjectResourcesComponent,
153154
ProjectSettingsComponent,
154155
ProjectSidenavComponent,
156+
ProjectThreadComponent,
155157
ProjectThreadNewComponent,
156158
],
157159
exports: [],

client/components/messaging/thread/thread.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { orderBy } from 'lodash/fp';
1616
})
1717
export class ThreadComponent implements OnInit, OnDestroy {
1818
@Input() threadId: string;
19+
@Input() private canEdit = false;
20+
@Input() private canDelete = false;
1921
@Output() deleted: EventEmitter<Thread> = new EventEmitter<Thread>();
2022

2123
private showThreadEditTemplate = false; // used in html

0 commit comments

Comments
 (0)