(core) Fixes persistence of the aclAsUser_ parameters across navigation

Summary:
  - The parameter was inadvertently removed by userOverrideParams().
  - when passed a function to `urlState().setHref(...)` or `urlState().makeUrl(...)` it is important that the function does not mutate the state that it receives as argument.

Link to the related task: https://gristlabs.getgrist.com/doc/check-ins/p/5#a1.s9.r791.c19

Test Plan: Adds test of the persistence by slightly modifying existing nbrowser/AccessRules2 tests.

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D2820
This commit is contained in:
Cyprien P
2021-05-17 20:19:34 +02:00
parent 8c2f0307e5
commit e3a957a715
2 changed files with 4 additions and 3 deletions

View File

@@ -95,7 +95,7 @@ export class UrlState<IUrlState extends object> extends Disposable {
*
* If urlState is an object (such as IGristUrlState), it gets merged with previous state
* according to rules (in gristUrlState's updateState). Alternatively, it can be a function that
* takes previous state and returns the new one.
* takes previous state and returns the new one (without mutating the previous state).
*/
public makeUrl(urlState: IUrlState|UpdateFunc<IUrlState>, use: UseCB = unwrap): string {
const fullState = this._mergeState(use(this.state), urlState);