(core) Polishing upgrade plan UI

Summary:
- Update nudge boxes content and collapsing on personal and free team site
- New confirmation after upgrading from a free team site
- Refactoring ProductUpgrade code, splitting plans / modals and nudges

Test Plan: Manual and updated tests

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3481
This commit is contained in:
Jarosław Sadziński
2022-06-29 12:19:20 +02:00
parent dd2eadc86e
commit aefe451bab
16 changed files with 203 additions and 76 deletions

View File

@@ -1,3 +1,4 @@
import {safeJsonParse} from 'app/common/gutil';
import {Observable} from 'grainjs';
/**
@@ -96,3 +97,14 @@ export function localStorageObs(key: string, defaultValue?: string): Observable<
obs.addListener((val) => (val === null) ? store.removeItem(key) : store.setItem(key, val));
return obs;
}
/**
* Helper to create a JSON observable whose state is stored in localStorage.
*/
export function localStorageJsonObs<T>(key: string, defaultValue: T): Observable<T> {
const store = getStorage();
const currentValue = safeJsonParse(store.getItem(key) || '', defaultValue ?? null);
const obs = Observable.create<T>(null, currentValue);
obs.addListener((val) => (val === null) ? store.removeItem(key) : store.setItem(key, JSON.stringify(val ?? null)));
return obs;
}