Canvas: Rework Deployment/Gateways tab

Change-Id: I938262b9a6ba2af060531e7dcdf91ddd66721385
diff --git a/apps/canvas/back/src/index.ts b/apps/canvas/back/src/index.ts
index 6dede14..4dc942f 100644
--- a/apps/canvas/back/src/index.ts
+++ b/apps/canvas/back/src/index.ts
@@ -261,29 +261,25 @@
 						draft: null,
 						instanceId: deployResponse.id,
 						deployKey: deployResponse.deployKey,
+						access: JSON.stringify(deployResponse.access),
 					},
 				});
 				diff = { toAdd: extractGithubRepos(state) };
 				deployKey = deployResponse.deployKey;
 			} else {
-				const success = await appManager.update(p.instanceId, req.body.config);
-				if (success) {
-					diff = calculateRepoDiff(extractGithubRepos(p.state), extractGithubRepos(state));
-					deployKey = p.deployKey;
-					await db.project.update({
-						where: {
-							id: projectId,
-						},
-						data: {
-							state,
-							draft: null,
-						},
-					});
-				} else {
-					resp.status(500);
-					resp.write(JSON.stringify({ error: "Failed to update deployment" }));
-					return;
-				}
+				const deployResponse = await appManager.update(p.instanceId, req.body.config);
+				diff = calculateRepoDiff(extractGithubRepos(p.state), extractGithubRepos(state));
+				deployKey = p.deployKey;
+				await db.project.update({
+					where: {
+						id: projectId,
+					},
+					data: {
+						state,
+						draft: null,
+						access: JSON.stringify(deployResponse.access),
+					},
+				});
 			}
 			if (diff && p.githubToken && deployKey) {
 				const github = new GithubClient(p.githubToken);
@@ -388,6 +384,7 @@
 			data: {
 				instanceId: null,
 				deployKey: null,
+				access: null,
 				state: null,
 				draft: p.draft ?? p.state,
 			},
@@ -465,6 +462,7 @@
 			select: {
 				deployKey: true,
 				githubToken: true,
+				access: true,
 			},
 		});
 		if (!project) {
@@ -480,6 +478,7 @@
 				// TODO(gio): get from env or command line flags
 				managerAddr: "http://10.42.0.95:8081",
 				deployKey: project.deployKey,
+				access: JSON.parse(project.access ?? "[]"),
 				integrations: {
 					github: !!project.githubToken,
 				},