style: auto-fix lint and format
This commit is contained in:
1 parent
aa8410d326
commit
d37545c98e
5 files changed
+11
-19
No files matched your search
@@ -94,7 +94,12 @@ export function CustomWidgetPreview({
|
|||||||
Widget makes HTTP requests:
|
Widget makes HTTP requests:
|
||||||
</Text>
|
</Text>
|
||||||
{httpMethods.map((m) => (
|
{httpMethods.map((m) => (
|
||||||
<Badge key={m} size="xs" color={m === "DELETE" ? "red" : m === "GET" ? "blue" : "orange"} variant="filled">
|
<Badge
|
||||||
|
key={m}
|
||||||
|
size="xs"
|
||||||
|
color={m === "DELETE" ? "red" : m === "GET" ? "blue" : "orange"}
|
||||||
|
variant="filled"
|
||||||
|
>
|
||||||
{m}
|
{m}
|
||||||
</Badge>
|
</Badge>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ const HTTP_METHODS = ["GET", "POST", "PUT", "DELETE", "PATCH"] as const;
|
|||||||
|
|
||||||
const validateUrl = (urlString: string): URL => new URL(urlString);
|
const validateUrl = (urlString: string): URL => new URL(urlString);
|
||||||
|
|
||||||
const resolveTargetUrl = (definitionUrl: string, targetUrl: string): URL => new URL(targetUrl, validateUrl(definitionUrl));
|
const resolveTargetUrl = (definitionUrl: string, targetUrl: string): URL =>
|
||||||
|
new URL(targetUrl, validateUrl(definitionUrl));
|
||||||
|
|
||||||
const assertSameOrigin = (definitionUrl: string, targetUrl: URL): void => {
|
const assertSameOrigin = (definitionUrl: string, targetUrl: URL): void => {
|
||||||
const definitionOrigin = validateUrl(definitionUrl).origin;
|
const definitionOrigin = validateUrl(definitionUrl).origin;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export function extractHttpMethods(template: string): string[] {
|
|||||||
if (/<ToggleSwitch\b/.test(template) && methods.size === 0) methods.add("POST");
|
if (/<ToggleSwitch\b/.test(template) && methods.size === 0) methods.add("POST");
|
||||||
if (/<SubFetch\b/.test(template) && methods.size === 0) methods.add("GET");
|
if (/<SubFetch\b/.test(template) && methods.size === 0) methods.add("GET");
|
||||||
}
|
}
|
||||||
return [...methods].sort();
|
return [...methods].toSorted();
|
||||||
}
|
}
|
||||||
|
|
||||||
const METHOD_COLORS: Record<string, string> = {
|
const METHOD_COLORS: Record<string, string> = {
|
||||||
|
|||||||
@@ -3,14 +3,7 @@
|
|||||||
import type { ComponentType, ReactNode } from "react";
|
import type { ComponentType, ReactNode } from "react";
|
||||||
import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
|
import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
|
||||||
import { Alert, Badge, Button, Code, Skeleton, Switch, Text, Title } from "@mantine/core";
|
import { Alert, Badge, Button, Code, Skeleton, Switch, Text, Title } from "@mantine/core";
|
||||||
import {
|
import { IconAlertTriangle, IconCheck, IconPlayerPlay, IconPower, IconRefresh, IconTrash } from "@tabler/icons-react";
|
||||||
IconAlertTriangle,
|
|
||||||
IconCheck,
|
|
||||||
IconPlayerPlay,
|
|
||||||
IconPower,
|
|
||||||
IconRefresh,
|
|
||||||
IconTrash,
|
|
||||||
} from "@tabler/icons-react";
|
|
||||||
|
|
||||||
import { clientApi } from "@homarr/api/client";
|
import { clientApi } from "@homarr/api/client";
|
||||||
import { useConfirmModal } from "@homarr/modals";
|
import { useConfirmModal } from "@homarr/modals";
|
||||||
@@ -243,7 +236,6 @@ export interface SubDataProps {
|
|||||||
c?: string;
|
c?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function SubData({ path, as = "Text", ...props }: SubDataProps) {
|
export function SubData({ path, as = "Text", ...props }: SubDataProps) {
|
||||||
const subData = useContext(SubFetchDataContext);
|
const subData = useContext(SubFetchDataContext);
|
||||||
const value = getByPath(subData, path);
|
const value = getByPath(subData, path);
|
||||||
|
|||||||
@@ -5,13 +5,7 @@ import { createContext, useContext } from "react";
|
|||||||
|
|
||||||
const WidgetDefinitionContext = createContext<string>("");
|
const WidgetDefinitionContext = createContext<string>("");
|
||||||
|
|
||||||
export function WidgetDefinitionProvider({
|
export function WidgetDefinitionProvider({ definitionId, children }: { definitionId: string; children: ReactNode }) {
|
||||||
definitionId,
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
definitionId: string;
|
|
||||||
children: ReactNode;
|
|
||||||
}) {
|
|
||||||
return <WidgetDefinitionContext.Provider value={definitionId}>{children}</WidgetDefinitionContext.Provider>;
|
return <WidgetDefinitionContext.Provider value={definitionId}>{children}</WidgetDefinitionContext.Provider>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user