From e93a3a3b5f7caa0f213c000951016d0ab9e5c847 Mon Sep 17 00:00:00 2001 From: Thomas Camlong Date: Tue, 28 Jun 2022 11:27:23 +0200 Subject: [PATCH] :sparkles: Add support for lists in module option This feature allows a module maker to use a list as the different possible values for a module integration. --- src/components/modules/moduleWrapper.tsx | 41 ++++++++++++++++++++++-- src/components/modules/modules.tsx | 3 +- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/components/modules/moduleWrapper.tsx b/src/components/modules/moduleWrapper.tsx index a28cde8a8..c7423f658 100644 --- a/src/components/modules/moduleWrapper.tsx +++ b/src/components/modules/moduleWrapper.tsx @@ -1,10 +1,18 @@ -import { Button, Card, Group, Menu, Switch, TextInput, useMantineColorScheme } from '@mantine/core'; +import { + Button, + Card, + Group, + Menu, + MultiSelect, + Switch, + TextInput, + useMantineColorScheme, +} from '@mantine/core'; import { useConfig } from '../../tools/state'; import { IModule } from './modules'; function getItems(module: IModule) { const { config, setConfig } = useConfig(); - const enabledModules = config.modules ?? {}; const items: JSX.Element[] = []; if (module.options) { const keys = Object.keys(module.options); @@ -15,6 +23,35 @@ function getItems(module: IModule) { types.forEach((type, index) => { const optionName = `${module.title}.${keys[index]}`; const moduleInConfig = config.modules?.[module.title]; + if (type === 'object') { + items.push( + { + setConfig({ + ...config, + modules: { + ...config.modules, + [module.title]: { + ...moduleInConfig, + options: { + ...moduleInConfig?.options, + [keys[index]]: { + ...moduleInConfig?.options?.[keys[index]], + value, + }, + }, + }, + }, + }); + }} + /> + ); + } if (type === 'string') { items.push(