mirror of
https://github.com/utterance/utterances.git
synced 2024-08-17 03:00:23 +03:00
lock reactions when issue is locked (#245)
This commit is contained in:
parent
071b85f647
commit
2227d6e18b
@ -19,7 +19,8 @@ export class CommentComponent {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public comment: IssueComment,
|
public comment: IssueComment,
|
||||||
private currentUser: string | null
|
private currentUser: string | null,
|
||||||
|
locked: boolean
|
||||||
) {
|
) {
|
||||||
const { user, html_url, created_at, body_html, author_association, reactions } = comment;
|
const { user, html_url, created_at, body_html, author_association, reactions } = comment;
|
||||||
this.element = document.createElement('article');
|
this.element = document.createElement('article');
|
||||||
@ -29,6 +30,17 @@ export class CommentComponent {
|
|||||||
}
|
}
|
||||||
const association = displayAssociations[author_association];
|
const association = displayAssociations[author_association];
|
||||||
const reactionCount = reactionTypes.reduce((sum, id) => sum + reactions[id], 0);
|
const reactionCount = reactionTypes.reduce((sum, id) => sum + reactions[id], 0);
|
||||||
|
let headerReactionsMenu = '';
|
||||||
|
let footerReactionsMenu = '';
|
||||||
|
if (!locked) {
|
||||||
|
if (currentUser) {
|
||||||
|
headerReactionsMenu = getReactionsMenuHtml(comment.reactions.url, 'right');
|
||||||
|
footerReactionsMenu = getReactionsMenuHtml(comment.reactions.url, 'center');
|
||||||
|
} else {
|
||||||
|
headerReactionsMenu = getSignInToReactMenuHtml('right');
|
||||||
|
footerReactionsMenu = getSignInToReactMenuHtml('center');
|
||||||
|
}
|
||||||
|
}
|
||||||
this.element.innerHTML = `
|
this.element.innerHTML = `
|
||||||
<a class="avatar" href="${user.html_url}" target="_blank" tabindex="-1">
|
<a class="avatar" href="${user.html_url}" target="_blank" tabindex="-1">
|
||||||
<img alt="@${user.login}" height="44" width="44"
|
<img alt="@${user.login}" height="44" width="44"
|
||||||
@ -43,7 +55,7 @@ export class CommentComponent {
|
|||||||
</span>
|
</span>
|
||||||
<div class="comment-actions">
|
<div class="comment-actions">
|
||||||
${association ? `<span class="author-association-badge">${association}</span>` : ''}
|
${association ? `<span class="author-association-badge">${association}</span>` : ''}
|
||||||
${currentUser ? getReactionsMenuHtml(comment.reactions.url, 'right') : getSignInToReactMenuHtml('right')}
|
${headerReactionsMenu}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div class="markdown-body markdown-body-scrollable">
|
<div class="markdown-body markdown-body-scrollable">
|
||||||
@ -51,9 +63,9 @@ export class CommentComponent {
|
|||||||
</div>
|
</div>
|
||||||
<div class="comment-footer" reaction-count="${reactionCount}" reaction-url="${reactions.url}">
|
<div class="comment-footer" reaction-count="${reactionCount}" reaction-url="${reactions.url}">
|
||||||
<form class="reaction-list BtnGroup" action="javascript:">
|
<form class="reaction-list BtnGroup" action="javascript:">
|
||||||
${reactionTypes.map(id => getReactionHtml(reactions.url, id, !currentUser, reactions[id])).join('')}
|
${reactionTypes.map(id => getReactionHtml(reactions.url, id, !currentUser || locked, reactions[id])).join('')}
|
||||||
</form>
|
</form>
|
||||||
${currentUser ? getReactionsMenuHtml(comment.reactions.url, 'center') : getSignInToReactMenuHtml('center')}
|
${footerReactionsMenu}
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
|
@ -53,7 +53,8 @@ export class TimelineComponent {
|
|||||||
public insertComment(comment: IssueComment, incrementCount: boolean) {
|
public insertComment(comment: IssueComment, incrementCount: boolean) {
|
||||||
const component = new CommentComponent(
|
const component = new CommentComponent(
|
||||||
comment,
|
comment,
|
||||||
this.user ? this.user.login : null);
|
this.user ? this.user.login : null,
|
||||||
|
this.issue!.locked);
|
||||||
|
|
||||||
const index = this.timeline.findIndex(x => x.comment.id >= comment.id);
|
const index = this.timeline.findIndex(x => x.comment.id >= comment.id);
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user