mirror of
https://github.com/NotAShelf/nix-evaluator-stats.git
synced 2026-05-17 12:44:16 +00:00
packages/web: allow editing invalid JSON paste; show snapshots list with 1+ entries
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I627907cd02575fb6e84c7837cf1712746a6a6964
This commit is contained in:
parent
1541046669
commit
6102e75a9e
2 changed files with 18 additions and 17 deletions
|
|
@ -195,6 +195,22 @@ const ComparisonView: Component<ComparisonViewProps> = props => {
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
|
<Show when={props.entries.length > 0}>
|
||||||
|
<div class="snapshots-list">
|
||||||
|
<h4>Saved Snapshots</h4>
|
||||||
|
<For each={props.entries}>
|
||||||
|
{entry => (
|
||||||
|
<div class="snapshot-item">
|
||||||
|
<span class="snapshot-name">{entry.name}</span>
|
||||||
|
<button class="delete-btn" onClick={() => props.onDelete(entry.id)}>
|
||||||
|
<XIcon size={16} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</For>
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
|
|
||||||
<Show
|
<Show
|
||||||
when={props.entries.length >= 2}
|
when={props.entries.length >= 2}
|
||||||
fallback={
|
fallback={
|
||||||
|
|
@ -215,22 +231,6 @@ const ComparisonView: Component<ComparisonViewProps> = props => {
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Show when={props.entries.length > 0}>
|
|
||||||
<div class="snapshots-list">
|
|
||||||
<h4>Saved Snapshots</h4>
|
|
||||||
<For each={props.entries}>
|
|
||||||
{entry => (
|
|
||||||
<div class="snapshot-item">
|
|
||||||
<span class="snapshot-name">{entry.name}</span>
|
|
||||||
<button class="delete-btn" onClick={() => props.onDelete(entry.id)}>
|
|
||||||
<XIcon size={16} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</For>
|
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
|
|
||||||
<Show
|
<Show
|
||||||
when={leftEntry() && rightEntry()}
|
when={leftEntry() && rightEntry()}
|
||||||
fallback={
|
fallback={
|
||||||
|
|
|
||||||
|
|
@ -87,11 +87,12 @@ export default function FileUpload(props: FileUploadProps) {
|
||||||
onPaste={e => {
|
onPaste={e => {
|
||||||
const text = e.clipboardData?.getData('text');
|
const text = e.clipboardData?.getData('text');
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
e.preventDefault();
|
|
||||||
try {
|
try {
|
||||||
JSON.parse(text);
|
JSON.parse(text);
|
||||||
|
e.preventDefault();
|
||||||
props.onTextLoad(text);
|
props.onTextLoad(text);
|
||||||
} catch {
|
} catch {
|
||||||
|
setTextInput(text);
|
||||||
setError('Invalid JSON in clipboard');
|
setError('Invalid JSON in clipboard');
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue