mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Add Support Grist page and nudge
Summary: Adds a new Support Grist page (accessible only in grist-core), containing options to opt in to telemetry and sponsor Grist Labs on GitHub. A nudge is also shown in the doc menu, which can be collapsed or permanently dismissed. Test Plan: Browser and server tests. Reviewers: paulfitz, dsagal Reviewed By: paulfitz Subscribers: jarek, dsagal Differential Revision: https://phab.getgrist.com/D3926
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
import {InstallPrefs} from "app/common/Install";
|
||||
import {ApiError} from "app/common/ApiError";
|
||||
import {InstallProperties, installPropertyKeys} from "app/common/InstallAPI";
|
||||
import {nativeValues} from "app/gen-server/lib/values";
|
||||
import {BaseEntity, Column, Entity, PrimaryColumn} from "typeorm";
|
||||
|
||||
@Entity({name: 'activations'})
|
||||
@@ -9,9 +13,47 @@ export class Activation extends BaseEntity {
|
||||
@Column({name: 'key', type: 'text', nullable: true})
|
||||
public key: string|null;
|
||||
|
||||
@Column({type: nativeValues.jsonEntityType, nullable: true})
|
||||
public prefs: InstallPrefs|null;
|
||||
|
||||
@Column({name: 'created_at', default: () => "CURRENT_TIMESTAMP"})
|
||||
public createdAt: Date;
|
||||
|
||||
@Column({name: 'updated_at', default: () => "CURRENT_TIMESTAMP"})
|
||||
public updatedAt: Date;
|
||||
|
||||
public checkProperties(props: any): props is Partial<InstallProperties> {
|
||||
for (const key of Object.keys(props)) {
|
||||
if (!installPropertyKeys.includes(key)) {
|
||||
throw new ApiError(`Unrecognized property ${key}`, 400);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public updateFromProperties(props: Partial<InstallProperties>) {
|
||||
if (props.prefs === undefined) { return; }
|
||||
|
||||
if (props.prefs === null) {
|
||||
this.prefs = null;
|
||||
} else {
|
||||
this.prefs = this.prefs || {};
|
||||
if (props.prefs.telemetry !== undefined) {
|
||||
this.prefs.telemetry = this.prefs.telemetry || {};
|
||||
if (props.prefs.telemetry.telemetryLevel !== undefined) {
|
||||
this.prefs.telemetry.telemetryLevel = props.prefs.telemetry.telemetryLevel;
|
||||
}
|
||||
}
|
||||
|
||||
for (const key of Object.keys(this.prefs) as Array<keyof InstallPrefs>) {
|
||||
if (this.prefs[key] === null) {
|
||||
delete this.prefs[key];
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(this.prefs).length === 0) {
|
||||
this.prefs = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user