Skip to content

Commit f376403

Browse files
committed
disable all commercialization for legacy upgrades holders
1 parent 958395e commit f376403

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/packages/frontend/account/store.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import { List, Map } from "immutable";
77
import { reduce } from "lodash";
8-
98
import { Store } from "@cocalc/util/redux/Store";
109
import { store as customizeStore } from "@cocalc/frontend/customize";
1110
import { make_valid_name } from "@cocalc/util/misc";

src/packages/frontend/account/table.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,18 @@ export class AccountTable extends Table {
5959
const changes = table.get_one();
6060
if (!changes) return;
6161
const actions = this.redux.getActions("account");
62-
actions.setState(changes.toJS());
62+
const obj = changes.toJS();
63+
actions.setState(obj);
6364
if (this.first_set) {
6465
this.first_set = false;
6566
actions.setState({ is_ready: true });
6667
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+
}
6774
}
6875
}
6976
}

src/packages/frontend/customize.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,16 @@ export interface CustomizeState {
126126
logo_rectangular: string;
127127
logo_square: string;
128128
max_upgrades: TypedMap<Partial<Upgrades>>;
129+
130+
// Commercialization parameters.
131+
// Be sure to also update disableCommercializationParameters
132+
// below if you change these:
129133
nonfree_countries?: List<string>;
130134
limit_free_project_uptime: number; // minutes
131135
require_license_to_create_project?: boolean;
132136
unlicensed_project_collaborator_limit?: number;
133137
unlicensed_project_timetravel_limit?: number;
138+
134139
onprem_quota_heading: string;
135140
organization_email: string;
136141
organization_name: string;
@@ -220,6 +225,7 @@ export class CustomizeActions extends Actions<CustomizeState> {
220225
this.setState({ compute_servers_images: `${err}` });
221226
}
222227
});
228+
223229
updateComputeServerImagesGoogle = reuseInFlight(async (reload?) => {
224230
if (!store.get("compute_servers_google-cloud_enabled")) {
225231
this.setState({ compute_servers_images_google: fromJS({}) as any });
@@ -235,6 +241,16 @@ export class CustomizeActions extends Actions<CustomizeState> {
235241
this.setState({ compute_servers_images_google: `${err}` });
236242
}
237243
});
244+
245+
// this is used for accounts that have legacy upgrades
246+
disableCommercializationParameters = () => {
247+
this.setState({
248+
limit_free_project_uptime: undefined,
249+
require_license_to_create_project: undefined,
250+
unlicensed_project_collaborator_limit: undefined,
251+
unlicensed_project_timetravel_limit: undefined,
252+
});
253+
};
238254
}
239255

240256
export const store = redux.createStore("customize", CustomizeStore, defaults);
@@ -317,6 +333,7 @@ function process_customize(obj) {
317333
}
318334
// the llm markup special case
319335
obj.llm_markup = obj_orig._llm_markup ?? 30;
336+
320337
// always set time, so other code can know for sure that customize was loaded.
321338
// it also might be helpful to know when
322339
obj["time"] = Date.now();

0 commit comments

Comments
 (0)