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

Adding timestamp to comment. fixes #11702 #12007

Merged
merged 1 commit into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions packages/plugin-ext/src/common/plugin-api-rpc-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ export interface Comment {
readonly contextValue?: string;
readonly label?: string;
readonly mode?: CommentMode;
/** Timestamp serialized as ISO date string via Date.prototype.toISOString */
readonly timestamp?: string;
}

export enum CommentThreadCollapsibleState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ export class ReviewComment<P extends ReviewComment.Props = ReviewComment.Props>
<div className={'review-comment-contents'}>
<div className={'comment-title monaco-mouse-cursor-text'}>
<strong className={'author'}>{comment.userName}</strong>
<small className={'timestamp'}>{this.localeDate(comment.timestamp)}</small>
<span className={'isPending'}>{comment.label}</span>
<div className={'theia-comments-inline-actions-container'}>
<div className={'theia-comments-inline-actions'} role={'toolbar'}>
Expand All @@ -498,6 +499,16 @@ export class ReviewComment<P extends ReviewComment.Props = ReviewComment.Props>
</div>
</div>;
}
protected localeDate(timestamp: string | undefined): string {
if (timestamp === undefined) {
return '';
}
const date = new Date(timestamp);
if (!isNaN(date.getTime())) {
return date.toLocaleString();
}
return '';
}
}

namespace CommentBody {
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-ext/src/main/browser/style/comments.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@
line-height: var(--theia-content-line-height);
}

.monaco-editor .review-widget .body .review-comment .review-comment-contents .timestamp {
line-height: var(--theia-content-line-height);
margin: 0 5px 0 5px;
padding: 0 2px 0 2px;
}

.monaco-editor .review-widget .body .review-comment .review-comment-contents .isPending {
margin: 0 5px 0 5px;
padding: 0 2px 0 2px;
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-ext/src/plugin/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ function convertToModeComment(thread: ExtHostCommentThread, commentController: C
}

const iconPath = theiaComment.author && theiaComment.author.iconPath ? theiaComment.author.iconPath.toString() : undefined;
const date = theiaComment.timestamp ? theiaComment.timestamp.toISOString() : undefined;

return {
mode: theiaComment.mode,
Expand All @@ -500,6 +501,7 @@ function convertToModeComment(thread: ExtHostCommentThread, commentController: C
userName: theiaComment.author.name,
userIconPath: iconPath,
label: theiaComment.label,
timestamp: date,
};
}

Expand Down
5 changes: 5 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12084,6 +12084,11 @@ export module '@theia/plugin' {
* Label will be rendered next to authorName if exists.
*/
label?: string;

/**
* Optional timestamp.
*/
timestamp?: Date;
}

/**
Expand Down