Run pre-commit hooks over existing codebase

Co-Authored-By: Ben Phelps <ben@phelps.io>
This commit is contained in:
shamoon 2023-10-17 23:26:55 -07:00
parent fa50bbad9c
commit 19c25713c4
387 changed files with 4785 additions and 4109 deletions

View file

@ -9,7 +9,7 @@ export default function Block({ value, label }) {
className={classNames(
"bg-theme-200/50 dark:bg-theme-900/20 rounded m-1 flex-1 flex flex-col items-center justify-center text-center p-1",
value === undefined ? "animate-pulse" : "",
"service-block"
"service-block",
)}
>
<div className="font-thin text-sm">{value === undefined || value === null ? "-" : value}</div>

View file

@ -12,14 +12,14 @@ export default function Container({ error = false, children, service }) {
return null;
}
return <Error service={service} error={error} />
return <Error service={service} error={error} />;
}
const childrenArray = Array.isArray(children) ? children : [children];
let visibleChildren = childrenArray;
let fields = service?.widget?.fields;
if (typeof fields === 'string') fields = JSON.parse(service.widget.fields);
if (typeof fields === "string") fields = JSON.parse(service.widget.fields);
const type = service?.widget?.type;
if (fields && type) {
// if the field contains a "." then it most likely contains a common loc value
@ -27,13 +27,15 @@ export default function Container({ error = false, children, service }) {
// fields: [ "resources.cpu", "resources.mem", "field"]
// or even
// fields: [ "resources.cpu", "widget_type.field" ]
visibleChildren = childrenArray?.filter(child => fields.some(field => {
let fullField = field;
if (!field.includes(".")) {
fullField = `${type}.${field}`;
}
return fullField === child?.props?.label;
}));
visibleChildren = childrenArray?.filter((child) =>
fields.some((field) => {
let fullField = field;
if (!field.includes(".")) {
fullField = `${type}.${field}`;
}
return fullField === child?.props?.label;
}),
);
}
return <div className="relative flex flex-row w-full service-container">{visibleChildren}</div>;

View file

@ -6,7 +6,7 @@ function displayError(error) {
}
function displayData(data) {
return (data.type === 'Buffer') ? Buffer.from(data).toString() : JSON.stringify(data, 4);
return data.type === "Buffer" ? Buffer.from(data).toString() : JSON.stringify(data, 4);
}
export default function Error({ error }) {
@ -20,29 +20,34 @@ export default function Error({ error }) {
<details className="px-1 pb-1">
<summary className="block text-center mt-1 mb-0 mx-auto p-3 rounded bg-rose-900/80 hover:bg-rose-900/95 text-theme-900 cursor-pointer">
<div className="flex items-center justify-center text-xs font-bold">
<IoAlertCircle className="mr-1 w-5 h-5"/>{t("widget.api_error")} {error.message && t("widget.information")}
<IoAlertCircle className="mr-1 w-5 h-5" />
{t("widget.api_error")} {error.message && t("widget.information")}
</div>
</summary>
<div className="bg-white dark:bg-theme-200/50 mt-2 rounded text-rose-900 text-xs font-mono whitespace-pre-wrap break-all">
<ul className="p-4">
{error.message && <li>
<span className="text-black">{t("widget.api_error")}:</span> {error.message}
</li>}
{error.url && <li className="mt-2">
<span className="text-black">{t("widget.url")}:</span> {error.url}
</li>}
{error.rawError && <li className="mt-2">
<span className="text-black">{t("widget.raw_error")}:</span>
<div className="ml-2">
{displayError(error.rawError)}
</div>
</li>}
{error.data && <li className="mt-2">
<span className="text-black">{t("widget.response_data")}:</span>
<div className="ml-2">
{displayData(error.data)}
</div>
</li>}
{error.message && (
<li>
<span className="text-black">{t("widget.api_error")}:</span> {error.message}
</li>
)}
{error.url && (
<li className="mt-2">
<span className="text-black">{t("widget.url")}:</span> {error.url}
</li>
)}
{error.rawError && (
<li className="mt-2">
<span className="text-black">{t("widget.raw_error")}:</span>
<div className="ml-2">{displayError(error.rawError)}</div>
</li>
)}
{error.data && (
<li className="mt-2">
<span className="text-black">{t("widget.response_data")}:</span>
<div className="ml-2">{displayData(error.data)}</div>
</li>
)}
</ul>
</div>
</details>