mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-07 15:19:20 +01:00
🚚 Move all dashboard files in board directory
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
import { ComponentType } from 'react';
|
||||
import { ItemWrapper } from '~/components/Board/Items/ItemWrapper';
|
||||
import { WidgetsMenu } from '~/components/Board/Items/Widget/WidgetsMenu';
|
||||
import { WidgetItem } from '~/components/Board/context';
|
||||
import { HomarrCardWrapper } from '~/components/Dashboard/Tiles/HomarrCardWrapper';
|
||||
import { WidgetsMenu } from '~/components/Dashboard/Tiles/Widgets/WidgetsMenu';
|
||||
|
||||
import Widgets from '.';
|
||||
import ErrorBoundary from './boundary';
|
||||
import { IWidget } from './widgets';
|
||||
|
||||
interface WidgetWrapperProps {
|
||||
widgetType: string;
|
||||
widget: WidgetItem;
|
||||
className: string;
|
||||
WidgetComponent: ComponentType<{ widget: WidgetItem }>;
|
||||
}
|
||||
|
||||
// If a property has no value, set it to the default value
|
||||
const useWidget = <T extends WidgetItem>(widget: T): T => {
|
||||
const useWidgetWithDefaultOptionValues = <T extends WidgetItem>(widget: T): T => {
|
||||
const definition = Widgets[widget.sort];
|
||||
|
||||
const newProps = { ...widget.options };
|
||||
@@ -32,20 +30,15 @@ const useWidget = <T extends WidgetItem>(widget: T): T => {
|
||||
};
|
||||
};
|
||||
|
||||
export const WidgetWrapper = ({
|
||||
widgetType,
|
||||
widget,
|
||||
className,
|
||||
WidgetComponent,
|
||||
}: WidgetWrapperProps) => {
|
||||
const widgetWithDefaultProps = useWidget(widget);
|
||||
export const WidgetWrapper = ({ widget, className, WidgetComponent }: WidgetWrapperProps) => {
|
||||
const widgetWithDefaultProps = useWidgetWithDefaultOptionValues(widget);
|
||||
|
||||
return (
|
||||
<ErrorBoundary integration={widgetType} widget={widgetWithDefaultProps}>
|
||||
<HomarrCardWrapper className={className}>
|
||||
<WidgetsMenu type={widgetType} widget={widgetWithDefaultProps} />
|
||||
<ErrorBoundary widget={widgetWithDefaultProps}>
|
||||
<ItemWrapper className={className}>
|
||||
<WidgetsMenu widget={widgetWithDefaultProps} />
|
||||
<WidgetComponent widget={widgetWithDefaultProps} />
|
||||
</HomarrCardWrapper>
|
||||
</ItemWrapper>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ import { useEffect } from 'react';
|
||||
import React from 'react';
|
||||
import { v4 } from 'uuid';
|
||||
import { z } from 'zod';
|
||||
import { useEditModeStore } from '~/components/Dashboard/Views/useEditModeStore';
|
||||
import { useEditModeStore } from '~/components/Board/useEditModeStore';
|
||||
import { IconSelector } from '~/components/IconSelector/IconSelector';
|
||||
|
||||
import { defineWidget } from '../helper';
|
||||
|
||||
@@ -4,10 +4,8 @@ import { IconBrandGithub, IconBug, IconInfoCircle, IconRefresh } from '@tabler/i
|
||||
import Consola from 'consola';
|
||||
import { withTranslation } from 'next-i18next';
|
||||
import React, { ReactNode } from 'react';
|
||||
import { WidgetsMenu } from '~/components/Board/Items/Widget/WidgetsMenu';
|
||||
import { WidgetItem } from '~/components/Board/context';
|
||||
import { WidgetsMenu } from '~/components/Dashboard/Tiles/Widgets/WidgetsMenu';
|
||||
|
||||
import { IWidget } from './widgets';
|
||||
|
||||
type ErrorBoundaryState = {
|
||||
hasError: boolean;
|
||||
@@ -17,7 +15,6 @@ type ErrorBoundaryState = {
|
||||
type ErrorBoundaryProps = {
|
||||
t: (key: string) => string;
|
||||
children: ReactNode;
|
||||
integration: string;
|
||||
widget: WidgetItem;
|
||||
};
|
||||
|
||||
@@ -56,7 +53,7 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
|
||||
withBorder
|
||||
h="calc(100% - 20px)"
|
||||
>
|
||||
<WidgetsMenu type={this.props.integration} widget={this.props.widget} />
|
||||
<WidgetsMenu widget={this.props.widget} />
|
||||
<ScrollArea h="100%" type="auto" offsetScrollbars>
|
||||
<Center>
|
||||
<Stack align="center" spacing="xs">
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Calendar } from '@mantine/dates';
|
||||
import { IconCalendarTime } from '@tabler/icons-react';
|
||||
import { useSession } from 'next-auth/react';
|
||||
import { useState } from 'react';
|
||||
import { useEditModeStore } from '~/components/Dashboard/Views/useEditModeStore';
|
||||
import { useEditModeStore } from '~/components/Board/useEditModeStore';
|
||||
import { useConfigContext } from '~/config/provider';
|
||||
import { getLanguageByCode } from '~/tools/language';
|
||||
import { RouterOutputs, api } from '~/utils/api';
|
||||
|
||||
@@ -6,7 +6,7 @@ import { BubbleMenu, useEditor } from '@tiptap/react';
|
||||
import StarterKit from '@tiptap/starter-kit';
|
||||
import { useState } from 'react';
|
||||
import { useRequiredBoard } from '~/components/Board/context';
|
||||
import { useEditModeStore } from '~/components/Dashboard/Views/useEditModeStore';
|
||||
import { useEditModeStore } from '~/components/Board/useEditModeStore';
|
||||
import { useColorTheme } from '~/tools/color';
|
||||
import { api } from '~/utils/api';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user