Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

refactor(cloudcp): split Pulse Account account view

rcourtman299a4edb51e0
diff --git a/internal/cloudcp/portal/dist/build_manifest.json b/internal/cloudcp/portal/dist/build_manifest.json
index 5686ccee4b..a7142e6e93 100644
--- a/internal/cloudcp/portal/dist/build_manifest.json
+++ b/internal/cloudcp/portal/dist/build_manifest.json
@@ -1,5 +1,5 @@
{
- "source_hash": "c5820ed501462e9b98f77f96c6295641a192d8abb092e09e70a71e77b1fc8bb9",
+ "source_hash": "fa9579f943be9f038eb58d746c28ed9bd8b04f65441c327560693d31e79c84b7",
"build_inputs": [
"package.json",
"tsconfig.json",
diff --git a/internal/cloudcp/portal/dist/portal_app.js b/internal/cloudcp/portal/dist/portal_app.js
index e61c39e4b9..16173c83e4 100644
--- a/internal/cloudcp/portal/dist/portal_app.js
+++ b/internal/cloudcp/portal/dist/portal_app.js
@@ -266,23 +266,114 @@
};
var portalStore = createPortalStore(bootstrapDefaults, embeddedBootstrap);
- // src/account_controller.ts
+ // src/account_view.ts
function getElement(id) {
return document.getElementById(id);
}
function asHTMLElement(target) {
return target instanceof HTMLElement ? target : null;
}
+ function focusElement(id) {
+ var input = getElement(id);
+ if (input) input.focus();
+ }
function setTbodyMessage(tbody, msg, isError) {
tbody.textContent = "";
- const tr = document.createElement("tr");
- const td = document.createElement("td");
+ var tr = document.createElement("tr");
+ var td = document.createElement("td");
td.setAttribute("colspan", "3");
td.style.cssText = "text-align:center;padding:16px;color:" + (isError ? "#991b1b" : "#94a3b8");
td.textContent = msg;
tr.appendChild(td);
tbody.appendChild(tr);
}
+ function renderTeamMemberRoleCell(accountID, member, isOwner) {
+ var tdRole = document.createElement("td");
+ if (member.role === "owner" && !isOwner) {
+ tdRole.textContent = "owner";
+ return tdRole;
+ }
+ var sel = document.createElement("select");
+ var roles = isOwner ? ["owner", "admin", "tech", "read_only"] : ["admin", "tech", "read_only"];
+ for (var j = 0; j < roles.length; j += 1) {
+ var opt = document.createElement("option");
+ opt.value = roles[j];
+ opt.textContent = roles[j].replace("_", " ");
+ if (member.role === roles[j]) opt.selected = true;
+ sel.appendChild(opt);
+ }
+ sel.setAttribute("data-action", "change-role");
+ sel.setAttribute("data-account-id", accountID);
+ sel.setAttribute("data-user-id", member.user_id);
+ tdRole.appendChild(sel);
+ return tdRole;
+ }
+ function renderTeamMemberActionCell(accountID, member, isOwner) {
+ var tdAction = document.createElement("td");
+ if (member.role === "owner" && !isOwner) {
+ return tdAction;
+ }
+ var btn = document.createElement("button");
+ btn.type = "button";
+ btn.className = "btn-remove";
+ btn.textContent = "Remove";
+ btn.setAttribute("data-action", "remove-member");
+ btn.setAttribute("data-account-id", accountID);
+ btn.setAttribute("data-user-id", member.user_id);
+ btn.setAttribute("data-member-email", member.email);
+ tdAction.appendChild(btn);
+ return tdAction;
+ }
+ function renderAddWorkspaceSection(accountID, entry) {
+ var form = getElement("add-ws-form-" + accountID);
+ if (!form) return;
+ form.classList.toggle("visible", entry.addWorkspaceOpen);
+ }
+ function renderTeamSection(accountID, entry) {
+ var section = getElement("team-section-" + accountID);
+ var tbody = getElement("team-list-" + accountID);
+ if (!section || !tbody) return;
+ var actorRole = section.getAttribute("data-actor-role") || "";
+ var isOwner = actorRole === "owner";
+ section.classList.toggle("visible", entry.teamVisible);
+ if (!entry.teamVisible) {
+ return;
+ }
+ if (entry.teamLoading) {
+ setTbodyMessage(tbody, "Loading\u2026", false);
+ return;
+ }
+ if (entry.teamError) {
+ setTbodyMessage(tbody, entry.teamError, true);
+ return;
+ }
+ if (!entry.teamMembers.length) {
+ setTbodyMessage(tbody, "No team members.", false);
+ return;
+ }
+ tbody.textContent = "";
+ for (var i = 0; i < entry.teamMembers.length; i += 1) {
+ var member = entry.teamMembers[i];
+ var tr = document.createElement("tr");
+ var tdEmail = document.createElement("td");
+ tdEmail.textContent = member.email;
+ tr.appendChild(tdEmail);
+ tr.appendChild(renderTeamMemberRoleCell(accountID, member, isOwner));
+ tr.appendChild(renderTeamMemberActionCell(accountID, member, isOwner));
+ tbody.appendChild(tr);
+ }
+ }
+ function renderAccountUI(accountState) {
+ var accountIDs = Object.keys(accountState.byAccountID);
+ for (var i = 0; i < accountIDs.length; i += 1) {
+ var accountID = accountIDs[i];
+ var entry = accountState.byAccountID[accountID];
+ renderAddWorkspaceSection(accountID, entry);
+ renderTeamSection(accountID, entry);
+ }
+ }
+
+ // src/account_controller.ts
function installAccountController(deps) {
const getAccountAPIBasePath = () => deps.store.getBootstrap().account_api_base_path;
const getPortalAPIBasePath = () => deps.store.getBootstrap().portal_api_base_path;
@@ -294,86 +385,8 @@
}
return true;
};
- const renderAddWorkspaceSection = (accountID) => {
- const form = getElement("add-ws-form-" + accountID);
- if (!form) return;
- const entry = ensurePortalAccountUIEntry(deps.store.getAccountState(), accountID);
- form.classList.toggle("visible", entry.addWorkspaceOpen);
- };
- const renderTeamSection = (accountID) => {
- const section = getElement("team-section-" + accountID);
- const tbody = getElement("team-list-" + accountID);
- if (!section || !tbody) return;
- const entry = ensurePortalAccountUIEntry(deps.store.getAccountState(), accountID);
- const actorRole = section.getAttribute("data-actor-role") || "";
- const isOwner = actorRole === "owner";
- section.classList.toggle("visible", entry.teamVisible);
- if (!entry.teamVisible) {
- return;
- }
- if (entry.teamLoading) {
- setTbodyMessage(tbody, "Loading\u2026", false);
- return;
- }
- if (entry.teamError) {
- setTbodyMessage(tbody, entry.teamError, true);
- return;
- }
- if (!entry.teamMembers.length) {
- setTbodyMessage(tbody, "No team members.", false);
- return;
- }
- const allRoles = ["owner", "admin", "tech", "read_only"];
- const nonOwnerRoles = ["admin", "tech", "read_only"];
- tbody.textContent = "";
- for (let i = 0; i < entry.teamMembers.length; i += 1) {
- const member = entry.teamMembers[i];
- const tr = document.createElement("tr");
- const tdEmail = document.createElement("td");
- tdEmail.textContent = member.email;
- tr.appendChild(tdEmail);
- const tdRole = document.createElement("td");
- if (member.role === "owner" && !isOwner) {
- tdRole.textContent = "owner";
- } else {
- const sel = document.createElement("select");
- const roles = isOwner ? allRoles : nonOwnerRoles;
- for (let j = 0; j < roles.length; j += 1) {
- const opt = document.createElement("option");
- opt.value = roles[j];
- opt.textContent = roles[j].replace("_", " ");
- if (member.role === roles[j]) opt.selected = true;
- sel.appendChild(opt);
- }
- sel.setAttribute("data-action", "change-role");
- sel.setAttribute("data-account-id", accountID);
- sel.setAttribute("data-user-id", member.user_id);
- tdRole.appendChild(sel);
- }
- tr.appendChild(tdRole);
- const tdAction = document.createElement("td");
- if (!(member.role === "owner" && !isOwner)) {
- const btn = document.createElement("button");
- btn.type = "button";
- btn.className = "btn-remove";
- btn.textContent = "Remove";
- btn.setAttribute("data-action", "remove-member");
- btn.setAttribute("data-account-id", accountID);
- btn.setAttribute("data-user-id", member.user_id);
- btn.setAttribute("data-member-email", member.email);
- tdAction.appendChild(btn);
- }
- tr.appendChild(tdAction);
- tbody.appendChild(tr);
- }
- };
- const renderAccountUI = () => {
- const state = deps.store.getAccountState();
- const accountIDs = Object.keys(state.byAccountID);
- for (let i = 0; i < accountIDs.length; i += 1) {
- renderAddWorkspaceSection(accountIDs[i]);
- renderTeamSection(accountIDs[i]);
- }
+ const renderAccountRuntime = () => {
+ renderAccountUI(deps.store.getAccountState());
};
const loadTeam = async (accountID) => {
const section = getElement("team-section-" + accountID);
@@ -433,8 +446,7 @@
shouldFocus = entry.addWorkspaceOpen;
});
if (shouldFocus) {
- const input = getElement("ws-name-" + accountID);
- if (input) input.focus();
+ focusElement("ws-name-" + accountID);
}
};
const createWorkspace = async (accountID) => {
@@ -663,8 +675,8 @@
target.value
);
});
- deps.store.subscribeAccount(renderAccountUI);
- deps.store.subscribeBootstrap(renderAccountUI);
+ deps.store.subscribeAccount(renderAccountRuntime);
+ deps.store.subscribeBootstrap(renderAccountRuntime);
}
// src/auth_controller.ts
@@ -948,7 +960,7 @@
var el = getElement3(id);
return el ? el.value.trim() : "";
}
- function focusElement(id) {
+ function focusElement2(id) {
var el = getElement3(id);
if (el) el.focus();
}
@@ -1339,7 +1351,7 @@
if (!flow) return;
var email = flow.readEmailValue ? flow.readEmailValue() : readValue(flow.emailInputID);
if (!email) {
- focusElement(flow.emailInputID);
+ focusElement2(flow.emailInputID);
return;
}
if (flow.onRequestStart) {
@@ -1465,7 +1477,7 @@
portalStore.subscribeServices(renderServiceRuntime);
installServicesController({
toggleServicePanel,
- focusElement,
+ focusElement: focusElement2,
requestVerificationCode: function(flowID) {
void requestVerificationCode(flowID);
},
diff --git a/internal/cloudcp/portal/frontend/src/account_controller.ts b/internal/cloudcp/portal/frontend/src/account_controller.ts
index 312a6c0920..a267601d1a 100644
--- a/internal/cloudcp/portal/frontend/src/account_controller.ts
+++ b/internal/cloudcp/portal/frontend/src/account_controller.ts
@@ -1,3 +1,4 @@
+import { asHTMLElement, focusElement, getElement, renderAccountUI as renderAccountUIState } from './account_view';
import { ensurePortalAccountUIEntry } from './state';
import type { PortalStore } from './store';
import type { PortalTeamMember } from './types';
@@ -8,27 +9,6 @@ export interface AccountControllerDeps {
showToast(message: string, isError?: boolean): void;
}
-type FormValueElement = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
-
-function getElement<T extends HTMLElement = HTMLElement>(id: string): T | null {
- return document.getElementById(id) as T | null;
-}
-
-function asHTMLElement(target: EventTarget | null): HTMLElement | null {
- return target instanceof HTMLElement ? target : null;
-}
-
-function setTbodyMessage(tbody: HTMLElement, msg: string, isError: boolean): void {
- tbody.textContent = '';
- const tr = document.createElement('tr');
- const td = document.createElement('td');
- td.setAttribute('colspan', '3');
- td.style.cssText = 'text-align:center;padding:16px;color:' + (isError ? '#991b1b' : '#94a3b8');
- td.textContent = msg;
- tr.appendChild(td);
- tbody.appendChild(tr);
-}
-
export function installAccountController(deps: AccountControllerDeps): void {
const getAccountAPIBasePath = (): string => deps.store.getBootstrap().account_api_base_path;
const getPortalAPIBasePath = (): string => deps.store.getBootstrap().portal_api_base_path;
@@ -42,92 +22,8 @@ export function installAccountController(deps: AccountControllerDeps): void {
return true;
};
- const renderAddWorkspaceSection = (accountID: string): void => {
- const form = getElement<HTMLElement>('add-ws-form-' + accountID);
- if (!form) return;
- const entry = ensurePortalAccountUIEntry(deps.store.getAccountState(), accountID);
- form.classList.toggle('visible', entry.addWorkspaceOpen);
- };
-
- const renderTeamSection = (accountID: string): void => {
- const section = getElement<HTMLElement>('team-section-' + accountID);
- const tbody = getElement<HTMLElement>('team-list-' + accountID);
- if (!section || !tbody) return;
- const entry = ensurePortalAccountUIEntry(deps.store.getAccountState(), accountID);
- const actorRole = section.getAttribute('data-actor-role') || '';
- const isOwner = actorRole === 'owner';
- section.classList.toggle('visible', entry.teamVisible);
-
- if (!entry.teamVisible) {
- return;
- }
- if (entry.teamLoading) {
- setTbodyMessage(tbody, 'Loading…', false);
- return;
- }
- if (entry.teamError) {
- setTbodyMessage(tbody, entry.teamError, true);
- return;
- }
- if (!entry.teamMembers.length) {
- setTbodyMessage(tbody, 'No team members.', false);
- return;
- }
-
- const allRoles = ['owner', 'admin', 'tech', 'read_only'];
- const nonOwnerRoles = ['admin', 'tech', 'read_only'];
- tbody.textContent = '';
- for (let i = 0; i < entry.teamMembers.length; i += 1) {
- const member = entry.teamMembers[i];
- const tr = document.createElement('tr');
- const tdEmail = document.createElement('td');
- tdEmail.textContent = member.email;
- tr.appendChild(tdEmail);
-
- const tdRole = document.createElement('td');
- if (member.role === 'owner' && !isOwner) {
- tdRole.textContent = 'owner';
- } else {
- const sel = document.createElement('select');
- const roles = isOwner ? allRoles : nonOwnerRoles;
- for (let j = 0; j < roles.length; j += 1) {
- const opt = document.createElement('option');
- opt.value = roles[j];
- opt.textContent = roles[j].replace('_', ' ');
- if (member.role === roles[j]) opt.selected = true;
- sel.appendChild(opt);
- }
- sel.setAttribute('data-action', 'change-role');
- sel.setAttribute('data-account-id', accountID);
- sel.setAttribute('data-user-id', member.user_id);
- tdRole.appendChild(sel);
- }
- tr.appendChild(tdRole);
-
- const tdAction = document.createElement('td');
- if (!(member.role === 'owner' && !isOwner)) {
- const btn = document.createElement('button');
- btn.type = 'button';
- btn.className = 'btn-remove';
- btn.textContent = 'Remove';
- btn.setAttribute('data-action', 'remove-member');
- btn.setAttribute('data-account-id', accountID);
- btn.setAttribute('data-user-id', member.user_id);
- btn.setAttribute('data-member-email', member.email);
- tdAction.appendChild(btn);
- }
- tr.appendChild(tdAction);
- tbody.appendChild(tr);
- }
- };
-
- const renderAccountUI = (): void => {
- const state = deps.store.getAccountState();
- const accountIDs = Object.keys(state.byAccountID);
- for (let i = 0; i < accountIDs.length; i += 1) {
- renderAddWorkspaceSection(accountIDs[i]);
- renderTeamSection(accountIDs[i]);
- }
+ const renderAccountRuntime = (): void => {
+ renderAccountUIState(deps.store.getAccountState());
};
const loadTeam = async (accountID: string): Promise<void> => {
@@ -190,13 +86,12 @@ export function installAccountController(deps: AccountControllerDeps): void {
shouldFocus = entry.addWorkspaceOpen;
});
if (shouldFocus) {
- const input = getElement<FormValueElement>('ws-name-' + accountID);
- if (input) input.focus();
+ focusElement('ws-name-' + accountID);
}
};
const createWorkspace = async (accountID: string): Promise<void> => {
- const nameEl = getElement<FormValueElement>('ws-name-' + accountID);
+ const nameEl = getElement<HTMLInputElement>('ws-name-' + accountID);
if (!nameEl) return;
const name = nameEl.value.trim();
if (!name) {
@@ -431,6 +326,6 @@ export function installAccountController(deps: AccountControllerDeps): void {
);
});
- deps.store.subscribeAccount(renderAccountUI);
- deps.store.subscribeBootstrap(renderAccountUI);
+ deps.store.subscribeAccount(renderAccountRuntime);
+ deps.store.subscribeBootstrap(renderAccountRuntime);
}
diff --git a/internal/cloudcp/portal/frontend/src/account_view.test.ts b/internal/cloudcp/portal/frontend/src/account_view.test.ts
new file mode 100644
index 0000000000..efa3d7ebd7
--- /dev/null
+++ b/internal/cloudcp/portal/frontend/src/account_view.test.ts
@@ -0,0 +1,79 @@
+import { beforeEach, describe, expect, it } from 'vitest';
+
+import { renderAccountUI, renderAddWorkspaceSection, renderTeamSection } from './account_view';
+import type { PortalAccountState, PortalAccountUIEntry } from './types';
+
+function createEntry(overrides: Partial<PortalAccountUIEntry> = {}): PortalAccountUIEntry {
+ return {
+ addWorkspaceOpen: false,
+ teamVisible: false,
+ teamLoading: false,
+ teamError: '',
+ teamMembers: [],
+ ...overrides,
+ };
+}
+
+describe('account view', function() {
+ beforeEach(function() {
+ document.body.innerHTML = '';
+ });
+
+ it('renders add-workspace visibility from account UI state', function() {
+ document.body.innerHTML = '<div id="add-ws-form-acct_1" class="add-workspace-form"></div>';
+
+ renderAddWorkspaceSection('acct_1', createEntry({ addWorkspaceOpen: true }));
+ expect(document.getElementById('add-ws-form-acct_1')?.classList.contains('visible')).toBe(true);
+
+ renderAddWorkspaceSection('acct_1', createEntry({ addWorkspaceOpen: false }));
+ expect(document.getElementById('add-ws-form-acct_1')?.classList.contains('visible')).toBe(false);
+ });
+
+ it('renders team loading, error, and populated member states', function() {
+ document.body.innerHTML =
+ '<div id="team-section-acct_1" class="team-section" data-actor-role="owner">' +
+ '<table><tbody id="team-list-acct_1"></tbody></table>' +
+ '</div>';
+
+ renderTeamSection('acct_1', createEntry({ teamVisible: true, teamLoading: true }));
+ expect(document.getElementById('team-list-acct_1')?.textContent).toContain('Loading');
+
+ renderTeamSection('acct_1', createEntry({ teamVisible: true, teamError: 'Failed to load team.' }));
+ expect(document.getElementById('team-list-acct_1')?.textContent).toContain('Failed to load team.');
+
+ renderTeamSection(
+ 'acct_1',
+ createEntry({
+ teamVisible: true,
+ teamMembers: [{ email: '[email protected]', role: 'owner', user_id: 'u1' }],
+ })
+ );
+ expect(document.querySelector('[data-action="change-role"]')).not.toBeNull();
+ expect(document.querySelector('[data-action="remove-member"]')).not.toBeNull();
+ });
+
+ it('renders account UI for every tracked account entry', function() {
+ document.body.innerHTML =
+ '<div id="add-ws-form-acct_1" class="add-workspace-form"></div>' +
+ '<div id="team-section-acct_1" class="team-section" data-actor-role="admin"><table><tbody id="team-list-acct_1"></tbody></table></div>' +
+ '<div id="add-ws-form-acct_2" class="add-workspace-form"></div>' +
+ '<div id="team-section-acct_2" class="team-section" data-actor-role="owner"><table><tbody id="team-list-acct_2"></tbody></table></div>';
+
+ var state: PortalAccountState = {
+ byAccountID: {
+ acct_1: createEntry({ addWorkspaceOpen: true, teamVisible: true }),
+ acct_2: createEntry({
+ addWorkspaceOpen: false,
+ teamVisible: true,
+ teamMembers: [{ email: '[email protected]', role: 'tech', user_id: 'u2' }],
+ }),
+ },
+ };
+
+ renderAccountUI(state);
+
+ expect(document.getElementById('add-ws-form-acct_1')?.classList.contains('visible')).toBe(true);
+ expect(document.getElementById('add-ws-form-acct_2')?.classList.contains('visible')).toBe(false);
+ expect(document.getElementById('team-list-acct_2')?.textContent).toContain('[email protected]');
+ });
+});
diff --git a/internal/cloudcp/portal/frontend/src/account_view.ts b/internal/cloudcp/portal/frontend/src/account_view.ts
new file mode 100644
index 0000000000..0c7c73a8ca
--- /dev/null
+++ b/internal/cloudcp/portal/frontend/src/account_view.ts
@@ -0,0 +1,122 @@
+import type { PortalAccountState, PortalAccountUIEntry, PortalTeamMember } from './types';
+
+type FormValueElement = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
+
+export function getElement<T extends HTMLElement = HTMLElement>(id: string): T | null {
+ return document.getElementById(id) as T | null;
+}
+
+export function asHTMLElement(target: EventTarget | null): HTMLElement | null {
+ return target instanceof HTMLElement ? target : null;
+}
+
+export function focusElement(id: string): void {
+ var input = getElement<FormValueElement>(id);
+ if (input) input.focus();
+}
+
+function setTbodyMessage(tbody: HTMLElement, msg: string, isError: boolean): void {
+ tbody.textContent = '';
+ var tr = document.createElement('tr');
+ var td = document.createElement('td');
+ td.setAttribute('colspan', '3');
+ td.style.cssText = 'text-align:center;padding:16px;color:' + (isError ? '#991b1b' : '#94a3b8');
+ td.textContent = msg;
+ tr.appendChild(td);
+ tbody.appendChild(tr);
+}
+
+function renderTeamMemberRoleCell(accountID: string, member: PortalTeamMember, isOwner: boolean): HTMLTableCellElement {
+ var tdRole = document.createElement('td');
+ if (member.role === 'owner' && !isOwner) {
+ tdRole.textContent = 'owner';
+ return tdRole;
+ }
+
+ var sel = document.createElement('select');
+ var roles = isOwner ? ['owner', 'admin', 'tech', 'read_only'] : ['admin', 'tech', 'read_only'];
+ for (var j = 0; j < roles.length; j += 1) {
+ var opt = document.createElement('option');
+ opt.value = roles[j];
+ opt.textContent = roles[j].replace('_', ' ');
+ if (member.role === roles[j]) opt.selected = true;
+ sel.appendChild(opt);
+ }
+ sel.setAttribute('data-action', 'change-role');
+ sel.setAttribute('data-account-id', accountID);
+ sel.setAttribute('data-user-id', member.user_id);
+ tdRole.appendChild(sel);
+ return tdRole;
+}
+
+function renderTeamMemberActionCell(accountID: string, member: PortalTeamMember, isOwner: boolean): HTMLTableCellElement {
+ var tdAction = document.createElement('td');
+ if (member.role === 'owner' && !isOwner) {
+ return tdAction;
+ }
+
+ var btn = document.createElement('button');
+ btn.type = 'button';
+ btn.className = 'btn-remove';
+ btn.textContent = 'Remove';
+ btn.setAttribute('data-action', 'remove-member');
+ btn.setAttribute('data-account-id', accountID);
+ btn.setAttribute('data-user-id', member.user_id);
+ btn.setAttribute('data-member-email', member.email);
+ tdAction.appendChild(btn);
+ return tdAction;
+}
+
+export function renderAddWorkspaceSection(accountID: string, entry: PortalAccountUIEntry): void {
+ var form = getElement<HTMLElement>('add-ws-form-' + accountID);
+ if (!form) return;
+ form.classList.toggle('visible', entry.addWorkspaceOpen);
+}
+
+export function renderTeamSection(accountID: string, entry: PortalAccountUIEntry): void {
+ var section = getElement<HTMLElement>('team-section-' + accountID);
+ var tbody = getElement<HTMLElement>('team-list-' + accountID);
+ if (!section || !tbody) return;
+
+ var actorRole = section.getAttribute('data-actor-role') || '';
+ var isOwner = actorRole === 'owner';
+ section.classList.toggle('visible', entry.teamVisible);
+
+ if (!entry.teamVisible) {
+ return;
+ }
+ if (entry.teamLoading) {
+ setTbodyMessage(tbody, 'Loading…', false);
+ return;
+ }
+ if (entry.teamError) {
+ setTbodyMessage(tbody, entry.teamError, true);
+ return;
+ }
+ if (!entry.teamMembers.length) {
+ setTbodyMessage(tbody, 'No team members.', false);
+ return;
+ }
+
+ tbody.textContent = '';
+ for (var i = 0; i < entry.teamMembers.length; i += 1) {
+ var member = entry.teamMembers[i];
+ var tr = document.createElement('tr');
+ var tdEmail = document.createElement('td');
+ tdEmail.textContent = member.email;
+ tr.appendChild(tdEmail);
+ tr.appendChild(renderTeamMemberRoleCell(accountID, member, isOwner));
+ tr.appendChild(renderTeamMemberActionCell(accountID, member, isOwner));
+ tbody.appendChild(tr);
+ }
+}
+
+export function renderAccountUI(accountState: PortalAccountState): void {
+ var accountIDs = Object.keys(accountState.byAccountID);
+ for (var i = 0; i < accountIDs.length; i += 1) {
+ var accountID = accountIDs[i];
+ var entry = accountState.byAccountID[accountID];
+ renderAddWorkspaceSection(accountID, entry);
+ renderTeamSection(accountID, entry);
+ }
+}