Skip to content
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

Add loading spinners and mermaid error handling #12358

Merged
merged 1 commit into from Aug 4, 2020

Conversation

silverwind
Copy link
Member

@silverwind silverwind commented Jul 28, 2020

  • Add loading spinners on editor and mermaid renderers
  • Add error handling and inline error box for mermaid
  • Fix mermaid rendering by using the .init API

image

image

image

image

@lafriks lafriks added topic/ui Change the appearance of the Gitea UI skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. labels Jul 28, 2020
@lafriks lafriks added this to the 1.13.0 milestone Jul 28, 2020
@lafriks
Copy link
Member

lafriks commented Jul 28, 2020

Could you rename loadingcircle to is-loading?

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 28, 2020
@silverwind
Copy link
Member Author

I'm kind of wary of using too common classnames because they could clash with other frameworks like swagger-ui that uses .loading. .is-loading is probably fine thought.

@silverwind
Copy link
Member Author

Classes switched.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 28, 2020
@lafriks
Copy link
Member

lafriks commented Jul 28, 2020

Bit off topic... But related, what will happen if mermaid can not render image because of syntax error?

@silverwind
Copy link
Member Author

silverwind commented Jul 28, 2020

I think it may throw an JS error, not sure how well that library behaves or if it has a fallback rendering. Looking at GitLab code, they seem to have a .catch handler for such an case.

Edit: Yeah it does throw an error. Will check that later. Probably good to fix this in this PR because otherwise the box would stay loading forever.

@silverwind silverwind marked this pull request as draft July 28, 2020 22:55
@silverwind silverwind changed the title Add loading spinner on editor and mermaid renderer Add loading spinners and toasts system Jul 29, 2020
@silverwind silverwind marked this pull request as ready for review July 29, 2020 19:28
@silverwind silverwind force-pushed the spinners branch 2 times, most recently from 9736b24 to ac57d87 Compare July 29, 2020 19:39
@silverwind silverwind marked this pull request as draft July 29, 2020 19:57
@silverwind silverwind force-pushed the spinners branch 3 times, most recently from fe2fe18 to f33f740 Compare July 30, 2020 18:29
@silverwind silverwind changed the title Add loading spinners and toasts system Add loading spinners and mermaid error handling Jul 30, 2020
@silverwind silverwind marked this pull request as ready for review July 30, 2020 18:34
@silverwind
Copy link
Member Author

silverwind commented Jul 30, 2020

Ready for review again. I went with a inline error block on mermaid errors:

image

image

@silverwind
Copy link
Member Author

One more tweak: text is now left-aligned so the ----^ pointers work:

image

@silverwind
Copy link
Member Author

silverwind commented Jul 31, 2020

It seems the way we initialize mermaid using mermaidApi is resulting in many weird/wrong renderings even thought docs say it's the recommended method. mermaid.init seems to produce better renderings, working on using that instead.

@silverwind
Copy link
Member Author

silverwind commented Jul 31, 2020

Should be fixed. That API of mermaid is absolutely horrendous, especially its error handling but this seems to produce much better renderings now for me.

- Add loading spinners on editor and mermaid renderers
- Add error handling and inline error box for mermaid
- Fix Mermaid rendering by using the .init api
@silverwind
Copy link
Member Author

Squashed, update OP and removed a few outdated comments in this PR.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Aug 4, 2020
@zeripath
Copy link
Contributor

zeripath commented Aug 4, 2020

I still think we'll end up with mermaid being used outside of markdown and will have to move stuff around but that's fine

@zeripath zeripath merged commit e61c09e into go-gitea:master Aug 4, 2020
@silverwind
Copy link
Member Author

Yeah I guess we can move both less and js files around then but the current structure is good enough for markdown-only content like mermaid currently.

@silverwind silverwind deleted the spinners branch August 4, 2020 20:12
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. topic/ui Change the appearance of the Gitea UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants