Skip to content

Feature standalone popup #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yaxit24
Copy link

@yaxit24 yaxit24 commented Apr 2, 2025

Changes made: I've added a standalone tab to the SCRUM Helper extension, enabling users to generate and copy reports directly from the popup without needing email clients. The implementation includes a clean, user-friendly interface with a text area for editing reports and buttons for convenient report generation and clipboard copying. The design follows the extension's existing style patterns, ensuring a seamless experience while giving users more flexibility in how they create and share their SCRUM reports.

Screenshots for the change:
Screenshot 2025-04-03 at 12 43 04 AM
Screenshot 2025-04-03 at 12 53 01 AM

Screenshot 2025-04-03 at 12 55 52 AM

Summary by Sourcery

Add a standalone report generation tab to the SCRUM Helper extension, allowing users to create and copy reports directly from the popup

New Features:

  • Introduce a new 'Standalone' tab in the extension popup that enables users to generate and copy SCRUM reports without needing an email client

Enhancements:

  • Modify the existing tab layout to accommodate the new standalone report feature
  • Implement report generation and clipboard copying functionality within the popup

Chores:

  • Update the extension's user interface to support a third tab
  • Add event listeners for the new standalone report functionality

Copy link

sourcery-ai bot commented Apr 2, 2025

Reviewer's Guide by Sourcery

This pull request introduces a 'Standalone' tab to the SCRUM Helper extension, enabling users to generate and copy reports directly from the popup. The implementation includes a new UI section with a textarea and buttons for report generation and clipboard copying. A background script was added to forward messages from the popup to the content script.

Sequence Diagram for Standalone Report Generation

sequenceDiagram
    participant User
    participant Popup
    participant ChromeStorage
    participant Clipboard

    User->>Popup: Clicks 'Generate Report'
    Popup->>ChromeStorage: Get stored data (username, project name, etc.)
    ChromeStorage-->>Popup: Returns stored data
    Popup->>Popup: Generates report
    Popup->>Popup: Displays report in textarea
    User->>Popup: Clicks 'Copy to Clipboard'
    Popup->>Clipboard: Copies report to clipboard
    Clipboard-->>Popup: Acknowledges copy
    Popup->>User: Shows success message
Loading

File-Level Changes

Change Details Files
Implemented a new 'Standalone' tab in the extension popup, allowing users to generate and copy reports directly without needing to navigate to other pages.
  • Added a new tab to the popup's tab structure.
  • Created a new UI section for the standalone report generator, including a textarea for report display and buttons for generating and copying the report.
  • Implemented functions to generate a basic report based on user settings stored in chrome storage.
  • Added functionality to copy the generated report to the clipboard.
  • Added event listeners to the generate and copy buttons.
  • Added logic to switch between the main settings and the standalone report tab.
src/scripts/main.js
src/popup.html
src/index.css
Added background script to forward messages from the popup to the content script.
  • Added a listener for messages from the popup.
  • Forwarded the message to the active tab.
  • Sent a response back to the popup.
src/scripts/background.js

Possibly linked issues

  • #123: The PR implements the standalone pop-up interface requested by the issue, including report generation and copy functionality within the extension.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @yaxit24 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using a more robust state management solution for tab visibility instead of directly manipulating display styles.
  • The generateStandaloneReport function duplicates some logic from the content script; consider refactoring to share code.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -169,3 +169,128 @@ userReasonElement.addEventListener('keyup', handleUserReasonChange);
document.addEventListener('DOMContentLoaded', handleBodyOnLoad);
document.getElementById('codeheatTab').addEventListener('click', handleCodeheatClick);
document.getElementById('gsocTab').addEventListener('click', handleGsocClick);
Copy link

Choose a reason for hiding this comment

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

issue (complexity): Consider creating a helper function for tab switching to reduce code duplication and improve readability by defining DOM references once and avoiding inline anonymous functions for click listeners, which significantly reduces complexity and improves maintainability without altering functionality

Consider extracting and reusing common functionality to reduce duplication and nesting. For example, you can create a helper function for tab switching instead of providing nearly identical inline click listeners. This refactoring also lets you define DOM references once in the DOMContentLoaded handler. For instance:

// Helper to switch tabs
function switchTab(showEl, hideEl) {
  showEl.style.display = 'block';
  hideEl.style.display = 'none';
}

document.addEventListener('DOMContentLoaded', function() {
  // Initialize tabs if Materialize is available
  if (typeof M !== 'undefined' && M.Tabs) {
    const tabs = document.querySelectorAll('.tabs');
    M.Tabs.init(tabs);
  }

  // Cache elements
  const mainSettings = document.getElementById('main-settings');
  const standalone = document.getElementById('standalone');

  // Tab click event handlers using the helper function
  document.getElementById('codeheatTab').addEventListener('click', () => {
    switchTab(mainSettings, standalone);
  });

  document.getElementById('gsocTab').addEventListener('click', () => {
    switchTab(mainSettings, standalone);
  });

  document.getElementById('standaloneTab').addEventListener('click', () => {
    switchTab(standalone, mainSettings);
  });

  // Standalone report functionality remains unchanged
  const generateReportBtn = document.getElementById('generate-report');
  const copyReportBtn = document.getElementById('copy-report');
  if (generateReportBtn) {
    generateReportBtn.addEventListener('click', generateStandaloneReport);
  }
  if (copyReportBtn) {
    copyReportBtn.addEventListener('click', copyToClipboard);
  }
});

These changes extract duplicated logic into a single function, reduce inline anonymous functions, and make the flow easier to follow without altering any functionality.

@yaxit24
Copy link
Author

yaxit24 commented Apr 2, 2025

@hongquan, @mariobehling, please review my changes.

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