Skip to content

Feat/enable monetary button#1078

Merged
pokhiii merged 2 commits intomainfrom
feat/enable-monetary-button
Mar 8, 2025
Merged

Feat/enable monetary button#1078
pokhiii merged 2 commits intomainfrom
feat/enable-monetary-button

Conversation

@nishant22029
Copy link
Copy Markdown
Collaborator

@nishant22029 nishant22029 commented Mar 8, 2025

  • Enabled monetary button for collection camp and dropping center
  • Update action page to enable monetary button for events, collection camp, and dropping-center only

Summary by CodeRabbit

  • New Features

    • The monetary contribution link is now displayed only in relevant sections (e.g., events, collection camps, and dropping centers).
    • Access to monetary contribution features for events has been expanded to include an additional administrative role.
  • Refactor

    • Monetary contribution options have been streamlined by removing redundant tabs across various sections, resulting in a cleaner and more focused user interface.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 8, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR adjusts the handling of monetary contribution tabs and links across several modules. In most service classes, tab configurations for "monetaryContribution" and "monetaryContributionForUrbanOps" have been commented out, effectively disabling their display in the UI. In one service, the permission list for the "monetaryContribution" tab was expanded to include an additional role. Additionally, Puppeteer’s configuration was updated to activate the Chrome executable and the rendering logic for the "Monetary Contribution" link now conditionally checks the target value.

Changes

File(s) Change Summary
wp-content/.../Civi/{DroppingCenterService.php, GoonjActivitiesService.php, InstitutionCollectionCampService.php, InstitutionDroppingCenterService.php, InstitutionGoonjActivitiesService.php} Commented out tab configurations for monetaryContribution and monetaryContributionForUrbanOps, disabling these UI elements.
wp-content/.../Civi/GoonjInitiatedEventsService.php Expanded the permissions array for the monetaryContribution tab to include 'urban_ops_admin'.
wp-content/.../js/puppeteer.js Uncommented the executablePath line to enable Puppeteer to launch Chrome with the specified executable.
wp-content/plugins/.../goonj-blocks/{build,src}/render.php Introduced a conditional check to render the "Monetary Contribution" link only when the $target variable matches 'events', 'collection-camp', or 'dropping-center'.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant Renderer as Template Renderer
    participant Checker as Target Condition Checker

    User->>Renderer: Request page rendering
    Renderer->>Checker: Evaluate $target value
    alt $target is valid
        Checker-->>Renderer: Valid target confirmed
        Renderer->>User: Render "Monetary Contribution" link
    else $target is invalid
        Checker-->>Renderer: Target not valid
        Renderer->>User: Skip rendering link
    end
Loading

Possibly related PRs

Suggested labels

status : ready for review

Suggested reviewers

  • tarunnjoshi

Poem

In code we dance with logic tight,
Tabs once shone now rest in night.
Conditions watch with steadfast eye,
And permissions soar to new sky.
Paths are trimmed, Puppeteer awakes—
A joyful tune in every break!
Let our code sing, for change’s sake!


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nishant22029 nishant22029 changed the base branch from develop to main March 8, 2025 08:10
Copy link
Copy Markdown

@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

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 2

🧹 Nitpick comments (8)
wp-content/civi-extensions/goonjcustom/js/puppeteer.js (1)

4-7: Lack of error handling for browser launch failures

The script doesn't handle potential browser launch failures, which could occur if the specified Chrome executable isn't found or accessible.

Add try/catch block for better error handling:

(async () => {
+   try {
        const browser = await puppeteer.launch({
            executablePath: '/home/apache/.cache/puppeteer/chrome/linux-129.0.6668.89/chrome-linux64/chrome',
            args: ['--no-sandbox', '--disable-setuid-sandbox'],
        });
        
        // Rest of the code...
        
        await browser.close();
+   } catch (error) {
+       console.error('Failed to execute Puppeteer script:', error);
+       process.exit(1);
+   }
})();
wp-content/civi-extensions/goonjcustom/Civi/InstitutionDroppingCenterService.php (1)

846-859: Commented code should be removed instead of kept.

While commenting out the monetaryContribution tab configurations aligns with the PR objectives, keeping commented-out code creates maintenance issues:

  1. It clutters the codebase, making it harder to read
  2. It creates confusion about whether this is temporary or permanent
  3. Future developers might not understand the context of why this code was commented

If these features are being disabled intentionally as part of enabling monetary buttons elsewhere, consider removing the code completely and tracking it in version control instead.

-      // 'monetaryContribution' => [
-      //   'title' => ts('Monetary Contribution'),
-      //   'module' => 'afsearchMonetaryContribution',
-      //   'directive' => 'afsearch-monetary-contribution',
-      //   'template' => 'CRM/Goonjcustom/Tabs/CollectionCamp.tpl',
-      //   'permissions' => ['account_team', 'ho_account'],
-      // ],
-      // 'monetaryContributionForUrbanOps' => [
-      //   'title' => ts('Monetary Contribution'),
-      //   'module' => 'afsearchMonetaryContributionForUrbanOps',
-      //   'directive' => 'afsearch-monetary-contribution-for-urban-ops',
-      //   'template' => 'CRM/Goonjcustom/Tabs/CollectionCamp.tpl',
-      //   'permissions' => ['goonj_chapter_admin', 'urbanops'],
-      // ],
wp-content/plugins/goonj-blocks/build/render.php (1)

