Skip to content
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

Add Scrum Preview Modal Functionality #79

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

Conversation

Preeti9764
Copy link

@Preeti9764 Preeti9764 commented Apr 4, 2025

Fixed Issue: #74

Changes:

  • Added a modal that displays a preview of the generated Scrum.
  • Modal opens on "Generate Scrum" button click.
  • Includes a "Copy" button to copy the Scrum content to clipboard.
  • Toast notification shows successful copy — now appears within the modal for better visibility.
  • Moved modal logic to main.js and cleaned up inline scripts in popup.html.

Why:
Enhances user experience by providing a preview and copy functionality before pushing Scrum reports.

Screenshots for the change:

Summary by Sourcery

Add a preview modal for generated Scrum reports with copy functionality

New Features:

  • Implement a modal to preview generated Scrum reports before finalizing
  • Add a copy-to-clipboard feature for Scrum content within the modal
  • Introduce a toast notification for successful content copying

Enhancements:

  • Refactor modal and toast logic from inline scripts to main.js
  • Improve user interaction by providing a preview of Scrum content
  • Add dynamic content generation for Scrum preview based on user inputs

Chores:

  • Clean up HTML structure and remove unnecessary inline scripts
  • Improve modal and toast styling for better user experience

Copy link

sourcery-ai bot commented Apr 4, 2025

Reviewer's Guide by Sourcery

This pull request introduces a Scrum preview modal with copy functionality. The modal displays the generated Scrum content, allowing users to preview and copy it to their clipboard. The implementation involves adding HTML for the modal, JavaScript for handling modal interactions and clipboard functionality, and CSS for styling. The modal logic was moved to main.js to reduce inline scripts.

Sequence diagram for generating and copying Scrum content

sequenceDiagram
    participant User
    participant Popup
    participant Modal

    User->>Popup: Clicks 'Generate Scrum' button
    Popup->>Popup: Retrieves data (project name, username, reason)
    Popup->>Popup: Generates Scrum content
    Popup->>Modal: Displays Scrum content in modal
    User->>Modal: Clicks 'Copy' button
    Modal->>Modal: Copies Scrum content to clipboard
    Modal->>Modal: Shows 'Copied successfully!' toast
    Modal-->>User: Scrum content copied
Loading

File-Level Changes

Change Details Files
Implemented a modal to preview the generated Scrum content before submission.
  • Added modal HTML structure and styling.
  • Added logic to populate the modal with Scrum content.
  • Added event listeners to open and close the modal.
  • Added styling for the modal, including positioning, background, and content area.
  • Implemented a close button for the modal.
  • Added a toast notification within the modal to confirm successful copy.
src/popup.html
src/scripts/main.js
src/index.css
Added functionality to copy the Scrum content to the clipboard.
  • Added a 'Copy' button within the modal.
  • Implemented the clipboard copy functionality using navigator.clipboard.writeText().
  • Displayed a toast notification upon successful copy.
src/popup.html
src/scripts/main.js
Refactored code by moving modal-related logic from popup.html to main.js.
  • Removed inline scripts from popup.html related to modal functionality.
  • Consolidated modal-related JavaScript code into main.js for better organization and maintainability.
src/popup.html
src/scripts/main.js

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 @Preeti9764 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using a templating library to generate the scrum content instead of string concatenation.
  • It would be good to add some error handling to the clipboard copy operation.
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.

@@ -158,6 +158,64 @@ function handleGsocClick() {
chrome.storage.local.set({ gsoc: 1 });
handleLastWeekContributionChange();
}
document.getElementById("openModal").addEventListener("click", () => {
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 extracting the modal and clipboard handling logic into well-named helper functions to improve code organization and readability by reducing inline nesting and complexity within event listeners, promoting a more modular structure..

Consider extracting the modal and clipboard handling logic into small, well-named helper functions. For example, you can refactor the inline callbacks like this:

function showScrumModal() {
  chrome.storage.local.get(['projectName', 'githubUsername', 'userReason'], (items) => {
    const projectName = items.projectName || "[Project]";
    const githubUsername = items.githubUsername || "[Username]";
    const userReason = items.userReason || "None";

    // TEMP: Hardcoded sample data (replace later with GitHub API logic)
    const pastWork = [
      `(${projectName}) - Made PR (#71) - Fixes issue #69 : Enhanced feedback to Selection/Deselection of CheckBox open`,
      `(${projectName}) - Opened Issue(#69) - UI Issue with Checkbox Selection/Deselection Feedback open`,
      `(${projectName}) - Reviewed PR - #70 (Fixed UI Issue with Checkbox Selection/Deselection Feedback) open`
    ].join('\n');

    const scrum = `1. What did I do last week?\n ${pastWork}\n\n 2. What I plan to do this week?\n\n 3. What is stopping me from doing my work?\n      ${userReason}`;

    document.getElementById("scrumContent").textContent = scrum;

    // Show modal & disable body scroll
    const modal = document.getElementById("scrumModal");
    modal.style.display = "flex"; // changed from block to flex for proper centering
    document.body.style.overflow = "hidden";
  });
}

function hideScrumModal() {
  document.getElementById("scrumModal").style.display = "none";
  document.body.style.overflow = "";
}

function copyScrumContent() {
  const content = document.getElementById("scrumContent").textContent;
  const toast = document.getElementById("toast");

  navigator.clipboard.writeText(content).then(() => {
    toast.classList.add("show");
    toast.style.display = "block";

    setTimeout(() => {
      toast.classList.remove("show");
      toast.style.display = "none";
    }, 3000);
  });
}

Then, attach them to your events:

document.getElementById("openModal").addEventListener("click", showScrumModal);
document.getElementById("closeModal").addEventListener("click", hideScrumModal);
document.getElementById("copyScrum").addEventListener("click", copyScrumContent);

This refactoring reduces inline nesting and improves readability while keeping functionality intact.

@Preeti9764
Copy link
Author

@hongquan Can you review this PR and guide me for further change

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