Browse Source

refactor(sidebar): update LND sidebar componenets to support c-lightning

master
jamaljsr 5 years ago
parent
commit
61ffdea9c6
  1. 9
      src/components/designer/Sidebar.tsx
  2. 4
      src/components/designer/lnd/ActionsTab.tsx
  3. 18
      src/components/designer/lnd/ConnectTab.tsx
  4. 4
      src/components/designer/lnd/InfoTab.tsx
  5. 6
      src/components/designer/lnd/LndDetails.tsx
  6. 4
      src/components/designer/lnd/actions/Deposit.tsx
  7. 4
      src/components/designer/lnd/actions/OpenChannelButtons.tsx
  8. 4
      src/components/designer/lnd/actions/RemoveNode.tsx
  9. 4
      src/components/terminal/OpenTerminalButton.tsx

9
src/components/designer/Sidebar.tsx

@ -1,10 +1,9 @@
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import { IChart } from '@mrblenny/react-flow-chart'; import { IChart } from '@mrblenny/react-flow-chart';
import { LightningNode, LndNode } from 'shared/types'; import { LightningNode } from 'shared/types';
import { Network } from 'types'; import { Network } from 'types';
import BitcoindDetails from './bitcoind/BitcoindDetails'; import BitcoindDetails from './bitcoind/BitcoindDetails';
import DefaultSidebar from './default/DefaultSidebar'; import DefaultSidebar from './default/DefaultSidebar';
import LightningNodeDetails from './lightning/LightningNodeDetails';
import LinkDetails from './link/LinkDetails'; import LinkDetails from './link/LinkDetails';
import LndDetails from './lnd/LndDetails'; import LndDetails from './lnd/LndDetails';
@ -22,10 +21,8 @@ const Sidebar: React.FC<Props> = ({ network, chart }) => {
const node = bitcoin.find(n => n.name === id) || lightning.find(n => n.name === id); const node = bitcoin.find(n => n.name === id) || lightning.find(n => n.name === id);
if (node && node.implementation === 'bitcoind') { if (node && node.implementation === 'bitcoind') {
return <BitcoindDetails node={node} />; return <BitcoindDetails node={node} />;
} else if (node && node.implementation === 'LND') { } else if (node && node.type === 'lightning') {
return <LndDetails node={node as LndNode} />; return <LndDetails node={node as LightningNode} />;
} else if (node && node.implementation === 'c-lightning') {
return <LightningNodeDetails node={node as LightningNode} />;
} }
} else if (type === 'link' && id) { } else if (type === 'link' && id) {
const link = chart.links[id]; const link = chart.links[id];

4
src/components/designer/lnd/ActionsTab.tsx

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { LndNode, Status } from 'shared/types'; import { LightningNode, Status } from 'shared/types';
import { OpenTerminalButton } from 'components/terminal'; import { OpenTerminalButton } from 'components/terminal';
import { Deposit, OpenChannelButtons, RemoveNode } from './actions'; import { Deposit, OpenChannelButtons, RemoveNode } from './actions';
@ -11,7 +11,7 @@ const Styled = {
}; };
interface Props { interface Props {
node: LndNode; node: LightningNode;
} }
const ActionsTab: React.FC<Props> = ({ node }) => { const ActionsTab: React.FC<Props> = ({ node }) => {

18
src/components/designer/lnd/ConnectTab.tsx

@ -2,7 +2,7 @@ import React, { ReactNode, useState } from 'react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { Icon, Radio } from 'antd'; import { Icon, Radio } from 'antd';
import { usePrefixedTranslation } from 'hooks'; import { usePrefixedTranslation } from 'hooks';
import { LndNode, Status } from 'shared/types'; import { LightningNode, LndNode, Status } from 'shared/types';
import { useStoreActions, useStoreState } from 'store'; import { useStoreActions, useStoreState } from 'store';
import { ellipseInner } from 'utils/strings'; import { ellipseInner } from 'utils/strings';
import CopyIcon from 'components/common/CopyIcon'; import CopyIcon from 'components/common/CopyIcon';
@ -30,7 +30,7 @@ const Styled = {
}; };
interface Props { interface Props {
node: LndNode; node: LightningNode;
} }
const ConnectTab: React.FC<Props> = ({ node }) => { const ConnectTab: React.FC<Props> = ({ node }) => {
@ -47,6 +47,12 @@ const ConnectTab: React.FC<Props> = ({ node }) => {
return <>{l('notStarted')}</>; return <>{l('notStarted')}</>;
} }
if (node.implementation !== 'LND') {
return <div>{`${node.implementation} coming soon..`}</div>;
}
const lndNode = node as LndNode;
const grpcHost = `127.0.0.1:${node.ports.grpc}`; const grpcHost = `127.0.0.1:${node.ports.grpc}`;
const restHost = `https://127.0.0.1:${node.ports.rest}`; const restHost = `https://127.0.0.1:${node.ports.rest}`;
const hosts: DetailValues = [ const hosts: DetailValues = [
@ -75,10 +81,10 @@ const ConnectTab: React.FC<Props> = ({ node }) => {
}); });
const authCmps: Record<string, ReactNode> = { const authCmps: Record<string, ReactNode> = {
paths: <FilePaths node={node} />, paths: <FilePaths node={lndNode} />,
hex: <EncodedStrings node={node} encoding="hex" />, hex: <EncodedStrings node={lndNode} encoding="hex" />,
base64: <EncodedStrings node={node} encoding="base64" />, base64: <EncodedStrings node={lndNode} encoding="base64" />,
lndc: <LndConnect node={node} />, lndc: <LndConnect node={lndNode} />,
}; };
return ( return (

4
src/components/designer/lnd/InfoTab.tsx

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { Alert, Tooltip } from 'antd'; import { Alert, Tooltip } from 'antd';
import { usePrefixedTranslation } from 'hooks'; import { usePrefixedTranslation } from 'hooks';
import { LndNode, Status } from 'shared/types'; import { LightningNode, Status } from 'shared/types';
import { useStoreState } from 'store'; import { useStoreState } from 'store';
import { ellipseInner } from 'utils/strings'; import { ellipseInner } from 'utils/strings';
import { format } from 'utils/units'; import { format } from 'utils/units';
@ -10,7 +10,7 @@ import CopyIcon from 'components/common/CopyIcon';
import DetailsList, { DetailValues } from 'components/common/DetailsList'; import DetailsList, { DetailValues } from 'components/common/DetailsList';
interface Props { interface Props {
node: LndNode; node: LightningNode;
} }
const InfoTab: React.FC<Props> = ({ node }) => { const InfoTab: React.FC<Props> = ({ node }) => {

6
src/components/designer/lnd/LndDetails.tsx

@ -2,7 +2,7 @@ import React, { ReactNode, useState } from 'react';
import { useAsync } from 'react-async-hook'; import { useAsync } from 'react-async-hook';
import { Alert, Icon } from 'antd'; import { Alert, Icon } from 'antd';
import { usePrefixedTranslation } from 'hooks'; import { usePrefixedTranslation } from 'hooks';
import { LndNode, Status } from 'shared/types'; import { LightningNode, Status } from 'shared/types';
import { useStoreActions, useStoreState } from 'store'; import { useStoreActions, useStoreState } from 'store';
import { abbreviate } from 'utils/numbers'; import { abbreviate } from 'utils/numbers';
import { Loader } from 'components/common'; import { Loader } from 'components/common';
@ -12,7 +12,7 @@ import ConnectTab from './ConnectTab';
import InfoTab from './InfoTab'; import InfoTab from './InfoTab';
interface Props { interface Props {
node: LndNode; node: LightningNode;
} }
const LndDetails: React.FC<Props> = ({ node }) => { const LndDetails: React.FC<Props> = ({ node }) => {
@ -20,7 +20,7 @@ const LndDetails: React.FC<Props> = ({ node }) => {
const [activeTab, setActiveTab] = useState('info'); const [activeTab, setActiveTab] = useState('info');
const { getInfo, getWalletBalance, getChannels } = useStoreActions(s => s.lnd); const { getInfo, getWalletBalance, getChannels } = useStoreActions(s => s.lnd);
const getInfoAsync = useAsync( const getInfoAsync = useAsync(
async (node: LndNode) => { async (node: LightningNode) => {
if (node.status !== Status.Started) return; if (node.status !== Status.Started) return;
await getInfo(node); await getInfo(node);
await getWalletBalance(node); await getWalletBalance(node);

4
src/components/designer/lnd/actions/Deposit.tsx

@ -2,13 +2,13 @@ import React, { useState } from 'react';
import { useAsyncCallback } from 'react-async-hook'; import { useAsyncCallback } from 'react-async-hook';
import { Button, Form, Input, InputNumber } from 'antd'; import { Button, Form, Input, InputNumber } from 'antd';
import { usePrefixedTranslation } from 'hooks'; import { usePrefixedTranslation } from 'hooks';
import { LndNode } from 'shared/types'; import { LightningNode } from 'shared/types';
import { useStoreActions } from 'store'; import { useStoreActions } from 'store';
import { format } from 'utils/units'; import { format } from 'utils/units';
const InputGroup = Input.Group; const InputGroup = Input.Group;
const LndDeposit: React.FC<{ node: LndNode }> = ({ node }) => { const LndDeposit: React.FC<{ node: LightningNode }> = ({ node }) => {
const { l } = usePrefixedTranslation('cmps.designer.lnd.actions.Deposit'); const { l } = usePrefixedTranslation('cmps.designer.lnd.actions.Deposit');
const [amount, setAmount] = useState(1000000); const [amount, setAmount] = useState(1000000);
const { notify } = useStoreActions(s => s.app); const { notify } = useStoreActions(s => s.app);

4
src/components/designer/lnd/actions/OpenChannelButtons.tsx

@ -2,7 +2,7 @@ import React from 'react';
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { Button, Form, Icon } from 'antd'; import { Button, Form, Icon } from 'antd';
import { usePrefixedTranslation } from 'hooks'; import { usePrefixedTranslation } from 'hooks';
import { LndNode } from 'shared/types'; import { LightningNode } from 'shared/types';
import { useStoreActions } from 'store'; import { useStoreActions } from 'store';
const Styled = { const Styled = {
@ -12,7 +12,7 @@ const Styled = {
}; };
interface Props { interface Props {
node: LndNode; node: LightningNode;
} }
const OpenChannelButtons: React.FC<Props> = ({ node }) => { const OpenChannelButtons: React.FC<Props> = ({ node }) => {

4
src/components/designer/lnd/actions/RemoveNode.tsx

@ -1,11 +1,11 @@
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { Button, Form, Modal } from 'antd'; import { Button, Form, Modal } from 'antd';
import { usePrefixedTranslation } from 'hooks'; import { usePrefixedTranslation } from 'hooks';
import { LndNode } from 'shared/types'; import { LightningNode } from 'shared/types';
import { useStoreActions } from 'store'; import { useStoreActions } from 'store';
interface Props { interface Props {
node: LndNode; node: LightningNode;
} }
const RemoveNode: React.FC<Props> = ({ node }) => { const RemoveNode: React.FC<Props> = ({ node }) => {

4
src/components/terminal/OpenTerminalButton.tsx

@ -2,13 +2,13 @@ import React from 'react';
import { useAsyncCallback } from 'react-async-hook'; import { useAsyncCallback } from 'react-async-hook';
import { Button, Form } from 'antd'; import { Button, Form } from 'antd';
import { usePrefixedTranslation } from 'hooks'; import { usePrefixedTranslation } from 'hooks';
import { BitcoinNode, LndNode } from 'shared/types'; import { BitcoinNode, LightningNode } from 'shared/types';
import { useStoreActions } from 'store'; import { useStoreActions } from 'store';
import { getContainerName } from 'utils/network'; import { getContainerName } from 'utils/network';
import { TERMINAL } from 'components/routing'; import { TERMINAL } from 'components/routing';
interface Props { interface Props {
node: LndNode | BitcoinNode; node: LightningNode | BitcoinNode;
} }
const OpenTerminalButton: React.FC<Props> = ({ node }) => { const OpenTerminalButton: React.FC<Props> = ({ node }) => {

Loading…
Cancel
Save