@kiva/kv-components 3.59.1 → 3.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.61.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.60.0...@kiva/kv-components@3.61.0) (2024-03-04)
7
+
8
+
9
+ ### Features
10
+
11
+ * fetchlenderinfo method injected to comment item component ([#362](https://github.com/kiva/kv-ui-elements/issues/362)) ([2aba5e0](https://github.com/kiva/kv-ui-elements/commit/2aba5e0837d57eec77f2d1bee48ca2c3c127c1d4))
12
+
13
+
14
+
15
+
16
+
17
+ # [3.60.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.59.1...@kiva/kv-components@3.60.0) (2024-03-04)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * unit test update ([e0e943b](https://github.com/kiva/kv-ui-elements/commit/e0e943bf51a9f7775f9b1279dc449787d7d05055))
23
+
24
+
25
+ ### Features
26
+
27
+ * use new avatar in commenting components ([c707f71](https://github.com/kiva/kv-ui-elements/commit/c707f71e87661feb93486d3b900d4f0a77aff353))
28
+
29
+
30
+
31
+
32
+
6
33
  ## [3.59.1](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.59.0...@kiva/kv-components@3.59.1) (2024-03-04)
7
34
 
8
35
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "3.59.1",
3
+ "version": "3.61.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -75,5 +75,5 @@
75
75
  "optional": true
76
76
  }
77
77
  },
78
- "gitHead": "eaefca5854f506ac1cd70d1e70ef6a836396416a"
78
+ "gitHead": "5a1b6f22bba95529946eaf398992273b8e117d6b"
79
79
  }
@@ -19,7 +19,7 @@ describe('KvCommentsAdd', () => {
19
19
  userImageUrl: 'test.com',
20
20
  userDisplayName: 'User',
21
21
  });
22
- getByAltText('Lender');
22
+ getByAltText('Image of lender');
23
23
  getByText('User');
24
24
  });
25
25
 
@@ -6,7 +6,20 @@ import { LIKE_COMMENT_EVENT, REPLY_COMMENT_EVENT } from '../../../../vue/KvComme
6
6
  import { ADD_REACTION_EVENT } from '../../../../vue/KvCommentsContainer.vue';
7
7
 
8
8
  const renderList = (props = {}) => {
9
- return render(ListComponent, { props });
9
+ return render(ListComponent,
10
+ {
11
+ props,
12
+ // provide function for vue 2 testing
13
+ provide: {
14
+ fetchLenderInfo: () => Promise.resolve({}),
15
+ },
16
+ // provide function for vue 3 testing
17
+ global: {
18
+ provide: {
19
+ fetchLenderInfo: () => Promise.resolve({}),
20
+ },
21
+ },
22
+ });
10
23
  };
11
24
 
12
25
  const comments = activityFeed.results[0].latest_reactions;
@@ -7,7 +7,20 @@ import { ADD_REACTION_EVENT } from '../../../../vue/KvCommentsContainer.vue';
7
7
  const comment = activityFeed.results[0].latest_reactions.comment[0];
8
8
 
9
9
  const renderComment = (props = {}) => {
10
- return render(KvCommentsListItem, { props });
10
+ return render(KvCommentsListItem,
11
+ {
12
+ props,
13
+ // provide function for vue 2 testing
14
+ provide: {
15
+ fetchLenderInfo: () => Promise.resolve({}),
16
+ },
17
+ // provide function for vue 3 testing
18
+ global: {
19
+ provide: {
20
+ fetchLenderInfo: () => Promise.resolve({}),
21
+ },
22
+ },
23
+ });
11
24
  };
12
25
 
