-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Enhance Schema Error Visualization with New Icons #855
feat: Enhance Schema Error Visualization with New Icons #855
Conversation
…iple-rerenders-on-editor-lifecycle
…iple-rerenders-on-editor-lifecycle
…github.com/near/queryapi into 836-multiple-rerenders-on-editor-lifecycle
Schema now no longer throws an Alert component in between the Editor and the DevelopMenu cause a 'janky experience'. Instead schema not showcases errors based on the file tab itself through small icons. Similarly the debugMode no longer has a Alert component but is now directs the user to open their console through a onHover tooltip. Indexer.js has a similar funtionality but is locked through a feature flag as it is dependent on Monaco having types of node, near-lake first before we can properly prompt the user there is an error in the Indexer. |
There's a lot going on in this PR, could you please split it in to smaller ones, one for each of the Smaller PRs are preferable because they:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small change in validators.ts, no functionality change.
Purpose is to make the error handling more consistent with others functions in the same file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small change in index.js, no functionality change.
Purpose is to make component more readable
@morgsmccauley I removed the "fix: multiple rerenders" to a different PR. The exception are the 2 small more readability refactors in the files commented above that are trivial. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a few minor comments
Indexer.js | ||
<span>Indexer.js</span> | ||
<div className="inline-flex items-center"> | ||
{/* {indexerError ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we just remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to add this the second I get monaco Types inserted. I attempted it with a little time but I was having trouble. Will retackle it in the next ticket so I would like to keep it
console.error(error.message); | ||
return { data: code, error }; | ||
} else { | ||
throw error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand, there is a functional change here. Previously, if the error was not an Error
it would be re-thrown. Are you sure we don't need that functionality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Im fairly certain the error will be handled properly.
const debouncedValidateCode = useDebouncedCallback((_code: string) => {
const { error } = validateJSCode(_code);
console.log(error);
indexerErrorHandler(error);
}, 500);
export function validateJSCode(code: string): { data: string | null; error: Error | null } {
if (!code) return { data: null, error: null };
try {
const formattedCode = formatIndexingCode(code);
return { data: formattedCode, error: null };
} catch (error: any) {
return {
data: code,
error: error.message,
};
}
}
export const formatIndexingCode = (code) => {
try {
return prettier.format(code, {
parser: 'babel',
plugins: [parserBabel],
});
} catch (error) {
throw new Error(`Failed to format code: ${error.message}`);
}
};
validateJSCode function will attempt to format the code. If an error occurs during formatting, it catches the error and returns it. formatIndexingCode function tries to format the code using Prettier. If Prettier fails, it throws an error with a clear message. This error will be caught by the validateJSCode function.
Optimized Editor Lifecycle methods and removed the 'janky' Alert that would insert itself between the developer tools and Editor component in favor of a small icon that is in the fileswitcher.