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

feat: add template #3032

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

Conversation

AmanNegi
Copy link
Contributor

@AmanNegi AmanNegi commented Jul 20, 2023

Issue: Add Template in AppFlowy

Fixes #444


This Issue basically aims at adding the template feature in AppFlowy. This allows users to export their documents as templates and share them with others meanwhile, others can simply import the template to achieve the same structure. A further feature request may add the feature to add a Template Marketplace to AppFlowy as well.

Major Challenges

  • Importing Nested Documents.
  • Importing Databases while maintaining references.
  • Importing Local Images.

📹✨ Find Progress Clips here.

PR Checklist

  • My code adheres to the AppFlowy Style Guide
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

- added Template service to create/use template
- updated Rust code to return id after adding db
@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Attention: 31 lines in your changes are missing coverage. Please review.

Comparison is base (94f9349) 9.70% compared to head (b6e1cb6) 64.77%.
Report is 102 commits behind head on main.

❗ Current head b6e1cb6 differs from pull request most recent head 8420071. Consider uploading reports for the commit 8420071 to get more accurate results

Files Patch % Lines
...ocument/application/template/template_service.dart 83.94% 22 Missing ⚠️
.../document/application/template/config_service.dart 90.10% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            main    #3032       +/-   ##
==========================================
+ Coverage   9.70%   64.77%   +55.07%     
==========================================
  Files        685      540      -145     
  Lines      31812    25369     -6443     
==========================================
+ Hits        3086    16434    +13348     
+ Misses     28726     8935    -19791     
Flag Coverage Δ
appflowy_flutter_integrateion_test 64.77% <87.60%> (?)
appflowy_flutter_unit_test ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AmanNegi
Copy link
Contributor Author

@LucasXu0 I was able to add the test for exporting a template. I tested a lot of methods for writing tests for the import method, but it doesn't work as expected. I am prompted with a FilePicker even though I have mocked it. Could you please assist me in writing tests for importing a template.

@annieappflowy
Copy link
Collaborator

@AmanNegi , amazing work! The video is very helpful! Thanks for creating it.

@LucasXu0
Copy link
Collaborator

@LucasXu0 I was able to add the test for exporting a template. I tested a lot of methods for writing tests for the import method, but it doesn't work as expected. I am prompted with a FilePicker even though I have mocked it. Could you please assist me in writing tests for importing a template.

Hey, @AmanNegi. Did it still fail after the discussion in Discord?

@AmanNegi
Copy link
Contributor Author

AmanNegi commented Jul 25, 2023

Yes, I have actually left the test's code for importing the template so you could help me diagnose the problem with the test.

Copy link
Collaborator

@annieappflowy annieappflowy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @AmanNegi , could you add a project doc to the documentation for the templates?

- Template feature now supports nested pages.
- ConfigService added which generates config.json which acts as the
controller for exporting/importing a template.
- Supports importing and exporting.
- Template tests added.
@AmanNegi
Copy link
Contributor Author

AmanNegi commented Aug 25, 2023

Progress so far:

template.mp4

Changes:

  • Template now supports nested page structure.
  • Option to import template added to options menu.
  • Exporting now auto generates config.json which contains the data regarding the structure of documents/databases.
  • Supports Document, Grid and Board out of the box.

Upcoming:

  • Support Referenced Grids.

Due to the support of nested pages, the feature was completely re-written, as earlier nested pages were not supported.

cc @LucasXu0 @annieappflowy

- support images in templates
- mitigate file naming conflicts
- fix positioning of template action buttons
- add strings i8n
- update outdated tests
@AmanNegi
Copy link
Contributor Author

AmanNegi commented Sep 7, 2023

Update:

  • Supports images in templates.
  • Supports nested documents, grids and boards.
  • Mitigate file naming conflicts.
  • Fix positioning of Template action buttons.
  • Use of getIt for single instance of TemplateService throughout the app.

Demo:

template_update.mp4

cc: @LucasXu0

@AmanNegi
Copy link
Contributor Author

AmanNegi commented Oct 5, 2023

@Xazin I have fixed the merge conflict now and synced it with the main branch. 😄

@rileyhawk1417
Copy link
Collaborator

@AmanNegi Is it possible to compress the files when the user shares the template? That way the user doesn't have to go ahead and compress the files after sharing the template.

@AmanNegi
Copy link
Contributor Author

@rileyhawk1417 definitely, that's how it will work. The files will be converted to a zip, as soon as we are done with the exporting process.

@AmanNegi
Copy link
Contributor Author

AmanNegi commented Dec 21, 2023

Here's a major update on the Template feature. After the nested pages feature release in AppFlowy, several things have changed, and thus the requirement for updates to the Template feature.

✨ Now we support ✨

  • Importing/Exporting Nested Documents.
  • Importing/Exporting Nested Databases while also maintaining their references (if present)(only grid).
  • Importing/Exporting Documents with Local Images.
  • Some Pre-Made Templates baked into AppFlowy.

Demo 📹📱

These features and others have been thoroughly tested and displayed by me on YouTube (because the video was too large). You can find the video link below:

https://www.youtube.com/watch?v=Tef6CEu7VpM

@annieappflowy @LucasXu0

PS: The updated code will be pushed soon!

- add support for nested docs
- add support for online/offline images
- add support for references and displays of grids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Templates
5 participants