From 8c56f1dccfd00f87770717a81b75903183a4a751 Mon Sep 17 00:00:00 2001
From: Frank Sauerburger <frank@sauerburger.com>
Date: Wed, 24 Feb 2021 11:36:22 +0100
Subject: [PATCH] Use ?? operator to inject default values

---
 uhepp-js/src/common.scss                 | 14 ++++++++++++++
 uhepp-js/src/components/UheppHist.jsx    | 10 ++++------
 uhepp_org/uhepp_vault/templates/404.html |  2 ++
 uhepp_org/uhepp_vault/templates/500.html |  2 ++
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/uhepp-js/src/common.scss b/uhepp-js/src/common.scss
index c5668a1..7e23296 100644
--- a/uhepp-js/src/common.scss
+++ b/uhepp-js/src/common.scss
@@ -131,3 +131,17 @@ body {
     background-size: contain;
   }
 }
+
+.alert {
+  border-bottom: none;
+  border-left: none;
+  border-right: none;
+  border-top-width: 0.25rem;
+}
+
+.alert-danger {
+  border-color: theme-color("danger");
+}
+.alert-success {
+  border-color: theme-color("success");
+}
diff --git a/uhepp-js/src/components/UheppHist.jsx b/uhepp-js/src/components/UheppHist.jsx
index 23dd5da..644b9c1 100644
--- a/uhepp-js/src/components/UheppHist.jsx
+++ b/uhepp-js/src/components/UheppHist.jsx
@@ -667,8 +667,8 @@ const UheppHistPost = ({width, height, uhepp}) => {
 	})
 	const maxBinMain = getMaxBin(post_uhepp)
   const isScaleLin = !(uhepp.y_axis && uhepp.y_axis.log)
-  const yScaleMin = (uhepp.y_axis && uhepp.y_axis.min) || (isScaleLin ? 0 : 1);
-  const yScaleMax = (uhepp.y_axis && uhepp.y_axis.max) || (isScaleLin ?  maxBinMain * 1.5 : maxBinMain * 10**1.5 );
+  const yScaleMin = (uhepp.y_axis && uhepp.y_axis.min) ?? (isScaleLin ? 0 : 1);
+  const yScaleMax = (uhepp.y_axis && uhepp.y_axis.max) ?? (isScaleLin ?  maxBinMain * 1.5 : maxBinMain * 10**1.5 );
 
 
 	const yScale = isScaleLin ? (
@@ -689,14 +689,12 @@ const UheppHistPost = ({width, height, uhepp}) => {
 	const ratioScale = ratioScaleMaker({
 		range: [ratioMax, 0],
 		domain: [
-      (uhepp.ratio_axis && uhepp.ratio_axis.min) || 0.5,
-      (uhepp.ratio_axis && uhepp.ratio_axis.max) || 1.5,
+      (uhepp.ratio_axis && uhepp.ratio_axis.min) ?? 0.5,
+      (uhepp.ratio_axis && uhepp.ratio_axis.max) ?? 1.5,
     ],
     clamp: !isRatioScaleLin,
 	})
 
-
-
   const equidistent = computeEquidistent(uhepp.bins.rebin || uhepp.bins.edges, uhepp.bins.density_width)
 
 	return (
diff --git a/uhepp_org/uhepp_vault/templates/404.html b/uhepp_org/uhepp_vault/templates/404.html
index 654949b..d9260fe 100644
--- a/uhepp_org/uhepp_vault/templates/404.html
+++ b/uhepp_org/uhepp_vault/templates/404.html
@@ -14,6 +14,7 @@
 
 {% block content %}
 
+<div class="alert alert-danger">
 <h2 class="mt-2">Oops, something went wrong</h2>
 <p>
 We couldn't find the resource you were looking for.
@@ -23,4 +24,5 @@ Please make sure that</p>
   <li>you have permission to view the resource.</li>
 </ul>
 The owner of the resource might have not made it visible to you.
+</div>
 {% endblock %}
diff --git a/uhepp_org/uhepp_vault/templates/500.html b/uhepp_org/uhepp_vault/templates/500.html
index 3650a98..d9a9831 100644
--- a/uhepp_org/uhepp_vault/templates/500.html
+++ b/uhepp_org/uhepp_vault/templates/500.html
@@ -13,8 +13,10 @@
 
 {% block content %}
 
+<div class="alert alert-danger">
 <h2 class="mt-2">Oops, this is embarrassing</h2>
 <p>
 Something wend wrong at our end. This might be a temporary issue. Please try
 again. If the issue persists, please contact an administrator.
+</div>
 {% endblock %}
-- 
GitLab