Skip to content

Fix button not updating label after subscription #4195 #4283

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 20 commits into
base: main
Choose a base branch
from

Conversation

guillermo2519
Copy link
Contributor

Hi @tdonohue, I'am @jtimal partner, I like to share this PR with you.

References

Description

Fixes an issue where the "Subscribe" button label does not update to reflect the successful subscription.

Instructions for Reviewers

List of changes in this PR:

*Added logic to update the button label dynamically after a successful subscription.
*Ensured UI reflects current subscription status immediately without requiring page reload.

How to test:

*Go to a community or collection where the subscription button is available.
*Click "Subscribe".
*Confirm that the button text updates to reflect the new subscription status (e.g., "Unsubscribe").

Reload the page and verify that the subscription state is preserved.

Include guidance for how to test or review your PR. This may include: steps to reproduce a bug, screenshots or description of a new feature, or reasons behind specific changes.

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@tdonohue tdonohue added bug 1 APPROVAL pull request only requires a single approval to merge testathon Reported by a tester during Community Testathon labels Apr 30, 2025
@tdonohue tdonohue moved this to 🙋 Needs Reviewers Assigned in DSpace 9.0 Release Apr 30, 2025
Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

@guillermo2519 : Thanks for this PR. Overall, the feature works, but I was surprised by the change in behavior of the "Subscribe" / "Unsubscribe" option on a Community/Collection page.

Before this PR:

  • If you visited a Community/Collection you were already subscribed to, you'd still see the word "Subscribe", but clicking it would allow you to view/edit your current subscription.

After this PR:

  • In this PR, if you visit a Community/Collection you were already subscribed to, you now see the word "Unsubscribe", and clicking it will immediately unsubscribe you from that Community/Collection. There's no longer a way to view/edit your current subscription, unless you go to you click on your account & visit "Subscriptions" in the menu.

After seeing the new behavior, I feel like I prefer the ability to see the current subscription before unsubscribing. But, I don't know what others think about this.

It makes me think that the original ticket is flawed. I'm not sure if this button should say "Unsubscribe". Maybe it should simply say "Manage Subscription" or similar, and revert back to the previous behavior (if you click it, show the current subscription to allow for editing).

That's just my personal opinion here though, so I'd want feedback from others.

Finally, I have a few notes below. You've disabled some e2e tests from running. Those need to be re-enabled.

it('should load if you click on "Statistics" from a Collection page', () => {
cy.visit('/collections/'.concat(Cypress.env('DSPACE_TEST_COLLECTION')));
it.skip('should load if you click on "Statistics" from a Community page', () => {
cy.visit('/communities/'.concat(Cypress.env('DSPACE_TEST_COMMUNITY')));
Copy link
Member

Choose a reason for hiding this comment

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

This test should not be skipped. Please remove the "skip". Also, it looks like you modified the test to test a Community instead of a Collection. This test is for collection statistics, not community statistics.

Copy link
Contributor Author

@guillermo2519 guillermo2519 May 1, 2025

Choose a reason for hiding this comment

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

Thank you @tdonohue very much for your detailed feedback! 🙏

You're absolutely right regarding the unexpected change in behavior for the "Subscribe" / "Unsubscribe" button. I now realize that the current implementation may remove the user's ability to review or manage their subscription before unsubscribing. I agree that the previous behavior was more intuitive in that regard.

I'm happy to revert the current logic and instead update the button label to "Manage Subscription", which would bring users to the existing subscription dialog for viewing or editing.

I'll also re-enable the Cypress tests that were unintentionally skipped and ensure they work as expected. Apologies for the oversight.

Thanks again for your input, i’ll push the necessary changes shortly.

@github-project-automation github-project-automation bot moved this from 🙋 Needs Reviewers Assigned to 👀 Under Review in DSpace 9.0 Release May 1, 2025
Copy link

github-actions bot commented May 2, 2025

Hi @guillermo2519,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@guillermo2519
Copy link
Contributor Author

Hello @tdonohue,

I'm running into an issue where the collection-edit.cy.ts test passes perfectly on my local machine, but fails in GitHub Actions.

I confirmed that in local, everything works fine, I've attached the screenshot as evidence. However, the same test fails during the CI run without any code changes on my side.

This seems to be a CI-only issue, possibly related to timing, environment setup, or differences in how assets or routes load in GitHub Actions.

Has this happened before on your end? Any insight into why Cypress tests might pass locally but fail in CI would be very helpful.

Thanks in advance!

prube  de collection

@tdonohue
Copy link
Member

tdonohue commented May 6, 2025

@guillermo2519 : From the logs in GitHub actions, it appears that the Collection page tests are essentially "crashing" npm. I've never seen this behavior before, but it may be the sign of some unsafe code that is hitting a memory issue or loop or similar.

Have you tried testing your PR in both development mode and production mode (npm run build:prod; npm run serve:ssr) to verify it works in both scenarios? It's possible that this error could also be coming from server-side rendering (SSR) which is only triggered in production mode.

I don't immediately have time to help with this PR currently. but those are my best guesses. If I can find time to test this locally, I'll let you know anything that I find. Otherwise, you are also welcome to ask for other developers to help take a look at your code/PR by asking on our #dev channel in Slack or using our dspace-devel mailing list

@guillermo2519
Copy link
Contributor Author

Hi @tdonohue thanks for the suggestions!

I’ve just tested the PR locally using both development mode and production SSR as you recommended:

*npm run build:prod

*npm run serve:ssr

In both cases, everything works as expected — the Collection page loads correctly and there are no crashes or visible errors.
I also ran the Cypress test locally with npx cypress run --spec "cypress/e2e/collection-page.cy.ts", and it passes successfully.

So far, I haven't been able to reproduce the npm crash locally, which suggests it might be something specific to the CI environment — possibly related to resource limits, Node version differences (my local is Node 18.x, while GitHub Actions is using Node 20), or something triggered post-test.

I’ll keep investigating to determine what could be causing this issue in the CI environment.

@tdonohue tdonohue self-requested a review May 9, 2025 21:37
Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

@guillermo2519 : I tried testing this today, and it seems to be having odd side effects on the Community & Collection pages when running in production mode. Here's what I'm seeing...

  1. First, I'm using production mode (npm run build:prod && npm run serve:ssr) with this PR installed
  2. I login as an Administrator
  3. Visit a Community. The page loads very slowly. Click on one of the "browse by" options on the Community page. The page hangs and looks like this (notice how no items are loading. This particular Community has a lot of Items on my local machine)
    loading-items-community

If I reload the page, everything will briefly work again. But, if I browse to a different Community or Collection, then the page starts hanging again on the browse by options on those pages.

I've also noticed in those scenarios, the edit "dropdown" (three dots) on the Community/Collection page will be missing the "Subscribe" or "Manage Subscriptions" option in the menu.

I'm not sure what exactly is going on, but it almost seems like the page is waiting on a response to something and not getting it.

@guillermo2519
Copy link
Contributor Author

Hi @tdonohue thanks for testing this and for the detailed feedback. I’ll take a closer look to see what might be causing these issues in production mode. It does sound like something is hanging or not resolving properly, possibly a pending request or a missing response.

I’ll investigate the performance on the Community and Collection pages, especially related to the "browse by" functionality and the missing "Subscribe / Manage Subscriptions" options. I’ll get back to you as soon as I find out more.

Thanks again for reporting this!

Copy link

Hi @guillermo2519,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 APPROVAL pull request only requires a single approval to merge bug merge conflict testathon Reported by a tester during Community Testathon
Projects
Status: 👀 Under Review
Development

Successfully merging this pull request may close these issues.

Button still says "subscribe" after subscription
2 participants