diff --git a/frontend/src/ResultsRow.js b/frontend/src/ResultsRow.js
index 9b4146a..969cc34 100644
--- a/frontend/src/ResultsRow.js
+++ b/frontend/src/ResultsRow.js
@@ -1,25 +1,34 @@
import {h, Component} from 'preact'
+function renderSuccess(server = '') {
+ return (
+
+ {server.toUpperCase()}
+
+ )
+}
+
+function renderError(server = '', text, details) {
+ return (
+
+
{server.toUpperCase()}
+ {text && (
{text}
)}
+
{details}
+
+ )
+}
+
function renderStatus(endpoint) {
const servers = Object.entries(endpoint.servers)
- const working = servers.filter(([,{status}]) => status < 400)
const broken = servers.filter(([,{status}]) => status >= 400)
if(broken.length === 0) {
- return ()
+ return renderSuccess();
}
return servers.map(
([server, {status, error}]) => (
- status < 400 ? (
- {server.toUpperCase()}
- ) : (
-
-
{server.toUpperCase()}
-
{status}
-
{error || 'Unknown error'}
-
- )
+ status < 400 ? renderSuccess(server) : renderError(server, status, error || 'Unknown error')
)
)
}
@@ -31,23 +40,26 @@ function renderSchema(endpoint) {
return ('—')
}
- const working = servers.filter(([,{schemaValid}]) => schemaValid)
const broken = servers.filter(([,{schemaValid}]) => !schemaValid)
if(broken.length === 0) {
- return ()
+ return renderSuccess()
}
+ const firstServer = servers[0][1];
+ const sameError = servers.every(
+ ([, {schemaValid, schemaChanges}]) =>
+ schemaValid === firstServer.schemaValid &&
+ schemaChanges === firstServer.schemaChanges
+ )
+
+ if(sameError) {
+ return renderError('', null, ({firstServer.schemaChanges}
))
+ }
+
return servers.map(
([server, {schemaValid, schemaChanges}]) => (
- schemaValid ? (
- {server.toUpperCase()}
- ) : (
-
-
{server.toUpperCase()}
-
-
- )
+ schemaValid ? renderSuccess(server) : renderError(server, null, ({schemaChanges}
))
)
)
}
@@ -59,23 +71,26 @@ function renderSnapshot(endpoint) {
return ('—')
}
- const working = servers.filter(([,{snapshotValid}]) => snapshotValid)
const broken = servers.filter(([,{snapshotValid}]) => !snapshotValid)
if(broken.length === 0) {
- return ()
+ return renderSuccess();
+ }
+
+ const firstServer = servers[0][1];
+ const sameError = servers.every(
+ ([, {snapshotValid, snapshotChanges}]) =>
+ snapshotValid === firstServer.snapshotValid &&
+ snapshotChanges === firstServer.snapshotChanges
+ )
+
+ if(sameError) {
+ return renderError('', null, ({firstServer.snapshotChanges}
))
}
return servers.map(
([server, {snapshotValid, snapshotChanges}]) => (
- snapshotValid ? (
- {server.toUpperCase()}
- ) : (
-
-
{server.toUpperCase()}
-
-
- )
+ snapshotValid ? renderSuccess(server) : renderError(server, null, ({snapshotChanges}
))
)
)
}