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. Commercial Alternative to JupyterHub.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/account/table.ts
Views: 923
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
balance: null,
29
min_balance: null,
30
balance_alert: null,
31
auto_balance: null,
32
email_address: null,
33
email_address_verified: null,
34
email_address_problem: null,
35
editor_settings: null,
36
other_settings: null,
37
name: null,
38
first_name: null,
39
last_name: null,
40
terminal: null,
41
autosave: null,
42
evaluate_key: null,
43
font_size: null,
44
passports: null,
45
groups: null,
46
last_active: null,
47
ssh_keys: null,
48
created: null,
49
unlisted: null,
50
//tags: null,
51
tours: null,
52
purchase_closing_day: null,
53
email_daily_statements: null,
54
stripe_checkout_session: null,
55
stripe_usage_subscription: null,
56
stripe_customer: null, // used for legacy upgrades ONLY.
57
unread_message_count: null,
58
},
59
],
60
};
61
}
62
63
_change(table: { get_one: () => { toJS: () => any } }) {
64
const changes = table.get_one();
65
if (!changes) return;
66
const actions = this.redux.getActions("account");
67
const obj = changes.toJS();
68
actions.setState(obj);
69
if (this.first_set) {
70
this.first_set = false;
71
actions.setState({ is_ready: true });
72
this.redux.getStore("account").emit("is_ready");
73
if (obj.stripe_customer?.subscriptions?.data != null) {
74
// exclude legacy customers from commercialization requirements.
75
(
76
this.redux.getActions("customize") as any
77
).disableCommercializationParameters();
78
}
79
}
80
}
81
}
82
83