Skip to content

Improve message notification#4148

Merged
ildyria merged 1 commit intomasterfrom
message-notifications
Mar 5, 2026
Merged

Improve message notification#4148
ildyria merged 1 commit intomasterfrom
message-notifications

Conversation

@ildyria
Copy link
Member

@ildyria ildyria commented Mar 4, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added badge indicators for unread contact messages in the admin menu.
  • Refactor

    • Contact form feature configuration has been reorganized across the system.

@ildyria ildyria requested a review from a team as a code owner March 4, 2026 22:41
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

This PR migrates contact form configuration from the global Lychee store to the ModulesRightsResource, restricting visibility of unread message counts to administrators. A visual badge component is integrated into the left menu to display message counters where available.

Changes

Cohort / File(s) Summary
Backend Resource Updates
app/Http/Resources/GalleryConfigs/InitConfig.php, app/Http/Resources/Rights/ModulesRightsResource.php
InitConfig removes config-driven assignment of contact form enabled state; ModulesRightsResource adds is_contact_enabled flag and messages_count field with private isContactEnabled() method that enforces admin-only visibility of unread message counts.
Frontend State & Composition
resources/js/stores/LycheeState.ts, resources/js/composables/contextMenus/leftMenu.ts, resources/js/lychee.d.ts
Removed is_contact_form_enabled property from LycheeState store; leftMenu composable updated to reference initData.value.modules instead and now passes messages_count as num field; TypeScript definitions extended to include is_contact_enabled and messages_count in ModulesRightsResource type.
UI Menu Component
resources/js/menus/LeftMenu.vue
Added conditional OverlayBadge wrapper around menu icons when item.num exceeds zero; includes new import and CSS styling for badge positioning and outline removal.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 The message counter hops into view,
No longer in the store, but in modules true,
Admins alone shall see the unread light,
While badges dance with overlay delight,
Config refactored—a cleaner sight!

🚥 Pre-merge checks | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
resources/js/composables/contextMenus/leftMenu.ts (1)

12-26: ⚠️ Potential issue | 🟡 Minor

Missing num property in MenyType definition.

The MenyType union type does not include a num property, but line 163 adds num: initData.value.modules.messages_count to a menu item, and LeftMenu.vue (line 29) accesses item.num > 0 for badge rendering. This type mismatch will either cause TypeScript compilation errors or runtime issues.

🐛 Proposed fix to add the optional num property
 export type MenyType =
 	| {
 			label: string;
 			icon: string;
 			route?: string;
 			url?: string;
 			target?: string;
 			access: boolean;
 			seTag?: boolean;
+			num?: number;
 			command?: () => void;
 	  }
 	| {
 			label: string;
 			items: MenyType[];
 	  };
🧹 Nitpick comments (5)
app/Http/Resources/Rights/ModulesRightsResource.php (3)

191-211: Method naming inconsistency: consider returning bool or renaming to setContactEnabled.

All other module check methods in this class (isMapEnabled, isModFrameEnabled, isModFlowEnabled, etc.) return bool and follow the pattern of returning a value assigned in the constructor. This method mutates properties directly and returns void, which breaks the established pattern and may confuse future maintainers.

Consider either:

  1. Renaming to setContactEnabled() to indicate the side-effect nature, or
  2. Refactoring to return bool like the other methods and setting messages_count separately.

199-199: Inconsistent config access pattern.

This line uses resolve(ConfigManager::class)->getValueAsBool(...) while the rest of the class uses request()->configs()->getValueAsBool(...). Although functionally equivalent (per the macro defined in AppServiceProvider), maintaining consistency improves readability.

♻️ Suggested change for consistency
-		if (!resolve(ConfigManager::class)->getValueAsBool('contact_form_enabled')) {
+		if (!request()->configs()->getValueAsBool('contact_form_enabled')) {

With this change, you can also remove the use App\Repositories\ConfigManager; import on line 17.


210-210: Unnecessary toBase() call before count().

The ->toBase() conversion is typically used to avoid Eloquent model hydration, but count() doesn't hydrate models regardless. This call has no performance benefit here and adds noise.

♻️ Suggested simplification
-		$this->messages_count = ContactMessage::query()->where('is_read', '=', false)->toBase()->count();
+		$this->messages_count = ContactMessage::query()->where('is_read', '=', false)->count();
resources/js/menus/LeftMenu.vue (2)

29-32: Leading space in pt:badge:class attribute.

The value ' outline-0' has a leading space which is likely unintentional. This won't break functionality but is a minor quality issue.

♻️ Remove leading space
-							<OverlayBadge v-if="item.num > 0" severity="primary" :pt:badge:class="' outline-0'">
+							<OverlayBadge v-if="item.num > 0" severity="primary" :pt:badge:class="'outline-0'">

185-189: Unscoped CSS affects global styles.

This <style lang="css"> block is not scoped, so .p-overlaybadge .p-badge styles will apply globally to all OverlayBadge components in the application. If this is intentional (to establish a consistent badge style), consider adding a comment to clarify. Otherwise, use <style scoped> or a more specific selector.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 862280e0-e3d6-4d68-b7c7-c62555cc1b9f

📥 Commits

Reviewing files that changed from the base of the PR and between 7caed45 and 0836292.

📒 Files selected for processing (6)
  • app/Http/Resources/GalleryConfigs/InitConfig.php
  • app/Http/Resources/Rights/ModulesRightsResource.php
  • resources/js/composables/contextMenus/leftMenu.ts
  • resources/js/lychee.d.ts
  • resources/js/menus/LeftMenu.vue
  • resources/js/stores/LycheeState.ts
💤 Files with no reviewable changes (2)
  • resources/js/stores/LycheeState.ts
  • app/Http/Resources/GalleryConfigs/InitConfig.php

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.04%. Comparing base (b335a7e) to head (0836292).
⚠️ Report is 3 commits behind head on master.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ildyria ildyria merged commit 3a625ee into master Mar 5, 2026
45 checks passed
@ildyria ildyria deleted the message-notifications branch March 5, 2026 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant