-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: add API to retrieve grant notes for specific user via Finder API - Implemented `getOrganizationNotesForGrantByUser()` function in `grantsCollaboration/notes.js` - Renamed `getOrganizationNotesForGrant()` to `getCurrentNoteRevisions()` and updated signature - Made conditional `WHERE` clause for `grantId` and `userId` in `getCurrentNoteRevisions()` - Created API route `GET /:grantId/notes/user/:userId` in `grants.js` for fetching user-specific grant notes - Added validation for `afterRevision` and `limit` query parameters in the new API - Ensured results are paginated and ordered by `created_at` in descending order - Added necessary imports/exports in `grantsCollaboration/index.js` * ES Lint fixes * ES Lint fixes * ES Lint fixes * ES Lint fixes * ES Lint fixes * first pass * add notes for user * adjust styling * refine grant notes * add FE tests * adjust grant notes * adjust styling * adjust notes display * adjust styling * fix test * extract header text to component * adjust styling * correct limit * remove unused * adjust form validation * use cursor naming * include limit feature flag * limit unbounded row query --------- Co-authored-by: Sushil Rajeeva Bhandary <[email protected]>
- Loading branch information
1 parent
7140173
commit 5e71973
Showing
24 changed files
with
1,006 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<template> | ||
<div class="d-flex note-container"> | ||
<div class="d-flex flex-column"> | ||
<UserAvatar | ||
:user-name="note.user.name" | ||
size="2.5rem" | ||
:color="note.user.avatarColor" | ||
/> | ||
<div class="note_vertical position-relative flex-grow-1" /> | ||
</div> | ||
|
||
<div class="d-flex flex-column flex-grow-1 has-flexi-truncate ml-2"> | ||
<UserHeaderText | ||
:name="note.user.name" | ||
:team="note.user.team.name" | ||
/> | ||
<div class="text-gray-500"> | ||
<CopyButton | ||
:copy-text="note.user.email" | ||
hide-icon | ||
> | ||
{{ note.user.email }} | ||
</CopyButton> | ||
</div> | ||
<div class="mt-1 text-gray-600"> | ||
{{ note.text }} | ||
</div> | ||
<div class="d-flex mt-1 align-items-end"> | ||
<span class="note-date-text"> | ||
{{ timeElapsedString }} | ||
<span | ||
v-if="note.isRevised" | ||
class="text-gray-500" | ||
>(edited)</span> | ||
</span> | ||
<div class="ml-auto"> | ||
<slot name="actions" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { DateTime } from 'luxon'; | ||
import UserAvatar from '@/components/UserAvatar.vue'; | ||
import CopyButton from '@/components/CopyButton.vue'; | ||
import UserHeaderText from '@/components/UserHeaderText.vue'; | ||
export const formatActivityDate = (createdAtISO) => { | ||
const createdDate = DateTime.fromISO(createdAtISO); | ||
const today = DateTime.now().endOf('day'); | ||
let dateText = ''; | ||
if (createdDate.hasSame(today, 'day')) { | ||
dateText = createdDate.toRelativeCalendar({ base: today, unit: 'days' }); | ||
} else if (createdDate > today.minus({ days: 7 })) { | ||
dateText = createdDate.toRelative({ base: today, unit: 'days' }); | ||
} else { | ||
dateText = createdDate.toFormat('MMMM d'); | ||
} | ||
return dateText; | ||
}; | ||
export default { | ||
components: { | ||
UserAvatar, | ||
CopyButton, | ||
UserHeaderText, | ||
}, | ||
props: { | ||
note: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
computed: { | ||
timeElapsedString() { | ||
return formatActivityDate(this.note.createdAt); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
@import '@/scss/colors-semantic-tokens.scss'; | ||
@import '@/scss/colors-base-tokens.scss'; | ||
.note-container { | ||
padding: 1rem 1.25rem; | ||
} | ||
.text-gray-500 { | ||
color: $raw-gray-500 | ||
} | ||
.note-date-text { | ||
font-size:0.75rem; | ||
} | ||
.note-date-text:first-letter { | ||
text-transform: capitalize; | ||
} | ||
.text-gray-600 { | ||
color: $raw-gray-600; | ||
font-weight: 400; | ||
} | ||
.note_vertical:before { | ||
content: ""; | ||
background: $raw-gray-600; | ||
height: calc(100% - .5rem); | ||
width: 1px; | ||
position: absolute; | ||
left: calc(2.5rem / 2); | ||
top: 0.375rem; | ||
bottom: 0; | ||
} | ||
</style> |
Oops, something went wrong.