feat!: release v2 (#6545)
Co-authored-by: Artur <145776561+arturict@users.noreply.github.com> Co-authored-by: arturict <arturict@users.noreply.github.com> Co-authored-by: Thomas <thomas@ajnart.fr> Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com> Co-authored-by: Danura30082 <danura30082+github@gmail.com> Co-authored-by: Kushie <122986913+kushiemoon-dev@users.noreply.github.com> Co-authored-by: ajnart <thomas@ajnart.fr> Co-authored-by: ajnart <thomas@ajnart.dev> Co-authored-by: chenjun <chenjun@foxmail.com> Co-authored-by: Wikibear <wikibear@users.noreply.github.com> Co-authored-by: Bergasha <bergasha@gmail.com> Co-authored-by: leafyelin <43306196+leafyelin@users.noreply.github.com> Co-authored-by: Lucas Araujo <lucas.lra@gmail.com> Co-authored-by: GreenMonito <86085570+GreenMonito@users.noreply.github.com> Co-authored-by: Nerdy-Technician <roffo@nerdy-technician.social> Co-authored-by: Jun <34545896+jcstrong@users.noreply.github.com> Co-authored-by: Edmond Abraham <54119952+gitedmond@users.noreply.github.com> Co-authored-by: thrawnx <tight.bulb9384@fastmail.com> Co-authored-by: Chris <58918656+nordada@users.noreply.github.com> Co-authored-by: yi111 <153097222+Yi-111-a@users.noreply.github.com> Co-authored-by: Yanis <naamaneyanis@gmail.com> Co-authored-by: Wikibear <me@sej.de> Co-authored-by: alessiottavo <93441886+alessiottavo@users.noreply.github.com>
This commit is contained in:
3286 files changed
+284386
-139176
No files matched your search
@@ -1,7 +1,3 @@
|
||||
[data-mantine-color-scheme="light"] .card {
|
||||
background-color: var(--mantine-color-gray-1);
|
||||
}
|
||||
|
||||
[data-mantine-color-scheme="dark"] .card {
|
||||
background-color: var(--mantine-color-dark-7);
|
||||
.card {
|
||||
background-color: transparent;
|
||||
}
|
||||
@@ -8,39 +8,52 @@ import { clientApi } from "@homarr/api/client";
|
||||
import { useRequiredBoard } from "@homarr/boards/context";
|
||||
import { getIconUrl } from "@homarr/definitions";
|
||||
import type { WudContainerUpdate } from "@homarr/integrations";
|
||||
import { useScopedI18n } from "@homarr/translation/client";
|
||||
import { useI18n } from "@homarr/translation/client";
|
||||
import { zoomCompensatedSize } from "@homarr/ui";
|
||||
|
||||
import { WidgetEmptyState } from "../common/empty-state";
|
||||
import { getSafeApplicationUrl, SAFE_NEW_TAB_REL } from "../common/application-url";
|
||||
import type { WidgetComponentProps } from "../definition";
|
||||
import classes from "./component.module.css";
|
||||
|
||||
export default function WudWidget({ integrationIds, options, width }: WidgetComponentProps<"wud">) {
|
||||
export default function WudWidget({ integrationIds, options, width, displayMode }: WidgetComponentProps<"wud">) {
|
||||
const integrationId = integrationIds[0];
|
||||
if (!integrationId) return null;
|
||||
return <WudWidgetContent integrationId={integrationId} options={options} width={width} />;
|
||||
return (
|
||||
<WudWidgetContent
|
||||
integrationId={integrationId}
|
||||
options={options}
|
||||
width={width}
|
||||
isAdvanced={displayMode === "advanced"}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const WudWidgetContent = ({
|
||||
integrationId,
|
||||
options,
|
||||
width,
|
||||
isAdvanced,
|
||||
}: {
|
||||
integrationId: string;
|
||||
options: WidgetComponentProps<"wud">["options"];
|
||||
width: number;
|
||||
isAdvanced: boolean;
|
||||
}) => {
|
||||
const t = useScopedI18n("widget.wud");
|
||||
const t = useI18n("widget.wud");
|
||||
const [data] = clientApi.widget.wud.getStats.useSuspenseQuery({ integrationId });
|
||||
const board = useRequiredBoard();
|
||||
|
||||
const isTiny = width < 256;
|
||||
const isTiny = !isAdvanced && width < 256;
|
||||
const stats = data.stats;
|
||||
|
||||
if (stats.totalContainers === 0) return <WidgetEmptyState />;
|
||||
|
||||
const updatePercentage = Math.round((stats.updatesAvailable / stats.totalContainers) * 100);
|
||||
const badgeColor = stats.updatesAvailable === 0 ? "green" : progressColor(updatePercentage);
|
||||
const showUpdateList = options.showUpdateList && stats.updates.length > 0;
|
||||
const showTitle = isAdvanced || options.showTitle;
|
||||
const showRing = isAdvanced || options.showRing;
|
||||
const showUpdateList = (isAdvanced || options.showUpdateList) && stats.updates.length > 0;
|
||||
|
||||
const ring = (
|
||||
<RingProgress
|
||||
@@ -52,7 +65,7 @@ const WudWidgetContent = ({
|
||||
<Text size={isTiny ? "8px" : "xs"} fw={700}>
|
||||
{updatePercentage}%
|
||||
</Text>
|
||||
<IconBrandDocker size={isTiny ? 8 : 16} />
|
||||
<IconBrandDocker style={zoomCompensatedSize(isTiny ? 8 : 16)} />
|
||||
</Center>
|
||||
}
|
||||
sections={[{ value: updatePercentage, color: progressColor(updatePercentage) }]}
|
||||
@@ -73,7 +86,7 @@ const WudWidgetContent = ({
|
||||
</Stack>
|
||||
);
|
||||
|
||||
const tinyContent = options.showRing ? (
|
||||
const tinyContent = showRing ? (
|
||||
<Tooltip
|
||||
label={
|
||||
<Stack gap={2}>
|
||||
@@ -102,7 +115,7 @@ const WudWidgetContent = ({
|
||||
|
||||
return (
|
||||
<Stack p="xs" gap="xs" h="100%">
|
||||
{options.showTitle && !isTiny && (
|
||||
{showTitle && !isTiny && (
|
||||
<Group gap="xs" wrap="nowrap" justify="space-between" miw={0}>
|
||||
<Group gap="xs" wrap="nowrap" miw={0}>
|
||||
<Avatar size={20} radius="sm" src={getIconUrl("wud")} />
|
||||
@@ -122,12 +135,12 @@ const WudWidgetContent = ({
|
||||
tinyContent
|
||||
) : options.layout === "horizontal" ? (
|
||||
<Group justify="center" wrap="nowrap" gap="md">
|
||||
{options.showRing && ring}
|
||||
{showRing && ring}
|
||||
{summary}
|
||||
</Group>
|
||||
) : (
|
||||
<Stack align="center" gap="xs">
|
||||
{options.showRing && ring}
|
||||
{showRing && ring}
|
||||
{summary}
|
||||
</Stack>
|
||||
)}
|
||||
@@ -180,33 +193,34 @@ const UpdateCard = ({
|
||||
radius: string | undefined;
|
||||
className: string | undefined;
|
||||
}) => {
|
||||
const t = useScopedI18n("widget.wud");
|
||||
const t = useI18n("widget.wud");
|
||||
const href = getSafeApplicationUrl(update.link);
|
||||
const isDigestUpdate = isDigestVersion(update.newVersion);
|
||||
const fullVersionText = buildVersionText(update.currentVersion, update.newVersion);
|
||||
const versionText = isDigestUpdate
|
||||
? t("updateAvailable")
|
||||
: buildVersionText(truncateVersion(update.currentVersion), truncateVersion(update.newVersion));
|
||||
const versionBadge = versionText ? (
|
||||
<Badge size="xs" variant="subtle" color="gray" style={{ whiteSpace: "nowrap" }}>
|
||||
{versionText}
|
||||
</Badge>
|
||||
) : null;
|
||||
const showVersionTooltip = versionText !== null && !isDigestUpdate && versionText !== fullVersionText;
|
||||
|
||||
return (
|
||||
<Card className={combineClasses(className)} radius={radius} p="xs" style={{ overflow: "visible" }}>
|
||||
<Card className={combineClasses(className)} radius={radius} p="xs" bg="transparent" style={{ overflow: "visible" }}>
|
||||
<Group justify="space-between" wrap="nowrap" gap="xs" miw={0}>
|
||||
<Text size="xs" fw={500} lineClamp={1} miw={0}>
|
||||
{update.name}
|
||||
</Text>
|
||||
<Group gap={4} wrap="nowrap" style={{ flexShrink: 0 }}>
|
||||
{versionText && (
|
||||
<Tooltip label={fullVersionText} disabled={isDigestUpdate || versionText === fullVersionText}>
|
||||
<Badge size="xs" variant="light" color="gray" style={{ whiteSpace: "nowrap" }}>
|
||||
{versionText}
|
||||
</Badge>
|
||||
</Tooltip>
|
||||
)}
|
||||
{update.link && (
|
||||
{showVersionTooltip ? <Tooltip label={fullVersionText}>{versionBadge}</Tooltip> : versionBadge}
|
||||
{href && (
|
||||
<ActionIcon
|
||||
component="a"
|
||||
href={update.link}
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
rel={SAFE_NEW_TAB_REL}
|
||||
variant="subtle"
|
||||
color="gray"
|
||||
size="sm"
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { IconBrandDocker } from "@tabler/icons-react";
|
||||
|
||||
import { getWidgetIntegrationConfig } from "@homarr/definitions";
|
||||
|
||||
import { createWidgetDefinition } from "../definition";
|
||||
import { optionsBuilder } from "../options";
|
||||
|
||||
export const { definition, componentLoader } = createWidgetDefinition("wud", {
|
||||
icon: IconBrandDocker,
|
||||
supportsAdvancedFocus: true,
|
||||
refetchInterval: null,
|
||||
supportedIntegrations: ["wud"],
|
||||
...getWidgetIntegrationConfig("wud"),
|
||||
createOptions() {
|
||||
return optionsBuilder.from((factory) => ({
|
||||
showTitle: factory.switch({ defaultValue: true }),
|
||||
@@ -14,7 +17,7 @@ export const { definition, componentLoader } = createWidgetDefinition("wud", {
|
||||
layout: factory.select({
|
||||
options: (["horizontal", "vertical"] as const).map((value) => ({
|
||||
value,
|
||||
label: (t) => t(`widget.wud.option.layout.option.${value}.label`),
|
||||
label: (t) => t(`widget.common.layout.option.${value}`),
|
||||
})),
|
||||
defaultValue: "horizontal",
|
||||
}),
|
||||
|
||||
Reference in new issue
Block a user