mirror of
https://github.com/NotAShelf/nix-evaluator-stats.git
synced 2026-05-03 22:47:55 +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>
|
||||
</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
|
||||
when={props.entries.length >= 2}
|
||||
fallback={
|
||||
|
|
@ -215,22 +231,6 @@ const ComparisonView: Component<ComparisonViewProps> = props => {
|
|||
</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
|
||||
when={leftEntry() && rightEntry()}
|
||||
fallback={
|
||||
|
|
|
|||
|
|
@ -87,11 +87,12 @@ export default function FileUpload(props: FileUploadProps) {
|
|||
onPaste={e => {
|
||||
const text = e.clipboardData?.getData('text');
|
||||
if (!text) return;
|
||||
e.preventDefault();
|
||||
try {
|
||||
JSON.parse(text);
|
||||
e.preventDefault();
|
||||
props.onTextLoad(text);
|
||||
} catch {
|
||||
setTextInput(text);
|
||||
setError('Invalid JSON in clipboard');
|
||||
}
|
||||
}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue