From ef78c0557475f69e7629ecf29cbf00092f4d2aee Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Fri, 29 May 2015 17:41:43 -0700 Subject: [PATCH] add 'sign in as xyzw' buttons if you have signin-xyzw permission --- editor/hub.ts | 13 +++++++++++++ rt/cloud.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/editor/hub.ts b/editor/hub.ts index c0f40387..064b1d35 100644 --- a/editor/hub.ts +++ b/editor/hub.ts @@ -490,6 +490,19 @@ module TDev.Browser { ])]) } + var users = Object.keys(Cloud.litePermissions).filter(k => /^signin-/.test(k)).map(k => k.replace(/signin-/, "")) + + if (users.length > 0) { + m.add(div("wall-dialog-header", lf("sign in as:"))); + var usersDiv = div("wall-dialog-body") + m.add(usersDiv) + users.map(u => TheApiCacheMgr.getAsync(u, true).done(r => { + if (r) { + usersDiv.appendChild(HTML.mkButton(r.name, () => Editor.loginAs(r.id))) + } + })) + } + m.show(); } diff --git a/rt/cloud.ts b/rt/cloud.ts index 178a1d9b..dc546b60 100644 --- a/rt/cloud.ts +++ b/rt/cloud.ts @@ -2,6 +2,7 @@ module TDev.Cloud { export var lite = false; + export var litePermissions:StringMap = {}; export interface EditorWidgets { // edit @@ -216,7 +217,6 @@ module TDev.Cloud { return id ? HTML.proxyResource(Util.fmt("{0}/{1}/{2:uri}", Cloud.config.cdnUrl, thumb ? "thumb" : "pub", id)) : undefined; } - var litePermissions:StringMap = {}; export function setPermissions(perms:string = null) { if (perms !== null)