diff --git a/packages/client/src/components/GrantActivity.vue b/packages/client/src/components/GrantActivity.vue index 30325dfd4..46e49bac4 100644 --- a/packages/client/src/components/GrantActivity.vue +++ b/packages/client/src/components/GrantActivity.vue @@ -2,11 +2,12 @@
@@ -135,7 +136,7 @@ export default { return `${textCount} ${this.notes.length === 1 ? 'note' : 'notes'}`; }, }, - async beforeMount() { + beforeMount() { this.fetchFollowAndNotes(); }, methods: { diff --git a/packages/client/src/components/GrantNote.spec.js b/packages/client/src/components/GrantNote.spec.js deleted file mode 100644 index 0b218f545..000000000 --- a/packages/client/src/components/GrantNote.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import { describe, it, expect } from 'vitest'; -import { mount } from '@vue/test-utils'; -import GrantNote from '@/components/GrantNote.vue'; -import { id } from '@/helpers/testHelpers'; - -const note = { - id: id(), - createdAt: new Date().toISOString(), - isRevised: true, - text: 'Text', - grant: { id: id() }, - user: { - id: id(), - name: 'User', - email: 'email@net', - avatarColor: 'red', - team: { - id: id(), - name: 'Team', - }, - organization: { - id: id(), - name: 'Org', - }, - }, -}; - -describe('GrantNote component', () => { - it('renders', () => { - const wrapper = mount(GrantNote, { - props: { - note, - }, - }); - expect(wrapper.exists()).toBe(true); - }); -}); diff --git a/packages/client/src/components/GrantNotes.spec.js b/packages/client/src/components/GrantNotes.spec.js index 9982c25b5..7218fe952 100644 --- a/packages/client/src/components/GrantNotes.spec.js +++ b/packages/client/src/components/GrantNotes.spec.js @@ -79,15 +79,16 @@ describe('GrantNotes component', () => { const inputCmp = wrapper.findComponent('[data-test-note-input]'); expect(inputCmp.exists()).toEqual(false); - const userNoteCmp = wrapper.findComponent('[data-test-user-note]'); + const userNoteCmp = wrapper.findComponent('[data-test-user-note-id]'); expect(userNoteCmp.exists()).equal(true); - const otherNoteCmps = wrapper.findAllComponents('[data-test-other-note]'); + const otherNoteCmps = wrapper.findAllComponents('[data-test-other-note-id]'); expect(otherNoteCmps).toHaveLength(5); // excludes user note otherNoteCmps.forEach((cmp) => { - expect(cmp.props('note').user.id).not.toEqual(CURRENT_USER_ID); + expect(cmp.attributes('data-test-other-note-id')).toBeTruthy(); + expect(cmp.attributes('data-test-other-note-id')).not.toEqual(CURRENT_USER_ID); }); }); @@ -133,7 +134,7 @@ describe('GrantNotes component', () => { await flushPromises(); expect(mockStore.actions['grants/saveNoteForGrant'].mock.lastCall[1].text).toEqual('My Note'); - const userNoteCmp = wrapper.findComponent('[data-test-user-note]'); + const userNoteCmp = wrapper.findComponent('[data-test-user-note-id]'); expect(userNoteCmp.exists()).equal(true); }); @@ -162,7 +163,7 @@ describe('GrantNotes component', () => { await flushPromises(); expect(mockStore.actions['grants/getNotesForGrant'].mock.lastCall[1].cursor).toEqual(NEXT_ID); - const otherNoteCmps = wrapper.findAllComponents('[data-test-other-note]'); + const otherNoteCmps = wrapper.findAllComponents('[data-test-other-note-id]'); expect(otherNoteCmps).toHaveLength(4); expect(wrapper.findComponent('[data-test-show-more-btn]').exists()).toEqual(false); }); diff --git a/packages/client/src/components/GrantNotes.vue b/packages/client/src/components/GrantNotes.vue index 99b291001..da8aed610 100644 --- a/packages/client/src/components/GrantNotes.vue +++ b/packages/client/src/components/GrantNotes.vue @@ -6,11 +6,11 @@ class="d-flex note-edit-container" > - + - + {{ userNote.text }} - +
    @@ -78,10 +85,19 @@ v-for="note of otherNotes" :key="note.id" > - + + {{ note.text }} +
@@ -107,13 +123,13 @@ import { nextTick } from 'vue'; import { mapActions, mapGetters } from 'vuex'; import UserAvatar from '@/components/UserAvatar.vue'; -import GrantNote from '@/components/GrantNote.vue'; +import UserActivityItem from '@/components/UserActivityItem.vue'; import { grantNotesLimit } from '@/helpers/featureFlags'; export default { components: { UserAvatar, - GrantNote, + UserActivityItem, }, emits: ['noteSaved'], data() { @@ -149,9 +165,9 @@ export default { return `ml-auto ${errColor}`; }, userNoteClass() { - const corners = this.emptyNoteText ? 'rounded-bottom-corners' : ''; + const corners = this.otherNotes.length === 0 ? 'rounded-bottom-corners' : ''; - return `user-note ${corners}`; + return `user-note activity-container ${corners}`; }, }, async beforeMount() { @@ -241,6 +257,10 @@ textarea.note-textarea { padding-right: 2.25rem; } +.activity-container { + padding: 1.25rem; +} + textarea.note-textarea::placeholder { font-size: 0.875rem } diff --git a/packages/client/src/components/Modals/GrantFollowers.vue b/packages/client/src/components/Modals/GrantFollowers.vue index 35a5a1109..d74c90191 100644 --- a/packages/client/src/components/Modals/GrantFollowers.vue +++ b/packages/client/src/components/Modals/GrantFollowers.vue @@ -15,35 +15,25 @@
  • - -
    - -
    - {{ follower.email }} -
    -
    - {{ follower.dateFollowedText }} -
    -
    - import { mapActions, mapGetters } from 'vuex'; -import UserAvatar from '@/components/UserAvatar.vue'; import CopyButton from '@/components/CopyButton.vue'; -import UserHeaderText from '@/components/UserHeaderText.vue'; -import { formatActivityDate } from '@/components/GrantNote.vue'; +import UserActivityItem from '@/components/UserActivityItem.vue'; export default { components: { - UserAvatar, CopyButton, - UserHeaderText, + UserActivityItem, }, props: { modalId: { @@ -123,21 +110,6 @@ export default { loadMoreVisible() { return this.followersNextCursor !== null; }, - formattedFollowers() { - return this.followers - .map((follower) => { - const { user, id, createdAt } = follower; - - return { - id, - name: user.name, - email: user.email, - team: user.team.name, - dateFollowedText: formatActivityDate(createdAt), - avatarColor: user.avatarColor, - }; - }); - }, followersEmailText() { return this.followers .map((follower) => follower.user.email) diff --git a/packages/client/src/components/ShareGrant.vue b/packages/client/src/components/ShareGrant.vue index 0008a2e11..4efa5bd37 100644 --- a/packages/client/src/components/ShareGrant.vue +++ b/packages/client/src/components/ShareGrant.vue @@ -1,11 +1,15 @@
    @@ -80,10 +83,12 @@ import { datadogRum } from '@datadog/browser-rum'; import { newTerminologyEnabled, shareTerminologyEnabled } from '@/helpers/featureFlags'; import { formatDate, formatDateTime } from '@/helpers/dates'; import { gtagEvent } from '@/helpers/gtag'; -import UserAvatar from '@/components/UserAvatar.vue'; +import UserActivityItem from '@/components/UserActivityItem.vue'; export default { - components: { UserAvatar }, + components: { + UserActivityItem, + }, data() { return { selectedAgencyToAssign: null, @@ -150,5 +155,4 @@ export default { }; - + diff --git a/packages/client/src/components/UserActivityItem.spec.js b/packages/client/src/components/UserActivityItem.spec.js new file mode 100644 index 000000000..ddf1388a4 --- /dev/null +++ b/packages/client/src/components/UserActivityItem.spec.js @@ -0,0 +1,30 @@ +import { describe, it, expect } from 'vitest'; +import { mount } from '@vue/test-utils'; +import UserActivityItem from '@/components/UserActivityItem.vue'; +import { id } from '@/helpers/testHelpers'; + +const activity = { + id: id(), + createdAt: new Date().toISOString(), + isEdited: false, + userName: 'User', + teamName: 'Team', + userEmail: 'e@net.com', + avatarColor: 'red', +}; + +describe('GrantNote component', () => { + it('renders', () => { + const wrapper = mount(UserActivityItem, { + props: { + ...activity, + }, + slots: { + default: '
    Text
    ', + }, + }); + + expect(wrapper.exists()).toBe(true); + expect(wrapper.find('[data-test-text]').exists()).toBe(true); + }); +}); diff --git a/packages/client/src/components/GrantNote.vue b/packages/client/src/components/UserActivityItem.vue similarity index 53% rename from packages/client/src/components/GrantNote.vue rename to packages/client/src/components/UserActivityItem.vue index bd753494a..0e5c63e24 100644 --- a/packages/client/src/components/GrantNote.vue +++ b/packages/client/src/components/UserActivityItem.vue @@ -1,35 +1,42 @@