Skip to content

Conversation

Preeti9764
Copy link
Contributor

@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
Contributor

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
Contributor

@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.

chrome.storage.local.set({ gsoc: 1 });
handleLastWeekContributionChange();
}
document.getElementById("openModal").addEventListener("click", () => {
Copy link
Contributor

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
Contributor Author

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

@mariobehling mariobehling requested a review from vedansh-5 May 23, 2025 17:10
Copy link
Member

@vedansh-5 vedansh-5 left a comment

Choose a reason for hiding this comment

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

Left a few comments, also the modal can be significantly better, I'm not sure if they are hyperlinks, also make sure the copy button copies the preview in rich HTML and not just text. Thanks!

@Preeti9764
Copy link
Contributor Author

Left a few comments, also the modal can be significantly better, I'm not sure if they are hyperlinks, also make sure the copy button copies the preview in rich HTML and not just text. Thanks!

Thanks for the feedback! I've improved the modal's styling to make it cleaner and more readable, and ensured that all links are clearly visible and properly styled as hyperlinks. The copy button now copies the content in rich HTML format, preserving both the formatting and the links. I've also addressed the other comments you left—let me know if there's anything else you'd like me to adjust.

@vedansh-5
Copy link
Member

Left a few comments, also the modal can be significantly better, I'm not sure if they are hyperlinks, also make sure the copy button copies the preview in rich HTML and not just text. Thanks!

Thanks for the feedback! I've improved the modal's styling to make it cleaner and more readable, and ensured that all links are clearly visible and properly styled as hyperlinks. The copy button now copies the content in rich HTML format, preserving both the formatting and the links. I've also addressed the other comments you left—let me know if there's anything else you'd like me to adjust.
Thanks, just make sure you work on this feature and test it extensively, also make sure the generate scrum button works as intended without needing to refresh the extension. Once that's done we'll work towards a setting menu for options.

@Preeti9764
Copy link
Contributor Author

@mariobehling @hpdang Can you please take a look and suggest changes i could do to enhance this pr

@hpdang
Copy link
Member

hpdang commented May 30, 2025

@Preeti9764 Yes, I’ve already reviewed it and it works well. However, from a UI perspective, having the popup appear on a separate screen doesn’t provide a comfortable viewing experience for users. I think we should consider the approach used in PR #76, where the popup appears on the same screen, it feels more natural.

Did you see my comment on that other PR? May be you have an idea because your PR works well without the unmatched issue

@Preeti9764
Copy link
Contributor Author

@Preeti9764 Yes, I’ve already reviewed it and it works well. However, from a UI perspective, having the popup appear on a separate screen doesn’t provide a comfortable viewing experience for users. I think we should consider the approach used in PR #76, where the popup appears on the same screen, it feels more natural.

Thank you for the feedback! I completely understand your point regarding the UX and agree that having the preview appear inline (as in PR #76) would feel more seamless and intuitive for users.

@Preeti9764
Copy link
Contributor Author

Did you see my comment on that other PR? May be you have an idea because your PR works well without the unmatched issue

Yes, I’ve seen your comment on the other PR. I believe the issue there could likely be resolved by making some adjustments to how the GitHub data is fetched and handled. Ensuring proper synchronization during data retrieval can help prevent mismatches between the generated scrum and the preview report.

@vedansh-5
Copy link
Member

image
Over a date range the injected content (left hand side) is missing, all the data is visible on the scrum preview(rhs)

preeti_scrumPreview.mp4

Also I see a couple more issues:

  • The content in the scrum preview is not being fetched for the current data until I reload.
  • An inconsistent behavior of date range in injected content, the date range is sometimes inaccurate to the set parameters.
  • The content changes when open another compose body.

@hpdang
Copy link
Member

hpdang commented Jun 1, 2025

Closed this PR for now, let's focus on #76

@hpdang hpdang closed this Jun 1, 2025
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.

3 participants