mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
✨ Migrate tiles from id to type
This commit is contained in:
@@ -28,7 +28,7 @@ export const ChangeWidgetPositionModal = ({
|
||||
updateConfig(
|
||||
configName,
|
||||
(prev) => {
|
||||
const currentWidget = prev.widgets.find((x) => x.id === innerProps.widgetId);
|
||||
const currentWidget = prev.widgets.find((x) => x.type === innerProps.widgetType);
|
||||
currentWidget!.shape[shapeSize] = {
|
||||
location: {
|
||||
x,
|
||||
@@ -42,7 +42,10 @@ export const ChangeWidgetPositionModal = ({
|
||||
|
||||
return {
|
||||
...prev,
|
||||
widgets: [...prev.widgets.filter((x) => x.id !== innerProps.widgetId), currentWidget!],
|
||||
widgets: [
|
||||
...prev.widgets.filter((x) => x.type !== innerProps.widgetType),
|
||||
currentWidget!,
|
||||
],
|
||||
};
|
||||
},
|
||||
true
|
||||
@@ -54,8 +57,8 @@ export const ChangeWidgetPositionModal = ({
|
||||
closeModal(id);
|
||||
};
|
||||
|
||||
const widthData = useWidthData(innerProps.widgetId);
|
||||
const heightData = useHeightData(innerProps.widgetId);
|
||||
const widthData = useWidthData(innerProps.widgetType);
|
||||
const heightData = useHeightData(innerProps.widgetType);
|
||||
|
||||
return (
|
||||
<ChangePositionModal
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Grid, Text } from '@mantine/core';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useConfigContext } from '../../../../../../config/provider';
|
||||
import widgets from '../../../../../../widgets';
|
||||
import { SelectorBackArrow } from '../Shared/SelectorBackArrow';
|
||||
import { WidgetElementType } from './WidgetElementType';
|
||||
@@ -13,7 +12,6 @@ export const AvailableIntegrationElements = ({
|
||||
onClickBack,
|
||||
}: AvailableIntegrationElementsProps) => {
|
||||
const { t } = useTranslation('layout/element-selector/selector');
|
||||
const activeWidgets = useConfigContext().config?.widgets ?? [];
|
||||
return (
|
||||
<>
|
||||
<SelectorBackArrow onClickBack={onClickBack} />
|
||||
@@ -23,11 +21,9 @@ export const AvailableIntegrationElements = ({
|
||||
</Text>
|
||||
|
||||
<Grid>
|
||||
{Object.entries(widgets)
|
||||
.filter(([widgetId]) => !activeWidgets.some((aw) => aw.id === widgetId))
|
||||
.map(([k, v]) => (
|
||||
<WidgetElementType key={k} id={k} image={v.icon} widget={v} />
|
||||
))}
|
||||
{Object.entries(widgets).map(([k, v]) => (
|
||||
<WidgetElementType key={k} id={k} image={v.icon} widget={v} />
|
||||
))}
|
||||
</Grid>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useModals } from '@mantine/modals';
|
||||
import { showNotification } from '@mantine/notifications';
|
||||
import { IconChecks, TablerIcon } from '@tabler/icons';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { useConfigContext } from '../../../../../../config/provider';
|
||||
import { useConfigStore } from '../../../../../../config/store';
|
||||
import { IWidget, IWidgetDefinition } from '../../../../../../widgets/widgets';
|
||||
@@ -32,9 +33,10 @@ export const WidgetElementType = ({ id, image, disabled, widget }: WidgetElement
|
||||
(prev) => ({
|
||||
...prev,
|
||||
widgets: [
|
||||
...prev.widgets.filter((w) => w.id !== widget.id),
|
||||
...prev.widgets,
|
||||
{
|
||||
id: widget.id,
|
||||
id: uuidv4(),
|
||||
type: widget.id,
|
||||
properties: Object.entries(widget.options).reduce((prev, [k, v]) => {
|
||||
const newPrev = prev;
|
||||
newPrev[k] = v.defaultValue;
|
||||
|
||||
Reference in New Issue
Block a user