Re-add show source for comments (#2290)

Co-authored-by: SleeplessOne1917 <insomnia-void@protonmail.com>
This commit is contained in:
SleeplessOne1917 2023-12-18 16:51:44 +00:00 committed by GitHub
parent 82b939b0ec
commit 714618c80c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 1 deletions

View File

@ -112,6 +112,13 @@ interface CommentNodeProps {
onPurgeComment(form: PurgeComment): Promise<void>;
}
function handleToggleViewSource(i: CommentNode) {
i.setState(({ viewSource, ...restPrev }) => ({
viewSource: !viewSource,
...restPrev,
}));
}
export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
state: CommentNodeState = {
showReply: false,
@ -306,7 +313,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
/>
)}
</div>
<div className="comment-bottom-btns d-flex justify-content-between justify-content-lg-start flex-wrap text-muted fw-bold">
<div className="comment-bottom-btns d-flex justify-content-between justify-content-lg-start flex-wrap text-muted fw-bold mt-1">
{this.props.showContext && this.getLinkButton()}
{this.props.markable && (
<button
@ -345,6 +352,22 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
counts={counts}
my_vote={my_vote}
/>
<button
type="button"
className="btn btn-link btn-animate text-muted"
onClick={linkEvent(this, handleToggleViewSource)}
data-tippy-content={I18NextService.i18n.t(
"view_source",
)}
aria-label={I18NextService.i18n.t("view_source")}
>
<Icon
icon="file-text"
classes={`icon-inline ${
this.state.viewSource && "text-success"
}`}
/>
</button>
<CommentActionDropdown
commentView={this.commentView}
admins={this.props.admins}