Chore: full react hooks eslint compliance (#7040)

This commit is contained in:
shamoon
2026-08-21 14:00:02 -07:00
committed by GitHub
parent 7c26cf6d97
commit 4c361422ca
111 changed files with 1072 additions and 867 deletions
+4 -8
View File
@@ -3,19 +3,15 @@ import Container from "components/services/widget/container";
import { useTranslation } from "next-i18next/pages";
import useWidgetAPI from "utils/proxy/use-widget-api";
import withWidgetFields from "utils/widget-fields";
const MAX_FIELDS = 4;
const DEFAULT_FIELDS = ["running", "total", "cpu", "memory"];
export default function Component({ service }) {
export default function Component({ service: configuredService }) {
const { t } = useTranslation();
const service = withWidgetFields(configuredService, DEFAULT_FIELDS);
const { widget } = service;
if (!widget.fields) {
widget.fields = ["running", "total", "cpu", "memory"];
} else if (widget.fields.length > MAX_FIELDS) {
widget.fields = widget.fields.slice(0, MAX_FIELDS);
}
const { data: stats, error: statsError } = useWidgetAPI(widget, "dashboard/stats");
if (statsError) {
+5 -1
View File
@@ -22,7 +22,11 @@ describe("widgets/dockhand/component", () => {
const service = { widget: { type: "dockhand" } };
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
expect(service.widget.fields).toEqual(["running", "total", "cpu", "memory"]);
expect(service.widget.fields).toBeUndefined();
expect(useWidgetAPI).toHaveBeenCalledWith(
{ type: "dockhand", fields: ["running", "total", "cpu", "memory"] },
"dashboard/stats",
);
expect(container.querySelectorAll(".service-block")).toHaveLength(4);
expect(screen.getByText("dockhand.running")).toBeInTheDocument();
expect(screen.getByText("dockhand.total")).toBeInTheDocument();