-
Notifications
You must be signed in to change notification settings - Fork 191
feat: show CSV import error details with inline indicator and modal #2401
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,7 +8,9 @@ | |||||||||||||||||||||||||||||
import { getProjectId } from '$lib/helpers/project'; | ||||||||||||||||||||||||||||||
import { writable, type Writable } from 'svelte/store'; | ||||||||||||||||||||||||||||||
import { addNotification } from '$lib/stores/notifications'; | ||||||||||||||||||||||||||||||
import { Layout, Typography } from '@appwrite.io/pink-svelte'; | ||||||||||||||||||||||||||||||
import { Layout, Typography, Icon } from '@appwrite.io/pink-svelte'; | ||||||||||||||||||||||||||||||
import { IconExclamationCircle } from '@appwrite.io/pink-icons-svelte'; | ||||||||||||||||||||||||||||||
import { Modal, Code } from '$lib/components'; | ||||||||||||||||||||||||||||||
import { type Models, type Payload, Query } from '@appwrite.io/console'; | ||||||||||||||||||||||||||||||
// re-render the key for sheet UI. | ||||||||||||||||||||||||||||||
|
@@ -18,6 +20,7 @@ | |||||||||||||||||||||||||||||
type ImportItem = { | ||||||||||||||||||||||||||||||
status: string; | ||||||||||||||||||||||||||||||
table?: string; | ||||||||||||||||||||||||||||||
errors?: string[]; | ||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||
type ImportItemsMap = Map<string, ImportItem>; | ||||||||||||||||||||||||||||||
|
@@ -112,7 +115,10 @@ | |||||||||||||||||||||||||||||
if (shouldSkip) return items; | ||||||||||||||||||||||||||||||
const next = new Map(items); | ||||||||||||||||||||||||||||||
next.set(importData.$id, { status, table: tableName ?? undefined }); | ||||||||||||||||||||||||||||||
const errors = Array.isArray((importData as Payload).errors) | ||||||||||||||||||||||||||||||
? ((importData as Payload).errors as string[]) | ||||||||||||||||||||||||||||||
: undefined; | ||||||||||||||||||||||||||||||
next.set(importData.$id, { status, table: tableName ?? undefined, errors }); | ||||||||||||||||||||||||||||||
return next; | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
|
@@ -138,7 +144,7 @@ | |||||||||||||||||||||||||||||
return 60; | ||||||||||||||||||||||||||||||
case 'completed': | ||||||||||||||||||||||||||||||
case 'failed': | ||||||||||||||||||||||||||||||
return 100; | ||||||||||||||||||||||||||||||
return 60; | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be 100% because the process is completed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why was this marked resolved? |
||||||||||||||||||||||||||||||
default: | ||||||||||||||||||||||||||||||
return 30; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
@@ -149,7 +155,7 @@ | |||||||||||||||||||||||||||||
switch (status) { | ||||||||||||||||||||||||||||||
case 'completed': | ||||||||||||||||||||||||||||||
case 'failed': | ||||||||||||||||||||||||||||||
return `Import to ${name} ${status}`; | ||||||||||||||||||||||||||||||
return `Importing CSV file${name ? ` to ${name}` : ''}`; | ||||||||||||||||||||||||||||||
HarshMN2345 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||
case 'processing': | ||||||||||||||||||||||||||||||
return `Importing CSV file${name ? ` to ${name}` : ''}`; | ||||||||||||||||||||||||||||||
default: | ||||||||||||||||||||||||||||||
Comment on lines
157
to
162
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy fix: Completed/failed messages shouldn't say "Importing". Use explicit completed/failed text for clarity. Apply this diff: - case 'completed':
- case 'failed':
- return `Importing CSV file${name ? ` to ${name}` : ''}`;
+ case 'completed':
+ return `CSV import finished${name ? ` for ${name}` : ''}.`;
+ case 'failed':
+ return `CSV import failed${name ? ` for ${name}` : ''}.`; 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree @HarshMN2345 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||||||
|
@@ -179,6 +185,22 @@ | |||||||||||||||||||||||||||||
$: isOpen = true; | ||||||||||||||||||||||||||||||
$: showCsvImportBox = $importItems.size > 0; | ||||||||||||||||||||||||||||||
let showDetails = false; | ||||||||||||||||||||||||||||||
let selectedErrors: string[] = []; | ||||||||||||||||||||||||||||||
function openDetails(errors: string[] | undefined) { | ||||||||||||||||||||||||||||||
selectedErrors = errors ?? []; | ||||||||||||||||||||||||||||||
showDetails = true; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
$: parsedErrors = selectedErrors.map((err) => { | ||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||
return JSON.stringify(JSON.parse(err), null, 2); | ||||||||||||||||||||||||||||||
} catch { | ||||||||||||||||||||||||||||||
return err; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
HarshMN2345 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||
</script> | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
{#if showCsvImportBox} | ||||||||||||||||||||||||||||||
|
@@ -222,6 +244,25 @@ | |||||||||||||||||||||||||||||
class:is-danger={value.status === 'failed'} | ||||||||||||||||||||||||||||||
style="--graph-size:{graphSize(value.status)}%"> | ||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||
{#if value.status === 'failed'} | ||||||||||||||||||||||||||||||
<Layout.Stack | ||||||||||||||||||||||||||||||
direction="row" | ||||||||||||||||||||||||||||||
gap="xs" | ||||||||||||||||||||||||||||||
alignItems="center" | ||||||||||||||||||||||||||||||
inline> | ||||||||||||||||||||||||||||||
<Icon | ||||||||||||||||||||||||||||||
icon={IconExclamationCircle} | ||||||||||||||||||||||||||||||
color="--fgcolor-error" | ||||||||||||||||||||||||||||||
size="s" /> | ||||||||||||||||||||||||||||||
<Typography.Text color="--fgcolor-error"> | ||||||||||||||||||||||||||||||
There was an import issue. | ||||||||||||||||||||||||||||||
<button | ||||||||||||||||||||||||||||||
class="link-button" | ||||||||||||||||||||||||||||||
on:click={() => openDetails(value.errors)} | ||||||||||||||||||||||||||||||
>View details</button> | ||||||||||||||||||||||||||||||
</Typography.Text> | ||||||||||||||||||||||||||||||
</Layout.Stack> | ||||||||||||||||||||||||||||||
{/if} | ||||||||||||||||||||||||||||||
</section> | ||||||||||||||||||||||||||||||
</li> | ||||||||||||||||||||||||||||||
</ul> | ||||||||||||||||||||||||||||||
|
@@ -232,6 +273,14 @@ | |||||||||||||||||||||||||||||
</Layout.Stack> | ||||||||||||||||||||||||||||||
{/if} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
<Modal title="Import error" bind:show={showDetails} hideFooter> | ||||||||||||||||||||||||||||||
<Layout.Stack gap="m"> | ||||||||||||||||||||||||||||||
<Layout.Stack> | ||||||||||||||||||||||||||||||
<Code language="json" code={parsedErrors.join('\n\n')} withCopy allowScroll /> | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need join? the parser should already have formatted logs, right? Also refer - https://github.com/appwrite/console/blob/main/src/routes/(console)/project-%5Bregion%5D-%5Bproject%5D/settings/migrations/details.svelte |
||||||||||||||||||||||||||||||
</Layout.Stack> | ||||||||||||||||||||||||||||||
</Layout.Stack> | ||||||||||||||||||||||||||||||
</Modal> | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
<style lang="scss"> | ||||||||||||||||||||||||||||||
.upload-box { | ||||||||||||||||||||||||||||||
display: flex; | ||||||||||||||||||||||||||||||
|
@@ -252,7 +301,7 @@ | |||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
.upload-box-content { | ||||||||||||||||||||||||||||||
width: 304px; | ||||||||||||||||||||||||||||||
width: 324px; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
.upload-box-button { | ||||||||||||||||||||||||||||||
|
@@ -274,4 +323,13 @@ | |||||||||||||||||||||||||||||
background-color: var(--bgcolor-error); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
.link-button { | ||||||||||||||||||||||||||||||
background: none; | ||||||||||||||||||||||||||||||
border: none; | ||||||||||||||||||||||||||||||
padding: 0; | ||||||||||||||||||||||||||||||
color: var(--fgcolor-error); | ||||||||||||||||||||||||||||||
text-decoration: underline; | ||||||||||||||||||||||||||||||
cursor: pointer; | ||||||||||||||||||||||||||||||
HarshMN2345 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
</style> |
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.
don't think we need to cast here. we have a similar check above for
showCompletionNotification
, we can make a helper function to return the error instead of hard type casts and duplicating the logic.