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): unify Pulse Account mutation state

rcourtman558242504332
diff --git a/internal/cloudcp/portal/dist/build_manifest.json b/internal/cloudcp/portal/dist/build_manifest.json
index 7804b11df4..eb3d3ac82f 100644
--- a/internal/cloudcp/portal/dist/build_manifest.json
+++ b/internal/cloudcp/portal/dist/build_manifest.json
@@ -1,20 +1,37 @@
{
- "source_hash": "e221cd9215efbf93b59b4b9d02300e5b17896320677dc8f523b69f6a48bdade6",
+ "source_hash": "4af6a846ae6295f7fb1c6f60f1b764cbfa4224664e3751b932d0675229bc0a29",
"build_inputs": [
"package.json",
"tsconfig.json",
"build.mjs",
- "src/index.ts",
+ "src/account_controller.test.ts",
"src/account_controller.ts",
+ "src/account_runtime.test.ts",
+ "src/account_runtime.ts",
+ "src/account_view.test.ts",
+ "src/account_view.ts",
+ "src/api.test.ts",
+ "src/api.ts",
+ "src/app.test.ts",
+ "src/app.ts",
+ "src/auth_controller.test.ts",
"src/auth_controller.ts",
- "src/state.ts",
- "src/shell.ts",
- "src/shell_view.ts",
+ "src/index.ts",
+ "src/runtime.test.ts",
+ "src/runtime.ts",
"src/services.ts",
+ "src/services_controller.test.ts",
"src/services_controller.ts",
+ "src/services_view.test.ts",
"src/services_view.ts",
- "src/runtime.ts",
- "src/types.ts",
- "src/styles.css"
+ "src/shell.ts",
+ "src/shell_view.test.ts",
+ "src/shell_view.ts",
+ "src/state.test.ts",
+ "src/state.ts",
+ "src/store.test.ts",
+ "src/store.ts",
+ "src/styles.css",
+ "src/types.ts"
]
}
diff --git a/internal/cloudcp/portal/dist/portal_app.js b/internal/cloudcp/portal/dist/portal_app.js
index 04dd0c2649..ac9bf028dd 100644
--- a/internal/cloudcp/portal/dist/portal_app.js
+++ b/internal/cloudcp/portal/dist/portal_app.js
@@ -327,8 +327,8 @@
function newVerificationFlowState() {
return {
pendingEmail: "",
- requesting: false,
- confirming: false,
+ request: createMutationState(),
+ confirm: createMutationState(),
step2Visible: false,
status: emptyStatus(),
result: null,
@@ -340,9 +340,8 @@
function createPortalLoginState() {
return {
emailValue: "",
- sending: false,
- success: false,
- error: ""
+ request: createMutationState(),
+ success: false
};
}
function createPortalAccountState() {
@@ -386,7 +385,7 @@
refund: {
emailValue: "",
tokenValue: "",
- submitting: false,
+ submit: createMutationState(),
status: emptyStatus()
}
};
@@ -707,31 +706,31 @@
return;
}
deps.store.updateLoginState(function(nextState) {
- nextState.sending = true;
- nextState.error = "";
+ nextState.request.pending = true;
+ nextState.request.error = "";
nextState.success = false;
});
try {
await deps.api.requestMagicLink(email);
deps.store.updateLoginState(function(nextState) {
- nextState.sending = false;
+ nextState.request.pending = false;
nextState.success = true;
});
return;
} catch (error) {
if (error instanceof PortalAPIError && error.status === 404) {
deps.store.updateLoginState(function(nextState) {
- nextState.sending = false;
+ nextState.request.pending = false;
nextState.success = true;
});
return;
}
deps.store.updateLoginState(function(nextState) {
- nextState.error = error instanceof PortalAPIError && error.status === 429 ? "Too many requests. Please wait a moment and try again." : "Network error. Please check your connection and try again.";
+ nextState.request.error = error instanceof PortalAPIError && error.status === 429 ? "Too many requests. Please wait a moment and try again." : "Network error. Please check your connection and try again.";
});
}
deps.store.updateLoginState(function(nextState) {
- nextState.sending = false;
+ nextState.request.pending = false;
});
}
document.addEventListener("click", function(event) {
@@ -747,7 +746,7 @@
event.preventDefault();
deps.store.updateLoginState(function(nextState) {
nextState.success = false;
- nextState.error = "";
+ nextState.request.error = "";
});
void sendMagicLink();
return;
@@ -993,8 +992,8 @@
if (flow.renderPanel) {
flow.renderPanel(flowState);
}
- renderButton(flow.requestButtonID, flowState.requesting, flowState.requesting ? flow.requestPendingLabel : flow.requestLabel);
- renderButton(flow.confirmButtonID, flowState.confirming, flowState.confirming ? flow.confirmPendingLabel : flow.confirmLabel);
+ renderButton(flow.requestButtonID, flowState.request.pending, flowState.request.pending ? flow.requestPendingLabel : flow.requestLabel);
+ renderButton(flow.confirmButtonID, flowState.confirm.pending, flowState.confirm.pending ? flow.confirmPendingLabel : flow.confirmLabel);
renderStatus(flow.statusID, flowState.status);
if (flow.step2ID) {
setVisible(flow.step2ID, flowState.step2Visible);
@@ -1013,7 +1012,7 @@
function renderRefund() {
var refundState = getServiceState().refund;
renderRefundPanel(refundState, store.getBootstrap());
- renderButton("refund-inline-submit", refundState.submitting, refundState.submitting ? "Processing..." : "Process Refund");
+ renderButton("refund-inline-submit", refundState.submit.pending, refundState.submit.pending ? "Processing..." : "Process Refund");
renderStatus("refund-inline-status", refundState.status);
}
function resetVerificationFlow(flowID) {
@@ -1202,7 +1201,8 @@
flow.onRequestStart();
}
updateServiceState(function(serviceState) {
- serviceState.flows[flowID].requesting = true;
+ serviceState.flows[flowID].request.pending = true;
+ serviceState.flows[flowID].request.error = "";
clearFlowStatus(serviceState, flowID);
});
try {
@@ -1218,7 +1218,7 @@
});
} finally {
updateServiceState(function(serviceState) {
- serviceState.flows[flowID].requesting = false;
+ serviceState.flows[flowID].request.pending = false;
});
}
}
@@ -1249,7 +1249,8 @@
return;
}
updateServiceState(function(serviceState) {
- serviceState.flows[flowID].confirming = true;
+ serviceState.flows[flowID].confirm.pending = true;
+ serviceState.flows[flowID].confirm.error = "";
});
try {
var data = await api.postCommercialJSON(flow.confirmPath, { email, code });
@@ -1260,7 +1261,7 @@
});
} finally {
updateServiceState(function(serviceState) {
- serviceState.flows[flowID].confirming = false;
+ serviceState.flows[flowID].confirm.pending = false;
});
}
}
@@ -1285,7 +1286,8 @@
if (!email || !token) return;
if (!confirm("Are you sure? This will immediately revoke the license and request the refund.")) return;
updateServiceState(function(serviceState) {
- serviceState.refund.submitting = true;
+ serviceState.refund.submit.pending = true;
+ serviceState.refund.submit.error = "";
serviceState.refund.status = emptyStatus();
});
try {
@@ -1300,7 +1302,7 @@
});
} finally {
updateServiceState(function(serviceState) {
- serviceState.refund.submitting = false;
+ serviceState.refund.submit.pending = false;
});
}
}
@@ -1420,12 +1422,12 @@
}
function renderSignedOutPortalHTML(context) {
var statusHTML = "";
- if (context.loginState.error) {
- statusHTML = '<div class="service-status visible error">' + escapeHTML(context.loginState.error) + "</div>";
+ if (context.loginState.request.error) {
+ statusHTML = '<div class="service-status visible error">' + escapeHTML(context.loginState.request.error) + "</div>";
} else if (context.loginState.success) {
statusHTML = `<div class="service-status visible success">Magic link sent. Check your inbox and click the link to sign in.<br><br><strong>Don't see it?</strong> <a href="#" data-portal-action="resend-magic-link">Send a new link</a>.</div>`;
}
- return '<section class="intro-card"><h1>Pulse Account</h1><p>Sign in to manage Cloud workspaces, MSP access, and commercial account services from one account surface.</p></section><section class="service-section"><div class="service-panel visible"><h3>Sign in</h3><p>Enter the commercial email address for your Pulse account. I will send a magic link so you can open Pulse Account without managing a password.</p><div class="form-group"><label for="portal-login-email">Email address</label><input id="portal-login-email" type="email" autocomplete="email" placeholder="[email protected]" value="' + escapeAttr(context.loginState.emailValue || "") + '" data-portal-input="login-email"></div><div class="form-actions"><button class="btn-primary" id="portal-login-send" type="button" data-portal-action="send-magic-link">' + (context.loginState.sending ? "Sending\u2026" : "Send magic link") + '</button><a class="btn-secondary" href="' + escapeAttr(context.signupPath) + '" style="text-decoration:none">Create an account</a></div>' + statusHTML + "</div></section>";
+ return '<section class="intro-card"><h1>Pulse Account</h1><p>Sign in to manage Cloud workspaces, MSP access, and commercial account services from one account surface.</p></section><section class="service-section"><div class="service-panel visible"><h3>Sign in</h3><p>Enter the commercial email address for your Pulse account. I will send a magic link so you can open Pulse Account without managing a password.</p><div class="form-group"><label for="portal-login-email">Email address</label><input id="portal-login-email" type="email" autocomplete="email" placeholder="[email protected]" value="' + escapeAttr(context.loginState.emailValue || "") + '" data-portal-input="login-email"></div><div class="form-actions"><button class="btn-primary" id="portal-login-send" type="button" data-portal-action="send-magic-link">' + (context.loginState.request.pending ? "Sending\u2026" : "Send magic link") + '</button><a class="btn-secondary" href="' + escapeAttr(context.signupPath) + '" style="text-decoration:none">Create an account</a></div>' + statusHTML + "</div></section>";
}
// src/shell.ts
diff --git a/internal/cloudcp/portal/frontend/build.mjs b/internal/cloudcp/portal/frontend/build.mjs
index 26d0766e77..bf194b9247 100644
--- a/internal/cloudcp/portal/frontend/build.mjs
+++ b/internal/cloudcp/portal/frontend/build.mjs
@@ -13,25 +13,36 @@ const repoRoot = path.resolve(frontendRoot, '../../../../');
const distRoot = path.resolve(frontendRoot, '../dist');
const lockPath = path.join(repoRoot, 'tmp', 'locks', 'pulse-account-frontend-build.lock');
const manifestPath = path.join(distRoot, 'build_manifest.json');
-const buildInputs = [
- 'package.json',
- 'tsconfig.json',
- 'build.mjs',
- 'src/index.ts',
- 'src/account_controller.ts',
- 'src/auth_controller.ts',
- 'src/state.ts',
- 'src/shell.ts',
- 'src/shell_view.ts',
- 'src/services.ts',
- 'src/services_controller.ts',
- 'src/services_view.ts',
- 'src/runtime.ts',
- 'src/types.ts',
- 'src/styles.css',
-];
-async function computeSourceHash() {
+async function listSourceInputs(relativeDir) {
+ const absoluteDir = path.join(frontendRoot, relativeDir);
+ const entries = await fs.readdir(absoluteDir, { withFileTypes: true });
+ const files = [];
+ for (const entry of entries) {
+ const childRelativePath = path.posix.join(relativeDir, entry.name);
+ if (entry.isDirectory()) {
+ files.push(...await listSourceInputs(childRelativePath));
+ continue;
+ }
+ if (entry.isFile() && /\.(ts|css)$/.test(entry.name)) {
+ files.push(childRelativePath);
+ }
+ }
+ files.sort();
+ return files;
+}
+
+async function getBuildInputs() {
+ const sourceInputs = await listSourceInputs('src');
+ return [
+ 'package.json',
+ 'tsconfig.json',
+ 'build.mjs',
+ ...sourceInputs,
+ ];
+}
+
+async function computeSourceHash(buildInputs) {
const hash = crypto.createHash('sha256');
for (const relativePath of buildInputs) {
hash.update(relativePath);
@@ -45,7 +56,8 @@ async function computeSourceHash() {
await withExclusiveLock(
lockPath,
async () => {
- const sourceHash = await computeSourceHash();
+ const buildInputs = await getBuildInputs();
+ const sourceHash = await computeSourceHash(buildInputs);
await fs.mkdir(distRoot, { recursive: true });
await fs.rm(path.join(distRoot, 'portal_app.js'), { force: true });
await fs.rm(path.join(distRoot, 'portal_app.css'), { force: true });
diff --git a/internal/cloudcp/portal/frontend/src/auth_controller.test.ts b/internal/cloudcp/portal/frontend/src/auth_controller.test.ts
index 7069f11492..7d5ffec06c 100644
--- a/internal/cloudcp/portal/frontend/src/auth_controller.test.ts
+++ b/internal/cloudcp/portal/frontend/src/auth_controller.test.ts
@@ -78,7 +78,8 @@ describe('auth controller', function() {
document.getElementById('send')?.dispatchEvent(new MouseEvent('click', { bubbles: true }));
await flushAsync();
- expect(controller.getLoginState().sending).toBe(false);
+ expect(controller.getLoginState().request.pending).toBe(false);
+ expect(controller.getLoginState().request.error).toBe('');
expect(controller.getLoginState().success).toBe(true);
expect(fetch).toHaveBeenCalledWith(
'/magic-link',
diff --git a/internal/cloudcp/portal/frontend/src/auth_controller.ts b/internal/cloudcp/portal/frontend/src/auth_controller.ts
index 3673ec931e..8f8c0dd10b 100644
--- a/internal/cloudcp/portal/frontend/src/auth_controller.ts
+++ b/internal/cloudcp/portal/frontend/src/auth_controller.ts
@@ -38,33 +38,33 @@ export function installAuthController(deps: AuthControllerDeps): AuthController
return;
}
deps.store.updateLoginState(function(nextState) {
- nextState.sending = true;
- nextState.error = '';
+ nextState.request.pending = true;
+ nextState.request.error = '';
nextState.success = false;
});
try {
await deps.api.requestMagicLink(email);
deps.store.updateLoginState(function(nextState) {
- nextState.sending = false;
+ nextState.request.pending = false;
nextState.success = true;
});
return;
} catch (error) {
if (error instanceof PortalAPIError && error.status === 404) {
deps.store.updateLoginState(function(nextState) {
- nextState.sending = false;
+ nextState.request.pending = false;
nextState.success = true;
});
return;
}
deps.store.updateLoginState(function(nextState) {
- nextState.error = error instanceof PortalAPIError && error.status === 429
+ nextState.request.error = error instanceof PortalAPIError && error.status === 429
? 'Too many requests. Please wait a moment and try again.'
: 'Network error. Please check your connection and try again.';
});
}
deps.store.updateLoginState(function(nextState) {
- nextState.sending = false;
+ nextState.request.pending = false;
});
}
@@ -81,7 +81,7 @@ export function installAuthController(deps: AuthControllerDeps): AuthController
event.preventDefault();
deps.store.updateLoginState(function(nextState) {
nextState.success = false;
- nextState.error = '';
+ nextState.request.error = '';
});
void sendMagicLink();
return;
diff --git a/internal/cloudcp/portal/frontend/src/services.ts b/internal/cloudcp/portal/frontend/src/services.ts
index 62acf97d8c..30a4ce7e0c 100644
--- a/internal/cloudcp/portal/frontend/src/services.ts
+++ b/internal/cloudcp/portal/frontend/src/services.ts
@@ -96,8 +96,8 @@ export function installServicesRuntime(deps: ServicesRuntimeDeps): void {
if (flow.renderPanel) {
flow.renderPanel(flowState);
}
- renderButton(flow.requestButtonID, flowState.requesting, flowState.requesting ? flow.requestPendingLabel : flow.requestLabel);
- renderButton(flow.confirmButtonID, flowState.confirming, flowState.confirming ? flow.confirmPendingLabel : flow.confirmLabel);
+ renderButton(flow.requestButtonID, flowState.request.pending, flowState.request.pending ? flow.requestPendingLabel : flow.requestLabel);
+ renderButton(flow.confirmButtonID, flowState.confirm.pending, flowState.confirm.pending ? flow.confirmPendingLabel : flow.confirmLabel);
renderStatus(flow.statusID, flowState.status);
if (flow.step2ID) {
setVisible(flow.step2ID, flowState.step2Visible);
@@ -118,7 +118,7 @@ export function installServicesRuntime(deps: ServicesRuntimeDeps): void {
function renderRefund() {
var refundState = getServiceState().refund;
renderRefundPanel(refundState, store.getBootstrap());
- renderButton('refund-inline-submit', refundState.submitting, refundState.submitting ? 'Processing...' : 'Process Refund');
+ renderButton('refund-inline-submit', refundState.submit.pending, refundState.submit.pending ? 'Processing...' : 'Process Refund');
renderStatus('refund-inline-status', refundState.status);
}
@@ -309,7 +309,8 @@ export function installServicesRuntime(deps: ServicesRuntimeDeps): void {
flow.onRequestStart();
}
updateServiceState(function(serviceState) {
- serviceState.flows[flowID].requesting = true;
+ serviceState.flows[flowID].request.pending = true;
+ serviceState.flows[flowID].request.error = '';
clearFlowStatus(serviceState, flowID);
});
try {
@@ -325,7 +326,7 @@ export function installServicesRuntime(deps: ServicesRuntimeDeps): void {
});
} finally {
updateServiceState(function(serviceState) {
- serviceState.flows[flowID].requesting = false;
+ serviceState.flows[flowID].request.pending = false;
});
}
}
@@ -358,7 +359,8 @@ export function installServicesRuntime(deps: ServicesRuntimeDeps): void {
return;
}
updateServiceState(function(serviceState) {
- serviceState.flows[flowID].confirming = true;
+ serviceState.flows[flowID].confirm.pending = true;
+ serviceState.flows[flowID].confirm.error = '';
});
try {
var data = await api.postCommercialJSON(flow.confirmPath, { email: email, code: code });
@@ -369,7 +371,7 @@ export function installServicesRuntime(deps: ServicesRuntimeDeps): void {
});
} finally {
updateServiceState(function(serviceState) {
- serviceState.flows[flowID].confirming = false;
+ serviceState.flows[flowID].confirm.pending = false;
});
}
}
@@ -396,7 +398,8 @@ export function installServicesRuntime(deps: ServicesRuntimeDeps): void {
if (!email || !token) return;
if (!confirm('Are you sure? This will immediately revoke the license and request the refund.')) return;
updateServiceState(function(serviceState) {
- serviceState.refund.submitting = true;
+ serviceState.refund.submit.pending = true;
+ serviceState.refund.submit.error = '';
serviceState.refund.status = emptyStatus();
});
try {
@@ -411,7 +414,7 @@ export function installServicesRuntime(deps: ServicesRuntimeDeps): void {
});
} finally {
updateServiceState(function(serviceState) {
- serviceState.refund.submitting = false;
+ serviceState.refund.submit.pending = false;
});
}
}
diff --git a/internal/cloudcp/portal/frontend/src/services_view.test.ts b/internal/cloudcp/portal/frontend/src/services_view.test.ts
index 673f2728f2..a9a3796ef1 100644
--- a/internal/cloudcp/portal/frontend/src/services_view.test.ts
+++ b/internal/cloudcp/portal/frontend/src/services_view.test.ts
@@ -34,8 +34,14 @@ function createBootstrap(overrides: Partial<PortalBootstrapData> = {}): PortalBo
function createFlowState(overrides: Partial<VerificationFlowState> = {}): VerificationFlowState {
return {
pendingEmail: '',
- requesting: false,
- confirming: false,
+ request: {
+ pending: false,
+ error: '',
+ },
+ confirm: {
+ pending: false,
+ error: '',
+ },
step2Visible: false,
status: {
visible: false,
@@ -54,7 +60,10 @@ function createRefundState(overrides: Partial<RefundState> = {}): RefundState {
return {
emailValue: '',
tokenValue: '',
- submitting: false,
+ submit: {
+ pending: false,
+ error: '',
+ },
status: {
visible: false,
message: '',
diff --git a/internal/cloudcp/portal/frontend/src/shell_view.test.ts b/internal/cloudcp/portal/frontend/src/shell_view.test.ts
index e132fd562d..3e440ac689 100644
--- a/internal/cloudcp/portal/frontend/src/shell_view.test.ts
+++ b/internal/cloudcp/portal/frontend/src/shell_view.test.ts
@@ -31,9 +31,11 @@ function createBootstrap(overrides: Partial<PortalBootstrapData> = {}): PortalBo
function createLoginState(overrides: Partial<PortalLoginState> = {}): PortalLoginState {
return {
emailValue: '',
- sending: false,
+ request: {
+ pending: false,
+ error: '',
+ },
success: false,
- error: '',
...overrides,
};
}
@@ -128,7 +130,10 @@ describe('shell view', function() {
bootstrap: createBootstrap({ authenticated: false, email: '' }),
loginState: createLoginState({
emailValue: '[email protected]',
- error: 'Invalid email',
+ request: {
+ pending: false,
+ error: 'Invalid email',
+ },
}),
})
);
@@ -138,7 +143,10 @@ describe('shell view', function() {
loginState: createLoginState({
emailValue: '[email protected]',
success: true,
- sending: false,
+ request: {
+ pending: false,
+ error: '',
+ },
}),
})
);
diff --git a/internal/cloudcp/portal/frontend/src/shell_view.ts b/internal/cloudcp/portal/frontend/src/shell_view.ts
index 9162212ea9..365fdd597c 100644
--- a/internal/cloudcp/portal/frontend/src/shell_view.ts
+++ b/internal/cloudcp/portal/frontend/src/shell_view.ts
@@ -281,8 +281,8 @@ export function renderAuthenticatedPortalHTML(context: ShellViewContext): string
export function renderSignedOutPortalHTML(context: ShellViewContext): string {
var statusHTML = '';
- if (context.loginState.error) {
- statusHTML = '<div class="service-status visible error">' + escapeHTML(context.loginState.error) + '</div>';
+ if (context.loginState.request.error) {
+ statusHTML = '<div class="service-status visible error">' + escapeHTML(context.loginState.request.error) + '</div>';
} else if (context.loginState.success) {
statusHTML =
'<div class="service-status visible success">' +
@@ -307,7 +307,7 @@ export function renderSignedOutPortalHTML(context: ShellViewContext): string {
'</div>' +
'<div class="form-actions">' +
'<button class="btn-primary" id="portal-login-send" type="button" data-portal-action="send-magic-link">' +
- (context.loginState.sending ? 'Sending…' : 'Send magic link') +
+ (context.loginState.request.pending ? 'Sending…' : 'Send magic link') +
'</button>' +
'<a class="btn-secondary" href="' + escapeAttr(context.signupPath) + '" style="text-decoration:none">Create an account</a>' +
'</div>' +
diff --git a/internal/cloudcp/portal/frontend/src/state.test.ts b/internal/cloudcp/portal/frontend/src/state.test.ts
index f063fe053a..0c1b8b39e0 100644
--- a/internal/cloudcp/portal/frontend/src/state.test.ts
+++ b/internal/cloudcp/portal/frontend/src/state.test.ts
@@ -18,6 +18,7 @@ describe('portal state', function() {
var loginState = createPortalLoginState();
syncLoginStateBootstrapEmail(loginState, '[email protected]');
expect(loginState.emailValue).toBe('[email protected]');
+ expect(loginState.request.pending).toBe(false);
syncLoginStateBootstrapEmail(loginState, '[email protected]');
expect(loginState.emailValue).toBe('[email protected]');
@@ -30,6 +31,9 @@ describe('portal state', function() {
expect(serviceState.flows.manage.emailValue).toBe('[email protected]');
expect(serviceState.flows.retrieve.emailValue).toBe('[email protected]');
expect(serviceState.refund.emailValue).toBe('[email protected]');
+ expect(serviceState.flows.manage.request.pending).toBe(false);
+ expect(serviceState.flows.manage.confirm.pending).toBe(false);
+ expect(serviceState.refund.submit.pending).toBe(false);
serviceState.flows.manage.emailValue = '[email protected]';
syncServiceStateBootstrapEmail(serviceState, '[email protected]');
@@ -61,6 +65,8 @@ describe('portal state', function() {
serviceState.flows.export.codeValue = '999999';
serviceState.flows.export.pendingEmail = '[email protected]';
serviceState.flows.export.result = { ok: true };
+ serviceState.flows.export.request.pending = true;
+ serviceState.flows.export.confirm.pending = true;
setFlowStatus(serviceState, 'export', 'done', false);
resetVerificationFlowState(serviceState, 'export');
@@ -69,6 +75,8 @@ describe('portal state', function() {
expect(serviceState.flows.export.codeValue).toBe('');
expect(serviceState.flows.export.pendingEmail).toBe('');
expect(serviceState.flows.export.result).toBeNull();
+ expect(serviceState.flows.export.request.pending).toBe(false);
+ expect(serviceState.flows.export.confirm.pending).toBe(false);
expect(serviceState.flows.export.status.visible).toBe(false);
setFlowStatus(serviceState, 'export', 'broken', true);
diff --git a/internal/cloudcp/portal/frontend/src/state.ts b/internal/cloudcp/portal/frontend/src/state.ts
index 4c1e8f73fa..f2af3742fa 100644
--- a/internal/cloudcp/portal/frontend/src/state.ts
+++ b/internal/cloudcp/portal/frontend/src/state.ts
@@ -23,8 +23,8 @@ export function emptyStatus(): ServiceStatus {
export function newVerificationFlowState(): VerificationFlowState {
return {
pendingEmail: '',
- requesting: false,
- confirming: false,
+ request: createMutationState(),
+ confirm: createMutationState(),
step2Visible: false,
status: emptyStatus(),
result: null,
@@ -37,9 +37,8 @@ export function newVerificationFlowState(): VerificationFlowState {
export function createPortalLoginState(): PortalLoginState {
return {
emailValue: '',
- sending: false,
+ request: createMutationState(),
success: false,
- error: '',
};
}
@@ -88,7 +87,7 @@ export function createPortalServiceState(): PortalServiceState {
refund: {
emailValue: '',
tokenValue: '',
- submitting: false,
+ submit: createMutationState(),
status: emptyStatus(),
},
};
diff --git a/internal/cloudcp/portal/frontend/src/types.ts b/internal/cloudcp/portal/frontend/src/types.ts
index 955aab598a..9c8cbd5877 100644
--- a/internal/cloudcp/portal/frontend/src/types.ts
+++ b/internal/cloudcp/portal/frontend/src/types.ts
@@ -35,9 +35,8 @@ export interface PortalBootstrapData {
export interface PortalLoginState {
emailValue: string;
- sending: boolean;
+ request: PortalMutationState;
success: boolean;
- error: string;
}
export interface PortalTeamMember {
@@ -80,8 +79,8 @@ export interface ServiceStatus {
export interface VerificationFlowState {
pendingEmail: string;
- requesting: boolean;
- confirming: boolean;
+ request: PortalMutationState;
+ confirm: PortalMutationState;
step2Visible: boolean;
status: ServiceStatus;
result: unknown;
@@ -93,7 +92,7 @@ export interface VerificationFlowState {
export interface RefundState {
emailValue: string;
tokenValue: string;
- submitting: boolean;
+ submit: PortalMutationState;
status: ServiceStatus;
}