Convert gr-comment to typescript

The change converts the following files to typescript:

* elements/shared/gr-comment/gr-comment.ts

Change-Id: I34975acf43537d9317462eb721d64a82fd21b441
This commit is contained in:
Milutin Kristofic
2020-09-17 10:38:08 +02:00
parent 7172b95421
commit afae005caf
6 changed files with 524 additions and 382 deletions

View File

@@ -789,6 +789,9 @@ suite('gr-change-view tests', () => {
suite('_recomputeComments', () => { suite('_recomputeComments', () => {
setup(() => { setup(() => {
element._changeNum = '1';
element._change = {_number: '1'};
flushAsynchronousOperations();
// Fake computeDraftCount as its required for ChangeComments, // Fake computeDraftCount as its required for ChangeComments,
// see gr-comment-api#reloadDrafts. // see gr-comment-api#reloadDrafts.
sinon.stub(element.$.commentAPI, 'reloadDrafts') sinon.stub(element.$.commentAPI, 'reloadDrafts')
@@ -927,7 +930,9 @@ suite('gr-change-view tests', () => {
rev4: {_number: 4, commit: {parents: []}}, rev4: {_number: 4, commit: {parents: []}},
}, },
current_revision: 'rev4', current_revision: 'rev4',
_number: '1',
}; };
element._changeNum = '1';
element._commentThreads = THREADS; element._commentThreads = THREADS;
const paperTabs = element.shadowRoot.querySelector('#primaryTabs'); const paperTabs = element.shadowRoot.querySelector('#primaryTabs');
MockInteractions.tap(paperTabs.querySelectorAll('paper-tab')[3]); MockInteractions.tap(paperTabs.querySelectorAll('paper-tab')[3]);

File diff suppressed because it is too large Load Diff

View File

@@ -3226,7 +3226,7 @@ export class GrRestApiInterface
commentID: UrlEncodedCommentId, commentID: UrlEncodedCommentId,
reason: string reason: string
) { ) {
return this._getChangeURLAndSend({ return (this._getChangeURLAndSend({
changeNum, changeNum,
method: HttpMethod.POST, method: HttpMethod.POST,
patchNum, patchNum,
@@ -3234,7 +3234,7 @@ export class GrRestApiInterface
body: {reason}, body: {reason},
parseResponse: true, parseResponse: true,
anonymizedEndpoint: '/comments/*/delete', anonymizedEndpoint: '/comments/*/delete',
}); }) as unknown) as Promise<CommentInfo>;
} }
/** /**

View File

@@ -25,7 +25,7 @@ export interface StorageLocation {
patchNum: PatchSetNum; patchNum: PatchSetNum;
path: string; path: string;
line: number; line: number;
range: CommentRange; range?: CommentRange;
} }
export interface StorageObject { export interface StorageObject {

View File

@@ -78,6 +78,7 @@ import {
GroupAuditEventInfo, GroupAuditEventInfo,
EncodedGroupId, EncodedGroupId,
Base64FileContent, Base64FileContent,
UrlEncodedCommentId,
} from '../../../types/common'; } from '../../../types/common';
import {ParsedChangeInfo} from '../../../elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser'; import {ParsedChangeInfo} from '../../../elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser';
import {HttpMethod} from '../../../constants/constants'; import {HttpMethod} from '../../../constants/constants';
@@ -604,6 +605,18 @@ export interface RestApiService {
label: string label: string
): Promise<Response>; ): Promise<Response>;
deleteComment(
changeNum: ChangeNum,
patchNum: PatchSetNum,
commentID: UrlEncodedCommentId,
reason: string
): Promise<CommentInfo>;
deleteDiffDraft(
changeNum: ChangeNum,
patchNum: PatchSetNum,
draft: {id: UrlEncodedCommentId}
): Promise<Response>;
deleteChangeCommitMessage( deleteChangeCommitMessage(
changeNum: ChangeNum, changeNum: ChangeNum,
messageId: ChangeMessageId messageId: ChangeMessageId

View File

@@ -1039,7 +1039,7 @@ export interface UserConfigInfo {
* The CommentInfo entity contains information about an inline comment. * The CommentInfo entity contains information about an inline comment.
* https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#comment-info * https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#comment-info
*/ */
export interface CommentInfo { export interface CommentInfo extends CommentInput {
patch_set?: PatchSetNum; patch_set?: PatchSetNum;
id: UrlEncodedCommentId; id: UrlEncodedCommentId;
path?: string; path?: string;
@@ -1047,9 +1047,9 @@ export interface CommentInfo {
parent?: number; parent?: number;
line?: number; line?: number;
range?: CommentRange; range?: CommentRange;
in_reply_to?: string; in_reply_to?: UrlEncodedCommentId;
message?: string; message?: string;
updated: string; updated: Timestamp;
author?: AccountInfo; author?: AccountInfo;
tag?: string; tag?: string;
unresolved?: boolean; unresolved?: boolean;