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
+3 -13
View File
@@ -3,14 +3,14 @@ import Container from "components/services/widget/container";
import { useTranslation } from "next-i18next/pages";
import useWidgetAPI from "utils/proxy/use-widget-api";
const MAX_ALLOWED_FIELDS = 4;
import withWidgetFields from "utils/widget-fields";
export const technitiumDefaultFields = ["totalQueries", "totalAuthoritative", "totalCached", "totalServerFailure"];
export default function Component({ service }) {
export default function Component({ service: configuredService }) {
const { t } = useTranslation();
const service = withWidgetFields(configuredService, technitiumDefaultFields);
const { widget } = service;
const params = {
@@ -20,16 +20,6 @@ export default function Component({ service }) {
const { data: statsData, error: statsError } = useWidgetAPI(widget, "stats", params);
// Default fields
if (!widget.fields?.length > 0) {
widget.fields = technitiumDefaultFields;
}
// Limits max number of displayed fields
if (widget.fields?.length > MAX_ALLOWED_FIELDS) {
widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS);
}
if (statsError) {
return <Container service={service} error={statsError} />;
}
+2 -2
View File
@@ -9,7 +9,7 @@ import { expectBlockValue, findServiceBlockByLabel } from "test-utils/widget-ass
const { useWidgetAPI } = vi.hoisted(() => ({ useWidgetAPI: vi.fn() }));
vi.mock("utils/proxy/use-widget-api", () => ({ default: useWidgetAPI }));
import Component, { technitiumDefaultFields } from "./component";
import Component from "./component";
describe("widgets/technitium/component", () => {
beforeEach(() => {
@@ -22,7 +22,7 @@ describe("widgets/technitium/component", () => {
const service = { widget: { type: "technitium" } };
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
expect(service.widget.fields).toEqual(technitiumDefaultFields);
expect(service.widget.fields).toBeUndefined();
expect(container.querySelectorAll(".service-block")).toHaveLength(4);
expect(screen.getByText("technitium.totalQueries")).toBeInTheDocument();
expect(screen.getByText("technitium.totalAuthoritative")).toBeInTheDocument();