13
26
  describe('KvCommentsListItem', () => {
@@ -2,20 +2,11 @@
2
2
  <div class="tw-flex tw-flex-col">
3
3
  <div class="tw-flex tw-flex-col md:tw-flex-row md:tw-items-center tw-gap-0.5 md:tw-gap-1">
4
4
  <div class="tw-flex tw-items-center tw-gap-1">
5
- <img
6
- v-if="userImageUrl"
7
- :src="userImageUrl"
8
- alt="Lender"
9
- class="
10
- data-hj-suppress
11
- tw-inline-block
12
- tw-w-3.5
13
- tw-h-3.5
14
- tw-rounded-full
15
- tw-overflow-hidden
16
- tw-object-fill
17
- "
18
- >
5
+ <kv-user-avatar
6
+ :lender-name="userDisplayName"
7
+ :lender-image-url="userImageUrl"
8
+ is-small
9
+ />
19
10
  <div class="data-hj-suppress tw-font-medium">
20
11
  {{ userDisplayName }}
21
12
  </div>
@@ -52,6 +43,7 @@
52
43
  import { computed, ref } from 'vue-demi';
53
44
  import KvButton from './KvButton.vue';
54
45
  import KvTextInput from './KvTextInput.vue';
46
+ import KvUserAvatar from './KvUserAvatar.vue';
55
47
 
56
48
  export const ADD_COMMENT_ID = 'add-comment-value';
57
49
  export const ADD_COMMENT_EVENT = 'add-comment';
@@ -62,6 +54,7 @@ export default {
62
54
  components: {
63
55
  KvButton,
64
56
  KvTextInput,
57
+ KvUserAvatar,
65
58
  },
66
59
  props: {
67
60
  /**
@@ -56,7 +56,7 @@ export default {
56
56
  */
57
57
  comments: {
58
58
  type: Object,
59
- default: () => {},
59
+ default: () => ({}),
60
60
  },
61
61
  },
62
62
  emits: [ADD_REACTION_EVENT],
@@ -52,7 +52,7 @@ export default {
52
52
  */
53
53
  comments: {
54
54
  type: Object,
55
- default: () => {},
55
+ default: () => ({}),
56
56
  },
57
57
  },
58
58
  emits: [ADD_REACTION_EVENT],
@@ -2,23 +2,14 @@
2
2
  <div>
3
3
  <div>
4
4
  <div class="tw-flex tw-items-center tw-gap-1">
5
- <img
6
- v-if="authorImage"
7
- class="
8
- data-hj-suppress
9
- tw-inline-block
10
- tw-w-3.5
11
- tw-h-3.5
12
- tw-rounded-full
13
- tw-overflow-hidden
14
- tw-object-fill
15
- "
16
- :src="authorImage"
17
- alt="picture"
18
- >
5
+ <kv-user-avatar
6
+ :lender-name="authorName"
7
+ :lender-image-url="authorImage"
8
+ is-small
9
+ />
19
10
  <p
20
11
  v-if="authorName"
21
- class="tw-font-medium"
12
+ class="data-hj-suppress tw-font-medium"
22
13
  >
23
14
  {{ authorName }}
24
15
  </p>
@@ -92,10 +83,13 @@ import {
92
83
  nextTick,
93
84
  computed,
94
85
  toRefs,
86
+ onMounted,
87
+ inject,
95
88
  } from 'vue-demi';
96
89
  import KvCommentsReplyButton from './KvCommentsReplyButton.vue';
97
90
  import KvCommentsHeartButton from './KvCommentsHeartButton.vue';
98
91
  import KvCommentsAdd from './KvCommentsAdd.vue';
92
+ import KvUserAvatar from './KvUserAvatar.vue';
99
93
 
100
94
  export const REPLY_COMMENT_EVENT = 'reply-comment';
101
95
  export const LIKE_COMMENT_EVENT = 'like-comment';
@@ -107,6 +101,7 @@ export default {
107
101
  KvCommentsReplyButton,
108
102
  KvCommentsHeartButton,
109
103
  KvCommentsAdd,
104
+ KvUserAvatar,
110
105
  },
111
106
  props: {
112
107
  /**
@@ -156,10 +151,14 @@ export default {
156
151
 
157
152
  const showInput = ref(false);
158
153
  const commentsAddRef = ref(null);
154
+ const authorInfo = ref();
159
155
 
160
156
  const commentText = computed(() => comment?.value?.data?.text ?? '');
161
- const authorImage = computed(() => comment?.value?.user?.data?.image ?? '');
162
- const authorName = computed(() => comment?.value?.user?.data?.name ?? '');
157
+
158
+ const authorId = computed(() => comment?.value?.user?.data?.publicLenderId ?? '');
159
+ const authorImage = computed(() => authorInfo?.value?.image?.url ?? '');
160
+ const authorName = computed(() => authorInfo?.value?.name ?? '');
161
+
163
162
  const childComments = computed(() => comment?.value?.latest_children?.comment ?? null);
164
163
  const childLikes = computed(() => comment?.value?.latest_children?.like ?? []);
165
164
  const likedObject = computed(() => childLikes.value.find((child) => child.user.data.publicLenderId === userPublicId.value)); // eslint-disable-line max-len
@@ -192,6 +191,15 @@ export default {
192
191
 
193
192
  const numberOfReplies = computed(() => comment?.value?.children_counts?.comment ?? 0);
194
193
 
194
+ const fetchLenderInfo = inject('fetchLenderInfo');
195
+
196
+ onMounted(async () => {
197
+ if (authorId.value) {
198
+ const authorData = await fetchLenderInfo(authorId.value);
199
+ authorInfo.value = authorData;
200
+ }
201
+ });
202
+
195
203
  return {
196
204
  hideInput,
197
205
  showInput,
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div
3
- class="data-hj-suppress"
3
+ class="data-hj-suppress tw-flex"
4
4
  :class="{ 'tw-w-3': isSmall, 'tw-w-6': !isSmall }"
5
5
  >
6
6
  <!-- User is anonymous or data is missing -->