From e5a8cf5d9fd67090633ad85155d0803dca8fc2e5 Mon Sep 17 00:00:00 2001 From: ChrisAmora <27789416+ChrisAmora@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:13:09 -0300 Subject: [PATCH 1/4] feat: add enable and disable feed manager queries --- .changeset/eight-parents-leave.md | 5 + .../useFeedsManagerWithProposalsQuery.ts | 1 + src/hooks/queries/useFeedsManagersQuery.ts | 1 + .../FeedsManager/FeedsManagerCard.test.tsx | 26 ++++- src/screens/FeedsManager/FeedsManagerCard.tsx | 44 ++++++- .../FeedsManager/FeedsManagerScreen.test.tsx | 74 +++++++++++- .../FeedsManager/FeedsManagerScreen.tsx | 108 +++++++++++++++++- .../FeedsManager/FeedsManagerView.test.tsx | 8 +- src/screens/FeedsManager/FeedsManagerView.tsx | 20 +++- ...nnectionStatus.tsx => StatusIndicator.tsx} | 27 ++--- .../JobDistributors/JobDistributorsRow.tsx | 15 ++- .../JobDistributorsView.test.tsx | 3 +- .../JobDistributors/JobDistributorsView.tsx | 3 +- support/factories/gql/fetchFeedsManagers.ts | 1 + .../gql/fetchFeedsManagersWithProposals.ts | 1 + 15 files changed, 299 insertions(+), 38 deletions(-) create mode 100644 .changeset/eight-parents-leave.md rename src/screens/FeedsManager/{ConnectionStatus.tsx => StatusIndicator.tsx} (56%) diff --git a/.changeset/eight-parents-leave.md b/.changeset/eight-parents-leave.md new file mode 100644 index 00000000..8e4c6a0d --- /dev/null +++ b/.changeset/eight-parents-leave.md @@ -0,0 +1,5 @@ +--- +'@smartcontractkit/operator-ui': minor +--- + +#added Enable and Disable Feeds Manager mutations diff --git a/src/hooks/queries/useFeedsManagerWithProposalsQuery.ts b/src/hooks/queries/useFeedsManagerWithProposalsQuery.ts index 1581e201..f42fede7 100644 --- a/src/hooks/queries/useFeedsManagerWithProposalsQuery.ts +++ b/src/hooks/queries/useFeedsManagerWithProposalsQuery.ts @@ -44,6 +44,7 @@ export const FEEDS_MANAGER_FIELDS = gql` uri publicKey isConnectionActive + disabledAt chainConfigs { ...FeedsManager_ChainConfigFields } diff --git a/src/hooks/queries/useFeedsManagersQuery.ts b/src/hooks/queries/useFeedsManagersQuery.ts index 3737171b..d3481e6c 100644 --- a/src/hooks/queries/useFeedsManagersQuery.ts +++ b/src/hooks/queries/useFeedsManagersQuery.ts @@ -9,6 +9,7 @@ export const FEEDS_MANAGERS_QUERY = gql` publicKey isConnectionActive createdAt + disabledAt } query FetchFeedsManagers { feedsManagers { diff --git a/src/screens/FeedsManager/FeedsManagerCard.test.tsx b/src/screens/FeedsManager/FeedsManagerCard.test.tsx index 6789092c..2724e6b6 100644 --- a/src/screens/FeedsManager/FeedsManagerCard.test.tsx +++ b/src/screens/FeedsManager/FeedsManagerCard.test.tsx @@ -1,12 +1,12 @@ import * as React from 'react' +import userEvent from '@testing-library/user-event' import { Route } from 'react-router-dom' import { renderWithRouter, screen } from 'support/test-utils' -import userEvent from '@testing-library/user-event' -import { FeedsManagerCard } from './FeedsManagerCard' -import { buildFeedsManagerFields } from 'support/factories/gql/fetchFeedsManagersWithProposals' import { shortenHex } from 'src/utils/shortenHex' +import { buildFeedsManagerFields } from 'support/factories/gql/fetchFeedsManagersWithProposals' +import { FeedsManagerCard } from './FeedsManagerCard' const { getByRole, queryByText } = screen @@ -14,7 +14,11 @@ function renderComponent(manager: FeedsManagerFields) { renderWithRouter( <> - + {}} + onEnable={() => {}} + /> Redirect Success @@ -33,6 +37,19 @@ describe('FeedsManagerCard', () => { expect(queryByText(mgr.uri)).toBeInTheDocument() expect(queryByText(shortenHex(mgr.publicKey))).toBeInTheDocument() expect(queryByText('Disconnected')).toBeInTheDocument() + expect(queryByText('Disabled')).toBeInTheDocument() + }) + + it('renders an enabled Feeds Manager', () => { + const mgr = buildFeedsManagerFields({ disabledAt: null }) + + renderComponent(mgr) + + expect(queryByText(mgr.name)).toBeInTheDocument() + expect(queryByText(mgr.uri)).toBeInTheDocument() + expect(queryByText(shortenHex(mgr.publicKey))).toBeInTheDocument() + expect(queryByText('Disconnected')).toBeInTheDocument() + expect(queryByText('Enabled')).toBeInTheDocument() }) it('renders a connected boostrapper Feeds Manager', () => { @@ -48,6 +65,7 @@ describe('FeedsManagerCard', () => { expect(queryByText(shortenHex(mgr.publicKey))).toBeInTheDocument() expect(queryByText('Flux Monitor')).toBeNull() expect(queryByText('Connected')).toBeInTheDocument() + expect(queryByText('Disabled')).toBeInTheDocument() }) it('navigates to edit', () => { diff --git a/src/screens/FeedsManager/FeedsManagerCard.tsx b/src/screens/FeedsManager/FeedsManagerCard.tsx index 4b510c93..e84a1c96 100644 --- a/src/screens/FeedsManager/FeedsManagerCard.tsx +++ b/src/screens/FeedsManager/FeedsManagerCard.tsx @@ -5,8 +5,11 @@ import IconButton from '@material-ui/core/IconButton' import ListItemIcon from '@material-ui/core/ListItemIcon' import ListItemText from '@material-ui/core/ListItemText' import Menu from '@material-ui/core/Menu' +import MenuItem from '@material-ui/core/MenuItem' import EditIcon from '@material-ui/icons/Edit' import MoreVertIcon from '@material-ui/icons/MoreVert' +import ToggleOffIcon from '@material-ui/icons/ToggleOff' +import ToggleOnIcon from '@material-ui/icons/ToggleOn' import { DetailsCard, @@ -16,13 +19,15 @@ import { import { CopyIconButton } from 'src/components/Copy/CopyIconButton' import { MenuItemLink } from 'src/components/MenuItemLink' import { shortenHex } from 'src/utils/shortenHex' -import { ConnectionStatus } from './ConnectionStatus' +import { StatusIndicator } from './StatusIndicator' interface Props { manager: FeedsManagerFields + onEnable: () => void | Promise + onDisable: () => void | Promise } -export const FeedsManagerCard = ({ manager }: Props) => { +export const FeedsManagerCard = ({ manager, onEnable, onDisable }: Props) => { const [anchorEl, setAnchorEl] = React.useState(null) const handleOpen = (event: React.MouseEvent) => { @@ -33,6 +38,15 @@ export const FeedsManagerCard = ({ manager }: Props) => { setAnchorEl(null) } + const handleToggleEnabled = () => { + if (manager.disabledAt) { + onEnable() + } else { + onDisable() + } + handleClose() + } + return ( { Edit + + + {manager.disabledAt ? ( + + ) : ( + + )} + + + {manager.disabledAt ? 'Enable' : 'Disable'} + + } > + + + + - + diff --git a/src/screens/FeedsManager/FeedsManagerScreen.test.tsx b/src/screens/FeedsManager/FeedsManagerScreen.test.tsx index e9e157c6..2de3d849 100644 --- a/src/screens/FeedsManager/FeedsManagerScreen.test.tsx +++ b/src/screens/FeedsManager/FeedsManagerScreen.test.tsx @@ -1,15 +1,27 @@ import * as React from 'react' +import { MockedProvider, MockedResponse } from '@apollo/client/testing' import { GraphQLError } from 'graphql' import { Route, Switch } from 'react-router-dom' -import { renderWithRouter, screen } from 'support/test-utils' -import { MockedProvider, MockedResponse } from '@apollo/client/testing' +import { renderWithRouter, screen, waitFor } from 'support/test-utils' -import { FeedsManagerScreen } from './FeedsManagerScreen' -import { buildFeedsManagerResultFields } from 'support/factories/gql/fetchFeedsManagersWithProposals' +import userEvent from '@testing-library/user-event' import { FEEDS_MANAGER_WITH_PROPOSALS_QUERY } from 'src/hooks/queries/useFeedsManagerWithProposalsQuery' - -const { findByText, findByTestId } = screen +import { buildFeedsManager } from 'support/factories/gql/fetchFeedsManagers' +import { buildFeedsManagerResultFields } from 'support/factories/gql/fetchFeedsManagersWithProposals' +import { + ENABLE_FEEDS_MANAGER_MUTATION, + FeedsManagerScreen, +} from './FeedsManagerScreen' + +const { + findByText, + findByTestId, + getByRole, + getByText, + getAllByRole, + queryByText, +} = screen function renderComponent(mocks: MockedResponse[]) { renderWithRouter( @@ -52,6 +64,56 @@ describe('FeedsManagerScreen', () => { expect(await findByText('Job Proposals')).toBeInTheDocument() }) + it('should enable a feed', async () => { + const id = '1' + const mocks: MockedResponse[] = [ + { + request: { + query: FEEDS_MANAGER_WITH_PROPOSALS_QUERY, + variables: { id }, + }, + result: { + data: { + feedsManager: buildFeedsManagerResultFields(), + }, + }, + }, + { + request: { + query: ENABLE_FEEDS_MANAGER_MUTATION, + variables: { id }, + }, + result: { + data: { + enableFeedsManager: { + feedsManager: buildFeedsManager({ + disabledAt: null, + }), + __typename: 'EnableFeedsManagerSuccess', + }, + }, + }, + }, + ] + + renderComponent(mocks) + + expect(await findByText('Job Distributors')).toBeInTheDocument() + expect(await findByText('Job Proposals')).toBeInTheDocument() + expect(await findByText('Disabled')).toBeInTheDocument() + expect(await queryByText('Enabled')).not.toBeInTheDocument() + + const openMenuButtons = await getAllByRole('button', { + name: /open-menu/i, + }) + userEvent.click(openMenuButtons[0]) + userEvent.click(await getByRole('menuitem', { name: /enable/i })) + await waitFor(() => { + expect(getByText('Enabled')).toBeInTheDocument() + }) + expect(await queryByText('Disabled')).not.toBeInTheDocument() + }) + it('should render not found page when a manager is not found', async () => { const mocks: MockedResponse[] = [ { diff --git a/src/screens/FeedsManager/FeedsManagerScreen.tsx b/src/screens/FeedsManager/FeedsManagerScreen.tsx index 5ed028f7..d29f7a69 100644 --- a/src/screens/FeedsManager/FeedsManagerScreen.tsx +++ b/src/screens/FeedsManager/FeedsManagerScreen.tsx @@ -1,24 +1,84 @@ import React from 'react' +import { gql, useMutation } from '@apollo/client' +import { notifyErrorMsg, notifySuccessMsg } from 'actionCreators' +import { useDispatch } from 'react-redux' import { Redirect, useParams } from 'react-router-dom' import { GraphqlErrorHandler } from 'src/components/ErrorHandler/GraphqlErrorHandler' import { Loading } from 'src/components/Feedback/Loading' import { useFeedsManagerWithProposalsQuery } from 'src/hooks/queries/useFeedsManagerWithProposalsQuery' +import { useMutationErrorHandler } from 'src/hooks/useMutationErrorHandler' import NotFound from 'src/pages/NotFound' import { FeedsManagerView } from './FeedsManagerView' +export const ENABLE_FEEDS_MANAGER_MUTATION = gql` + mutation EnableFeedsManager($id: ID!) { + enableFeedsManager(id: $id) { + ... on EnableFeedsManagerSuccess { + feedsManager { + id + name + uri + publicKey + isConnectionActive + createdAt + disabledAt + } + } + ... on NotFoundError { + message + code + } + } + } +` + +export const DISABLE_FEEDS_MANAGER_MUTATION = gql` + mutation DisableFeedsManager($id: ID!) { + disableFeedsManager(id: $id) { + ... on DisableFeedsManagerSuccess { + feedsManager { + id + name + uri + publicKey + isConnectionActive + createdAt + disabledAt + } + } + ... on NotFoundError { + message + code + } + } + } +` + interface RouteParams { id: string } export const FeedsManagerScreen: React.FC = () => { const { id } = useParams() + const { handleMutationError } = useMutationErrorHandler() + const dispatch = useDispatch() const { data, loading, error } = useFeedsManagerWithProposalsQuery({ variables: { id }, fetchPolicy: 'cache-and-network', }) + const [enableFeedsManager] = useMutation< + EnableFeedsManager, + EnableFeedsManagerVariables + >(ENABLE_FEEDS_MANAGER_MUTATION) + + const [disableFeedsManager] = useMutation< + DisableFeedsManager, + DisableFeedsManagerVariables + >(DISABLE_FEEDS_MANAGER_MUTATION) + if (loading) { return } @@ -27,12 +87,58 @@ export const FeedsManagerScreen: React.FC = () => { return } + const handleEnable = async () => { + try { + const result = await enableFeedsManager({ + variables: { id }, + }) + + const payload = result.data?.enableFeedsManager + switch (payload?.__typename) { + case 'EnableFeedsManagerSuccess': + dispatch(notifySuccessMsg('Job Distributor Enabled')) + break + case 'NotFoundError': + dispatch(notifyErrorMsg(payload.message)) + break + } + } catch (e) { + handleMutationError(e) + } + } + + const handleDisable = async () => { + try { + const result = await disableFeedsManager({ + variables: { id }, + }) + + const payload = result.data?.disableFeedsManager + switch (payload?.__typename) { + case 'DisableFeedsManagerSuccess': + dispatch(notifySuccessMsg('Job Distributor Disabled')) + break + case 'NotFoundError': + dispatch(notifyErrorMsg(payload.message)) + break + } + } catch (e) { + handleMutationError(e) + } + } + const payload = data?.feedsManager switch (payload?.__typename) { case 'NotFoundError': return case 'FeedsManager': - return + return ( + + ) default: return ( { renderWithRouter( - + {}} + onEnable={() => {}} + /> , ) diff --git a/src/screens/FeedsManager/FeedsManagerView.tsx b/src/screens/FeedsManager/FeedsManagerView.tsx index 4df36531..6957cefc 100644 --- a/src/screens/FeedsManager/FeedsManagerView.tsx +++ b/src/screens/FeedsManager/FeedsManagerView.tsx @@ -2,24 +2,34 @@ import React from 'react' import Grid from '@material-ui/core/Grid' -import { SupportedChainsCard } from './SupportedChainsCard' -import { FeedsManagerCard } from './FeedsManagerCard' -import { JobProposalsCard } from './JobProposalsCard' import { Heading1 } from 'src/components/Heading/Heading1' import { Heading2 } from 'src/components/Heading/Heading2' +import { FeedsManagerCard } from './FeedsManagerCard' +import { JobProposalsCard } from './JobProposalsCard' +import { SupportedChainsCard } from './SupportedChainsCard' interface Props { manager: FeedsManagerPayload_ResultsFields + onEnable: () => void | Promise + onDisable: () => void | Promise } -export const FeedsManagerView: React.FC = ({ manager }) => { +export const FeedsManagerView: React.FC = ({ + manager, + onDisable, + onEnable, +}) => { return ( Job Distributors - + diff --git a/src/screens/FeedsManager/ConnectionStatus.tsx b/src/screens/FeedsManager/StatusIndicator.tsx similarity index 56% rename from src/screens/FeedsManager/ConnectionStatus.tsx rename to src/screens/FeedsManager/StatusIndicator.tsx index 0474b1a8..b95689ea 100644 --- a/src/screens/FeedsManager/ConnectionStatus.tsx +++ b/src/screens/FeedsManager/StatusIndicator.tsx @@ -1,20 +1,20 @@ -import React from 'react' import green from '@material-ui/core/colors/green' import red from '@material-ui/core/colors/red' import { createStyles, WithStyles, withStyles } from '@material-ui/core/styles' import Typography from '@material-ui/core/Typography' import CancelIcon from '@material-ui/icons/Cancel' import CheckCircleIcon from '@material-ui/icons/CheckCircle' +import React from 'react' -const connectionStatusStyles = () => { +const statusStyles = () => { return createStyles({ root: { display: 'flex', }, - connectedIcon: { + activeIcon: { color: green[500], }, - disconnectedIcon: { + inactiveIcon: { color: red[500], }, text: { @@ -23,23 +23,24 @@ const connectionStatusStyles = () => { }) } -interface ConnectionStatusProps - extends WithStyles { - isConnected: boolean +interface StatusIndicatorProps extends WithStyles { + 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)