feat: Add unread badge to sidebar for inbox view (#10803)
# Pull Request Template ## Description This PR adds a badge to the icon in the sidebar group header and an unread highlight for the inbox view. ## Type of change - [x] New feature (non-breaking change which adds functionality) ## How Has This Been Tested? **Loom video** https://www.loom.com/share/1a880aa16de249a1836b8d014325c067?sid=87cc7b64-667b-4066-8993-d33abccf7b67 ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
This commit is contained in:
@@ -35,4 +35,7 @@ export const getters = {
|
||||
getNotificationFilters($state) {
|
||||
return $state.notificationFilters;
|
||||
},
|
||||
getHasUnreadNotifications: $state => {
|
||||
return $state.meta.unreadCount > 0;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ const state = {
|
||||
meta: {
|
||||
count: 0,
|
||||
currentPage: 1,
|
||||
unReadCount: 0,
|
||||
unreadCount: 0,
|
||||
},
|
||||
records: {},
|
||||
uiFlags: {
|
||||
|
||||
@@ -95,4 +95,27 @@ describe('#getters', () => {
|
||||
state.notificationFilters
|
||||
);
|
||||
});
|
||||
|
||||
describe('getHasUnreadNotifications', () => {
|
||||
it('should return true when there are unread notifications', () => {
|
||||
const state = {
|
||||
meta: { unreadCount: 5 },
|
||||
};
|
||||
expect(getters.getHasUnreadNotifications(state)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false when there are no unread notifications', () => {
|
||||
const state = {
|
||||
meta: { unreadCount: 0 },
|
||||
};
|
||||
expect(getters.getHasUnreadNotifications(state)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false when meta is empty', () => {
|
||||
const state = {
|
||||
meta: {},
|
||||
};
|
||||
expect(getters.getHasUnreadNotifications(state)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user