Skip to content

Commit d68f5da

Browse files
authored
Team invitations (#3994)
* Team invitations * Smaller logo * Fix types * Fix types * Make timeAlive optional * Add tracks
1 parent b8657fe commit d68f5da

File tree

13 files changed

+426
-101
lines changed

13 files changed

+426
-101
lines changed

packages/app/src/app/graphql/schema.graphql

Lines changed: 92 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# source: https://codesandbox.io/api/graphql
2-
# timestamp: Wed Apr 15 2020 12:57:51 GMT+0200 (Central European Summer Time)
1+
# source: http://server:4000/api/graphql
2+
# timestamp: Mon Apr 27 2020 13:17:23 GMT+0000 (Coordinated Universal Time)
33

44
schema {
55
query: RootQuery
@@ -30,6 +30,7 @@ input CodeReference {
3030
anchor: Int!
3131
code: String!
3232
head: Int!
33+
lastUpdatedAt: String!
3334
path: String!
3435
}
3536

@@ -38,6 +39,7 @@ type CodeReferenceMetadata {
3839
code: String!
3940
head: Int!
4041
path: String!
42+
sandboxId: String!
4143
}
4244

4345
"""
@@ -162,19 +164,21 @@ union ReferenceMetadata = CodeReferenceMetadata
162164

163165
type RootMutation {
164166
"""
165-
Change authorization of a collaborator
167+
Remove a collaborator
166168
"""
167-
changeCollaboratorAuthorization(
168-
authorization: Authorization!
169+
removeCollaborator(sandboxId: ID!, username: String!): Collaborator!
170+
createComment(
171+
codeReference: CodeReference
172+
content: String!
173+
id: ID
174+
parentCommentId: ID
169175
sandboxId: ID!
170-
username: String!
171-
): Collaborator!
176+
): Comment!
172177

173178
"""
174179
Clear notification unread count
175180
"""
176181
clearNotificationCount: User
177-
renameSandbox(id: ID!, title: String!): Sandbox!
178182

179183
"""
180184
Add sandboxes to a collection
@@ -186,137 +190,140 @@ type RootMutation {
186190
): Collection!
187191

188192
"""
189-
Delete a collection and all subfolders
193+
Set the description of the team
190194
"""
191-
deleteCollection(path: String!, teamId: ID): [Collection!]!
195+
setTeamDescription(description: String!, teamId: ID!): Team
196+
197+
"""
198+
Create a team
199+
"""
200+
createTeam(name: String!): Team
192201

193202
"""
194203
Revoke an invitation to a team
195204
"""
196205
revokeTeamInvitation(teamId: ID!, userId: ID!): Team
197206

198207
"""
199-
Soft delete a comment. Note: all child comments will also be deleted.
208+
Unbookmark a template
200209
"""
201-
deleteComment(commentId: ID!, sandboxId: ID!): Comment!
202-
changeSandboxInvitationAuthorization(
203-
authorization: Authorization!
204-
invitationId: ID!
205-
sandboxId: ID!
206-
): Invitation!
207-
resolveComment(commentId: ID!, sandboxId: ID!): Comment!
208-
createSandboxInvitation(
209-
authorization: Authorization!
210-
email: String!
211-
sandboxId: ID!
212-
): Invitation!
210+
unbookmarkTemplate(teamId: ID, templateId: ID!): Template
213211

214212
"""
215-
Create a team
213+
Invite someone to a team
216214
"""
217-
createTeam(name: String!): Team
215+
inviteToTeam(email: String, teamId: ID!, username: String): Team
216+
unresolveComment(commentId: ID!, sandboxId: ID!): Comment!
218217

219218
"""
220-
Rename a collection and all subfolders
219+
Delete a collection and all subfolders
221220
"""
222-
renameCollection(
223-
newPath: String!
224-
newTeamId: ID
225-
path: String!
226-
teamId: ID
227-
): [Collection!]!
221+
deleteCollection(path: String!, teamId: ID): [Collection!]!
228222

229223
"""
230-
Convert templates back to sandboxes
224+
Make templates from sandboxes
231225
"""
232-
unmakeSandboxesTemplates(sandboxIds: [ID!]!): [Template!]!
226+
makeSandboxesTemplates(sandboxIds: [ID!]!): [Template!]!
233227

234228
"""
235-
Delete sandboxes
229+
Accept an invitation to a team
236230
"""
237-
deleteSandboxes(sandboxIds: [ID!]!): [Sandbox!]!
231+
acceptTeamInvitation(teamId: ID!): Team
238232

239233
"""
240-
Unbookmark a template
234+
Redeem an invite token from a team
241235
"""
242-
unbookmarkTemplate(teamId: ID, templateId: ID!): Template
236+
redeemTeamInviteToken(inviteToken: String!): Team
243237

244238
"""
245-
Leave a team
239+
Delete sandboxes
246240
"""
247-
leaveTeam(teamId: ID!): String
241+
deleteSandboxes(sandboxIds: [ID!]!): [Sandbox!]!
242+
setSandboxesPrivacy(privacy: Int, sandboxIds: [ID!]!): [Sandbox!]!
243+
createSandboxInvitation(
244+
authorization: Authorization!
245+
email: String!
246+
sandboxId: ID!
247+
): Invitation!
248248

249249
"""
250-
bookmark a template
250+
Add a collaborator
251251
"""
252-
bookmarkTemplate(teamId: ID, templateId: ID!): Template
253-
updateComment(commentId: ID!, content: String, sandboxId: ID!): Comment!
254-
createComment(
255-
codeReference: CodeReference
256-
content: String!
257-
id: ID
258-
parentCommentId: ID
252+
addCollaborator(
253+
authorization: Authorization!
259254
sandboxId: ID!
260-
): Comment!
255+
username: String!
256+
): Collaborator!
257+
renameSandbox(id: ID!, title: String!): Sandbox!
258+
259+
"""
260+
Convert templates back to sandboxes
261+
"""
262+
unmakeSandboxesTemplates(sandboxIds: [ID!]!): [Template!]!
261263

262264
"""
263265
Reject an invitation to a team
264266
"""
265267
rejectTeamInvitation(teamId: ID!): String
268+
permanentlyDeleteSandboxes(sandboxIds: [ID!]!): [Sandbox!]!
266269

267270
"""
268-
Accept an invitation to a team
271+
Rename a collection and all subfolders
269272
"""
270-
acceptTeamInvitation(teamId: ID!): Team
273+
renameCollection(
274+
newPath: String!
275+
newTeamId: ID
276+
path: String!
277+
teamId: ID
278+
): [Collection!]!
271279

272280
"""
273-
Make templates from sandboxes
281+
bookmark a template
274282
"""
275-
makeSandboxesTemplates(sandboxIds: [ID!]!): [Template!]!
283+
bookmarkTemplate(teamId: ID, templateId: ID!): Template
284+
revokeSandboxInvitation(invitationId: ID!, sandboxId: ID!): Invitation!
276285

277286
"""
278287
Create a collection
279288
"""
280289
createCollection(path: String!, teamId: ID): Collection!
281290

282291
"""
283-
Remove a collaborator
292+
Mark all notifications as read
284293
"""
285-
removeCollaborator(sandboxId: ID!, username: String!): Collaborator!
286-
setSandboxesPrivacy(privacy: Int, sandboxIds: [ID!]!): [Sandbox!]!
294+
markAllNotificationsAsRead: User
295+
redeemSandboxInvitation(invitationToken: String!, sandboxId: ID!): Invitation!
287296

288297
"""
289-
Remove someone from a team
298+
Soft delete a comment. Note: all child comments will also be deleted.
290299
"""
291-
removeFromTeam(teamId: ID!, userId: ID!): Team
300+
deleteComment(commentId: ID!, sandboxId: ID!): Comment!
301+
resolveComment(commentId: ID!, sandboxId: ID!): Comment!
302+
changeSandboxInvitationAuthorization(
303+
authorization: Authorization!
304+
invitationId: ID!
305+
sandboxId: ID!
306+
): Invitation!
307+
updateComment(commentId: ID!, content: String, sandboxId: ID!): Comment!
292308

293309
"""
294-
Set the description of the team
310+
Leave a team
295311
"""
296-
setTeamDescription(description: String!, teamId: ID!): Team
297-
permanentlyDeleteSandboxes(sandboxIds: [ID!]!): [Sandbox!]!
312+
leaveTeam(teamId: ID!): String
298313

299314
"""
300-
Add a collaborator
315+
Remove someone from a team
301316
"""
302-
addCollaborator(
317+
removeFromTeam(teamId: ID!, userId: ID!): Team
318+
319+
"""
320+
Change authorization of a collaborator
321+
"""
322+
changeCollaboratorAuthorization(
303323
authorization: Authorization!
304324
sandboxId: ID!
305325
username: String!
306326
): Collaborator!
307-
308-
"""
309-
Invite someone to a team
310-
"""
311-
inviteToTeam(teamId: ID!, username: String): Team
312-
unresolveComment(commentId: ID!, sandboxId: ID!): Comment!
313-
redeemSandboxInvitation(invitationToken: String!, sandboxId: ID!): Invitation!
314-
revokeSandboxInvitation(invitationId: ID!, sandboxId: ID!): Invitation!
315-
316-
"""
317-
Mark all notifications as read
318-
"""
319-
markAllNotificationsAsRead: User
320327
}
321328

322329
type RootQuery {
@@ -329,6 +336,11 @@ type RootQuery {
329336
Get a sandbox
330337
"""
331338
sandbox(sandboxId: ID!): Sandbox
339+
340+
"""
341+
A team from an invite token
342+
"""
343+
teamByToken(inviteToken: ID!): Team
332344
}
333345

334346
type RootSubscriptionType {
@@ -361,6 +373,7 @@ type Sandbox {
361373
"""
362374
customTemplate: Template
363375
description: String
376+
forkCount: Int!
364377
forkedTemplate: Template
365378

366379
"""
@@ -370,13 +383,15 @@ type Sandbox {
370383
id: ID!
371384
insertedAt: String!
372385
invitations: [Invitation!]!
386+
likeCount: Int!
373387
privacy: Int!
374388
removedAt: String
375389
screenshotOutdated: Boolean!
376390
screenshotUrl: String
377391
source: Source!
378392
title: String
379393
updatedAt: String!
394+
viewCount: Int!
380395
}
381396

382397
type Source {
@@ -390,6 +405,7 @@ type Team {
390405
creatorId: ID
391406
description: String
392407
id: ID!
408+
inviteToken: String!
393409
invitees: [User!]!
394410
name: String!
395411
templates: [Template!]!

packages/app/src/app/overmind/actions.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export const notificationAdded: Action<{
3333
title: string;
3434
notificationType: NotificationType;
3535
timeAlive?: number;
36-
}> = ({ effects }, { title, notificationType, timeAlive = 1 }) => {
36+
}> = ({ effects }, { title, notificationType, timeAlive }) => {
3737
effects.notificationToast.add({
3838
message: title,
3939
status: convertTypeToStatus(notificationType),
40-
timeAlive: timeAlive * 1000,
40+
timeAlive: timeAlive ? timeAlive * 1000 : undefined,
4141
});
4242
};
4343

@@ -248,6 +248,7 @@ export const acceptTeamInvitation: Action<{
248248
teamName: string;
249249
teamId: string;
250250
}> = ({ effects, actions }, { teamName }) => {
251+
effects.analytics.track('Team - Join Team', { source: 'invitation' });
251252
effects.analytics.track('Team - Invitation Accepted', {});
252253

253254
actions.internal.trackCurrentTeams();
@@ -259,7 +260,7 @@ export const rejectTeamInvitation: Action<{ teamName: string }> = (
259260
{ effects },
260261
{ teamName }
261262
) => {
262-
effects.analytics.track('Team - Invitation Accepted', {});
263+
effects.analytics.track('Team - Invitation Rejected', {});
263264

264265
effects.notificationToast.success(`Rejected invitation to ${teamName}`);
265266
};

0 commit comments

Comments
 (0)