Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Network): add description field #848

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
}
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"typescript.tsdk": "node_modules/typescript/lib"
}
2 changes: 1 addition & 1 deletion src/components/common/AdvancedOptionsModal.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('AdvancedOptionsModal', () => {
let unmount: () => void;

const renderComponent = async (status?: Status, nodeName = 'alice') => {
const network = getNetwork(1, 'test network', status);
const network = getNetwork(1, 'test network', status?.toString());
const initialState = {
network: {
networks: [network],
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/RemoveNode.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('RemoveNode', () => {
nodeName = 'alice',
nodeType?: CommonNode['type'],
) => {
const network = getNetwork(1, 'test network', status, 2);
const network = getNetwork(1, 'test network', status?.toString(), 2);
// add an extra lightning node to the network without a connected tapd node
const lnd = defaultRepoState.images.LND;
network.nodes.lightning.push(
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/RestartNode.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const dockerServiceMock = injections.dockerService as jest.Mocked<DockerLibrary>

describe('RestartNode', () => {
const renderComponent = (status?: Status) => {
const network = getNetwork(1, 'test network', status);
const network = getNetwork(1, 'test network', status?.toString());
const initialState = {
network: {
networks: [network],
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/form/TapDataSelect.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('TapDataSelect', () => {
const handleChange: jest.Mock | undefined = jest.fn();

const renderComponent = (selectBalances = true, changeEvent = true) => {
const network = getNetwork(1, 'test network', Status.Started, 3);
const network = getNetwork(1, 'test network', Status.Started.toString(), 3);
const initialState = {
tap: {
nodes: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/form/TapNodeSelect.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import TapNodeSelect from './TapNodeSelect';

describe('TapNodeSelect', () => {
const renderComponent = () => {
const network = getNetwork(1, 'test network', Status.Stopped, 3);
const network = getNetwork(1, 'test network', Status.Stopped.toString(), 3);
const TestForm = () => {
const [form] = Form.useForm();
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/designer/AutoMineButton.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('AutoMineButton', () => {
let unmount: () => void;

const renderComponent = (autoMineMode: AutoMineMode = AutoMineMode.AutoOff) => {
const network = getNetwork(1, 'test network', Status.Started);
const network = getNetwork(1, 'test network', Status.Started.toString());
network.autoMineMode = autoMineMode;

const autoMiner = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/designer/LinkContextMenu.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('LinkContextMenu', () => {
},
});
const renderComponent = (link: ILink, activeId?: number) => {
const network = getNetwork(1, 'test network', Status.Started, 2);
const network = getNetwork(1, 'test network', Status.Started?.toString(), 2);
const chart = initChartFromNetwork(network);
chart.links[link.id] = link;
const initialState = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/designer/NetworkDesigner.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('NetworkDesigner Component', () => {
});

const renderComponent = (charts?: Record<number, IChart>, theme = 'dark') => {
const network = getNetwork(1, 'test network', Status.Stopped, 2);
const network = getNetwork(1, 'test network', Status.Stopped?.toString(), 2);
const allCharts = charts || {
1: initChartFromNetwork(network),
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/designer/NodeContextMenu.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import NodeContextMenu from './NodeContextMenu';

describe('NodeContextMenu', () => {
const renderComponent = (nodeName: string, status?: Status, activeId?: number) => {
const network = getNetwork(1, 'test network', status, 2);
const network = getNetwork(1, 'test network', status?.toString(), 2);
const chart = initChartFromNetwork(network);
if (nodeName === 'invalid') {
chart.nodes.alice.id = 'invalid';
Expand Down
2 changes: 1 addition & 1 deletion src/components/designer/Sidebar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Sidebar Component', () => {
selectedId?: string,
status?: Status,
) => {
const network = getNetwork(1, 'test network', status, 2);
const network = getNetwork(1, 'test network', status?.toString(), 2);
const chart = initChartFromNetwork(network);
if (selectedType && selectedId) {
chart.selected = { type: selectedType, id: selectedId };
Expand Down
2 changes: 1 addition & 1 deletion src/components/designer/bitcoind/BitcoindDetails.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import BitcoindDetails from './BitcoindDetails';

describe('BitcoindDetails', () => {
const renderComponent = (status?: Status, custom = false) => {
const network = getNetwork(1, 'test network', status);
const network = getNetwork(1, 'test network', status?.toString());
if (status === Status.Error) {
network.nodes.bitcoin.forEach(n => (n.errorMsg = 'test-error'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import MineBlocksInput from './MineBlocksInput';

describe('MineBlocksInput', () => {
const renderComponent = (status?: Status) => {
const network = getNetwork(1, 'test network', status, 2);
const network = getNetwork(1, 'test network', status?.toString(), 2);
const initialState = {
network: {
networks: [network],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('SendOnChainModal', () => {
const network = createNetwork({
id: 1,
name: 'test network',
description: 'test network description',
lndNodes: 2,
clightningNodes: 1,
eclairNodes: 1,
Expand Down
2 changes: 1 addition & 1 deletion src/components/designer/default/DefaultSidebar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('DefaultSidebar Component', () => {
];

const renderComponent = (status?: Status, images?: CustomImage[]) => {
const network = getNetwork(1, 'test network', status);
const network = getNetwork(1, 'test network', status?.toString());
const chart = initChartFromNetwork(network);
const initialState = {
app: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('ChangeBackendModal', () => {
lnName = 'alice',
backendName = 'backend1',
) => {
const network = getNetwork(1, 'test network', status);
const network = getNetwork(1, 'test network', status?.toString());
const oldBitcoind = createBitcoindNetworkNode(
network,
'0.18.1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('CreateInvoiceModal', () => {
let unmount: () => void;

const renderComponent = async (status?: Status, nodeName = 'alice') => {
const network = getNetwork(1, 'test network', status);
const network = getNetwork(1, 'test network', status?.toString());
const initialState = {
network: {
networks: [network],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('OpenChannelModal', () => {
let unmount: () => void;

const renderComponent = async (from = 'alice', to?: string) => {
const network = getNetwork(1, 'test network', Status.Started);
const network = getNetwork(1, 'test network', Status.Started?.toString());
const initialState = {
network: {
networks: [network],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('PayInvoiceModal', () => {
let unmount: () => void;

const renderComponent = async (status?: Status, nodeName = 'alice') => {
const network = getNetwork(1, 'test network', status);
const network = getNetwork(1, 'test network', status?.toString());
const initialState = {
network: {
networks: [network],
Expand Down
2 changes: 1 addition & 1 deletion src/components/designer/link/Channel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const bitcoindServiceMock = injections.bitcoindService as jest.Mocked<

describe('Channel component', () => {
const renderComponent = (status = Status.Stopped) => {
const network = getNetwork(1, 'test network', status);
const network = getNetwork(1, 'test network', status?.toString());
const lnd1 = network.nodes.lightning[0];
const lnd2 = network.nodes.lightning[3];
const link: ILink = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/designer/link/LinkDetails.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import LinkDetails from './LinkDetails';

describe('LinkDetails component', () => {
const renderComponent = (from: string, to: string, properties: any) => {
const network = getNetwork(1, 'test network', Status.Stopped, 2);
const network = getNetwork(1, 'test network', Status.Stopped?.toString(), 2);
network.nodes.bitcoin.push(
createBitcoindNetworkNode(network, '0.18.1', testNodeDocker),
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/designer/link/TapBackend.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const filesMock = files as jest.Mocked<typeof files>;

describe('TAP Lnd Link Component', () => {
const renderComponent = () => {
const network = getNetwork(1, 'test network', Status.Stopped, 1);
const network = getNetwork(1, 'test network', Status.Stopped?.toString(), 1);
const allCharts = {
1: initChartFromNetwork(network),
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/designer/tap/TapNodeDetails.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('TapDetails', () => {
};

beforeEach(() => {
network = getNetwork(1, 'test network', Status.Stopped, 2);
network = getNetwork(1, 'test network', Status.Stopped?.toString(), 2);
node = network.nodes.tap[0];
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('ChangeTapBackendModal', () => {
tapName = 'alice-tap',
lndName = 'alice',
) => {
const network = getNetwork(1, 'test network', status, 2);
const network = getNetwork(1, 'test network', status?.toString(), 2);
const { compatibility } = defaultRepoState.images.LND;
const otherLND = createLndNetworkNode(
network,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('MintAssetModal', () => {
let node: TapNode;

const renderComponent = async () => {
const network = getNetwork(1, 'test network', Status.Started, 2);
const network = getNetwork(1, 'test network', Status.Started?.toString(), 2);
node = network.nodes.tap[0];

const initialState = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('NewAddressModal', () => {
let unmount: () => void;

const renderComponent = async () => {
const network = getNetwork(1, 'test network', Status.Started, 2);
const network = getNetwork(1, 'test network', Status.Started?.toString(), 2);

const initialState = {
network: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('SendAssetModal', () => {
let unmount: () => void;

const renderComponent = async () => {
const network = getNetwork(1, 'test network', Status.Started, 2);
const network = getNetwork(1, 'test network', Status.Started?.toString(), 2);

const initialState = {
tap: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/home/NetworkCard.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NETWORK_VIEW } from 'components/routing';
import NetworkCard from './NetworkCard';

describe('NetworkCard component', () => {
const network = getNetwork(1, 'my network 1', Status.Stopped, 4);
const network = getNetwork(1, 'my network 1', Status.Stopped?.toString(), 4);
const renderComponent = () => {
const initialState = {
network: {
Expand Down
15 changes: 15 additions & 0 deletions src/components/home/NetworkCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ const Styled = {
Card: styled(Card)`
margin-top: 16px;
`,
description: styled.div`
width: 100%;
height: 100%;
display: flex;
flex-direction: row;
margin-bottom: 20px;
`,
title: styled.div`
margin-bottom: 2px;
color: #ffffff73;
`,
};

const NetworkCard: React.FC<{ network: Network }> = ({ network }) => {
Expand All @@ -28,6 +39,10 @@ const NetworkCard: React.FC<{ network: Network }> = ({ network }) => {
extra={<StatusBadge status={network.status} />}
onClick={handleClick}
>
<Row>
<Styled.title>{`Description`}</Styled.title>
<Styled.description>{network.description}</Styled.description>
</Row>
Comment on lines +42 to +45
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look good for networks without a description set. I also don't like the height of the card varying based on how long the description is. I would suggest using an "info" icon with a tooltip next to the name, and only display it if a description is defined.
image

<Row>
<Col span={8}>
<Statistic
Expand Down
4 changes: 2 additions & 2 deletions src/components/network/ImportNetwork.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('ImportNetwork component', () => {
});

it('should import a TAP network successfully', async () => {
network = getNetwork(1, 'tap network', Status.Stopped, 2);
network = getNetwork(1, 'tap network', Status.Stopped?.toString(), 2);
chart = initChartFromNetwork(network);
filesMock.read.mockResolvedValue(JSON.stringify({ network, chart }));
const { queryByLabelText, findByText, fileInput } = renderComponent();
Expand All @@ -171,7 +171,7 @@ describe('ImportNetwork component', () => {
});

it('should throw for an unknown TAP implementation', async () => {
network = getNetwork(1, 'tap network', Status.Stopped, 2);
network = getNetwork(1, 'tap network', Status.Stopped?.toString(), 2);
chart = initChartFromNetwork(network);
network.nodes.tap[0].implementation = 'asdf' as any;
filesMock.read.mockResolvedValue(JSON.stringify({ network, chart }));
Expand Down
2 changes: 1 addition & 1 deletion src/components/network/NetworkActions.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('NetworkActions Component', () => {
const handleExportClick = jest.fn();

const renderComponent = (status: Status) => {
const network = getNetwork(1, 'test network', status);
const network = getNetwork(1, 'test network', status?.toString());
network.nodes.bitcoin.forEach(n => (n.status = status));
const chart = initChartFromNetwork(network);
const initialState = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/network/NetworkView.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('NetworkView Component', () => {
images?: string[],
withBitcoinData = true,
) => {
const network = getNetwork(1, 'test network', status);
const network = getNetwork(1, 'test network', status?.toString());
const bitcoinData = {
nodes: {
'1-backend1': {
Expand Down
1 change: 1 addition & 0 deletions src/components/network/NetworkView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
<Styled.PageHeader
colors={theme.pageHeader}
title={network.name}
description={'network.description'}

Check failure on line 175 in src/components/network/NetworkView.tsx

View workflow job for this annotation

GitHub Actions / Run tests on ubuntu-latest

Type '{ colors: { background: string; border: string; }; title: string; description: string; onBack: () => void; tags: Element; extra: Element; }' is not assignable to type 'IntrinsicAttributes & PageHeaderProps & { theme?: Theme | undefined; } & { colors: { background: string; border: string; }; }'.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is causing a Typescript error because there is no description prop on the PageHeader component.

onBack={handleBackClick}
tags={<StatusTag status={network.status} />}
extra={
Expand Down
12 changes: 12 additions & 0 deletions src/components/network/NewNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ const NewNetwork: React.FC = () => {
>
<Input placeholder={l('namePhldr')} />
</Form.Item>

<Form.Item
name="description"
label={l('descriptionLabel')}
rules={[
{ required: true, message: l('cmps.forms.required') },
{ max: 80, message: 'Maximum length is 80 characters' },
]}
>
<Input placeholder={l('descriptionPhldr')} />
</Form.Item>

{customNodes.length > 0 && (
<>
<Styled.Divider orientation="left">{l('customLabel')}</Styled.Divider>
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@
"cmps.network.ImportNetwork.importError": "Could not import '{{file}}'",
"cmps.network.NewNetwork.title": "Create a new Lightning Network",
"cmps.network.NewNetwork.nameLabel": "Network Name",
"cmps.network.NewNetwork.descriptionLabel": "Network Description",
"cmps.network.NewNetwork.namePhldr": "My Lightning Simnet",
"cmps.network.NewNetwork.descriptionPhldr": "My Lightning Simnet Description",
"cmps.network.NewNetwork.customLabel": "How many Custom Nodes?",
"cmps.network.NewNetwork.managedLabel": "How many Managed Nodes?",
"cmps.network.NewNetwork.clightningWindows": "Not supported on Windows yet.",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/docker/composeFile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('ComposeFile', () => {
const clnNode = network.nodes.lightning[1] as CLightningNode;
// create a separate network for tap nodes because it won't include any
// c-lightning nodes
const tapNetwork = getNetwork(2, 'tap', Status.Stopped, 2);
const tapNetwork = getNetwork(2, 'tap', Status.Stopped?.toString(), 2);
const tapNode = tapNetwork.nodes.tap[0] as TapdNode;
const tapLndNode = network.nodes.lightning[0] as LndNode;

Expand Down
Loading
Loading