Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
chore(website): error viewer in playground#5061
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
14 commits Select commitHold shift + click to select a range
e122a08
chore(website): add POC for error viewer in playground
armano2236a440
chore(website): correct colors
armano20471e16
chore(website): correct issue with optional fixers
armano2d541bcb
chore(website): expose fixers to errors-viewer
armano244206d1
chore(website): add simple locking system for fixers
armano2164f254
Merge remote-tracking branch 'origin/main' into chore/errors-view-in-…
armano2d7c249a
chore(website): change label apply to fix
armano29790b65
Merge remote-tracking branch 'origin/main' into chore/errors-view-in-…
armano2f7691a0
fix: correct small issue with compilerOptions not updating in eslint
armano2f0ae860
fix: apply changes requested in code review
armano285ad1b8
Merge remote-tracking branch 'origin/main' into chore/errors-view-in-…
armano2b7d93c7
fix: apply changes from code review
armano259ca8ca
fix: add useMemo to cache model
armano23694da2
Update packages/website/src/components/ErrorsViewer.tsx
armano2File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletionpackages/website/data/sponsors.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -229,4 +229,4 @@ | ||
"totalDonations": 1500, | ||
"website": "https://www.mysportsinjury.co.uk" | ||
} | ||
] | ||
bradzacher marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. |
21 changes: 21 additions & 0 deletionspackages/website/src/components/ErrorsViewer.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.list { | ||
font-family: var(--ifm-font-family-monospace); | ||
background: transparent; | ||
border: none; | ||
padding-left: 1.5rem; | ||
padding-right: 1.5rem; | ||
font-size: 13px; | ||
line-height: 18px; | ||
letter-spacing: 0; | ||
font-feature-settings: 'liga' 0, 'calt' 0; | ||
box-sizing: border-box; | ||
white-space: break-spaces; | ||
margin: 0; | ||
} | ||
.fixer { | ||
margin: 0.5rem 1.5rem; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} |
111 changes: 111 additions & 0 deletionspackages/website/src/components/ErrorsViewer.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import React, { useEffect, useMemo, useState } from 'react'; | ||
import type Monaco from 'monaco-editor'; | ||
import type { ErrorItem } from './types'; | ||
import styles from './ErrorsViewer.module.css'; | ||
export interface ErrorsViewerProps { | ||
readonly value?: ErrorItem[]; | ||
} | ||
export interface ErrorBlockProps { | ||
readonly item: ErrorItem; | ||
readonly setIsLocked: (value: boolean) => void; | ||
readonly isLocked: boolean; | ||
} | ||
function severityClass(severity: Monaco.MarkerSeverity): string { | ||
switch (severity) { | ||
case 8: | ||
return 'danger'; | ||
case 4: | ||
return 'caution'; | ||
case 2: | ||
return 'note'; | ||
} | ||
return 'info'; | ||
} | ||
function groupErrorItems(items: ErrorItem[]): [string, ErrorItem[]][] { | ||
return Object.entries( | ||
items.reduce<Record<string, ErrorItem[]>>((acc, obj) => { | ||
if (!acc[obj.group]) { | ||
acc[obj.group] = []; | ||
} | ||
acc[obj.group].push(obj); | ||
return acc; | ||
}, {}), | ||
).sort(([a], [b]) => a.localeCompare(b)); | ||
} | ||
function ErrorBlock({ | ||
item, | ||
setIsLocked, | ||
isLocked, | ||
}: ErrorBlockProps): JSX.Element { | ||
return ( | ||
<div className={`admonition alert alert--${severityClass(item.severity)}`}> | ||
<div className="admonition-content"> | ||
<div className="row row--no-gutters"> | ||
<div className="col col--12"> | ||
{item.message} {item.location} | ||
</div> | ||
{item.hasFixers && ( | ||
<div className="col col--12"> | ||
{item.fixers.map((fixer, index) => ( | ||
<div key={index} className={styles.fixer}> | ||
<span>> {fixer.message}</span> | ||
<button | ||
className="button button--primary button--sm" | ||
disabled={isLocked} | ||
onClick={(): void => { | ||
fixer.fix(); | ||
setIsLocked(true); | ||
}} | ||
> | ||
fix | ||
</button> | ||
</div> | ||
))} | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
export default function ErrorsViewer({ | ||
value, | ||
}: ErrorsViewerProps): JSX.Element { | ||
const model = useMemo( | ||
() => (value ? groupErrorItems(value) : undefined), | ||
[value], | ||
); | ||
const [isLocked, setIsLocked] = useState(false); | ||
useEffect(() => { | ||
setIsLocked(false); | ||
}, [value]); | ||
armano2 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
return ( | ||
<div className={styles.list}> | ||
{model?.map(([group, data]) => { | ||
return ( | ||
<div className="margin-top--sm" key={group}> | ||
<h4>{group}</h4> | ||
{data.map((item, index) => ( | ||
<ErrorBlock | ||
isLocked={isLocked} | ||
setIsLocked={setIsLocked} | ||
item={item} | ||
key={index} | ||
/> | ||
))} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
} |
4 changes: 0 additions & 4 deletionspackages/website/src/components/Playground.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -10,10 +10,6 @@ | ||
border: 1px solid var(--ifm-color-emphasis-100); | ||
} | ||
.codeBlocks { | ||
display: flex; | ||
flex-direction: row; | ||
50 changes: 23 additions & 27 deletionspackages/website/src/components/Playground.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletionpackages/website/src/components/editor/LoadedEditor.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletionspackages/website/src/components/editor/createProvideCodeActions.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletionpackages/website/src/components/editor/types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletionspackages/website/src/components/linter/WebLinter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
29 changes: 13 additions & 16 deletionspackages/website/src/components/linter/lintCode.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.