cds-snc / platform-forms-client

NextJS application that serves the public-facing website for Forms
https://forms-staging.cdssandbox.xyz/
MIT License
34 stars 13 forks source link

Fix/duplicate audit events #3906

Closed bryan-robitaille closed 3 months ago

bryan-robitaille commented 3 months ago

Summary | Résumé

fixes: #3855

React Component Refactors:

Removes the direct call to get the Template information from the database and instead uses the TemplateStore as the source of truth under the form-builder path.

As a stop gap to a larger refactor a <ClientContainer /> component was created to move the server side logic to the client side where possible.

The /form-builder/responses path was tricky and will need to be refactored / optimized in the future as many of the components were rendering up to 4 times per load.

Function Refators:

The getAllTemplates() function is now a function that requires ManageAllForms privilege

The getAllTemplateForUser() function has been modified to return all the templates for the calling abilities userId. It also accepts a requestedWhere option that allows fine grain control of the selection criteria.

The

Test instructions | Instructions pour tester la modification

Setup - /form-builder with draft form

  1. try to access the /form-builder/{id}/published route. Should be redirected to /publish
  2. Publish Form
  3. try to access the /form-builder/{id}/publish route. Should be redirected to /published
  4. submit responses to published form using the generator script found in utils
  5. access the `/form-builder/{id}/responses/new route.
  6. Test to ensure pagination and navigation between statuses functions properly.

Unresolved questions / Out of scope | Questions non résolues ou hors sujet

There is a larger refactor needed to optimize the amount of renderings. Many high level components are rendering multiple times per load causing all child components to render multiple times as well. This behavior was noticed in /form-builder/responses but could also be occurring elsewhere.

Pull Request Checklist

Please complete the following items in the checklist before you request a review:

github-actions[bot] commented 3 months ago

:test_tube: Review environment

https://qzbs4iw3ljwxrqzxqh5frtsdkq0ousnl.lambda-url.ca-central-1.on.aws/

craigzour commented 3 months ago

Not sure if it is related to your work but I am getting the following error sometimes when browsing through the different pages (still testing locally). ⨯ Internal error: TypeError [ERR_INVALID_STATE]: Invalid state: ReadableStream is already closed at ReadableByteStreamController.enqueue (node:internal/webstreams/readablestream:1175:13) at eV (/Users/clementjanin/github/platform-forms-client/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:211091) at eJ (/Users/clementjanin/github/platform-forms-client/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:210389) at Timeout._onTimeout (/Users/clementjanin/github/platform-forms-client/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:200146) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7)

Screenshot 2024-06-26 at 9 40 28 AM
thiessenp-cds commented 3 months ago

Not sure if it is related to your work but I am getting the following error sometimes when browsing through the different pages (still testing locally). ⨯ Internal error: TypeError [ERR_INVALID_STATE]: Invalid state: ReadableStream is already closed at ReadableByteStreamController.enqueue (node:internal/webstreams/readablestream:1175:13) at eV (/Users/clementjanin/github/platform-forms-client/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:211091) at eJ (/Users/clementjanin/github/platform-forms-client/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:210389) at Timeout._onTimeout (/Users/clementjanin/github/platform-forms-client/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:200146) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7) Screenshot 2024-06-26 at 9 40 28 AM

@craigzour Are you still seeing this error? I can't reproduce it

craigzour commented 3 months ago

Not sure if it is related to your work but I am getting the following error sometimes when browsing through the different pages (still testing locally). ⨯ Internal error: TypeError [ERR_INVALID_STATE]: Invalid state: ReadableStream is already closed at ReadableByteStreamController.enqueue (node:internal/webstreams/readablestream:1175:13) at eV (/Users/clementjanin/github/platform-forms-client/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:211091) at eJ (/Users/clementjanin/github/platform-forms-client/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:210389) at Timeout._onTimeout (/Users/clementjanin/github/platform-forms-client/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:200146) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7) Screenshot 2024-06-26 at 9 40 28 AM

@craigzour Are you still seeing this error? I can't reproduce it

I talked to Bryan about it and it is not related to his work but NextJS hot reload feature which should not be happening in a production build.

thiessenp-cds commented 3 months ago

Not sure if it is related to your work but I am getting the following error sometimes when browsing through the different pages (still testing locally). ⨯ Internal error: TypeError [ERR_INVALID_STATE]: Invalid state: ReadableStream is already closed at ReadableByteStreamController.enqueue (node:internal/webstreams/readablestream:1175:13) at eV (/Users/clementjanin/github/platform-forms-client/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:211091) at eJ (/Users/clementjanin/github/platform-forms-client/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:210389) at Timeout._onTimeout (/Users/clementjanin/github/platform-forms-client/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:200146) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7) Screenshot 2024-06-26 at 9 40 28 AM

@craigzour Are you still seeing this error? I can't reproduce it

I talked to Bryan about it and it is not related to his work but NextJS hot reload feature which should not be happening in a production build.

How weird. How could a hot reload even happen in a prod build :)

From my end everything looks good