Skip to content

Commit

Permalink
chore(delete-nodes): rename to [un]reachable
Browse files Browse the repository at this point in the history
  • Loading branch information
germanferrero committed Oct 14, 2021
1 parent 6fb7a5c commit f59ef6b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions plugins/lime-plugin-delete-nodes/deleteNodes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jest.mock('plugins/lime-plugin-network-nodes/src/networkNodesApi');
describe('delete nodes page', () => {
beforeEach(() => {
getNodes.mockImplementation(async () => [
{ hostname: 'node1', status: 'recently_connected' },
{ hostname: 'node2', status: 'recently_connected' },
{ hostname: 'node3', status: 'recently_connected' },
{ hostname: 'node4', status: 'disconnected' },
{ hostname: 'node5', status: 'disconnected' },
{ hostname: 'node6', status: 'disconnected' },
{ hostname: 'node7', status: 'disconnected' },
{ hostname: 'node1', status: 'recently_reachable' },
{ hostname: 'node2', status: 'recently_reachable' },
{ hostname: 'node3', status: 'recently_reachable' },
{ hostname: 'node4', status: 'unreachable' },
{ hostname: 'node5', status: 'unreachable' },
{ hostname: 'node6', status: 'unreachable' },
{ hostname: 'node7', status: 'unreachable' },
{ hostname: 'node8', status: 'gone' },
{ hostname: 'node9', status: 'gone' },
]);
Expand All @@ -32,7 +32,7 @@ describe('delete nodes page', () => {
markNodesAsGone.mockClear();
});

it('shows the list of disconnected nodes only', async () => {
it('shows the list of unreachable nodes only', async () => {
render(<DeleteNodesPage />);
expect(await screen.findByText('node4')).toBeVisible();
expect(await screen.findByText('node5')).toBeVisible();
Expand Down Expand Up @@ -75,4 +75,4 @@ describe('delete nodes page', () => {
fireEvent.click(await screen.findByRole('button', { name: /delete/i }));
expect(await screen.findByText(/successfully deleted/i)).toBeVisible();
})
})
})
12 changes: 6 additions & 6 deletions plugins/lime-plugin-delete-nodes/src/deleteNodesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import Toast from 'components/toast';
import { useEffect, useState } from 'preact/hooks';
import { useSet } from 'react-use';
import { useMarkNodesAsGone, useNetworkNodes } from 'plugins/lime-plugin-network-nodes/src/networkNodesQueries'
import style from './style.less';
import style from './deleteNodesStyle.less';
import I18n from 'i18n-js';

export const DeleteNodesPage_ = ({ nodes, onDelete, isSubmitting, isSuccess }) => {
const [selectedNodes, { toggle, has, reset }] = useSet(new Set([]));
const [showSuccess, setshowSuccess] = useState(false);
const disconnectedNodes = nodes.filter(n => n.status === "disconnected");
const unreachableNodes = nodes.filter(n => n.status === "unreachable");

useEffect(() => {
if (isSuccess) {
Expand All @@ -27,15 +27,15 @@ export const DeleteNodesPage_ = ({ nodes, onDelete, isSubmitting, isSuccess }) =
<div class="d-flex flex-column flex-grow-1 overflow-auto ">
<div class="d-flex flex-column flex-grow-1 overflow-auto container container-padded">
<h4>{I18n.t("Delete Nodes")}</h4>
{disconnectedNodes.length > 0 &&
{unreachableNodes.length > 0 &&
<p>{I18n.t("Select the nodes which no longer belong to the network and "
+ "delete them from the list of unreachable nodes")}</p>
}
{disconnectedNodes.length === 0 &&
{unreachableNodes.length === 0 &&
<p>{I18n.t("There are no left unreachable nodes")}</p>
}
<List>
{disconnectedNodes.map(node =>
{unreachableNodes.map(node =>
<ListItem key={node.hostname} onClick={() => toggle(node.hostname)} >
<div class={style.nodeItem} >
<input type="checkbox" name="selected-nodes" id={node.hostname}
Expand Down Expand Up @@ -83,4 +83,4 @@ const DeleteNodesPage = () => {
isSubmitting={isSubmitting} isSuccess={isSuccess} />
}

export default DeleteNodesPage;
export default DeleteNodesPage;

0 comments on commit f59ef6b

Please sign in to comment.