From b98af7cacabd88cfa51f554e8edbe50680f0b99e Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Sun, 13 Feb 2022 22:40:54 +1100 Subject: [PATCH] Add temp save buttons for settings, reorder chats --- src/components/FormFooter.tsx | 36 ---- src/components/generic/Blur.tsx | 31 ---- .../layout/Sidebar/Settings/Channels.tsx | 67 ++----- .../layout/Sidebar/Settings/Position.tsx | 170 ++++++++++-------- .../layout/Sidebar/Settings/Power.tsx | 48 +++-- .../layout/Sidebar/Settings/Radio.tsx | 36 ++-- .../layout/Sidebar/Settings/User.tsx | 112 +++++++----- .../layout/Sidebar/Settings/WiFi.tsx | 82 +++++---- src/pages/Messages/index.tsx | 24 +-- src/pages/Nodes/NodeCard.tsx | 9 +- 10 files changed, 292 insertions(+), 323 deletions(-) delete mode 100644 src/components/FormFooter.tsx delete mode 100644 src/components/generic/Blur.tsx diff --git a/src/components/FormFooter.tsx b/src/components/FormFooter.tsx deleted file mode 100644 index 65cccfa4..00000000 --- a/src/components/FormFooter.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import type React from 'react'; - -import { FiSave, FiXCircle } from 'react-icons/fi'; - -import { IconButton } from '@meshtastic/components'; - -export interface FormFooterProps { - dirty?: boolean; - clearAction?: () => void; - saveAction?: () => void; -} - -export const FormFooter = ({ - dirty, - clearAction, - saveAction, -}: FormFooterProps): JSX.Element => { - return ( -
- } - disabled={!dirty} - onClick={(): void => { - clearAction && clearAction(); - }} - /> - { - saveAction && saveAction(); - }} - icon={} - /> -
- ); -}; diff --git a/src/components/generic/Blur.tsx b/src/components/generic/Blur.tsx deleted file mode 100644 index 1e72298c..00000000 --- a/src/components/generic/Blur.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import type React from 'react'; - -type DefaultDivProps = JSX.IntrinsicElements['div']; - -interface BlurProps extends DefaultDivProps { - disableOnMd?: boolean; -} - -export const Blur = ({ - disableOnMd, - className, - onClick, - ...props -}: BlurProps): JSX.Element => { - return ( -
-
-
- ); -}; diff --git a/src/components/layout/Sidebar/Settings/Channels.tsx b/src/components/layout/Sidebar/Settings/Channels.tsx index a1f5f934..90f24a93 100644 --- a/src/components/layout/Sidebar/Settings/Channels.tsx +++ b/src/components/layout/Sidebar/Settings/Channels.tsx @@ -1,17 +1,11 @@ import React from 'react'; import { useForm } from 'react-hook-form'; -import { FiExternalLink, FiX } from 'react-icons/fi'; -import { - RiArrowDownLine, - RiArrowUpDownLine, - RiArrowUpLine, -} from 'react-icons/ri'; +import { FiSave } from 'react-icons/fi'; -import { ListItem } from '@app/components/generic/ListItem'; import { connection } from '@core/connection'; import { useAppSelector } from '@hooks/useAppSelector'; -import { Checkbox, Input, Select, Tooltip } from '@meshtastic/components'; +import { Checkbox, IconButton, Input, Select } from '@meshtastic/components'; import { Protobuf } from '@meshtastic/meshtasticjs'; export const Channels = (): JSX.Element => { @@ -106,54 +100,19 @@ export const Channels = (): JSX.Element => { {...register('settings.txPower', { valueAsNumber: true })} /> +
+
+ => { + await onSubmit(); + }} + icon={} + /> +
+
)} - {channels.map((channel) => ( - { - setSelectedChannel(channel); - }} - status={ -
role === channel.role) - ? 'bg-green-500' - : 'bg-gray-400' - }`} - /> - } - selected={selectedChannel?.index === channel.index} - selectedIcon={} - actions={ - -
- {channel.settings?.uplinkEnabled && - channel.settings?.downlinkEnabled ? ( - - ) : channel.settings?.uplinkEnabled ? ( - - ) : channel.settings?.downlinkEnabled ? ( - - ) : ( - - )} -
-
- } - > -
- {channel.settings?.name.length - ? channel.settings.name - : channel.role === Protobuf.Channel_Role.PRIMARY - ? 'Primary' - : `Channel: ${channel.index}`} -
- - ))} ); }; diff --git a/src/components/layout/Sidebar/Settings/Position.tsx b/src/components/layout/Sidebar/Settings/Position.tsx index c1722e88..d7151c22 100644 --- a/src/components/layout/Sidebar/Settings/Position.tsx +++ b/src/components/layout/Sidebar/Settings/Position.tsx @@ -1,13 +1,14 @@ import React from 'react'; import { Controller, useForm } from 'react-hook-form'; +import { FiSave } from 'react-icons/fi'; import { MultiSelect } from 'react-multi-select-component'; import { bitwiseEncode } from '@app/core/utils/bitwise'; import { Label } from '@components/generic/form/Label'; import { connection } from '@core/connection'; import { useAppSelector } from '@hooks/useAppSelector'; -import { Checkbox, Input, Select } from '@meshtastic/components'; +import { Checkbox, IconButton, Input, Select } from '@meshtastic/components'; import { Protobuf } from '@meshtastic/meshtasticjs'; export const Position = (): JSX.Element => { @@ -54,87 +55,100 @@ export const Position = (): JSX.Element => { }; return ( -
- + <> + + - { - const { value, onChange, ...rest } = field; - const { error } = fieldState; - const label = 'Position Flags'; - return ( -
- {label &&
+ ); + }} + /> - - - - - - + + + + + + +
+
+ => { + await onSubmit(); + }} + icon={} + /> +
+
+ ); }; diff --git a/src/components/layout/Sidebar/Settings/Power.tsx b/src/components/layout/Sidebar/Settings/Power.tsx index 1a531316..9be2cbd3 100644 --- a/src/components/layout/Sidebar/Settings/Power.tsx +++ b/src/components/layout/Sidebar/Settings/Power.tsx @@ -1,10 +1,11 @@ import React from 'react'; import { useForm } from 'react-hook-form'; +import { FiSave } from 'react-icons/fi'; import { connection } from '@core/connection'; import { useAppSelector } from '@hooks/useAppSelector'; -import { Checkbox, Select } from '@meshtastic/components'; +import { Checkbox, IconButton, Select } from '@meshtastic/components'; import { Protobuf } from '@meshtastic/meshtasticjs'; export const Power = (): JSX.Element => { @@ -33,21 +34,34 @@ export const Power = (): JSX.Element => { }); }); return ( -
- + + + +
+
+ => { + await onSubmit(); + }} + icon={} + /> +
+
+ ); }; diff --git a/src/components/layout/Sidebar/Settings/Radio.tsx b/src/components/layout/Sidebar/Settings/Radio.tsx index df42ce9f..116f6a64 100644 --- a/src/components/layout/Sidebar/Settings/Radio.tsx +++ b/src/components/layout/Sidebar/Settings/Radio.tsx @@ -1,10 +1,11 @@ import React from 'react'; import { useForm } from 'react-hook-form'; +import { FiSave } from 'react-icons/fi'; import { connection } from '@core/connection'; import { useAppSelector } from '@hooks/useAppSelector'; -import { Checkbox, Select } from '@meshtastic/components'; +import { Checkbox, IconButton, Select } from '@meshtastic/components'; import { Protobuf } from '@meshtastic/meshtasticjs'; export const Radio = (): JSX.Element => { @@ -30,15 +31,28 @@ export const Radio = (): JSX.Element => { }); }); return ( -
- - + + + +
+
+ => { + await onSubmit(); + }} + icon={} + /> +
+
+ ); }; diff --git a/src/components/layout/Sidebar/Settings/User.tsx b/src/components/layout/Sidebar/Settings/User.tsx index 96600f30..c1f2476e 100644 --- a/src/components/layout/Sidebar/Settings/User.tsx +++ b/src/components/layout/Sidebar/Settings/User.tsx @@ -1,11 +1,12 @@ import React from 'react'; import { useForm } from 'react-hook-form'; +import { FiSave } from 'react-icons/fi'; import { base16 } from 'rfc4648'; import { connection } from '@core/connection'; import { useAppSelector } from '@hooks/useAppSelector'; -import { Checkbox, Input, Select } from '@meshtastic/components'; +import { Checkbox, IconButton, Input, Select } from '@meshtastic/components'; import { Protobuf } from '@meshtastic/meshtasticjs'; export const User = (): JSX.Element => { @@ -62,53 +63,66 @@ export const User = (): JSX.Element => { }); return ( -
- - - - - - - - - - + <> +
+ + + + + + + + + + +
+
+ => { + await onSubmit(); + }} + icon={} + /> +
+
+ ); }; diff --git a/src/components/layout/Sidebar/Settings/WiFi.tsx b/src/components/layout/Sidebar/Settings/WiFi.tsx index 6d44e325..da27c168 100644 --- a/src/components/layout/Sidebar/Settings/WiFi.tsx +++ b/src/components/layout/Sidebar/Settings/WiFi.tsx @@ -1,10 +1,11 @@ import React from 'react'; import { useForm, useWatch } from 'react-hook-form'; +import { FiSave } from 'react-icons/fi'; import { connection } from '@core/connection'; import { useAppSelector } from '@hooks/useAppSelector'; -import { Checkbox, Input } from '@meshtastic/components'; +import { Checkbox, IconButton, Input } from '@meshtastic/components'; import type { Protobuf } from '@meshtastic/meshtasticjs'; export const WiFi = (): JSX.Element => { @@ -42,38 +43,51 @@ export const WiFi = (): JSX.Element => { }); }); return ( -
- - - - - - - - + <> +
+ + + + + + + + +
+
+ => { + await onSubmit(); + }} + icon={} + /> +
+
+ ); }; diff --git a/src/pages/Messages/index.tsx b/src/pages/Messages/index.tsx index bda62c6c..dd854a20 100644 --- a/src/pages/Messages/index.tsx +++ b/src/pages/Messages/index.tsx @@ -38,12 +38,12 @@ export const Messages = (): JSX.Element => { icon={} sidebarContents={
- {nodes - .filter((node) => node.number !== myNodeNum) - .map((node) => ( - channel.settings?.name !== 'admin') + .map((channel) => ( + @@ -51,12 +51,12 @@ export const Messages = (): JSX.Element => { {nodes.length !== 0 && channels.length !== 0 && (
)} - {channels - .filter((channel) => channel.settings?.name !== 'admin') - .map((channel) => ( - node.number !== myNodeNum) + .map((node) => ( + diff --git a/src/pages/Nodes/NodeCard.tsx b/src/pages/Nodes/NodeCard.tsx index 795b8485..fe68f921 100644 --- a/src/pages/Nodes/NodeCard.tsx +++ b/src/pages/Nodes/NodeCard.tsx @@ -116,7 +116,14 @@ export const NodeCard = ({ direction="x" > }> -
Info
+
+
+ +
+ {node?.user?.longName || 'Unknown'} +
+
+
}>
Info