mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-28 23:11:17 -07:00
Chore: full react hooks eslint compliance (#7040)
This commit is contained in:
@@ -2,18 +2,18 @@ import Block from "components/services/widget/block";
|
||||
import Container from "components/services/widget/container";
|
||||
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
import withWidgetFields from "utils/widget-fields";
|
||||
|
||||
export default function Component({ service }) {
|
||||
const DEFAULT_FIELDS = ["connected", "enabled", "total"];
|
||||
|
||||
export default function Component({ service: configuredService }) {
|
||||
const service = withWidgetFields(configuredService, DEFAULT_FIELDS);
|
||||
const { widget } = service;
|
||||
|
||||
const endpoint = widget.version === 2 ? "clientv2" : "client";
|
||||
|
||||
const { data: infoData, error: infoError } = useWidgetAPI(widget, endpoint);
|
||||
|
||||
if (!widget.fields) {
|
||||
widget.fields = ["connected", "enabled", "total"];
|
||||
}
|
||||
|
||||
if (infoError || infoData?.statusCode > 400) {
|
||||
return <Container service={service} error={infoError ?? { message: infoData.statusMessage, data: infoData }} />;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ describe("widgets/wgeasy/component", () => {
|
||||
const service = { widget: { type: "wgeasy" } };
|
||||
const { container } = renderWithProviders(<Component service={service} />, { settings: { hideErrors: false } });
|
||||
|
||||
expect(service.widget.fields).toEqual(["connected", "enabled", "total"]);
|
||||
expect(service.widget.fields).toBeUndefined();
|
||||
// Container filters by widget.fields; "disabled" is not included by default.
|
||||
expect(container.querySelectorAll(".service-block")).toHaveLength(3);
|
||||
expect(screen.getByText("wgeasy.connected")).toBeInTheDocument();
|
||||
|
||||
Reference in New Issue
Block a user