diff --git a/hyperglass/ui/.eslintrc b/hyperglass/ui/.eslintrc
new file mode 100644
index 0000000..6beb7e1
--- /dev/null
+++ b/hyperglass/ui/.eslintrc
@@ -0,0 +1,9 @@
+{
+ "extends": "@upstatement/eslint-config/react",
+ "plugins": ["react-hooks"],
+ "settings": { "import/resolver": { "typescript": {} } },
+ "rules": {
+ "react-hooks/rules-of-hooks": "error",
+ "react-hooks/exhaustive-deps": ["warn"]
+ }
+}
diff --git a/hyperglass/ui/components/BGPTable.js b/hyperglass/ui/components/BGPTable.js
index 1699213..7cb0e61 100644
--- a/hyperglass/ui/components/BGPTable.js
+++ b/hyperglass/ui/components/BGPTable.js
@@ -1,4 +1,4 @@
-import * as React from "react";
+import * as React from 'react';
import {
Flex,
Icon,
@@ -8,39 +8,39 @@ import {
PopoverTrigger,
Text,
Tooltip,
- useColorMode
-} from "@chakra-ui/core";
-import { MdLastPage } from "@meronex/icons/md";
-import dayjs from "dayjs";
-import relativeTimePlugin from "dayjs/plugin/relativeTime";
-import utcPlugin from "dayjs/plugin/utc";
-import { useConfig } from "app/context";
-import { Table } from "app/components";
+ useColorMode,
+} from '@chakra-ui/core';
+import { MdLastPage } from '@meronex/icons/md';
+import dayjs from 'dayjs';
+import relativeTimePlugin from 'dayjs/plugin/relativeTime';
+import utcPlugin from 'dayjs/plugin/utc';
+import { useConfig } from 'app/context';
+import { Table } from 'app/components';
dayjs.extend(relativeTimePlugin);
dayjs.extend(utcPlugin);
const isActiveColor = {
- true: { dark: "green.300", light: "green.500" },
- false: { dark: "gray.300", light: "gray.500" }
+ true: { dark: 'green.300', light: 'green.500' },
+ false: { dark: 'gray.300', light: 'gray.500' },
};
const arrowColor = {
- true: { dark: "blackAlpha.500", light: "blackAlpha.500" },
- false: { dark: "whiteAlpha.300", light: "blackAlpha.500" }
+ true: { dark: 'blackAlpha.500', light: 'blackAlpha.500' },
+ false: { dark: 'whiteAlpha.300', light: 'blackAlpha.500' },
};
-const rpkiIcon = ["not-allowed", "check-circle", "warning", "question"];
+const rpkiIcon = ['not-allowed', 'check-circle', 'warning', 'question'];
const rpkiColor = {
true: {
- dark: ["red.500", "green.600", "yellow.500", "gray.800"],
- light: ["red.500", "green.500", "yellow.500", "gray.600"]
+ dark: ['red.500', 'green.600', 'yellow.500', 'gray.800'],
+ light: ['red.500', 'green.500', 'yellow.500', 'gray.600'],
},
false: {
- dark: ["red.300", "green.300", "yellow.300", "gray.300"],
- light: ["red.400", "green.500", "yellow.400", "gray.500"]
- }
+ dark: ['red.300', 'green.300', 'yellow.300', 'gray.300'],
+ light: ['red.400', 'green.500', 'yellow.400', 'gray.500'],
+ },
};
const makeColumns = fields => {
@@ -50,7 +50,7 @@ const makeColumns = fields => {
Header: header,
accessor: accessor,
align: align,
- hidden: false
+ hidden: false,
};
if (align === null) {
columnConfig.hidden = true;
@@ -68,22 +68,15 @@ const MonoField = ({ v, ...props }) => (
const Active = ({ isActive }) => {
const { colorMode } = useColorMode();
return (
-
+
);
};
const Age = ({ inSeconds }) => {
const now = dayjs.utc();
- const then = now.subtract(inSeconds, "seconds");
+ const then = now.subtract(inSeconds, 'seconds');
return (
-
+
{now.to(then, true)}
);
@@ -91,9 +84,7 @@ const Age = ({ inSeconds }) => {
const Weight = ({ weight, winningWeight }) => {
const fixMeText =
- winningWeight === "low"
- ? "Lower Weight is Preferred"
- : "Higher Weight is Preferred";
+ winningWeight === 'low' ? 'Lower Weight is Preferred' : 'Higher Weight is Preferred';
return (
@@ -113,22 +104,12 @@ const ASPath = ({ path, active }) => {
const asnStr = String(asn);
i !== 0 &&
paths.push(
-
+ ,
);
paths.push(
-
+
{asnStr}
-
+ ,
);
});
return paths;
@@ -152,13 +133,12 @@ const Communities = ({ communities }) => {
textAlign="left"
p={4}
width="unset"
- color={colorMode === "dark" ? "white" : "black"}
+ color={colorMode === 'dark' ? 'white' : 'black'}
fontFamily="mono"
fontWeight="normal"
- whiteSpace="pre-wrap"
- >
+ whiteSpace="pre-wrap">
- {communities.join("\n")}
+ {communities.join('\n')}
));
@@ -172,18 +152,11 @@ const RPKIState = ({ state, active }) => {
web.text.rpki_invalid,
web.text.rpki_valid,
web.text.rpki_unknown,
- web.text.rpki_unverified
+ web.text.rpki_unverified,
];
return (
-
-
+
+
);
};
@@ -193,24 +166,16 @@ const Cell = ({ data, rawData, longestASN }) => {
prefix: ,
active: ,
age: ,
- weight: (
-
- ),
+ weight: ,
med: ,
local_preference: ,
- as_path: (
-
- ),
+ as_path: ,
communities: ,
next_hop: ,
source_as: ,
source_rid: ,
peer_rid: ,
- rpki_state:
+ rpki_state: ,
};
return component[data.column.id] ?? <> >;
};
@@ -220,7 +185,7 @@ export const BGPTable = ({ children: data, ...props }) => {
const columns = makeColumns(config.parsed_data_fields);
return (
-
+
{
if (completed) {
@@ -15,7 +15,7 @@ const Renderer = ({ hours, minutes, seconds, completed, props }) => {
{props.text}
- {time.join(":")}
+ {time.join(':')}
);
diff --git a/hyperglass/ui/components/Card/CardBody.js b/hyperglass/ui/components/Card/CardBody.js
index e7c7334..f4447b1 100644
--- a/hyperglass/ui/components/Card/CardBody.js
+++ b/hyperglass/ui/components/Card/CardBody.js
@@ -1,8 +1,8 @@
-import * as React from "react";
-import { Flex, useColorMode } from "@chakra-ui/core";
+import * as React from 'react';
+import { Flex, useColorMode } from '@chakra-ui/core';
-const bg = { light: "white", dark: "original.dark" };
-const color = { light: "original.dark", dark: "white" };
+const bg = { light: 'white', dark: 'original.dark' };
+const color = { light: 'original.dark', dark: 'white' };
export const CardBody = ({ onClick = () => false, children, ...props }) => {
const { colorMode } = useColorMode();
@@ -17,8 +17,7 @@ export const CardBody = ({ onClick = () => false, children, ...props }) => {
bg={bg[colorMode]}
color={color[colorMode]}
overflow="hidden"
- {...props}
- >
+ {...props}>
{children}
);
diff --git a/hyperglass/ui/components/Card/CardFooter.js b/hyperglass/ui/components/Card/CardFooter.js
index 3bddeb2..7800757 100644
--- a/hyperglass/ui/components/Card/CardFooter.js
+++ b/hyperglass/ui/components/Card/CardFooter.js
@@ -1,5 +1,5 @@
-import * as React from "react";
-import { Flex } from "@chakra-ui/core";
+import * as React from 'react';
+import { Flex } from '@chakra-ui/core';
export const CardFooter = ({ children, ...props }) => (
(
overflowY="hidden"
flexDirection="row"
justifyContent="space-between"
- {...props}
- >
+ {...props}>
{children}
);
diff --git a/hyperglass/ui/components/Card/CardHeader.js b/hyperglass/ui/components/Card/CardHeader.js
index 66a8952..9b8f6f7 100644
--- a/hyperglass/ui/components/Card/CardHeader.js
+++ b/hyperglass/ui/components/Card/CardHeader.js
@@ -1,7 +1,7 @@
-import * as React from "react";
-import { Flex, Text, useColorMode } from "@chakra-ui/core";
+import * as React from 'react';
+import { Flex, Text, useColorMode } from '@chakra-ui/core';
-const bg = { light: "blackAlpha.50", dark: "whiteAlpha.100" };
+const bg = { light: 'blackAlpha.50', dark: 'whiteAlpha.100' };
export const CardHeader = ({ children, ...props }) => {
const { colorMode } = useColorMode();
@@ -13,8 +13,7 @@ export const CardHeader = ({ children, ...props }) => {
roundedTopLeft={4}
roundedTopRight={4}
borderBottomWidth="1px"
- {...props}
- >
+ {...props}>
{children}
);
diff --git a/hyperglass/ui/components/Card/index.mjs b/hyperglass/ui/components/Card/index.mjs
index e211fac..39dfd07 100644
--- a/hyperglass/ui/components/Card/index.mjs
+++ b/hyperglass/ui/components/Card/index.mjs
@@ -1,3 +1,3 @@
-export * from "./CardBody";
-export * from "./CardFooter";
-export * from "./CardHeader";
+export * from './CardBody';
+export * from './CardFooter';
+export * from './CardHeader';
diff --git a/hyperglass/ui/components/ChakraSelect.js b/hyperglass/ui/components/ChakraSelect.js
index 5ab571b..c7e013c 100644
--- a/hyperglass/ui/components/ChakraSelect.js
+++ b/hyperglass/ui/components/ChakraSelect.js
@@ -1,85 +1,76 @@
-import * as React from "react";
-import { Text, useColorMode, useTheme } from "@chakra-ui/core";
-import Select from "react-select";
-import { opposingColor } from "app/util";
+import * as React from 'react';
+import { Text, useColorMode, useTheme } from '@chakra-ui/core';
+import Select from 'react-select';
+import { opposingColor } from 'app/util';
export const ChakraSelect = React.forwardRef(
- (
- { placeholder = "Select...", isFullWidth, size, children, ...props },
- ref
- ) => {
+ ({ placeholder = 'Select...', isFullWidth, size, children, ...props }, ref) => {
const theme = useTheme();
const { colorMode } = useColorMode();
const sizeMap = {
lg: { height: theme.space[12] },
md: { height: theme.space[10] },
- sm: { height: theme.space[8] }
+ sm: { height: theme.space[8] },
};
const colorSetPrimaryBg = {
dark: theme.colors.primary[300],
- light: theme.colors.primary[500]
+ light: theme.colors.primary[500],
};
- const colorSetPrimaryColor = opposingColor(
- theme,
- colorSetPrimaryBg[colorMode]
- );
+ const colorSetPrimaryColor = opposingColor(theme, colorSetPrimaryBg[colorMode]);
const bg = {
dark: theme.colors.whiteAlpha[100],
- light: theme.colors.white
+ light: theme.colors.white,
};
const color = {
dark: theme.colors.whiteAlpha[800],
- light: theme.colors.black
+ light: theme.colors.black,
};
const borderFocused = theme.colors.secondary[500];
const borderDisabled = theme.colors.whiteAlpha[100];
const border = {
dark: theme.colors.whiteAlpha[50],
- light: theme.colors.gray[100]
+ light: theme.colors.gray[100],
};
const borderRadius = theme.space[1];
const hoverColor = {
dark: theme.colors.whiteAlpha[200],
- light: theme.colors.gray[300]
+ light: theme.colors.gray[300],
};
const { height } = sizeMap[size];
const optionBgActive = {
dark: theme.colors.primary[400],
- light: theme.colors.primary[600]
+ light: theme.colors.primary[600],
};
const optionBgColor = opposingColor(theme, optionBgActive[colorMode]);
const optionSelectedBg = {
dark: theme.colors.whiteAlpha[400],
- light: theme.colors.blackAlpha[400]
+ light: theme.colors.blackAlpha[400],
};
- const optionSelectedColor = opposingColor(
- theme,
- optionSelectedBg[colorMode]
- );
+ const optionSelectedColor = opposingColor(theme, optionSelectedBg[colorMode]);
const selectedDisabled = theme.colors.whiteAlpha[400];
const placeholderColor = {
dark: theme.colors.whiteAlpha[700],
- light: theme.colors.gray[600]
+ light: theme.colors.gray[600],
};
const menuBg = {
dark: theme.colors.blackFaded[800],
- light: theme.colors.whiteFaded[50]
+ light: theme.colors.whiteFaded[50],
};
const menuColor = {
dark: theme.colors.white,
- light: theme.colors.blackAlpha[800]
+ light: theme.colors.blackAlpha[800],
};
const scrollbar = {
dark: theme.colors.whiteAlpha[300],
- light: theme.colors.blackAlpha[300]
+ light: theme.colors.blackAlpha[300],
};
const scrollbarHover = {
dark: theme.colors.whiteAlpha[400],
- light: theme.colors.blackAlpha[400]
+ light: theme.colors.blackAlpha[400],
};
const scrollbarBg = {
dark: theme.colors.whiteAlpha[50],
- light: theme.colors.blackAlpha[50]
+ light: theme.colors.blackAlpha[50],
};
return (
);
- }
+ },
);
diff --git a/hyperglass/ui/components/CodeBlock.js b/hyperglass/ui/components/CodeBlock.js
index 83767e7..e12e242 100644
--- a/hyperglass/ui/components/CodeBlock.js
+++ b/hyperglass/ui/components/CodeBlock.js
@@ -1,10 +1,10 @@
-import * as React from "react";
-import { Box, useColorMode } from "@chakra-ui/core";
+import * as React from 'react';
+import { Box, useColorMode } from '@chakra-ui/core';
export const CodeBlock = ({ children }) => {
const { colorMode } = useColorMode();
- const bg = { dark: "gray.800", light: "blackAlpha.100" };
- const color = { dark: "white", light: "black" };
+ const bg = { dark: 'gray.800', light: 'blackAlpha.100' };
+ const color = { dark: 'white', light: 'black' };
return (
{
color={color[colorMode]}
fontSize="sm"
whiteSpace="pre-wrap"
- as="pre"
- >
+ as="pre">
{children}
);
diff --git a/hyperglass/ui/components/ColorModeToggle.js b/hyperglass/ui/components/ColorModeToggle.js
index 84d85a1..e0f377d 100644
--- a/hyperglass/ui/components/ColorModeToggle.js
+++ b/hyperglass/ui/components/ColorModeToggle.js
@@ -1,43 +1,41 @@
-import * as React from "react";
-import { forwardRef } from "react";
-import { Button, useColorMode } from "@chakra-ui/core";
+import * as React from 'react';
+import { forwardRef } from 'react';
+import { Button, useColorMode } from '@chakra-ui/core';
-const Sun = ({ color, size = "1.5rem", ...props }) => (
+const Sun = ({ color, size = '1.5rem', ...props }) => (
);
-const Moon = ({ color, size = "1.5rem", ...props }) => (
+const Moon = ({ color, size = '1.5rem', ...props }) => (