✨ Change integration structure to array and rename to widgets in config
This commit is contained in:
@@ -2,7 +2,7 @@ import { ReactNode, RefObject } from 'react';
|
||||
|
||||
interface GridstackTileWrapperProps {
|
||||
id: string;
|
||||
type: 'app' | 'module';
|
||||
type: 'app' | 'widget';
|
||||
x?: number;
|
||||
y?: number;
|
||||
width?: number;
|
||||
|
||||
@@ -47,15 +47,15 @@ export const WidgetsEditModal = ({
|
||||
const handleSave = () => {
|
||||
updateConfig(configName, (prev) => ({
|
||||
...prev,
|
||||
integrations: {
|
||||
...prev.integrations,
|
||||
widgets: {
|
||||
...prev.widgets,
|
||||
[innerProps.integration]:
|
||||
'properties' in (prev.integrations[innerProps.integration] ?? {})
|
||||
'properties' in (prev.widgets[innerProps.integration] ?? {})
|
||||
? {
|
||||
...prev.integrations[innerProps.integration],
|
||||
...prev.widgets[innerProps.integration],
|
||||
properties: moduleProperties,
|
||||
}
|
||||
: prev.integrations[innerProps.integration],
|
||||
: prev.widgets[innerProps.integration],
|
||||
},
|
||||
}));
|
||||
context.closeModal(id);
|
||||
|
||||
@@ -8,18 +8,18 @@ import { WidgetsRemoveModalInnerProps } from './WidgetsRemoveModal';
|
||||
|
||||
export type WidgetChangePositionModalInnerProps = {
|
||||
integration: string;
|
||||
module: IWidget<string, any>;
|
||||
widget: IWidget<string, any>;
|
||||
};
|
||||
|
||||
interface WidgetsMenuProps {
|
||||
integration: string;
|
||||
module: IWidget<string, any> | undefined;
|
||||
widget: IWidget<string, any> | undefined;
|
||||
}
|
||||
|
||||
export const WidgetsMenu = ({ integration, module }: WidgetsMenuProps) => {
|
||||
export const WidgetsMenu = ({ integration, widget }: WidgetsMenuProps) => {
|
||||
const { t } = useTranslation(`modules/${integration}`);
|
||||
|
||||
if (!module) return null;
|
||||
if (!widget) return null;
|
||||
|
||||
const handleDeleteClick = () => {
|
||||
openContextModalGeneric<WidgetsRemoveModalInnerProps>({
|
||||
@@ -38,7 +38,7 @@ export const WidgetsMenu = ({ integration, module }: WidgetsMenuProps) => {
|
||||
title: null,
|
||||
innerProps: {
|
||||
integration,
|
||||
module,
|
||||
widget: widget,
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -49,7 +49,7 @@ export const WidgetsMenu = ({ integration, module }: WidgetsMenuProps) => {
|
||||
title: <Title order={4}>{t('descriptor.settings.title')}</Title>,
|
||||
innerProps: {
|
||||
integration,
|
||||
options: module.properties,
|
||||
options: widget.properties,
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -59,7 +59,7 @@ export const WidgetsMenu = ({ integration, module }: WidgetsMenuProps) => {
|
||||
handleClickEdit={handleEditClick}
|
||||
handleClickChangePosition={handleChangeSizeClick}
|
||||
handleClickDelete={handleDeleteClick}
|
||||
displayEdit={module.properties !== undefined}
|
||||
displayEdit={widget.properties !== undefined}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user