fix: resolve widget platform CI lint and formatting failures
This commit is contained in:
1 parent
9ff1019a3d
commit
a29ec26c27
12 files changed
+248
-100
No files matched your search
@@ -8,7 +8,11 @@ import type {
|
||||
WidgetCollectionContents,
|
||||
WidgetCollectionManifest,
|
||||
} from "@homarr/custom-widgets/package";
|
||||
import { getWidgetConnectionBindingNames, getWidgetConnectionRequirement, isWidgetConnectionCompatible } from "@homarr/custom-widgets/package";
|
||||
import {
|
||||
getWidgetConnectionBindingNames,
|
||||
getWidgetConnectionRequirement,
|
||||
isWidgetConnectionCompatible,
|
||||
} from "@homarr/custom-widgets/package";
|
||||
import { createWidgetCollectionArchive, validateWidgetCollectionArchive } from "@homarr/custom-widgets/package/server";
|
||||
|
||||
import { withWidgetArtifactReferenceLock } from "./artifact-references";
|
||||
@@ -145,8 +149,16 @@ export async function exportWidgetCollection(ctx: PackageContext, manifest: Widg
|
||||
const bindings = parseBindings(row.bindings);
|
||||
const mapping: Record<string, string> = {};
|
||||
for (const [name, requirement] of Object.entries(source.connections)) {
|
||||
const members = getWidgetConnectionBindingNames(name, requirement, bindings).map((key) => bindings[key]).toSorted();
|
||||
const identity = JSON.stringify([requirement.kind, requirement.serviceType, requirement.integrationKind, requirement.multiple, members.length ? members : [id, name]]);
|
||||
const members = getWidgetConnectionBindingNames(name, requirement, bindings)
|
||||
.map((key) => bindings[key])
|
||||
.toSorted();
|
||||
const identity = JSON.stringify([
|
||||
requirement.kind,
|
||||
requirement.serviceType,
|
||||
requirement.integrationKind,
|
||||
requirement.multiple,
|
||||
members.length ? members : [id, name],
|
||||
]);
|
||||
let slot = shared.get(identity);
|
||||
if (!slot) {
|
||||
slot = `connection${shared.size + 1}`;
|
||||
|
||||
@@ -6,7 +6,13 @@ import { constructIntegrationPermissions } from "@homarr/auth/shared";
|
||||
import { decryptSecret } from "@homarr/common/server";
|
||||
import { createId } from "@homarr/common";
|
||||
import { eq, inArray } from "@homarr/db";
|
||||
import { customWidgetConnections, groupMembers, integrationGroupPermissions, integrations, integrationUserPermissions } from "@homarr/db/schema";
|
||||
import {
|
||||
customWidgetConnections,
|
||||
groupMembers,
|
||||
integrationGroupPermissions,
|
||||
integrations,
|
||||
integrationUserPermissions,
|
||||
} from "@homarr/db/schema";
|
||||
import type { WidgetSdkInvocation } from "@homarr/custom-widgets/package/server";
|
||||
|
||||
import { readPackageHistory, widgetHistoryInputSchema } from "./history";
|
||||
@@ -69,7 +75,9 @@ export function createWidgetSdkBridge(
|
||||
return {
|
||||
options: resolved.configuration,
|
||||
bindingNames: Object.keys(resolved.bindings),
|
||||
bindingLabels: Object.fromEntries(Object.entries(resolved.bindings).map(([name, id]) => [name, labels.get(id) ?? name])),
|
||||
bindingLabels: Object.fromEntries(
|
||||
Object.entries(resolved.bindings).map(([name, id]) => [name, labels.get(id) ?? name]),
|
||||
),
|
||||
installationId: resolved.installation.id,
|
||||
isPreview: Boolean(resolved.preview),
|
||||
};
|
||||
|
||||
@@ -57,11 +57,7 @@ export function downloadPackage(name: string, value: unknown) {
|
||||
const maximumHistoryBytes = 2_000_000;
|
||||
const maximumRecoveryBytes = 1_000_000;
|
||||
|
||||
export function usePackageDocument(
|
||||
initial: PackageDocument,
|
||||
userId: string,
|
||||
installationId?: string,
|
||||
) {
|
||||
export function usePackageDocument(initial: PackageDocument, userId: string, installationId?: string) {
|
||||
const [document, setDocument] = useState(initial);
|
||||
const [saved, setSaved] = useState(initial);
|
||||
const [recovery, setRecovery] = useState<PackageDocument | null>(null);
|
||||
|
||||
@@ -21,10 +21,7 @@
|
||||
"permission": "modify",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"connection",
|
||||
"episodeIds"
|
||||
],
|
||||
"required": ["connection", "episodeIds"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"connection": {
|
||||
|
||||
@@ -41,7 +41,9 @@ export function PackageConnectionBindings({
|
||||
);
|
||||
if (connection.multiple) {
|
||||
const names = getWidgetConnectionBindingNames(name, connection, effectiveBindings);
|
||||
const selected = [...new Set(names.map((key) => effectiveBindings[key]!))];
|
||||
const selected = [
|
||||
...new Set(names.map((key) => effectiveBindings[key]).filter((id) => typeof id === "string")),
|
||||
];
|
||||
const choices = candidates.map((row) => ({ value: row.id, label: row.name }));
|
||||
for (const id of selected) {
|
||||
if (!choices.some((choice) => choice.value === id))
|
||||
|
||||
@@ -24,7 +24,11 @@ import classes from "./modals/widget-edit-modal.module.css";
|
||||
type Size = { width: number; height: number };
|
||||
|
||||
/** The same board grid controls and fitted canvas used by Edit Widget and package authoring. */
|
||||
export function WidgetPreviewFrame({ dimensions, resize, children }: {
|
||||
export function WidgetPreviewFrame({
|
||||
dimensions,
|
||||
resize,
|
||||
children,
|
||||
}: {
|
||||
dimensions: Size & { scale?: number };
|
||||
resize?: { size: Size; maximumSize: Size; onChange(size: Size): void };
|
||||
children(dimensions: Size & { scale: number }): ReactNode;
|
||||
@@ -39,17 +43,26 @@ export function WidgetPreviewFrame({ dimensions, resize, children }: {
|
||||
if (width > 0 && height > 0) scale = Math.min(width / sourceWidth, height / sourceHeight, scale);
|
||||
const change = (dimension: keyof Size, value: string | number) => {
|
||||
if (!resize || typeof value !== "number" || !Number.isFinite(value)) return;
|
||||
resize.onChange({ ...resize.size, [dimension]: Math.max(1, Math.min(Math.round(value), resize.maximumSize[dimension])) });
|
||||
resize.onChange({
|
||||
...resize.size,
|
||||
[dimension]: Math.max(1, Math.min(Math.round(value), resize.maximumSize[dimension])),
|
||||
});
|
||||
};
|
||||
return (
|
||||
<Stack className={classes.previewPanel} gap={0}>
|
||||
<Center ref={ref} className={classes.previewCanvas}>
|
||||
{resize && (
|
||||
<Group className={classes.previewSizeControls} gap={6} wrap="nowrap">
|
||||
<Text size="xs" fw={600} c="dimmed">{t("item.edit.preview.size")}</Text>
|
||||
<Text size="xs" fw={600} c="dimmed">
|
||||
{t("item.edit.preview.size")}
|
||||
</Text>
|
||||
{(["width", "height"] as const).map((dimension) => (
|
||||
<Group key={dimension} gap={6} wrap="nowrap">
|
||||
{dimension === "height" && <Text size="xs" c="dimmed" aria-hidden>×</Text>}
|
||||
{dimension === "height" && (
|
||||
<Text size="xs" c="dimmed" aria-hidden>
|
||||
×
|
||||
</Text>
|
||||
)}
|
||||
<Tooltip label={t(`item.moveResize.field.${dimension}.label`)}>
|
||||
<NumberInput
|
||||
className={classes.previewSizeInput}
|
||||
|
||||
Reference in new issue
Block a user