347-351: Build file changes match source file as expected.

The changes in the build file correctly match those in the source file, implementing the conditional display of the monetary contribution link for the appropriate targets. This consistency is good practice.

Note that there's also a commented-out monetary contribution link for processing centers at lines 374-376. Consider handling this consistently with your approach to the other monetary contribution configurations.

wp-content/civi-extensions/goonjcustom/Civi/GoonjActivitiesService.php (1)

406-419: Clarify Monetary Contribution Tab Changes

The tab configurations for 'monetaryContribution' and 'monetaryContributionForUrbanOps' have been commented out. Given the PR’s title “Feat/enable monetary button,” please confirm whether disabling these tab configurations is intentional or if they should actually be enabled to support the new monetary button functionality. This same pattern appears in several services, so centralizing these settings or adding explanatory comments/documentation could help ensure consistency.

wp-content/civi-extensions/goonjcustom/Civi/InstitutionGoonjActivitiesService.php (1)

578-591: Review Monetary Contribution Tab Removal

In this file, the monetary contribution tab configurations are also commented out. Please confirm that removing these tabs is the desired change in light of the feature’s objectives. If the intention is to eventually enable a monetary button elsewhere or via different configuration, consider adding a remark or reference to the relevant design document. This pattern is repeated across multiple modules, so consistency is essential.

wp-content/civi-extensions/goonjcustom/Civi/InstitutionCollectionCampService.php (1)

1206-1219: Monetary Contribution Tab Configurations Removal Review

The monetary contribution related tab configurations in this tabset are commented out, effectively disabling them. Since the PR aims to “enable monetary button” features, please verify if these removals are meant to deprecate old UI elements in favor of a new implementation. If so, consider centralizing the configuration for such tabs to avoid duplication across services.

wp-content/civi-extensions/goonjcustom/Civi/DroppingCenterService.php (2)

635-648: Monetary Contribution Tabs in DroppingCenterService

These commented-out lines remove the monetary contribution tabs for the Dropping Center module. Given the PR’s focus on “enabling the monetary button,” please confirm that the removal is correct—perhaps the monetary functionality is being re-implemented differently. Including a short note explaining the rationale would improve clarity and future maintainability.


549-673: Redundancy in Tab Configuration

Across the DroppingCenterService, the $tabConfigs array is built with several properties (like 'is_active' always set to 1) that are repeated for each tab. Since similar configurations appear in other service classes as well, consider refactoring this common logic into a helper or central configuration. This can reduce duplication and help maintain consistency across modules.
[duplicated_code]

🛑 Comments failed to post (2)
wp-content/civi-extensions/goonjcustom/js/puppeteer.js (2)

5-5: 🛠️ Refactor suggestion

Hardcoded Chrome executable path may cause maintainability issues

The Chrome executable path is now hardcoded to a specific version (129.0.6668.89) in a specific location. This could lead to failures if:

  1. Chrome gets updated to a newer version
  2. The file structure changes
  3. The code is deployed to a different environment

Consider using one of these approaches instead:

- executablePath: '/home/apache/.cache/puppeteer/chrome/linux-129.0.6668.89/chrome-linux64/chrome',
+ executablePath: process.env.CHROME_PATH || puppeteer.executablePath(),

Or if you need a more robust solution:

// At the top of the file
const fs = require('fs');

// In the launch configuration
executablePath: fs.existsSync('/home/apache/.cache/puppeteer/chrome/linux-129.0.6668.89/chrome-linux64/chrome') 
  ? '/home/apache/.cache/puppeteer/chrome/linux-129.0.6668.89/chrome-linux64/chrome'
  : puppeteer.executablePath(),

4-7: 💡 Verification agent

🧩 Analysis chain

Connection to PR purpose is unclear

The PR is titled "Feat/enable monetary button" but this change appears to be infrastructure-related, fixing Puppeteer's Chrome executable path. Consider adding a comment explaining how this change relates to the monetary button functionality.


🏁 Script executed:

#!/bin/bash
# Check if there are any references to monetary buttons in this file or related files
grep -r "monetary\|button" --include="*.js" --include="*.php" wp-content/civi-extensions/goonjcustom/

Length of output: 43218


Clarify Puppeteer Configuration in Relation to Monetary Button Feature

In wp-content/civi-extensions/goonjcustom/js/puppeteer.js (lines 4-7), the Puppeteer launch configuration is updated by specifying a custom Chrome executable path. However, this change appears purely infrastructural and doesn't obviously link to the “monetary button” functionality as suggested by the PR title. Although other parts of the code reference monetary contributions and button elements, this file doesn't connect to that logic.

Could you please add an inline comment or update the PR description to explain how this Puppeteer configuration change supports the monetary button feature? If it’s simply a necessary prerequisite for the overall functionality, clarifying that context would help future reviewers understand the connection.

  • File: wp-content/civi-extensions/goonjcustom/js/puppeteer.js
  • Lines: 4-7

Thanks for addressing this—providing a bit more context here will keep the PR aligned with our best practices for code clarity and maintainability!

@nishant22029 nishant22029 self-assigned this Mar 8, 2025
@nishant22029 nishant22029 requested a review from pokhiii March 8, 2025 08:13
@pokhiii pokhiii merged commit cc77295 into main Mar 8, 2025
1 check passed
@pokhiii pokhiii deleted the feat/enable-monetary-button branch March 8, 2025 08:15
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.

2 participants