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

chore: remove empty filter/empty indexer name JSX elements when creating a new indexer and renamed BOS jsx elements #973

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ const DeveloperToolsView = ({

return (
<div className="bg-gray-100 rounded-lg p-2 mb-0 mx-2">
<div className="text-center mb-3">
<span className="text-xs font-medium">Developer Tools</span>
</div>
<div className="flex justify-between">
<div className="flex space-x-1">
<button
Expand Down
26 changes: 12 additions & 14 deletions frontend/src/components/Editor/EditorView/EditorMenuView.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Navbar, Container, InputGroup, Form, ButtonGroup, Button } from 'react-bootstrap';
import { Navbar, Container, InputGroup, ButtonGroup, Button } from 'react-bootstrap';
import { Braces, ArrowCounterclockwise, FileText, TrashFill } from 'react-bootstrap-icons';
import CustomTooltip, { TooltipDirection } from '@/components/Common/CustomTooltip';

Expand All @@ -21,19 +21,17 @@ const EditorMenuView = ({
<Navbar bg="white" variant="light" className="shadow-sm p-3 bg-white rounded">
<Container fluid className="d-flex flex-wrap justify-content-between align-items-center">
<div className="d-flex flex-wrap align-items-center">
<span className="me-4 font-weight-bold text-secondary text-sm">
Indexer: {accountId}/{indexerName ? indexerName : 'Null'}
</span>
<span className="me-4 font-weight-bold text-secondary text-sm">
Filter:{' '}
{!isCreateNewIndexer ? (
indexerDetails.rule.affected_account_id
) : (
<InputGroup size="sm" hasValidation={true} style={{ width: 'fit-content' }}>
<Form.Control.Feedback type="invalid">Please provide a valid contract name.</Form.Control.Feedback>
</InputGroup>
)}
</span>
{accountId && indexerName && (
<span className="me-4 font-weight-bold text-secondary text-sm">
Indexer: {accountId}/{indexerName}
</span>
)}

{!isCreateNewIndexer && (
<span className="me-4 font-weight-bold text-secondary text-sm">
Filter: {indexerDetails.rule.affected_account_id}
</span>
)}
</div>
<ButtonGroup className="mt-3 mt-md-0">
{isUserIndexer && !isCreateNewIndexer && (
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/api/generateCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const validateRequestBody = (body: any): body is RequestBody => {
return (
isStringOrArray(body.contractFilter) &&
Array.isArray(body.selectedMethods) &&
body.selectedMethods.every(isValidMethod)
&& Array.isArray(body.selectedEvents) &&
body.selectedMethods.every(isValidMethod) &&
Array.isArray(body.selectedEvents) &&
body.selectedEvents.every(isValidEvent)
);
};
Expand Down
62 changes: 32 additions & 30 deletions frontend/src/test/api/generateCode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,42 +79,44 @@ describe('generateCode API ', () => {
const { req, res } = createRequestResponseMocks('POST', {
contractFilter: 'filter',
selectedMethods: [],
selectedEvents: [{
event_name: 'register',
schema: {
type: 'object',
properties: {
function_name: {
type: 'string',
},
code: {
type: 'string',
},
schema: {
type: 'string',
},
start_block_height: {
type: 'integer',
},
filter_json: {
type: 'string',
selectedEvents: [
{
event_name: 'register',
schema: {
type: 'object',
properties: {
function_name: {
type: 'string',
},
code: {
type: 'string',
},
schema: {
type: 'string',
},
start_block_height: {
type: 'integer',
},
filter_json: {
type: 'string',
},
},
required: ['function_name', 'code', 'schema', 'start_block_height', 'filter_json'],
},
required: ['function_name', 'code', 'schema', 'start_block_height', 'filter_json'],
},
},
{
event_name: 'remove_indexer_function',
schema: {
type: 'object',
properties: {
function_name: {
type: 'string',
{
event_name: 'remove_indexer_function',
schema: {
type: 'object',
properties: {
function_name: {
type: 'string',
},
},
required: ['function_name'],
},
required: ['function_name'],
},
},],
],
});

handler(req, res);
Expand Down
8 changes: 4 additions & 4 deletions frontend/widgets/src/QueryApi.Launchpad.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ const LoadingSpinner = () => {
justify-content: center;
font-size: 14px;
`
return <LoadingContainer> <LoadingSpinnerContainer><div style={spinnerStyle} /> </LoadingSpinnerContainer><>Generating Methods</></LoadingContainer>;
return <LoadingContainer> <LoadingSpinnerContainer><div style={spinnerStyle} /> </LoadingSpinnerContainer><>Inspecting Methods and Events</></LoadingContainer>;
};


Expand Down Expand Up @@ -440,8 +440,8 @@ const handleFetchCheckboxData = async () => {
}
const data = response.body;

if (data.length === 0) {
setContractInputMessage('No methods found for this contract');
if (data.methods.length === 0 && data.events.length === 0) {
setContractInputMessage('No methods and events found for this filter');
setLoading(false);
return;
};
Expand Down Expand Up @@ -612,7 +612,7 @@ return (
<NoQuerySVG
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none" /><line x1="144" y1="224" x2="112" y2="224" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16" /><circle cx="128" cy="100" r="12" fill="#A1A09A" /><path d="M94.81,192C37.52,95.32,103.87,32.53,123.09,17.68a8,8,0,0,1,9.82,0C152.13,32.53,218.48,95.32,161.19,192Z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16" /><path d="M183.84,110.88l30.31,36.36a8,8,0,0,1,1.66,6.86l-12.36,55.63a8,8,0,0,1-12.81,4.51L161.19,192" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16" /><path d="M72.16,110.88,41.85,147.24a8,8,0,0,0-1.66,6.86l12.36,55.63a8,8,0,0,0,12.81,4.51L94.81,192" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16" />
</NoQuerySVG>
<NoQueryText>No smart contract address entered</NoQueryText>
<NoQueryText>Enter smart contract filter on the left</NoQueryText>
</NoQueryContainer>
</>
: (
Expand Down
Loading