Skip to content

Commit

Permalink
vscode: Support Comment#timestamp
Browse files Browse the repository at this point in the history
Contributed on behalf of STMicroelectronics

Fixes #11702
  • Loading branch information
rschnekenbu committed Dec 21, 2022
1 parent 1cc8376 commit 6895086
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
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

0 comments on commit 6895086

Please sign in to comment.