mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(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:
parent
8c2f0307e5
commit
e3a957a715
@ -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
|
* 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
|
* 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 {
|
public makeUrl(urlState: IUrlState|UpdateFunc<IUrlState>, use: UseCB = unwrap): string {
|
||||||
const fullState = this._mergeState(use(this.state), urlState);
|
const fullState = this._mergeState(use(this.state), urlState);
|
||||||
|
@ -2,9 +2,10 @@ import {BillingPage, BillingSubPage, BillingTask} from 'app/common/BillingAPI';
|
|||||||
import {OpenDocMode} from 'app/common/DocListAPI';
|
import {OpenDocMode} from 'app/common/DocListAPI';
|
||||||
import {encodeQueryParams, isAffirmative} from 'app/common/gutil';
|
import {encodeQueryParams, isAffirmative} from 'app/common/gutil';
|
||||||
import {localhostRegex} from 'app/common/LoginState';
|
import {localhostRegex} from 'app/common/LoginState';
|
||||||
|
import {StringUnion} from 'app/common/StringUnion';
|
||||||
import {Document} from 'app/common/UserAPI';
|
import {Document} from 'app/common/UserAPI';
|
||||||
|
import clone = require('lodash/clone');
|
||||||
import pickBy = require('lodash/pickBy');
|
import pickBy = require('lodash/pickBy');
|
||||||
import {StringUnion} from './StringUnion';
|
|
||||||
|
|
||||||
export type IDocPage = number | 'new' | 'code' | 'acl';
|
export type IDocPage = number | 'new' | 'code' | 'acl';
|
||||||
|
|
||||||
@ -299,7 +300,7 @@ export function useNewUI(newui: boolean|undefined) {
|
|||||||
export function userOverrideParams(email: string|null, extraState?: IGristUrlState) {
|
export function userOverrideParams(email: string|null, extraState?: IGristUrlState) {
|
||||||
return function(prevState: IGristUrlState): IGristUrlState {
|
return function(prevState: IGristUrlState): IGristUrlState {
|
||||||
const combined = {...prevState, ...extraState};
|
const combined = {...prevState, ...extraState};
|
||||||
const linkParameters = combined.params?.linkParameters || {};
|
const linkParameters = clone(combined.params?.linkParameters) || {};
|
||||||
if (email) {
|
if (email) {
|
||||||
linkParameters.aclAsUser = email;
|
linkParameters.aclAsUser = email;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user