(core) Implement updated DocMenu UI: list/card mode and sort mode.

Summary:
- Add org-wide currentSort and currentView, saved as user preferences.
- Add per-workspace currentSort and currentView, backed by localStorage.
- Move localStorage-based observables to a separate file.
- Move hard-coded data about example docs to a separate file.
- Add UI for toggling sort and view mode.
- Removed unused features of buttonSelect to simplify it,
  and added support for light style of buttons.
- Added `parse` helper method to StringUnion, and use it in a few places where
  it simplifies code.
- Set `needRealOrg: true` in HomeDBManager.updateOrg() to fix saving prefs for
  mergedOrg.

Test Plan: WIP: Fixed some affected tests. New tests not yet written.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2587
This commit is contained in:
Dmitry S
2020-08-18 23:08:58 -04:00
parent 20d8124f45
commit 0a5afd1f98
4 changed files with 34 additions and 47 deletions

View File

@@ -33,6 +33,13 @@ export const StringUnion = <UnionType extends string>(...values: UnionType[]) =>
return value;
};
const unionNamespace = {guard, check, values};
/**
* StringUnion.parse(value) returns value when it's valid, and undefined otherwise.
*/
const parse = (value: string|null|undefined): UnionType|undefined => {
return value != null && guard(value) ? value : undefined;
};
const unionNamespace = {guard, check, parse, values};
return Object.freeze(unionNamespace as typeof unionNamespace & {type: UnionType});
};