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

Prod Release 06/08/24 #970

Merged
merged 10 commits into from
Aug 6, 2024
Prev Previous commit
Next Next commit
feat: run formatter/prettier on launchpad's generated code in Editor (#…
Kevin101Zhang authored Aug 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit e67d2da78e53bd439bba99cb15b9a1f6a911c9ad
7 changes: 4 additions & 3 deletions frontend/src/components/Editor/EditorComponents/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { request, useInitialPayload } from 'near-social-bridge';

Check warning on line 1 in frontend/src/components/Editor/EditorComponents/Editor.tsx

GitHub Actions / lint

Run autofix to sort these imports!
import type { ReactElement } from 'react';
import type { Method, Event } from '@/pages/api/generateCode';

@@ -31,7 +31,7 @@

declare const monaco: any;
const INDEXER_TAB_NAME = 'indexer.js';
const SCHEMA_TAB_NAME = 'schema.sql';

Check warning on line 34 in frontend/src/components/Editor/EditorComponents/Editor.tsx

GitHub Actions / lint

'SCHEMA_TAB_NAME' is assigned a value but never used. Allowed unused vars must match /^_/u
const originalSQLCode = formatSQL(defaultSchema);
const originalIndexingCode = formatIndexingCode(defaultCode);
const pgSchemaTypeGen = new PgSchemaTypeGen();
@@ -71,7 +71,7 @@
const [heights, setHeights] = useState<number[]>(initialHeights);

const [diffView, setDiffView] = useState<boolean>(false);
const [blockView, setBlockView] = useState<boolean>(false);

Check warning on line 74 in frontend/src/components/Editor/EditorComponents/Editor.tsx

GitHub Actions / lint

'setBlockView' is assigned a value but never used. Allowed unused vars must match /^_/u
const { showModal } = useModal();

const [isExecutingIndexerFunction, setIsExecutingIndexerFunction] = useState<boolean>(false);
@@ -131,7 +131,7 @@
const data = await response.json();

if (!data.hasOwnProperty('jsCode') || !data.hasOwnProperty('sqlCode')) {
throw new Error('No code was returned from the server');
throw new Error('No code was returned from the server with properties jsCode and sqlCode');
}

return data;
@@ -151,15 +151,16 @@
}

const codeResponse = await generateCode(wizardContractFilter, wizardMethods, wizardEvents);
setIndexingCode(codeResponse.jsCode);
setSchema(codeResponse.sqlCode);
const { validatedCode, validatedSchema } = reformatAll(codeResponse.jsCode, codeResponse.sqlCode);
validatedCode && setIndexingCode(validatedCode);
validatedSchema && setSchema(validatedSchema);
} catch (error: unknown) {
//todo: figure out best course of action for user if api fails
console.error(error);
}
};
fetchData();
}, []);

Check warning on line 163 in frontend/src/components/Editor/EditorComponents/Editor.tsx

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'reformatAll'. Either include it or remove the dependency array

useEffect(() => {
//* Load saved code from local storage if it exists else load code from context
@@ -177,7 +178,7 @@
monacoEditorRef.current.setPosition(savedCursorPosition || { lineNumber: 1, column: 1 });
monacoEditorRef.current.focus();
}
}, [indexerDetails.code]);

Check warning on line 181 in frontend/src/components/Editor/EditorComponents/Editor.tsx

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'fileName' and 'storageManager'. Either include them or remove the dependency array

useEffect(() => {
//* Load saved schema from local storage if it exists else load code from context
@@ -188,7 +189,7 @@
schemaErrorHandler(schemaError);
formattedSchema && setSchema(formattedSchema);
}
}, [indexerDetails.schema]);

Check warning on line 192 in frontend/src/components/Editor/EditorComponents/Editor.tsx

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'storageManager'. Either include it or remove the dependency array

useEffect(() => {
const { error: schemaError } = validateSQLSchema(schema);
@@ -201,11 +202,11 @@
}

handleCodeGen();
}, [fileName]);

Check warning on line 205 in frontend/src/components/Editor/EditorComponents/Editor.tsx

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'handleCodeGen', 'indexingCode', and 'schema'. Either include them or remove the dependency array

useEffect(() => {
cacheToLocal();
}, [indexingCode, schema]);

Check warning on line 209 in frontend/src/components/Editor/EditorComponents/Editor.tsx

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'cacheToLocal'. Either include it or remove the dependency array

useEffect(() => {
if (!monacoEditorRef.current) return;
@@ -216,12 +217,12 @@
return () => {
editorInstance.dispose();
};
}, [monacoEditorRef.current]);

Check warning on line 220 in frontend/src/components/Editor/EditorComponents/Editor.tsx

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'handleCursorChange'. Either include it or remove the dependency array. Mutable values like 'monacoEditorRef.current' aren't valid dependencies because mutating them doesn't re-render the component

useEffect(() => {
storageManager?.setSchemaTypes(schemaTypes);
handleCodeGen();
}, [schemaTypes, monacoMount]);

Check warning on line 225 in frontend/src/components/Editor/EditorComponents/Editor.tsx

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'handleCodeGen' and 'storageManager'. Either include them or remove the dependency array

useEffect(() => {
storageManager?.setDebugList(heights);