{
+ isActive: boolean
+ activeText: string
+ inactiveText: string
}
-export const ConnectionStatus = withStyles(connectionStatusStyles)(
- ({ isConnected, classes }: ConnectionStatusProps) => {
+export const StatusIndicator = withStyles(statusStyles)(
+ ({ isActive, activeText, inactiveText, classes }: StatusIndicatorProps) => {
return (
- {isConnected ? (
-
+ {isActive ? (
+
) : (
-
+
)}
- {isConnected ? 'Connected' : 'Disconnected'}
+ {isActive ? activeText : inactiveText}
)
diff --git a/src/screens/JobDistributors/JobDistributorsRow.tsx b/src/screens/JobDistributors/JobDistributorsRow.tsx
index 2e2078f3..5b572ef1 100644
--- a/src/screens/JobDistributors/JobDistributorsRow.tsx
+++ b/src/screens/JobDistributors/JobDistributorsRow.tsx
@@ -8,7 +8,7 @@ import Link from 'components/Link'
import { tableStyles } from 'components/Table'
import { CopyIconButton } from 'src/components/Copy/CopyIconButton'
import { shortenHex } from 'src/utils/shortenHex'
-import { ConnectionStatus } from '../FeedsManager/ConnectionStatus'
+import { StatusIndicator } from '../FeedsManager/StatusIndicator'
interface Props extends WithStyles {
jobDistributor: FetchFeedsManagersPayload_ResultsFields
@@ -27,7 +27,18 @@ export const JobDistributorsRow = withStyles(tableStyles)(
-
+
+
+
+
{shortenHex(jobDistributor.publicKey, { start: 6, end: 6 })}
diff --git a/src/screens/JobDistributors/JobDistributorsView.test.tsx b/src/screens/JobDistributors/JobDistributorsView.test.tsx
index 6d630d39..80f37623 100644
--- a/src/screens/JobDistributors/JobDistributorsView.test.tsx
+++ b/src/screens/JobDistributors/JobDistributorsView.test.tsx
@@ -46,7 +46,8 @@ describe('JobDistributorsView', () => {
expect(rows).toHaveLength(3)
expect(getByText('Name')).toBeInTheDocument()
- expect(getByText('Status')).toBeInTheDocument()
+ expect(getByText('Connection Status')).toBeInTheDocument()
+ expect(getByText('Enabled')).toBeInTheDocument()
expect(getByText('CSA Public Key')).toBeInTheDocument()
expect(getByText('RPC URL')).toBeInTheDocument()
diff --git a/src/screens/JobDistributors/JobDistributorsView.tsx b/src/screens/JobDistributors/JobDistributorsView.tsx
index 2500dfaa..87d6425f 100644
--- a/src/screens/JobDistributors/JobDistributorsView.tsx
+++ b/src/screens/JobDistributors/JobDistributorsView.tsx
@@ -46,7 +46,8 @@ export const JobDistributorsView: React.FC = ({ jobDistributors }) => {
Name
- Status
+ Connection Status
+ Enabled
CSA Public Key
RPC URL
diff --git a/support/factories/gql/fetchFeedsManagers.ts b/support/factories/gql/fetchFeedsManagers.ts
index 4e8473d2..c0c95b6f 100644
--- a/support/factories/gql/fetchFeedsManagers.ts
+++ b/support/factories/gql/fetchFeedsManagers.ts
@@ -10,6 +10,7 @@ export function buildFeedsManager(
publicKey: '1111',
isConnectionActive: false,
createdAt: new Date(),
+ disabledAt: new Date(),
...overrides,
}
}
diff --git a/support/factories/gql/fetchFeedsManagersWithProposals.ts b/support/factories/gql/fetchFeedsManagersWithProposals.ts
index 11139c9a..2465da18 100644
--- a/support/factories/gql/fetchFeedsManagersWithProposals.ts
+++ b/support/factories/gql/fetchFeedsManagersWithProposals.ts
@@ -21,6 +21,7 @@ export function buildFeedsManagerFields(
uri: 'localhost:8080',
publicKey: '1111',
isConnectionActive: false,
+ disabledAt: new Date(),
chainConfigs: [],
...overrides,
}
From 07628dd250264c30d93e5b72b8ed5dd9f7ab648d Mon Sep 17 00:00:00 2001
From: ChrisAmora <27789416+ChrisAmora@users.noreply.github.com>
Date: Tue, 29 Oct 2024 11:28:14 -0300
Subject: [PATCH 2/4] fix: address pr comments
---
.../FeedsManager/FeedsManagerCard.test.tsx | 38 +++++++++++++++++--
src/screens/FeedsManager/FeedsManagerCard.tsx | 4 +-
.../FeedsManager/FeedsManagerScreen.tsx | 1 +
src/screens/FeedsManager/FeedsManagerView.tsx | 4 +-
.../JobDistributorsView.test.tsx | 2 +-
.../JobDistributors/JobDistributorsView.tsx | 2 +-
6 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/src/screens/FeedsManager/FeedsManagerCard.test.tsx b/src/screens/FeedsManager/FeedsManagerCard.test.tsx
index 2724e6b6..3b373c72 100644
--- a/src/screens/FeedsManager/FeedsManagerCard.test.tsx
+++ b/src/screens/FeedsManager/FeedsManagerCard.test.tsx
@@ -10,14 +10,18 @@ import { FeedsManagerCard } from './FeedsManagerCard'
const { getByRole, queryByText } = screen
-function renderComponent(manager: FeedsManagerFields) {
+function renderComponent(
+ manager: FeedsManagerFields,
+ onEnable = () => {},
+ onDisable = () => {},
+) {
renderWithRouter(
<>
{}}
- onEnable={() => {}}
+ onDisable={onDisable}
+ onEnable={onEnable}
/>
@@ -76,4 +80,32 @@ describe('FeedsManagerCard', () => {
expect(queryByText('Redirect Success')).toBeInTheDocument()
})
+
+ it('calls onEnable when enable menu item is clicked', () => {
+ const onEnableMock = jest.fn()
+ const onDisableMock = jest.fn()
+
+ const mgr = buildFeedsManagerFields({ disabledAt: new Date() })
+
+ renderComponent(mgr, onEnableMock, onDisableMock)
+
+ userEvent.click(screen.getByRole('button', { name: /open-menu/i }))
+ userEvent.click(screen.getByRole('menuitem', { name: /enable/i }))
+
+ expect(onEnableMock).toHaveBeenCalledTimes(1)
+ })
+
+ it('calls onDisable when disable menu item is clicked', () => {
+ const onEnableMock = jest.fn()
+ const onDisableMock = jest.fn()
+
+ const mgr = buildFeedsManagerFields({ disabledAt: null })
+ renderComponent(mgr, onEnableMock, onDisableMock)
+
+ userEvent.click(screen.getByRole('button', { name: /open-menu/i }))
+
+ userEvent.click(screen.getByRole('menuitem', { name: /disable/i }))
+
+ expect(onDisableMock).toHaveBeenCalledTimes(1)
+ })
})
diff --git a/src/screens/FeedsManager/FeedsManagerCard.tsx b/src/screens/FeedsManager/FeedsManagerCard.tsx
index e84a1c96..25ff5290 100644
--- a/src/screens/FeedsManager/FeedsManagerCard.tsx
+++ b/src/screens/FeedsManager/FeedsManagerCard.tsx
@@ -23,8 +23,8 @@ import { StatusIndicator } from './StatusIndicator'
interface Props {
manager: FeedsManagerFields
- onEnable: () => void | Promise
- onDisable: () => void | Promise
+ onEnable: () => void
+ onDisable: () => void
}
export const FeedsManagerCard = ({ manager, onEnable, onDisable }: Props) => {
diff --git a/src/screens/FeedsManager/FeedsManagerScreen.tsx b/src/screens/FeedsManager/FeedsManagerScreen.tsx
index d29f7a69..2c295b0a 100644
--- a/src/screens/FeedsManager/FeedsManagerScreen.tsx
+++ b/src/screens/FeedsManager/FeedsManagerScreen.tsx
@@ -96,6 +96,7 @@ export const FeedsManagerScreen: React.FC = () => {
const payload = result.data?.enableFeedsManager
switch (payload?.__typename) {
case 'EnableFeedsManagerSuccess':
+ // TODO The notification seems to be permanent,create one that disappears after a few seconds
dispatch(notifySuccessMsg('Job Distributor Enabled'))
break
case 'NotFoundError':
diff --git a/src/screens/FeedsManager/FeedsManagerView.tsx b/src/screens/FeedsManager/FeedsManagerView.tsx
index 6957cefc..0e2f0c5d 100644
--- a/src/screens/FeedsManager/FeedsManagerView.tsx
+++ b/src/screens/FeedsManager/FeedsManagerView.tsx
@@ -10,8 +10,8 @@ import { SupportedChainsCard } from './SupportedChainsCard'
interface Props {
manager: FeedsManagerPayload_ResultsFields
- onEnable: () => void | Promise
- onDisable: () => void | Promise
+ onEnable: () => void
+ onDisable: () => void
}
export const FeedsManagerView: React.FC = ({
diff --git a/src/screens/JobDistributors/JobDistributorsView.test.tsx b/src/screens/JobDistributors/JobDistributorsView.test.tsx
index 80f37623..6162687f 100644
--- a/src/screens/JobDistributors/JobDistributorsView.test.tsx
+++ b/src/screens/JobDistributors/JobDistributorsView.test.tsx
@@ -47,7 +47,7 @@ describe('JobDistributorsView', () => {
expect(getByText('Name')).toBeInTheDocument()
expect(getByText('Connection Status')).toBeInTheDocument()
- expect(getByText('Enabled')).toBeInTheDocument()
+ expect(getByText('Status')).toBeInTheDocument()
expect(getByText('CSA Public Key')).toBeInTheDocument()
expect(getByText('RPC URL')).toBeInTheDocument()
diff --git a/src/screens/JobDistributors/JobDistributorsView.tsx b/src/screens/JobDistributors/JobDistributorsView.tsx
index 87d6425f..4f3fee4f 100644
--- a/src/screens/JobDistributors/JobDistributorsView.tsx
+++ b/src/screens/JobDistributors/JobDistributorsView.tsx
@@ -47,7 +47,7 @@ export const JobDistributorsView: React.FC = ({ jobDistributors }) => {
Name
Connection Status
- Enabled
+ Status
CSA Public Key
RPC URL
From 7f67aa3e64e2e075133817c5ec2aebf64b6024d4 Mon Sep 17 00:00:00 2001
From: ChrisAmora <27789416+ChrisAmora@users.noreply.github.com>
Date: Tue, 29 Oct 2024 12:28:02 -0300
Subject: [PATCH 3/4] fix: add loading
---
src/screens/FeedsManager/FeedsManagerScreen.tsx | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/screens/FeedsManager/FeedsManagerScreen.tsx b/src/screens/FeedsManager/FeedsManagerScreen.tsx
index 2c295b0a..4bc09698 100644
--- a/src/screens/FeedsManager/FeedsManagerScreen.tsx
+++ b/src/screens/FeedsManager/FeedsManagerScreen.tsx
@@ -69,17 +69,17 @@ export const FeedsManagerScreen: React.FC = () => {
fetchPolicy: 'cache-and-network',
})
- const [enableFeedsManager] = useMutation<
+ const [enableFeedsManager, { loading: enableLoading }] = useMutation<
EnableFeedsManager,
EnableFeedsManagerVariables
>(ENABLE_FEEDS_MANAGER_MUTATION)
- const [disableFeedsManager] = useMutation<
+ const [disableFeedsManager, { loading: disableLoading }] = useMutation<
DisableFeedsManager,
DisableFeedsManagerVariables
>(DISABLE_FEEDS_MANAGER_MUTATION)
- if (loading) {
+ if (loading || enableLoading || disableLoading) {
return
}
From 8c08ed51507708428705a55ae941bcb2aa95a8cc Mon Sep 17 00:00:00 2001
From: ChrisAmora <27789416+ChrisAmora@users.noreply.github.com>
Date: Tue, 29 Oct 2024 12:35:57 -0300
Subject: [PATCH 4/4] fix: sonarqube issues
---
src/screens/FeedsManager/FeedsManagerScreen.tsx | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/screens/FeedsManager/FeedsManagerScreen.tsx b/src/screens/FeedsManager/FeedsManagerScreen.tsx
index 4bc09698..a989b96d 100644
--- a/src/screens/FeedsManager/FeedsManagerScreen.tsx
+++ b/src/screens/FeedsManager/FeedsManagerScreen.tsx
@@ -102,6 +102,9 @@ export const FeedsManagerScreen: React.FC = () => {
case 'NotFoundError':
dispatch(notifyErrorMsg(payload.message))
break
+ default:
+ // We should update this if we add more types
+ break
}
} catch (e) {
handleMutationError(e)
@@ -122,6 +125,9 @@ export const FeedsManagerScreen: React.FC = () => {
case 'NotFoundError':
dispatch(notifyErrorMsg(payload.message))
break
+ default:
+ // We should update this if we add more types
+ break
}
} catch (e) {
handleMutationError(e)