(core) Improve dark mode

Summary:
Enhances dark mode support for the formula editor, and adds support to
the color select popup. Also fixes some bugs with dark mode.

Test Plan: Tested manually.

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D3847
This commit is contained in:
George Gevoian
2023-04-11 01:00:28 -04:00
parent 9d0e6694fc
commit 8a0bb4d4fe
27 changed files with 537 additions and 107 deletions

View File

@@ -472,7 +472,7 @@ export class ApiServer {
// GET /api/session/access/active
// Returns active user and active org (if any)
this._app.get('/api/session/access/active', expressWrap(async (req, res) => {
const fullUser = await this._getFullUser(req);
const fullUser = await this._getFullUser(req, {includePrefs: true});
const domain = getOrgFromRequest(req);
const org = domain ? (await this._withSupportUserAllowedToView(
domain, req, (scope) => this._dbManager.getOrg(scope, domain)
@@ -534,10 +534,10 @@ export class ApiServer {
}));
}
private async _getFullUser(req: Request): Promise<FullUser> {
private async _getFullUser(req: Request, options: {includePrefs?: boolean} = {}): Promise<FullUser> {
const mreq = req as RequestWithLogin;
const userId = getUserId(mreq);
const user = await this._dbManager.getUser(userId);
const user = await this._dbManager.getUser(userId, options);
if (!user) { throw new ApiError("unable to find user", 400); }
const fullUser = this._dbManager.makeFullUser(user);

View File

@@ -7,6 +7,7 @@ import {BaseEntity, BeforeInsert, Column, Entity, JoinTable, ManyToMany, OneToMa
import {Group} from "./Group";
import {Login} from "./Login";
import {Organization} from "./Organization";
import {Pref} from './Pref';
@Entity({name: 'users'})
export class User extends BaseEntity {
@@ -34,6 +35,9 @@ export class User extends BaseEntity {
@OneToMany(type => Login, login => login.user)
public logins: Login[];
@OneToMany(type => Pref, pref => pref.user)
public prefs: Pref[];
@ManyToMany(type => Group)
@JoinTable({
name: 'group_users',

View File

@@ -482,8 +482,14 @@ export class HomeDBManager extends EventEmitter {
return await User.findOne({where: {ref}, relations: ["logins"]}) || undefined;
}
public async getUser(userId: number): Promise<User|undefined> {
return await User.findOne({where: {id: userId}, relations: ["logins"]}) || undefined;
public async getUser(
userId: number,
options: {includePrefs?: boolean} = {}
): Promise<User|undefined> {
const {includePrefs} = options;
const relations = ["logins"];
if (includePrefs) { relations.push("prefs"); }
return await User.findOne({where: {id: userId}, relations}) || undefined;
}
public async getFullUser(userId: number): Promise<FullUser> {
@@ -505,7 +511,8 @@ export class HomeDBManager extends EventEmitter {
name: user.name,
picture: user.picture,
ref: user.ref,
locale: user.options?.locale
locale: user.options?.locale,
prefs: user.prefs?.find((p)=> p.orgId === null)?.prefs,
};
if (this.getAnonymousUserId() === user.id) {
result.anonymous = true;