Skip to content

Commit

Permalink
fix(CommentReply): fix props passed to it and add types
Browse files Browse the repository at this point in the history
  • Loading branch information
carsoli committed May 25, 2022
1 parent 134d42b commit 9d09175
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
9 changes: 1 addition & 8 deletions packages/kotti-ui/source/kotti-comment/KtComment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,9 @@

<div v-for="(reply, index) in replies" :key="reply.id">
<CommentReply
:id="reply.id"
:createdTime="reply.createdTime"
v-bind="reply"
:dangerouslyOverrideParser="dangerouslyOverrideParser"
:isDeletable="reply.isDeletable"
:isEditable="reply.isEditable"
:message="reply.message"
:postEscapeParser="postEscapeParser"
:userAvatar="reply.userAvatar"
:userId="reply.userId"
:userName="reply.userName"
@click="handleReplyClick"
@delete="(commentId) => handleDelete(commentId, true)"
@edit="($event) => handleEditReply($event, index)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { Kotti } from '../../types'
import CommentActions from './CommentActions.vue'
import CommentInlineEdit from './CommentInlineEdit.vue'
export default defineComponent<Kotti.Comment.PropsInternal>({
export default defineComponent<Kotti.Comment.Reply.PropsInternal>({
name: 'CommentReply',
components: {
CommentActions,
Expand Down
10 changes: 9 additions & 1 deletion packages/kotti-ui/source/kotti-comment/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ export namespace KottiComment {
userName: z.string().optional(),
})

export const propsSchema = commentSchema.extend({
const sharedSchema = commentSchema.extend({
dangerouslyOverrideParser: parseFunctionSchema.default(defaultParser),
postEscapeParser: parseFunctionSchema.default(defaultPostEscapeParser),
})

export namespace Reply {
export type Props = z.input<typeof sharedSchema>
export type PropsInternal = z.output<typeof sharedSchema>
}

export const propsSchema = sharedSchema.extend({
replies: z.array(commentSchema).optional(),
})

Expand Down

0 comments on commit 9d09175

Please sign in to comment.