mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-09 15:05:48 +01:00
✨ Widget menu in error boundary (#979)
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"modal": {
|
"modal": {
|
||||||
"text": "",
|
"text": "An unexpected error has occurred. Please check your configuration. Please report this issue, if you believe that this is a bug.",
|
||||||
"label": "Your error",
|
"label": "Your error",
|
||||||
"reportButton": "Report this error"
|
"reportButton": "Report this error"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,15 @@ export const GenericTileMenu = ({
|
|||||||
return (
|
return (
|
||||||
<Menu withinPortal withArrow position="right">
|
<Menu withinPortal withArrow position="right">
|
||||||
<Menu.Target>
|
<Menu.Target>
|
||||||
<ActionIcon size="md" radius="md" variant="light" pos="absolute" top={8} right={8}>
|
<ActionIcon
|
||||||
|
size="md"
|
||||||
|
radius="md"
|
||||||
|
variant="light"
|
||||||
|
pos="absolute"
|
||||||
|
top={8}
|
||||||
|
right={8}
|
||||||
|
style={{ zIndex: 1 }}
|
||||||
|
>
|
||||||
<IconDots />
|
<IconDots />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Menu.Target>
|
</Menu.Target>
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export const WidgetWrapper = ({
|
|||||||
const widgetWithDefaultProps = useWidget(widget);
|
const widgetWithDefaultProps = useWidget(widget);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary>
|
<ErrorBoundary integration={widgetType} widget={widgetWithDefaultProps}>
|
||||||
<HomarrCardWrapper className={className}>
|
<HomarrCardWrapper className={className}>
|
||||||
<WidgetsMenu integration={widgetType} widget={widgetWithDefaultProps} />
|
<WidgetsMenu integration={widgetType} widget={widgetWithDefaultProps} />
|
||||||
<WidgetComponent widget={widgetWithDefaultProps} />
|
<WidgetComponent widget={widgetWithDefaultProps} />
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ import Consola from 'consola';
|
|||||||
import React, { ReactNode } from 'react';
|
import React, { ReactNode } from 'react';
|
||||||
import { openModal } from '@mantine/modals';
|
import { openModal } from '@mantine/modals';
|
||||||
import { withTranslation } from 'next-i18next';
|
import { withTranslation } from 'next-i18next';
|
||||||
import { Button, Card, Center, Code, Group, Stack, Text, Title } from '@mantine/core';
|
import { Button, Card, Center, Code, Group, ScrollArea, Stack, Text, Title } from '@mantine/core';
|
||||||
import { IconBrandGithub, IconBug, IconInfoCircle, IconRefresh } from '@tabler/icons-react';
|
import { IconBrandGithub, IconBug, IconInfoCircle, IconRefresh } from '@tabler/icons-react';
|
||||||
|
import { WidgetsMenu } from '../components/Dashboard/Tiles/Widgets/WidgetsMenu';
|
||||||
|
import { IWidget } from './widgets';
|
||||||
|
|
||||||
type ErrorBoundaryState = {
|
type ErrorBoundaryState = {
|
||||||
hasError: boolean;
|
hasError: boolean;
|
||||||
@@ -13,6 +15,8 @@ type ErrorBoundaryState = {
|
|||||||
type ErrorBoundaryProps = {
|
type ErrorBoundaryProps = {
|
||||||
t: (key: string) => string;
|
t: (key: string) => string;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
|
integration: string;
|
||||||
|
widget: IWidget<string, any>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,12 +52,15 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
|
|||||||
radius="lg"
|
radius="lg"
|
||||||
shadow="sm"
|
shadow="sm"
|
||||||
withBorder
|
withBorder
|
||||||
|
h="calc(100% - 20px)"
|
||||||
>
|
>
|
||||||
|
<WidgetsMenu integration={this.props.integration} widget={this.props.widget} />
|
||||||
|
<ScrollArea h="100%" type="auto" offsetScrollbars>
|
||||||
<Center>
|
<Center>
|
||||||
<Stack align="center">
|
<Stack align="center" spacing="xs">
|
||||||
<IconBug color="white" />
|
<IconBug color="white" />
|
||||||
<Stack spacing={0} align="center">
|
<Stack spacing={0} align="center">
|
||||||
<Title order={4} color="white" align="center">
|
<Title order={5} color="white" align="center">
|
||||||
{this.props.t('card.title')}
|
{this.props.t('card.title')}
|
||||||
</Title>
|
</Title>
|
||||||
{this.state.error && (
|
{this.state.error && (
|
||||||
@@ -62,7 +69,7 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
|
|||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Group>
|
<Group spacing="xs">
|
||||||
<Button
|
<Button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
openModal({
|
openModal({
|
||||||
@@ -115,6 +122,7 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
|
|||||||
</Group>
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Center>
|
</Center>
|
||||||
|
</ScrollArea>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ interface DateTileProps {
|
|||||||
function DateTile({ widget }: DateTileProps) {
|
function DateTile({ widget }: DateTileProps) {
|
||||||
const date = useDateState();
|
const date = useDateState();
|
||||||
const formatString = widget.properties.display24HourFormat ? 'HH:mm' : 'h:mm A';
|
const formatString = widget.properties.display24HourFormat ? 'HH:mm' : 'h:mm A';
|
||||||
const { width, height, ref } = useElementSize();
|
const { width, ref } = useElementSize();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack ref={ref} spacing="xs" justify="space-around" align="center" style={{ height: '100%' }}>
|
<Stack ref={ref} spacing="xs" justify="space-around" align="center" style={{ height: '100%' }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user