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", "stopped", "total", "image_updates"];
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", "stopped", "total", "image_updates"];
} else if (widget.fields.length > MAX_FIELDS) {
widget.fields = widget.fields.slice(0, MAX_FIELDS);
}
const envNotSet = widget.env == null || widget.env === "";
const { data: containers, error: containersError } = useWidgetAPI(widget, envNotSet ? "" : "containers");
+3 -2
View File
@@ -57,7 +57,7 @@ describe("widgets/arcane/component", () => {
expect(screen.getByText("arcane.image_updates")).toBeInTheDocument();
});
it("truncates custom fields to the max allowed", () => {
it("renders only the first four custom fields without mutating the input", () => {
useWidgetAPI.mockImplementation(() => ({ data: undefined, error: undefined }));
const service = {
@@ -65,7 +65,8 @@ describe("widgets/arcane/component", () => {
};
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
// sliced to first four entries
// The helper caps the copied fields used for rendering and leaves the configured service unchanged.
expect(service.widget.fields).toEqual(["running", "stopped", "total", "images", "images_unused"]);
expect(container.querySelectorAll(".service-block")).toHaveLength(4);
expect(screen.getByText("docker.running")).toBeInTheDocument();
expect(screen.getByText("dockhand.stopped")).toBeInTheDocument();