Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ole Martin Handeland <[email protected]> updated altinn-app-fronte…
…nd to 4.8.0-performance.preview1 based on commit Altinn/app-frontend-react@e5c7527 Performance: Hierarchy generator rewrite (#2244) * Revert "Experimenting with flattening the node storage in order to increase throughput when adding/removing nodes" * Bundling up calls to addNode/setNodeProp/setRowExtras in order to reduce the impact of setState() with immer. Calling lots of setState() makes React have to decide what to re-render, so reducing this as much as possible speeds up things quite a bit. Now 250 rows in a repeating group is sort-of feasible (but takes ~5 seconds to generate, which was the time it initially took to just generate the 'group' form in the beginning). * Reverting the revert - adding back the attempt to flatten the store. This looks to be a better solution that also works with optional immer (I dropped immer for the hot paths). * Making it possible to restart the GeneratorStages when adding new components * Storing data about repeating group rows inside the item itself, allowing partial item updates (i.e. making it possible for evalExpressions() to maintain one part and for RepeatingChildrenPlugin to maintain the 'rows' state in the item object * Simplifying * Attempting to create some hooks that only select data when state store is ready * Fixing node removal * Filtering validations at the source * Improving the APIs in ValidationStorePlugin to limit the need to run selectValidations() in the result * Fixing non-updating validation state * Fixing minor issues that caused errors in frontend-test. When the 'pets' repeating group was hidden (because no pets are shown), the node context is not ready yet when the pets group started rendering (it was just starting to generate rows/nodes). So even if we're not ready yet, selecting node data should still do its job when the hook is running for the first time. * Fixing problems causing the pets group to crash when resetting the rows to 0 * Fixes after merge from main * Rewriting to hooks so that we can useNodeItem() instead of node.item * Moving the isValid state to inside components, adding validation filter for the Input component. This makes GenericComponent not have to re-render whenever validations change. * Using memoSelector to avoid large re-rendering of repeating groups when row state doesn't really change * Disabling debugging again * Re-introducing addRemoveCounter, as it optimizes re-rendering of NodeTraversal (which I forgot about) to only run when nodes have been added/removed. * Quick and dirty TabsPlugin based on CardsPlugin * Applying optimizations, useNode, etc * Replacing direct usages of node.item * Fixing an issue that caused the pets group to show validations for all rows, not just the relevant ones * Removing pickDataStorePath() and ignoreNodePathNotFound() * Removing the unused pickChild() function * Lots of changes: - Removing NodeRef, there is no need for this as long as BaseLayoutNode is just a reference to the internal state/data - Simplifying all the plugins, storing all the state for children in 'item' instead of inside the node-level state - Removing removeChild(), as there's no need to remove nodes (only to remove rows). If Studio removes a node, we'll regenerate them all anyway. - Adding data to child claims, so that plugins can more effectively set state in addChild(), and making it possible to have multiple child-bearing plugins in the future (as needed in RepeatingGroup, with 1x RepeatingChildrenPlugin and 2x GridRowsPlugin). * Removing the path property for BaseLayoutNode, as it's not needed anymore when state is not stored in a hierarchy * Implementing config and optionality for GridRowsPlugin (adding it to RepeatingGroup) and speeding up type-checking * Fixes after introducing support for multiple child-bearing components - filtering children for each of them * Fixes a crash when RepeatingGroup has no rows * Fixes for Grid rows in repeating groups * Low hanging fruit for unit tests - skipping node prop validation, fixing a bug where node generation would get stuck on options if no option-components exists * Implementing LikertRowsPlugin, which generates a statically defined LikertItem per row inside it * Fixing Tabs, along with some issues with laxness that caused frontend-test to crash when proceeding through the app * Implementing validation for expressions again. Slimming down prettyErrors and logging only to our devtools. * Implementing some more TODOs (mostly skipping layout pre-processing, as we support validation for expressions now) * Fixing more TODOs * Adding a couple more queues * Using public variables instead of getId()/getBaseId()/getType() etc on node objects * Re-implementing parts of #2186 after merge from main * Removing remaining uses of node.item (still some left, but very few) * Whoops, I found a bug * Whoops, I broke nested repeating groups by thinking mutateComponentId() wasn't a recursive mutator. Easy fix! * Re-implementing conditional rendering by using react components. This will now make sure to only run rules that are needed each time, instead of running them all when one of them needs to change. * Fixing a direct usage of node.item * Started getting shared-functions.test.tsx to work (split from shared.test.ts). Trying to fix some import order bugs, and I found that layout.d.ts was very broken. Renaming it to .ts shows all the problems that the typescript type-checker just ignored previously, leading me to having to make things like renderInTabs required. * Cleaning up d.ts files that were broken * First steps in fixing problems after merge from main * Fixes after merging from main (Summary2) * Trying to fix GridSummary properly * Fixing the broken 'summary overrides' in Summary2. In GroupSummary it was assumed the overrides included _all overrides_, but all other places assumed the overrides were specific to them. * Fixes for Summary2 after merge from main * Fixing a few things that crashed when testing out ttd/component-library * Delaying using import so that nodeConstructor works again (import order caused this to become undefined) * Fixing the basic workings of shared-functions.test.tsx * Fixes for running shared-functions.test.tsx * Fixes for component lookup expression tests * Fixes for running shared-functions.test.tsx * Fixes for attachments * Fixes to make sure shared-functions.test.tsx runs and reports about errors when they happen, not after * Fixing shared test: The 'ansatte' component does not exist with rowIndices [1,0], so I probably meant 'alder' or something like that * Fixing shared test: linkToPage crashes when using Task_3, because that task does not exist in applicationmetadata (we're using our default mocks because there are none here). This test should probably mock a lot more to work on the backend. * Fixing the linkToComponent so that it actually looks up the target component and page (and making a shared test for this make sense again). Removing summary tests, as these are no longer container components. * Low hanging test fruit * Low hanging test fruit * Fixing broken config in getMultiPageGroupMock.ts * Reverting back to useNavigate() instead of AppRouter.navigate(), as the latter does not seem to work well in unit tests * This test does not make sense - hidden: undefined means it's not hidden * More test fixes * The layout preprocessor does not exist in this way anymore, and I don't think the backend ever used these tests. No need to try to replicate them. * Rewriting runner for expression validation shared tests * Fixing "scalar" validation for expressions. Expressions are only invalid if they are expressions (i.e. arrays) * Re-implementing shared-context.test.tsx * Re-implementing all.test.tsx (not quite done yet) * Many smaller fixes to all.test.tsx - errors are now properly logged * Simulating a data model that always has one row in every repeating group (and Likert) * Fixing the other all-apps-tests (removing the one for layout validation, as we now do that in the hierarchy generator) * Hopefully fixing minor stuff after merge from main * Reverting to the old code in HiddenComponentsProvider. Turns out that for rules to work properly they cannot run individually, and my attempt to optimize them actually caused things to break in ttd/frontend-test. * Cleaning up a lot of stuff in Summary. Preparing for making it possible to render summaries without a summaryNode (from automatic PDF pages), simplifying the code to avoid passing in selectors (WIP), and getting rid of re-definitions and duplicates of SummaryRendererProps. * Rendering legacy PDFs using the method in PdfView2, and making it look more similar to the PdfView(1) version. * Fixes after merge from main * Fixing some tests * Fixing the functionality for changing the layout via DevTools, Cypress ++ * Fixing typescript errors in cypress * Fixing number formatting, which injected 'undefined' some places, which overwrote derived formatting from Intl * Importing a test in another means _running_ a test when running another. Fixing import in cypress tests. * Trying to enable adding nodes even though node generation is already running (by scheduling a new run right after the current one). This works sometimes, but also crashes sometimes. I think I'll need to move the runNum somewhere more central, to make sure no generator stages starts running before the node has been added properly. * Making sure new nodes (or new rows) are not being added to the node generator in-flight, but waits until the node generator is ready for it * Fixes for pet-group row sorting tests. No need to remove nodes unless they are part of a row ++. * Giving up on fixing the silly logic in SummaryComponent.tsx. Making it painfully visible instead. * Thank goodness for tests! * Fixing returnToView and heavy useNavigate() issues * Fixing broken unloading of Likert components * Fixing broken reference to page data * Fixing some broken group deep validation + error navigation * Implementing pretty much the rest of the TODOs (specifically the implicit hiding functionality) * Removing TODO - I'm not sure this was really needed * Re-fixing the broken onGroupCloseValidation. I struggled too long to figure out that I missed adding nodeValidationSelector as a dependency * Recursively removing children in rows * Making sure we detect form saving early enough * Using a proper setter instead of a ref (that does not work with immer, as it freezes the object) * Removing the 'removePage' functionality. There is no need for this, just like there is no real need for removing nodes. * A better way to reset the state when calling changeLayout() in tests. This way 'await validation()' is not broken in the process * Minor test fixes * Adding a comment in the repeating group, so that it doesn't fail when trying to close it * Fixing depth in mapping mutation, inlining function in useSourceOptions * More test fixes, trying to make all-process-steps more stable * Checking that the input is not disabled should produce more stable results - it will wait until the attachment has been uploaded before clicking in dsSelect() * The code here did not make sense to me originally, but now I remember the intention behind it. Making that code work again, and documenting it in a comment. * One test failed at some point because the validating function was not set (in custom confirm). Making sure we don't call undefined. * Minor test fixes, making sure things are ready before interacting, etc * Multiple fixes for auto-save-behavior.ts * Removing cy.startAppInstance(), as it just loads the app twice (and flashes an error for a short while) * Fixing the group test in pdf.ts * Fixing issues with the savingJustFinishedRef that causes the state to sometimes lock up in a non-ready state * Making numberFormatClear more robust * Fixing clearing of stale options * Fixing navigation test cases after I rewrote parts of linkToComponent * Catching errors on the end of a test-run (I saw this happen in navigation.ts, and I'm bothered we don't catch those). * It could be difficult to notice this functionality, so I'm logging it. * Fixing over-eager stale value removal (it removed values when fetching) * Opening row for editing after calling changeLayout() * Moving the validation filtering back. This breaks our internal validation system, so I re-opened the issue we have for this. * Re-implementing useAttachmentsMappedToFormData() inside AttachmentsStorePlugin. This makes the functionality a lot more stable, as we no longer rely on the FileUpload component being displayed while the upload is happening. * Allowing failure on end * Unseen groups now still run preselectedOptionIndex logic * Making sure attachment upload waits until upload is done before selecting in dropdown * Whoops, forgot dataModelBindings here * Making sure we set onCurrentOrPreviousPage only when there are errors * A couple more minor test fixes * Making sure pets arrays are copied and duplicated instead of re-used. Cypress seems to run this code multiple times, and not in the expected order, so mutating arrays seemed to make the test fail at least once. * Making the test less flaky by asserting read-only before attempting to click * Fetching form data re-used old values when rewriting the URL in this navigation.ts test, and later updates to the form data thus failed with a 409. I also removed prefetching of form data here, because it doesn't make sense (we keep a local copy of the form data, so prefetching and using potentially stale data means we might have overwritten the data in the past and are using an invalid model). * Fixes for stateless apps, type fixes * Making sure nodes in hidden rows are considered hidden (a test for the expression-validation-test app asserted this) * Fixing crash when groupExpressions were undefined * Instead of waitForNetworkIdle(), which seems to slow down a later reload() to a halt, intercepting and waiting for the actual upload * Test updates * Test fixes * Fixing duplicate IDs in shared tests, removing tests for duplicate IDs (these can no longer work, this causes a runtime hard error) * Fixing language tests in shared-functions * Fixing useDataModelBindingTranspose() so that it no longer needs node traversal, and thus works earlier * Adding expected warning for OpenByDefaultProvider.test. The way I read this test, this error should have been expected before as well, but at least now it's present in the log. * Extracting useResetScrollPosition() and making it more robust (by optionally waiting for an external element to be visible, and not scrolling until it's at least one pixel) * CodeQL found a scary bug! GridRows was imported, but also overwritten * Fixing tests that failed on tt02+github, but worked locally. One of them was actually fundamentally broken, as hiding the editButton should also not open the editContainer when adding a new row - but that limitation broke on my machine (because it's faster then the one on github?). When running on tt02+github, the edit container did not show up, which was the correct behaviour. Waiting to make sure the correct behaviour is consistent. * After I added the code to wait until the repeating group rows state was in sync, now suddenly the edit container won't open when the edit button has been hidden. This is really how it should have worked all along. Adjusting the tests to match, and making this functionality explicitly implemented, correctly detecting this case as the children having been hidden. * Making sure this validation test waits until the button is clickable and the validation is present * Using a better way to detect unsaved changes / wait for save * Fixing flakiness in group-pets.ts * Making this test less flaky * Making tests less flaky * When you've provided a dedicated pdf layout file, you'll want those components rendered directly, not via PdfForPage (which will attempt to summarize the pdf layout). * Adding quirks for some apps with broken layouts, in order to make them work again after this rewrite (these quirks will stop working if layouts change just slightly) * More quirks, filtering out duplicate components automatically (using that logic to generate quirks code for duplicates that we want to keep) * Fixing flakiness in case the number-formatted field has been saved (and we get the default '0' back from the server) * Fixing shared function tests with duplicate component IDs (that I now removed) * Making sure validations and options exist before allowing clicks and displaying the error message to the user * Waiting a bit to ensure test pass * Fixing transposeSelector that was not passed into useLanguageWithForcedNodeSelector() and thus not available in expressions. This was caused by a forced typescript type that was outdated. * Fixes after testing ssb/ra0760-01 * Hopefully a flaky fix * Making sure to wait until ruleHandler has run once before marking nodes as ready, and making sure to not set preselectedOptionIndex for nodes that are already hidden. This makes sure we maintain some backwards compatibility, and ensures the 'next' button does not show up early in frontend-test (as I noticed in Percy) * Fixes for Cards, to make sure title/texts gets passed on * Making percy snapshot match, even though functionality now have changed * Flaky fix + making sure grid in summary is backwards compatible * Now that I changed the behaviour for preSelectedOptionIndex for hidden components, these tests failed. Reverting the changes. * Adding an assertion for what I observe to happen in this test * Hopefully fixing flakiness issues in validation.ts (which uses changeLayout heavily) * Fixes after merge from main * Removing TODOs * Fixes in formFiller, adding back force.. :-( Also, printing out details of what went wrong when data models does not match expectations * Making sure the validation test actually waits for layout changes to become effective * Using URLSearchParams instead * Adding back force for uploader * eslint --fix * No need to resolve this expression ourselves - the plugin does it for us * Reverting changes to .gitignore * Instead of waiting for save, wait for the element we want * Fixing a very rare problem in the all-process-steps.ts test. When two attachments were uploaded one after the other, the first upload (when the data model was returned back from tt02) overwrote the second one, and the attachment disappeared from the UI. * Fixing problems with EditWindowComponent rendering when it shouldn't, and not showing the spinner when it should. Removing the functionality to show the button and dropdown as disabled until they were ready * Fixing unit tests after I changed behaviour around readOnly for FileUpload * Removing unused file * Reducing the diff from main * Fixes after merge from main * Fixing getting isCompact from parent overrides * Type fix * Fixes after merge from main * Minor fixes after merge from main - some unit tests broke * Applying change from #2275 (originally made to PdfView.tsx, which is deleted in this branch) * Removing prop that was deleted in #2275 * Fixing minor issues from SonarCloud * Fixes after merge from main * Avoiding destructing object and leaving a rest object that's passed as a dependency in useLanguage(). This caused every re-render to re-generate the callbacks and trash later useMemo() optimizations. * Avoiding reading an entire repeating group (including child data) when generating source options. This caused useless re-renders and re-generations of source options. * Adding mock function for formDataRowsSelector() * Evaluating expression in forceShowInSummary * Fixing expression evaluation, moving property to only work for summarizable components * Removing TODO * Basing row generation solely off the row index, not the uuid. This means the rows and nodes will only be removed if the actual row is removed from the data model, but now re-ordering rows will just cause the same nodes as before to reference _other data_ (i.e. a different row UUID at the same index). This aims to fix the breaking group-pets.ts test (although something else went wrong here, and some nodes are not showing up when re-ordering, so I'll look into that as well). * Making row-restrictions index-only. This actually makes more sense than using uuids everywhere (kindof regret that now), as nodes and data model bindings are always index-based. * Removing UpdateNodeRow now that the property is no longer in use * Partial revert. The index property in the 'editingRow' was not always up-to-date when rows are sorted/re-ordered. Only storing the UUID for which row is being edited right now, and getting the index from that when we need to. * Fixes to Likert after row changes. Now rows will be indexes according to their actual index, meaning rows[0] might not work in Likert (as it can have start/stop filters) * Removing debug log * Fix for failing unit test * Using TS 5.5 type inference instead of casting types * Keeping track of setTimeout * Re-introducing automatic removeNode(). This also causes child-types to have to be `| undefined`, as it's difficult to remove without that. This fixes the problems where we would like to remove a row and all nodes inside of it. Removing an early row will now shift the content from later rows up automatically. * Fixes for undefined rows * Review feedback * Review feedback: Converting useHasUnsavedChangesRef to a function, removing extra call to isSavingNow() * Fixing bug with innerGrid after my merge attempt regressed it (the new test pointed that out nicely!) * Fixes after merge from main. Number component has a value with type 'number', not string * Fixes for Text component after merge from main * Fixes for failing test in hide-row-in-group (pickDirectChildren did not account for restrictions in non-repeating plugins) * Removing commented-out code and TODOs --------- Co-authored-by: Ole Martin Handeland <[email protected]>
- Loading branch information