Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/client/project-collaborators.ts
5808 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
// cSpell:ignore replyto collabs noncloud
7
8
import type { ConatClient } from "@cocalc/frontend/conat/client";
9
import type { AddCollaborator } from "@cocalc/conat/hub/api/projects";
10
11
export class ProjectCollaborators {
12
private conat: ConatClient;
13
14
constructor(client) {
15
this.conat = client.conat_client;
16
}
17
18
public async invite_noncloud(opts: {
19
project_id: string;
20
title: string;
21
link2proj: string;
22
replyto?: string;
23
replyto_name?: string;
24
to: string;
25
email: string; // body in HTML format
26
subject?: string;
27
}): Promise<any> {
28
return await this.conat.hub.projects.inviteCollaboratorWithoutAccount({
29
opts,
30
});
31
}
32
33
public async invite(opts: {
34
project_id: string;
35
account_id: string;
36
title?: string;
37
link2proj?: string;
38
replyto?: string;
39
replyto_name?: string;
40
email?: string;
41
subject?: string;
42
}): Promise<any> {
43
return await this.conat.hub.projects.inviteCollaborator({
44
opts,
45
});
46
}
47
48
public async remove(opts: {
49
project_id: string;
50
account_id: string;
51
}): Promise<any> {
52
return await this.conat.hub.projects.removeCollaborator({
53
opts,
54
});
55
}
56
57
// Directly add one (or more) collaborators to (one or more) projects via
58
// a single API call. There is no defined invite email message.
59
public async add_collaborator(
60
opts: AddCollaborator,
61
): Promise<{ project_id?: string | string[] }> {
62
// project_id is a single string or possibly an array of project_id's
63
// in case of a token.
64
return await this.conat.hub.projects.addCollaborator({
65
opts,
66
});
67
}
68
69
public async change_user_type(opts: {
70
project_id: string;
71
target_account_id: string;
72
new_group: "owner" | "collaborator";
73
}): Promise<void> {
74
return await this.conat.hub.projects.changeUserType({ opts });
75
}
76
}
77
78