mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-09 23:15:46 +01:00
🐛 Fix issues with updating tiles
This commit is contained in:
@@ -28,7 +28,7 @@ export const ChangeWidgetPositionModal = ({
|
|||||||
updateConfig(
|
updateConfig(
|
||||||
configName,
|
configName,
|
||||||
(prev) => {
|
(prev) => {
|
||||||
const currentWidget = prev.widgets.find((x) => x.type === innerProps.widgetType);
|
const currentWidget = prev.widgets.find((x) => x.id === innerProps.widgetId);
|
||||||
currentWidget!.shape[shapeSize] = {
|
currentWidget!.shape[shapeSize] = {
|
||||||
location: {
|
location: {
|
||||||
x,
|
x,
|
||||||
@@ -42,10 +42,7 @@ export const ChangeWidgetPositionModal = ({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
widgets: [
|
widgets: [...prev.widgets.filter((x) => x.id !== innerProps.widgetId), currentWidget!],
|
||||||
...prev.widgets.filter((x) => x.type !== innerProps.widgetType),
|
|
||||||
currentWidget!,
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { IWidget } from '../../../../widgets/widgets';
|
|||||||
import { DraggableList } from './DraggableList';
|
import { DraggableList } from './DraggableList';
|
||||||
|
|
||||||
export type WidgetEditModalInnerProps = {
|
export type WidgetEditModalInnerProps = {
|
||||||
|
widgetId: string;
|
||||||
widgetType: string;
|
widgetType: string;
|
||||||
options: IWidget<string, any>['properties'];
|
options: IWidget<string, any>['properties'];
|
||||||
widgetOptions: IWidget<string, any>['properties'];
|
widgetOptions: IWidget<string, any>['properties'];
|
||||||
@@ -37,7 +38,6 @@ export const WidgetsEditModal = ({
|
|||||||
id,
|
id,
|
||||||
innerProps,
|
innerProps,
|
||||||
}: ContextModalProps<WidgetEditModalInnerProps>) => {
|
}: ContextModalProps<WidgetEditModalInnerProps>) => {
|
||||||
console.log('?');
|
|
||||||
const { t } = useTranslation([`modules/${innerProps.widgetType}`, 'common']);
|
const { t } = useTranslation([`modules/${innerProps.widgetType}`, 'common']);
|
||||||
const [moduleProperties, setModuleProperties] = useState(innerProps.options);
|
const [moduleProperties, setModuleProperties] = useState(innerProps.options);
|
||||||
const items = Object.entries(innerProps.widgetOptions ?? {}) as [
|
const items = Object.entries(innerProps.widgetOptions ?? {}) as [
|
||||||
@@ -64,15 +64,12 @@ export const WidgetsEditModal = ({
|
|||||||
updateConfig(
|
updateConfig(
|
||||||
configName,
|
configName,
|
||||||
(prev) => {
|
(prev) => {
|
||||||
const currentWidget = prev.widgets.find((x) => x.type === innerProps.widgetType);
|
const currentWidget = prev.widgets.find((x) => x.id === innerProps.widgetId);
|
||||||
currentWidget!.properties = moduleProperties;
|
currentWidget!.properties = moduleProperties;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
widgets: [
|
widgets: [...prev.widgets.filter((x) => x.id !== innerProps.widgetId), currentWidget!],
|
||||||
...prev.widgets.filter((x) => x.type !== innerProps.widgetType),
|
|
||||||
currentWidget!,
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
@@ -80,8 +77,6 @@ export const WidgetsEditModal = ({
|
|||||||
context.closeModal(id);
|
context.closeModal(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('??');
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack>
|
<Stack>
|
||||||
{items.map(([key, _], index) => {
|
{items.map(([key, _], index) => {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { WidgetEditModalInnerProps } from './WidgetsEditModal';
|
|||||||
import { WidgetsRemoveModalInnerProps } from './WidgetsRemoveModal';
|
import { WidgetsRemoveModalInnerProps } from './WidgetsRemoveModal';
|
||||||
|
|
||||||
export type WidgetChangePositionModalInnerProps = {
|
export type WidgetChangePositionModalInnerProps = {
|
||||||
|
widgetId: string;
|
||||||
widgetType: string;
|
widgetType: string;
|
||||||
widget: IWidget<string, any>;
|
widget: IWidget<string, any>;
|
||||||
wrapperColumnCount: number;
|
wrapperColumnCount: number;
|
||||||
@@ -38,14 +39,9 @@ export const WidgetsMenu = ({ integration, widget }: WidgetsMenuProps) => {
|
|||||||
modal: 'integrationRemove',
|
modal: 'integrationRemove',
|
||||||
title: <Title order={4}>{t('common:remove')}</Title>,
|
title: <Title order={4}>{t('common:remove')}</Title>,
|
||||||
innerProps: {
|
innerProps: {
|
||||||
|
widgetId: widget.id,
|
||||||
widgetType: integration,
|
widgetType: integration,
|
||||||
},
|
},
|
||||||
styles: {
|
|
||||||
inner: {
|
|
||||||
position: 'sticky',
|
|
||||||
top: 30,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -55,6 +51,7 @@ export const WidgetsMenu = ({ integration, widget }: WidgetsMenuProps) => {
|
|||||||
size: 'xl',
|
size: 'xl',
|
||||||
title: null,
|
title: null,
|
||||||
innerProps: {
|
innerProps: {
|
||||||
|
widgetId: widget.id,
|
||||||
widgetType: integration,
|
widgetType: integration,
|
||||||
widget,
|
widget,
|
||||||
wrapperColumnCount,
|
wrapperColumnCount,
|
||||||
@@ -65,8 +62,9 @@ export const WidgetsMenu = ({ integration, widget }: WidgetsMenuProps) => {
|
|||||||
const handleEditClick = () => {
|
const handleEditClick = () => {
|
||||||
openContextModalGeneric<WidgetEditModalInnerProps>({
|
openContextModalGeneric<WidgetEditModalInnerProps>({
|
||||||
modal: 'integrationOptions',
|
modal: 'integrationOptions',
|
||||||
title: t('descriptor.settings.title'),
|
title: <Title order={4}>{t('descriptor.settings.title')}</Title>,
|
||||||
innerProps: {
|
innerProps: {
|
||||||
|
widgetId: widget.id,
|
||||||
widgetType: integration,
|
widgetType: integration,
|
||||||
options: widget.properties,
|
options: widget.properties,
|
||||||
// Cast as the right type for the correct widget
|
// Cast as the right type for the correct widget
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { useConfigContext } from '../../../../config/provider';
|
|||||||
import { useConfigStore } from '../../../../config/store';
|
import { useConfigStore } from '../../../../config/store';
|
||||||
|
|
||||||
export type WidgetsRemoveModalInnerProps = {
|
export type WidgetsRemoveModalInnerProps = {
|
||||||
|
widgetId: string;
|
||||||
widgetType: string;
|
widgetType: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,7 +24,7 @@ export const WidgetsRemoveModal = ({
|
|||||||
configName,
|
configName,
|
||||||
(prev) => ({
|
(prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
widgets: prev.widgets.filter((w) => w.type !== innerProps.widgetType),
|
widgets: prev.widgets.filter((w) => w.id !== innerProps.widgetId),
|
||||||
}),
|
}),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ export function WrapperContent({ apps, refs, widgets }: WrapperContentProps) {
|
|||||||
| IWidgetDefinition
|
| IWidgetDefinition
|
||||||
| undefined;
|
| undefined;
|
||||||
if (!definition) return null;
|
if (!definition) return null;
|
||||||
console.log(definition);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<GridstackTileWrapper
|
<GridstackTileWrapper
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export const useConfigStore = create<UseConfigStoreType>((set, get) => ({
|
|||||||
const previousConfig: ConfigType = JSON.parse(JSON.stringify(currentConfig.value));
|
const previousConfig: ConfigType = JSON.parse(JSON.stringify(currentConfig.value));
|
||||||
|
|
||||||
const updatedConfig = updateCallback(currentConfig.value);
|
const updatedConfig = updateCallback(currentConfig.value);
|
||||||
|
|
||||||
set((old) => ({
|
set((old) => ({
|
||||||
...old,
|
...old,
|
||||||
configs: [
|
configs: [
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ interface WidgetWrapperProps {
|
|||||||
const useWidget = <T extends IWidget<string, any>>(widget: T): T => {
|
const useWidget = <T extends IWidget<string, any>>(widget: T): T => {
|
||||||
const definition = Widgets[widget.type as keyof typeof Widgets];
|
const definition = Widgets[widget.type as keyof typeof Widgets];
|
||||||
|
|
||||||
return useMemo(() => {
|
|
||||||
const newProps = { ...widget.properties };
|
const newProps = { ...widget.properties };
|
||||||
|
|
||||||
Object.entries(definition.options).forEach(([key, option]) => {
|
Object.entries(definition.options).forEach(([key, option]) => {
|
||||||
@@ -29,7 +28,6 @@ const useWidget = <T extends IWidget<string, any>>(widget: T): T => {
|
|||||||
...widget,
|
...widget,
|
||||||
properties: newProps,
|
properties: newProps,
|
||||||
};
|
};
|
||||||
}, [widget]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const WidgetWrapper = ({
|
export const WidgetWrapper = ({
|
||||||
|
|||||||
Reference in New Issue
Block a user