Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit afed00c

Browse files
fix(mr): add comment.
1 parent 7f559bd commit afed00c

File tree

9 files changed

+26
-16
lines changed

9 files changed

+26
-16
lines changed

‎src/codingServer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
IBranchListResp,
1717
IMemberListResp,
1818
IMRContentResp,
19+
ICreateCommentResp,
1920
} from 'src/typings/respResult';
2021
import { PromiseAdapter, promiseFromEvent, parseQuery, parseCloneUrl } from 'src/common/utils';
2122
import { GitService } from 'src/common/gitService';
@@ -511,7 +512,7 @@ export class CodingServer {
511512
public async commentMR(mrId: number, comment: string) {
512513
try {
513514
const { repoApiPrefix } = await this.getApiPrefix();
514-
const result: CodingResponse = await got
515+
const result: ICreateCommentResp = await got
515516
.post(`${repoApiPrefix}/line_notes`, {
516517
searchParams: {
517518
access_token: this._session?.accessToken,

‎src/panel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class Panel {
116116
break;
117117
case 'mr.add.comment':
118118
const commentRes = await this._codingSrv.commentMR(args.id, args.comment);
119-
this.replyMessage(message, commentRes.data);
119+
this.broadcast(command, commentRes.data);
120120
break;
121121
case 'mr.get.activities':
122122
const getActivitiesRes = await this._codingSrv.getMRActivities(args);

‎src/typings/respResult.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,7 @@ export interface IMRContent {
238238
export interface IMRContentResp extends CodingResponse {
239239
data: IMRContent;
240240
}
241+
242+
export interface ICreateCommentResp extends CodingResponse {
243+
data: IComment;
244+
}

‎webviews/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function App() {
144144
onChange={onChangeDesc}
145145
/>
146146
)}
147-
<h3>Activities</h3>
147+
<SectionTitle>Activities</SectionTitle>
148148
<Activities />
149149
</Body>
150150
<Sidebar>

‎webviews/components/Activities.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function Activities() {
1212

1313
const renderActivity = (activity: [IActivity]) => {
1414
return (
15-
<div key={activity[0].id}>
15+
<div key={activity[0]?.id}>
1616
<Activity
1717
activity={activity[0]}
1818
srcBranch={currentMR.data.merge_request.srcBranch}
@@ -31,16 +31,16 @@ function Activities() {
3131
};
3232

3333
const allActivities = [...activities.map((i) => [i]), ...comments].sort(
34-
(a, b) => a[0].created_at - b[0].created_at,
34+
(a, b) => a[0]?.created_at - b[0]?.created_at,
3535
);
3636

3737
return (
3838
<div>
3939
<div>
4040
{allActivities.map((activity: any) => {
41-
if (activity[0].action) {
41+
if (activity[0]?.action) {
4242
return renderActivity(activity as [IActivity]);
43-
} else if (!activity[0].action) {
43+
} else if (!activity[0]?.action) {
4444
return renderComment(activity as [IComment]);
4545
}
4646
return null;

‎webviews/components/Comment.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const ChildCommentContent = styled.div`
4040

4141
function Comment({ comment }: IProps) {
4242
const renderChildComments = () => {
43-
return comment.childComments?.map((c) => {
43+
return comment?.childComments?.map((c) => {
4444
return (
4545
<ChildComment key={c.id}>
4646
<AuthorLink for={c.author} />
@@ -55,14 +55,14 @@ function Comment({ comment }: IProps) {
5555
return (
5656
<Root>
5757
<Header>
58-
<Avatar for={comment.author} />{' '}
58+
<Avatar for={comment?.author} />{' '}
5959
<AuthorLinkWrap>
60-
<AuthorLink for={comment.author} />
60+
<AuthorLink for={comment?.author} />
6161
</AuthorLinkWrap>
62-
<Time>commented at {getTime(comment.created_at)}</Time>
62+
<Time>commented at {getTime(comment?.created_at)}</Time>
6363
</Header>
6464
<Body>
65-
<div dangerouslySetInnerHTML={{ __html: comment.content }} />
65+
<div dangerouslySetInnerHTML={{ __html: comment?.content }} />
6666
{renderChildComments()}
6767
</Body>
6868
</Root>

‎webviews/components/User.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ const AvatarImg = styled.img`
1212
border-radius: 50%;
1313
`;
1414

15-
export const Avatar = ({ for: author }: { for: Partial<IMRDetailMR['author']> }) => (
16-
<Link href={author.avatar}>
17-
<AvatarImg src={author.avatar} alt='' />
15+
export const Avatar = ({ for: author ={}}: { for: Partial<IMRDetailMR['author']> }) => (
16+
<Link href={author?.avatar}>
17+
<AvatarImg src={author?.avatar} alt='' />
1818
</Link>
1919
);
2020

2121
export const AuthorLink = ({ for: author }: { for: IMRDetailMR['author'] }) => (
22-
<a href={author.path}>{author.name}</a>
22+
<a href={author?.path}>{author?.name}</a>
2323
);

‎webviews/hooks/messageTransferHook.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export default function messageTransferHook() {
4444
toggleUpdatingDesc();
4545
break;
4646
}
47+
case actions.MR_ADD_COMMENT: {
48+
}
4749
default:
4850
break;
4951
}

‎webviews/store/appStore.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ const appStore = store({
131131
appStore.currentMR.data.merge_request.body = resp.body;
132132
appStore.currentMR.data.merge_request.body_plan = resp.body_plan;
133133
},
134+
addComment(comment: IComment) {
135+
appStore.comments.push(comment);
136+
},
134137
});
135138

136139
export const persistData = () =>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /