refactor: simplify widget and integration architecture
This commit is contained in:
1 parent
c988c35b29
commit
8f9efd0074
179 files changed
+1509
-4187
No files matched your search
@@ -1,11 +0,0 @@
|
||||
// This file is generated by pnpm widgets:sync. Do not edit it directly.
|
||||
|
||||
import { IconCloud, IconDownload } from "@tabler/icons-react";
|
||||
import type { TablerIcon } from "@tabler/icons-react";
|
||||
|
||||
import type { WidgetKind } from "@homarr/definitions";
|
||||
|
||||
export const generatedWidgetCatalogIcons = {
|
||||
downloads: IconDownload,
|
||||
weather: IconCloud,
|
||||
} satisfies Partial<Record<WidgetKind, TablerIcon>>;
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { IntegrationKind, WidgetKind } from "@homarr/definitions";
|
||||
import {
|
||||
getIntegrationName,
|
||||
getIntegrationOnboardingMetadata,
|
||||
getWidgetKindsForIntegration,
|
||||
integrationDefs,
|
||||
integrationKinds,
|
||||
@@ -54,7 +55,7 @@ export const buildSortedIntegrations = (
|
||||
integrationKinds
|
||||
.filter((kind) => {
|
||||
if (options.allowedKinds && !options.allowedKinds.includes(kind)) return false;
|
||||
if (options.onboarding && integrationDefs[kind].features.onboarding.hidden) return false;
|
||||
if (options.onboarding && getIntegrationOnboardingMetadata(kind).hidden) return false;
|
||||
if (!options.enableMockIntegration && kind === "mock") return false;
|
||||
return true;
|
||||
})
|
||||
@@ -65,8 +66,8 @@ export const buildSortedIntegrations = (
|
||||
widgets: getWidgetKindsForIntegration(kind),
|
||||
}))
|
||||
.toSorted((left, right) => {
|
||||
const leftFeaturedOrder = integrationDefs[left.kind].features.onboarding.featuredOrder;
|
||||
const rightFeaturedOrder = integrationDefs[right.kind].features.onboarding.featuredOrder;
|
||||
const leftFeaturedOrder = getIntegrationOnboardingMetadata(left.kind).featuredOrder;
|
||||
const rightFeaturedOrder = getIntegrationOnboardingMetadata(right.kind).featuredOrder;
|
||||
if (leftFeaturedOrder !== null && rightFeaturedOrder !== null) return leftFeaturedOrder - rightFeaturedOrder;
|
||||
if (leftFeaturedOrder !== null) return -1;
|
||||
if (rightFeaturedOrder !== null) return 1;
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
IconCloud,
|
||||
IconDeviceCctv,
|
||||
IconDeviceGamepad,
|
||||
IconDownload,
|
||||
IconFileText,
|
||||
IconGraphFilled,
|
||||
IconHeadphones,
|
||||
@@ -55,17 +56,9 @@ import type { TablerIcon } from "@tabler/icons-react";
|
||||
|
||||
import type { WidgetKind } from "@homarr/definitions";
|
||||
|
||||
import { generatedWidgetCatalogIcons } from "./generated/widget-icons";
|
||||
|
||||
const {
|
||||
weather: generatedWeatherIcon,
|
||||
downloads: generatedDownloadsIcon,
|
||||
...additionalGeneratedWidgetIcons
|
||||
} = generatedWidgetCatalogIcons;
|
||||
|
||||
export const widgetCatalogIcons: Record<WidgetKind, TablerIcon> = {
|
||||
clock: IconClock,
|
||||
weather: generatedWeatherIcon,
|
||||
weather: IconCloud,
|
||||
airQuality: IconWind,
|
||||
countdown: IconHourglass,
|
||||
timer: IconClockPlay,
|
||||
@@ -82,7 +75,7 @@ export const widgetCatalogIcons: Record<WidgetKind, TablerIcon> = {
|
||||
stockPrice: IconBuildingBank,
|
||||
mediaServer: IconVideo,
|
||||
calendar: IconCalendar,
|
||||
downloads: generatedDownloadsIcon,
|
||||
downloads: IconDownload,
|
||||
"mediaRequests-requestList": IconZoomQuestion,
|
||||
"mediaRequests-requestStats": IconChartBar,
|
||||
mediaTranscoding: IconTransform,
|
||||
@@ -123,5 +116,4 @@ export const widgetCatalogIcons: Record<WidgetKind, TablerIcon> = {
|
||||
traefik: IconRoute,
|
||||
customApi: IconApi,
|
||||
wud: IconBrandDocker,
|
||||
...additionalGeneratedWidgetIcons,
|
||||
};
|
||||
Reference in new issue
Block a user