CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/account/table.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Table } from "@cocalc/frontend/app-framework/Table";
7
8
// Create and register account table, which gets automatically
9
// synchronized with the server.
10
export class AccountTable extends Table {
11
private first_set: boolean = true;
12
13
constructor(name, redux) {
14
super(name, redux);
15
this.query = this.query.bind(this);
16
this._change = this._change.bind(this);
17
}
18
19
options() {
20
return [];
21
}
22
23
query() {
24
return {
25
accounts: [
26
{
27
account_id: null,
28
email_address: null,
29
email_address_verified: null,
30
email_address_problem: null,
31
editor_settings: null,
32
other_settings: null,
33
name: null,
34
first_name: null,
35
last_name: null,
36
terminal: null,
37
autosave: null,
38
evaluate_key: null,
39
font_size: null,
40
passports: null,
41
groups: null,
42
last_active: null,
43
ssh_keys: null,
44
created: null,
45
unlisted: null,
46
//tags: null,
47
tours: null,
48
purchase_closing_day: null,
49
email_daily_statements: null,
50
stripe_checkout_session: null,
51
stripe_usage_subscription: null,
52
stripe_customer: null, // used for legacy upgrades ONLY.
53
},
54
],
55
};
56
}
57
58
_change(table: { get_one: () => { toJS: () => any } }) {
59
const changes = table.get_one();
60
if (!changes) return;
61
const actions = this.redux.getActions("account");
62
const obj = changes.toJS();
63
actions.setState(obj);
64
if (this.first_set) {
65
this.first_set = false;
66
actions.setState({ is_ready: true });
67
this.redux.getStore("account").emit("is_ready");
68
if (obj.stripe_customer?.subscriptions?.data != null) {
69
// exclude legacy customers from commercialization requirements.
70
(
71
this.redux.getActions("customize") as any
72
).disableCommercializationParameters();
73
}
74
}
75
}
76
}
77
78