Commit Graph

5 Commits

Author SHA1 Message Date
Carlos Mendez
5a58c8516f feat: improved error message for CSV import (#5484)
<!--
Title (for the Pull Request title field at the top):
Use a short prefix so the change type is obvious. You do not need to
repeat it in the body below.

Examples:
- fix: — bugfix
- feat: — feature
- refactor: — internal change without user-facing feature
- docs: — documentation only
- chore: — tooling, CI, deps, build housekeeping
- test: — tests only
-->

## Linked issue (required)

<!-- Fixes #123 / Closes #123 -->
Fixes #4346 

## Summary / motivation (required)

<!-- What this PR does and why. For larger changes, add enough context
for reviewers. -->
Improves the CSV import error experience for empty or invalid CSV files.

Previously, the import error page exposed an HTTP status code and did
not provide a clear way for the user to dismiss the error and return to
the main Anki window.

Changes:
- displays the import error without exposing the HTTP status code
- adds an "Okay" button to dismiss the error
- use Anki frontend RPC architecture to close the active import dialog
- handles CSV import loader errors with a try/catch and displays them
through the shared ErrorPage component

The solution uses the existing `ImportDialog.reject()` path so the
dialog box performs normal clean up before closing.

This implementation was inspired by the previous discussion and earlier
work in #4383. Thank you @medProgAyat and @josod827. Your discussion and
implementations were a great assest to helping me solve and implement a
solution.

## Steps to reproduce (required, use N/A if not applicable)

<!-- Steps to reproduce: how to trigger the bug in the broken state (the
"before").
 - Mainly for bugfixes;
    - For bugs: numbered steps before the fix. For non-bugs: write N/A.
 - use N/A for features, refactors, docs, chore, etc.
-->

1. open Anki and click on import button
2. select a empty csv
3. error page should open

## How to test (required)

<!--- How to test: how you verified the change (checks, unit tests,
manual steps, edge cases — the "after" or general validation). --->

### Checklist (minimum)

- [ x] I ran `./ninja check` or an equivalent relevant check locally.
- [ ] I added or updated tests when the change is non-trivial or
behavior changed.

### Details

<!-- Commands, manual steps, edge cases, and what you observed -->
Manual testing:
1. Imported an empty CSV file.
2. Confirmed the custom error page is displayed.
3. Confirmed the HTTP status code is not displayed to the user.
4. Confirmed clicking the "Okay" button closes the import dialog and
returns to the main Anki window.
5. Imported a valid CSV file and confirmed the normal CSV import flow
still works.

## Before / after behavior (optional)

<!-- For bugfixes: behavior before vs after. For other types: N/A or a
short note. -->

Before:
- Empty CSV imports display an error without a clear dismissal action.
- Development error output may include the HTTP status code.

After:
- The error is displayed through the shared error UI.
- The user can click "Okay" to close the import dialog.
- The close action is handled through a frontend RPC.

## Risk / compatibility / migration (optional)

<!-- Breaking changes, rollout notes, or N/A for small / low-risk PRs
-->

Low risk. The change is limited to CSV import error handling and the
import dialog close path.


## UI evidence (required for visual changes; otherwise N/A)

<!-- Screenshot or short video -->

before:
<img width="800" height="800" alt="image"
src="https://github.com/user-attachments/assets/4fe77689-3ebd-4a98-9bd9-4916214bbb29"
/>

after:
<img width="788" height="818" alt="image"
src="https://github.com/user-attachments/assets/8451f465-894a-4f52-a11b-459fc6840326"
/>


## Scope

- [x ] This PR is focused on one change (no unrelated edits).
2026-09-01 15:43:18 +03:00
Abdo
643187a050 Shift editor control to TypeScript (#4029)
Closes https://github.com/ankitects/anki/issues/3830

---------

Co-authored-by: Fernando Lins <fernandolins@users.noreply.github.com>
2026-07-03 21:56:43 +03:00
Abdo
e2886017bd Ignore Fluent message errors in TypeScript (#4494)
Closes #4490

The italian and Catalan translations for the
importing-note-updated-as-file-had-newer string contain a variable
reference (probably from an older version of the string). We can avoid
throwing an exception in such cases by passing the `errors` argument to
`FluentBundle.formatpattern()`:
https://projectfluent.org/fluent.js/classes/_fluent_bundle.FluentBundle.html#formatpattern
2026-03-31 17:41:28 +03:00
Damien Elmes
e66adcca38 alertOnError should default to true
Regressed in svelte-kit port
2024-04-17 20:13:37 +10:00
Damien Elmes
9f55cf26fc Switch to SvelteKit (#3077)
* Update to latest Node LTS

* Add sveltekit

* Split tslib into separate @generated and @tslib components

SvelteKit's path aliases don't support multiple locations, so our old
approach of using @tslib to refer to both ts/lib and out/ts/lib will no
longer work. Instead, all generated sources and their includes are
placed in a separate out/ts/generated folder, and imported via @generated
instead. This also allows us to generate .ts files, instead of needing
to output separate .d.ts and .js files.

* Switch package.json to module type

* Avoid usage of baseUrl

Incompatible with SvelteKit

* Move sass into ts; use relative links

SvelteKit's default sass support doesn't allow overriding loadPaths

* jest->vitest, graphs example working with yarn dev

* most pages working in dev mode

* Some fixes after rebasing

* Fix/silence some svelte-check errors

* Get image-occlusion working with Fabric types

* Post-rebase lock changes

* Editor is now checked

* SvelteKit build integrated into ninja

* Use the new SvelteKit entrypoint for pages like congrats/deck options/etc

* Run eslint once for ts/**; fix some tests

* Fix a bunch of issues introduced when rebasing over latest main

* Run eslint fix

* Fix remaining eslint+pylint issues; tests now all pass

* Fix some issues with a clean build

* Latest bufbuild no longer requires @__PURE__ hack

* Add a few missed dependencies

* Add yarn.bat to fix Windows build

* Fix pages failing to show when ANKI_API_PORT not defined

* Fix svelte-check and vitest on Windows

* Set node path in ./yarn

* Move svelte-kit output to ts/.svelte-kit

Sadly, I couldn't figure out a way to store it in out/ if out/ is
a symlink, as it breaks module resolution when SvelteKit is run.

* Allow HMR inside Anki

* Skip SvelteKit build when HMR is defined

* Fix some post-rebase issues

I should have done a normal merge instead.
2024-03-31 09:16:31 +01:00