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

Migration of Individual Pages from Webpack/AngularJS to Lazy-Loaded Angular Modules #19435

Open
15 of 26 tasks
DubeySandeep opened this issue Jan 9, 2024 · 127 comments
Open
15 of 26 tasks
Labels
frontend good first issue Impact: High Blocks or significantly slows down a core workflow.

Comments

@DubeySandeep
Copy link
Member

DubeySandeep commented Jan 9, 2024

Description:

This issue aims to move individual page compilations from using Webpack (as AngularJS modules) to lazy-loaded Angular modules. This migration ensures each page has its own Angular module and is loaded only when needed, enhancing application performance. It also facilitates the shift from the AngularJS compilation process to Angular modules. Completing this migration will allow for the removal of Webpack and AngularJS-related code from our codebase.

Routes requiring these changes:

Ready for work:

Assigned(0):
In-review(5):
Completed(15):

Required changes:

Before making any changes, please navigate to the relevant page on your local machine (on the develop branch) and check that you understand how to reach it. Try out the behaviour of that page to get some idea of how it works, so that you can verify that the page continues to work fine after the changes below.

Backend changes:

  1. Register the Page:

    • Add the page to constants.PAGES_REGISTERED_WITH_FRONTEND. Reference
  2. Remove Backend Handler:

    • Remove the backend handler that returns <page-name>.mainpage.html. Reference
    • Update the associated backend tests accordingly. Reference
  3. Remove URL-to-handler linkage in main.py:

    • In main.py, remove the line that links url to the old handler which is removed in the above step. Reference
      Note: For each task, a link to the relevant URL-to-handler linkage in main.py is provided under the 'Route' bullet.
  4. Add access validator

Frontend changes:

  1. Delete Redundant File:

    • Remove the <page-name>.mainpage.html file. Reference
  2. Create Route Guard:

    • Create an access validator function in the access-validator backend service. (Reference)
    • Create a route guard file for the module. Reference
    • In the canActivate function make a call to the newly created access-validator function and return true if the user has permission else route to the error page and return false. Reference
  3. Component Upgrade:

    • Remove downgradeComponent from the page component. Reference
  4. Create Root Component Files:

    • Create <module-name>.root.component.ts with title and meta. Reference
    • Create <module-name>.root.component.html. The template should use the relevant page-component. Reference
  5. Update Main Module:

    • Remove providers, Browser*Module, any HTTP module, and everything related to the router module. Reference
    • Eliminate ngDoBootstrap from the module class and all code below the module class. Reference
    • Add router configuration in the module: Reference
      RouterModule.forChild([
        {
          path: '',
          component: <ModuleName>RootComponent,
          canActivate: [<NewRouteGuard>],
        },
      ]),
      
  6. Update Components in Module:

    • For each component in the declarations of <module-name>.module.ts:
      • Remove downgradeComponent from the bottom. References
      • If it's a navigation-related component, change smartRouterLink to routerLink. Reference
  7. Add Module to App Routing:

    • Include the module in app.routing.module.ts with IsLoggedInGuard [if required]. Reference
  8. Update Webpack Configuration:

    • Remove the module from the webpack configuration. Reference

How to test all the changes:

  1. Run the development server
  2. As each of the following users, go to the URL of the page you migrated:
    • Admin (Should be able to access the page, if it's allowed)
    • User who should have rights on the page (Should be able to load the page)
    • User doesn't have rights to use the page (Page should be loaded with 401/404 status.)
  3. If this page is accessible from any links on the home page or the footer, click those links and verify that the page loads correctly.

Helpful Tips

Reference Pull Request (PR): While working on your changes, refer to the PR at #18855. Your updates may not require all the modifications in that PR, but they will likely overlap.

Seeking Help: If you encounter persistent errors after applying your changes and can't resolve them despite multiple attempts, you can seek assistance from @DubeySandeep and others. To do this effectively:

  • Prepare a Draft PR: Initiate a draft pull request on GitHub incorporating all your changes.

  • Document Your Attempts: Create a debugging doc to fully describe the issues you are running into and the solutions you've tried, so that others can help you more easily.

  • Reach Out for Help: Contact @DubeySandeep via email (dubeysandeep.in@gmail.com). Include in your communication:

    • The specific error you're encountering.
    • The link to your draft PR.
    • The debugging doc, which includes the list of solutions you've already attempted.
    • Email title with "Need help with #19435"

    In addition, please leave a comment on this issue thread with the above details as well.

To remove webpack requirements for the codebase, firstly we need to get #19435 resolved though even after this we will be left with some pages which cannot be removed using the steps mentioned in #19435. This issue list outs all the remaining tasks (excluding #19435) required to be completed before removing webpack:

  • Remove /console-errors page as it's no more needed.
  • Render /maintenance page via OppiaRootHandler nad move the maintenance page to angular.
@jnvtnguyen
Copy link
Contributor

Hi @DubeySandeep,
Can I work on this issue?

@DubeySandeep
Copy link
Member Author

@jnvtnguyen I've assigned you to Moderator, you can start working on it! Also, I've sent you a message on Google Chat to keep in touch (send me an email in case you are not on google-chat).

@jnvtnguyen
Copy link
Contributor

@DubeySandeep Alright, do I create a pull request when I finish the Moderator migration?

@Vir-8
Copy link
Contributor

Vir-8 commented Jan 12, 2024

Hey @DubeySandeep, can I work on a page too?

@DubeySandeep
Copy link
Member Author

DubeySandeep commented Jan 12, 2024

@DubeySandeep Alright, do I create a pull request when I finish the Moderator migration?

@jnvtnguyen Yes! Also, you can create a draft PR if after completing all the steps mentioned above you are not able to fix any issue raised during testing! (This will help me check the changes and guied you better!)

@DubeySandeep
Copy link
Member Author

Hi @Vir-8 Thanks for showing interest in this issue! :)

I've assigned you to Blog admin, you can start working on it! Let me know if you have any questions or need any help! :)

@Vir-8
Copy link
Contributor

Vir-8 commented Jan 12, 2024

Sure thing, thanks!

@DubeySandeep
Copy link
Member Author

Assigning Creator dashboard to @jysin330

@jysin330 You can start working on it, let me know if you need any help! :) (Also, you can use #19449 for reference.)

@jnvtnguyen
Copy link
Contributor

Hi, I will work on the Contributor Dashboard Migration.

@jysin330
Copy link

Sure @DubeySandeep .Thank you for assigning me to issue #19453.

github-merge-queue bot pushed a commit that referenced this issue Jan 13, 2024
* Moderator Migration

* Review Changes #1

* Creator and Contributor Dashboard Migration

* Remove Backend Test

* Revert "Remove Backend Test"

This reverts commit ad0d047.

* Revert "Creator and Contributor Dashboard Migration"

This reverts commit b8cdad6.
@retrogtx
Copy link

Hi @DubeySandeep
can I be assigned something?

@DubeySandeep
Copy link
Member Author

@retrogtx I've assigned you to Email Dashboard, you can start working on it! Let me know if you have any questions. Good luck! :)

@shivanandan17
Copy link
Contributor

shivanandan17 commented Jan 14, 2024

Hi @DubeySandeep ,

I am new to open source. I would like to contribute to the community and I would like to start from here. Can I be assigned with something?

Also, Is there any other way I can communicate with you? As github discussion is kinda confusing for me. Thank you in advance.

@arnavchhokra
Copy link

Hi @DubeySandeep , can I be assigned something?

@Vir-8
Copy link
Contributor

Vir-8 commented Jan 15, 2024

@DubeySandeep Sure thing, I'd love to work on migrating another page

@DubeySandeep
Copy link
Member Author

@shivanandan17 @arnavchhokra Thanks for showing interest in this issue, as this issue is critcal and needs to be resolved quickly, I'm only assigning it to someone completed devlopment env setup. Can you please share a screenshot presenting a running development env?

@DubeySandeep
Copy link
Member Author

@Vir-8 I've assigned you to Learner dashboard & Curriculum admin, feel free to initiate one PR with both the section. I hope that's fine, let me know in case you only want to work on one at a time! :)

Note: Learner dashboard is simple and won't need any new route gaurd.

@arnavchhokra
Copy link

@DubeySandeep ,
image

@DubeySandeep
Copy link
Member Author

@arnavchhokra Thanks for sharing the screenshot, I've assigned you to Blog Dashboard, you can start working on it. Also, you can take #19471 for reference (if needed). Let me know if you have any questions, I'll be more than happy to help. Good luck!

@shivanandan17
Copy link
Contributor

shivanandan17 commented Jan 15, 2024

@DubeySandeep
Screenshot from 2024-01-15 17-20-26

amaanlari added a commit to amaanlari/oppia that referenced this issue Mar 8, 2024
amaanlari pushed a commit to amaanlari/oppia that referenced this issue Mar 8, 2024
amaanlari added a commit to amaanlari/oppia that referenced this issue Mar 13, 2024
amaanlari added a commit to amaanlari/oppia that referenced this issue Mar 16, 2024
amaanlari added a commit to amaanlari/oppia that referenced this issue Mar 18, 2024
amaanlari added a commit to amaanlari/oppia that referenced this issue Mar 19, 2024
@KaterinaNakou2003
Copy link

Hello @DubeySandeep can i be assigned to something too?

@DubeySandeep
Copy link
Member Author

@KaterinaNakou2003 I've assigned you to Story Editor!

@DubeySandeep
Copy link
Member Author

Unassigned @Happyashbunny because of lack of activity!

@abhisheksatpathy @pritam2317 Any update on the assigned part of the issue?

@KaterinaNakou2003
Copy link

@DubeySandeep Thank you!!

@pritam2317
Copy link
Collaborator

Hi @DubeySandeep by tomorrow, I will create a pull request; only the backend testing portion is left.
Thanks you:)

github-merge-queue bot pushed a commit that referenced this issue Mar 21, 2024
…ar Router (#19901)

* Registered the COLLECTION_PLAYER page

* Removed backend handler and updated the associated tests.

* Removed URL to handler linkage in main.py

* Added access validator

* Deleted Redundant File collection-player-page.mainpage.html

* Created Route Guard

* Component Upgraded

* Created Root Component Files

* Updated Main Module

* Updated Components in Module

* Added module to App Routing

* Updated Webpack Configuration

* Added required spec files

* Fixed a error

* Fixed lint and frontend karma errors

* Update authors since 7f6c6b6 (#19878)

* Update core/templates/pages/about-page/about-page.constants.ts

* Update AUTHORS

* Update CONTRIBUTORS

* Update contributors

* Fixed lint and frontend karma errors

* Fixed lint, frontend errors and backend errors.

* resolved minor issues

* Added access validator

* Created Route Guard

* resolved minor issues

* Added access validator

* Created Route Guard

* Fixed lint, frontend errors and backend errors.

* resolved minor issues

* format code with prettier

* format code with prettier

* format code with prettier

* format code with prettier

---------

Co-authored-by: amaanlari <amaanlari@outlook.comm>
Co-authored-by: Sean Lip <sean@seanlip.org>
@abhisheksatpathy
Copy link

@DubeySandeep ran into some errors, resolving them as of the moment. I'm really sorry for the delays, my mid-semester exams were going on.
Will finish this asap!

@abhisheksatpathy
Copy link

@DubeySandeep could you assign me subtopic viewer in the meantime?

@Ahmed-Bhouri
Copy link
Contributor

Hello @DubeySandeep
can i be assigned to something?

@DubeySandeep
Copy link
Member Author

DubeySandeep commented Mar 27, 2024

@abhisheksatpathy I've reviewed your PR and looks like it needs some work, for now, let's focus on that PR and once it's in a good state I'll assign you another task from this issue. I hope that's fine!

@Ahmed-Bhouri I've assigned you to Review Test!

@Lawful2002 Thanks for helping with this issue :), leave a comment when assigning anyone the task it helps better track the issue.

@DubeySandeep
Copy link
Member Author

@pritam2317 Any update on the assigned task?

@pritam2317
Copy link
Collaborator

pritam2317 commented Mar 29, 2024

@DubeySandeep Sorry for the delay; I was busy writing a proposal. I'll create a PR within tommorow.

github-merge-queue bot pushed a commit that referenced this issue Apr 19, 2024
* registered with frontend

* removed backend handler for the page

* correspoding tests for the backend handler removed

* removed the link to the old handler

* added access validator class for diagnostic test player

* added url for the validator

* added test class for diagnostic test player

* removed redundant mainpage file

* added service on frontend to call access validators defined on backend

* removed 'downgradeComponent' page component

* corrected constant.ts reference to diagnostic test player, added root page ts file

* added diagnostic test player root template

* removed excess imports and ngbootstrap form dtp module

* added routes within the module

* added the page to the app routing module

* removed the module from webpack config

* fix linter errors

* fixed linter error

* fix linter errorrs

* added frontend tests for root component and validator service method

* fixed url reference to validation service

* fixed pytype check error

* fixed merge conflict

* fixed linter error

* fixed MyPy type checks

* removed unnecessary auth guard for diagnostics test player

* implemented conditional rendering of the page, based on the feature flag value set in backend

* backent test error fixed

* added backend test for DiagnosticTestPlayerAccessValidationHandler

* removed unused import in the module

* correct the component name being tested by the karma test

* added unit test for diagnostic test player root component

* fixed linter errors

* reverted unwanted changes

* linter check fixed

* delegated error handling

* fix linter errors

* modified unit tests to match the code changes in component

* ran prettier for code formatting

* refactored code to include a route guard (instead of error 404 logic inside component)

* minor typo fix

* reverted relave paths to to alias-based paths for consistency
github-merge-queue bot pushed a commit that referenced this issue Apr 23, 2024
* registered the page in constant file

* removed the backend handler for the page

* removed handler linked in main.py

* removed linked test to the page

* added access validator

* added tests for access validator

* facilitator dashboard access validation handler added to main.py

* fixed indentation

* added validatation function to access validation backend api service

* added test for validation service method

* facilitator dashboard root page added

* added unit tests for facilitator dashboard root page

* removed downgrade of the component

* cleaned up facilitator dashboard module file

* added router module

* registered the facilitator dashboard page to routing module

* removed the page from webpack

* minor refactor

* modified linters checks

* liter checks fixed

* fixed unit test

* fixed minor misspellings

* added route guard for navigation for error page

* added unit tests for route guard

* minor renaming of classes and file

* fixed unit tests

* fixed typo

* adds passive event listener to facilitator dashboard page
github-merge-queue bot pushed a commit that referenced this issue Apr 28, 2024
* Translate exploration text

* fixes frontend coverage

* fixes frontend coverage

* fixes frontend coverage

* fixes frontend coverage

* fixes frontend coverage

* fixes frontend test

* fixes frontend test

* fixes frontend test

* fixes frontend statement

* fixes frontend statement

* fixes frontend statement

* fixes frontend statement

* fixes frontend statement

* lazy loading of collection editor page

* lazy loading of collection editor page

* fixes linter checks

* fixes backend issue

* Fixes backend test

* Address review comments

* fixes access-validation test

* fixes access validators test

* fixes handler name

* Fixes backend coverage

* fixes webpack configuration
@abhisheksatpathy
Copy link

Hi @DubeySandeep, My PR got closed(stale) as I have exams going on rn. I will open another PR on migration of topic viewer page asap! Sorry for the troubles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend good first issue Impact: High Blocks or significantly slows down a core workflow.
Projects
Development

No branches or pull requests