Planned refactoring and temporary feature freeze #4355
Replies: 27 comments 29 replies
-
Not to bandwagon on hype, but I think that if you're considering replacing the admin with another framework might be worth having a look at HTMX. I also have recently come across a use case where read-only fields, e.g. editable to create, but disabled for update would be really handy, I've had to use the update events to ensure the current field value is always set with the original record, if this could be added it would be really neat. Specifically my use case is for a migration seeded collection of templates, I have Thanks for all the work and looking forward to the new version(s) 👍 |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
Just out of curiosity: what kind of extensibility you are looking for? And why the presence of a compiler would stop the users from extending PocketBase? Willing to contribute to find a solution to this which doesn't require a rewrite...i personally think it's doable. 🙂 |
Beta Was this translation helpful? Give feedback.
-
Sorry. Is Pocketbase stopping development at version 0.22.0 until the v1 alpha release? |
Beta Was this translation helpful? Give feedback.
-
Just today in the link below I learned about Ponys HTML element library. It's only 1KB minified. It seems really flexible. It allows at least 3 ways to wrap template literals into shadow dom. You can put your HTML, CSS and JS into a single file, or an inline template tag or via a string. So it makes single file custom HTML element web components. I'm thinking that you could offer a combination of built-in libraries that are complimentary to each other. So that means HTMX is a must. Then you could offer some variation of Lit, Alpine.js and what seems pretty nice (at 1KB pre-zip) is Ponys. Another way of saying it is that HTMX is great because it works with everything to make life easier in some cool ways. Alpine.js is pretty great for it's simplicity and Golang template and HTMX synergy. A Custom HTML component library really compliments Alpine and HTMX very well because they're just HTML tags, and those libraries are all very super tiny. Alpine on its own is kind of rough because you have to duplicate important markup and script again each time that you want to use it. The hard parts of that should be put into web components. As you might vaguely recall, I recently took a sabbatical of about 10 days while I was playing with the Pocketbase GOJO JS side of things and how it worked with Alpine, custom element, Golang templates and others. So I feel pretty confident about my take on this. import Ponys from './ponys.js';
Ponys.import('modal-container', './components/modal-container.html'); <!-- modal-container.html -->
<div
id="container"
onclick="event.stopPropagation(); host.close()"
onkeydown="event.stopPropagation(); if (event.key === 'Escape') host.close()"
>
<article
id="modal"
part="modal"
aria-modal="true"
tabindex="-1"
onclick="event.stopPropagation()"
>
<slot></slot>
<div
id="controls"
part="controls"
>
<button type="button"
title="Close"
onclick="host.close()"
>
<span aria-hidden="true">×</span>
</button>
</div>
</article>
</div>
<script>
export default class extends HTMLElement {
close() {
this.hidden = true;
}
}
</script>
<style>
:host {
z-index: 9999;
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
}
#container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
#modal {
overflow-y: auto;
overscroll-behavior: none;
position: relative;
background: white;
}
#controls {
position: absolute;
top: 0;
right: 0;
width: 3rem;
height: 3rem;
font-size: 2rem;
}
button { /* reset */
cursor: pointer;
border: unset;
margin: unset;
padding: unset;
background: unset;
color: unset;
font: unset;
}
button {
position: fixed;
width: inherit;
height: inherit;
}
</style> Don't snooze on Lit either though. Again, I see any custom element library being essential for use with Alpine because it just gives Alpine more rich tags to use. Here are two combos that would make me happy.
or even offering 2 custom element libraries as options (they're both ridiculously tiny).
NOTE: Lit offers a downloadable non-NPM single file option. The difference is that it doesn't use decorators and so the boilerplate per component is just slightly more annoying without any other differences. <script src=" https://cdn.jsdelivr.net/npm/lit-html@3.1.2/lit-html.min.js "></script> |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
A lot of this stuff is really cool, thanks for the update. +1 for the user defined sql build. As for the frontend, I really like the idea of alpine.js; also, htmx would allow for creating html snippets for page layout, records, tables and settings on the server and sending it down to the client -- if someone wouldnt like one component it would be easily replaced by creating a template (not even having to code in go). But just choose something you feel comfortable working in. I really like the idea of being able to insert custom html components and all that stuff, sounds really great. Also, merging the Dao with the App instance and allowing migrations to access all the additional data feels like a logical step. As for the RecordUpsert thing, I personally think it's fine as it is and easily understandable. Good luck with your sabbatical and the refactoring. |
Beta Was this translation helpful? Give feedback.
-
I've done some work around svelte and compiling into web components. See a boilerplate I made here: https://github.com/jonshipman/web-component/tree/main/web-component Depends on if you've already started working on it, if not, you could keep the admin ui in Svelte (less work on you) and just break the pieces up into web-components. Setup an npm workspace and separate each piece into a separate svelte package. Then the packaged frontend could be web-components. e.g.
In another project, I wrote a reusable use:action listener https://github.com/jonshipman/jonshipman.com/blob/main/src/lib/util/listener.ts. It can be used instead of the event dispatcher to send native Custom Events that can bubble, so you can send deep events up to the top component if you need to. And so on. Only pitching in if it makes your work easier. |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
riot.js is round for a long time, stable, powerful and I have used it in many projects, syntax is very close to svelte and components can be compiled in-browser if one wants to avoid a build step (I'm doing this all the time when developing, can help with the setup if interested). |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
This post seems to have started some frontend frameworks war which wasn't my intention. The Admin UI rewrite is the least important part of the announcement. As mentioned in the post and the other replies regarding this - nothing specific is set in stone yet and I'll provide more details once I start working on this part of the refactoring. The Go APIs refactoring is with higher priority and has bigger impact for the PocketBase users as it will introduce breaking changes. So please be considerate, read the previous replies and keep the comments on topic to avoid the unnecessary noise. |
Beta Was this translation helpful? Give feedback.
-
Not pointing out my web preferences, but instead I'm sharing my appreciation for your work, while fully onboard with all the changes <3 Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hello Gani, I commend you for your initiative and transparency regarding the refactoring plans for PocketBase. The proposed changes are exciting and signal a promising future for the project. I would like to suggest a special emphasis on features that could significantly elevate the efficiency and utility of PocketBase: support for bulk operations, such as bulk insert, update, and delete. Given SQLite's limitation of allowing only one write at a time, the ability to process transactions in bulk would represent a significant improvement. Currently, to circumvent this limitation, we often resort to loops for insert, update, or delete operations, which can overload and potentially lock up the database. Implementing bulk operations could reduce the load on the database, avoid locks, and, consequently, improve the overall performance of the application. Furthermore, the functionality of importing and exporting data in the admin panel would simplify data management, making PocketBase an even more versatile and accessible tool for a variety of use scenarios. I recognize the challenges and the current focus on refactoring, but I believe these features could bring considerable benefits to PocketBase, both in terms of performance and flexibility. Thank you for your attention, and I look forward to following the project's updates. Success in implementing the planned changes! Best regards, |
Beta Was this translation helpful? Give feedback.
-
Like where Pocketbase is heading. Can we have better community involvement? Once the initial prototyping is done and when you decided on a plan of action, if you could post issues with a help-needed tag, I am sure there are enough people with interest in this project. Having more community contributions is good for the overall long term health of this project. It comes with it headaches, but the tradeoff could be worth it. |
Beta Was this translation helpful? Give feedback.
-
Hello @ganigeorgiev I feel following can to be included
|
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
I have a suggestion: the resulting json has the system fields id, created, updated on a different level then the other fields (data nested level). I'ld suggest to keep all the collection fields at the same level in the response. It's a big breaking change, so i guess it's worth of a deep thinking before v1. |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
Sorry for the intrusion,is it possible to customize the default sorting for each collection?Rather than specifying sort at params, can it be predefined? This way, the JSON obtained through 'expand' (relation and back-relations) would also follow the predefined sorting. |
Beta Was this translation helpful? Give feedback.
-
+1 for the re-usable standalone component library; I love the design you've created with PocketBase! I've been experimenting with building out a small CMS based on PB, using all the same components as you to keep a cohesive style. Rather than extending the UI, I've made the CMS its own admin dashboard entirely using PB as a framework (based on @ganigeorgiev 's response in #50). It is essentially a stripped back version of the PB admin dashboard, with limitations in place for what the users/clients can do. Having the re-usable components would help reduce a lot of the copy-pasting of component files and helpers that I've been doing. I will share a link soon once I think its usable. Maybe with these upcoming refactors and better admin UI extensibility a CMS project would be better suited as an extension/plugin of the admin UI itself rather than a standlone dashboard? Would love to hear other people's use cases for extending the admin UI. Edit: This would be perfectly suited to be an extension of the admin UI #3241 |
Beta Was this translation helpful? Give feedback.
-
The last couple weeks I've tried experimenting with slightly different internal structure and decided that it is time to share some notes regarding the planned refactoring and hopefully this will bring some clarity in what direction the project is headed.
The main takeaway is that after PocketBase v0.22.0 release there will be a temporary feature freeze for some time until I manage to finalize the refactoring.
Please note that there is no fixed timeline when it will be completed but I'm hoping that we will have at least a v1 alpha release with pretty much finalized APIs by the end of this year (this is also the limit to how much I could stretch my current sabbatical and will have to start looking for a regular employment).
With that said, below you can find some of the more notable planned changes:
Merge
Dao
withcore.App
There are a lot of scenarios where passing
daos.Dao
is not sufficient enough, for example you may want access to the app settings from a migration, or the app configured file system, or to trigger manually a hook, to send an email, to access the logger, etc.By eliminating the separate
Dao
abstraction and moving its logic to thecore.App
we can simplify the app related operations and have only 1 common interface that you can pass around (including when dealing with transactions).Additionally we will remove the various
Dao.Save(m)
,Dao.SaveCollection(m)
,Dao.SaveRecord(m)
,Dao.SaveAdmin(m)
, etc. methods and will replace them withApp.Save(m)
(andApp.RawSave(m)
when you want to skip validations).Remove/hide the
RecordUpsert
(and other similar forms)Currently there are 2 main ways of modifying records:
forms.RecordUpsert
model for when you need validationdao.SaveRecord()
call for when you want a direct db insertWe can simplify all of this by avoiding the extra form abstraction and move the form validation in the
Record
model itself.The end user will operates only with
Record
and custom validations and anything field specific will be done through it field structs.For example, to upload a new file programmatically, currently we have to do something like:
We can replace both options with just:
This would also simplify removing existing or intercepting uploaded files since you can just remove them from the
Record
instance like a regular field value and callapp.Save(record)
to persist the changes.Replace
echo
with a thin wrapper around the new Go 1.22 mux enhancementsGo 1.22 introduced some enhancements to the builtin HTTP router which we can try to make use of it in order to minimize the external dependencies and allow broader compatibility with the standard Go library.
For routing we currently rely on
echo
(v5_alpha
) but we don't really use that much of it since we have to supply our own custom error handling,Binder
,Serializer
, etc. implementations anyway to accommodate better some PocketBase specific use cases.Additionally I've also seems to have made a wrong assumption that the
echo
v5_alpha
branch was going to be released soon after the first PocketBase release back in 2022, which in hindsight based on currentecho
development pace and some recent discussions it doesn't seem to be the case anymore (see also labstack/echo#2000 (comment)).Rewrite the Admin UI to be extendable
At the moment we support extending some of the PocketBase server-side functionality with Go (or JS
pb_hooks
), but there is no support for customizing the Admin UI, which prevents us to offer full-featured "plugin"-like functionality.To make the Admin UI customizable we will have to:
Create a small standalone HTML/CSS components library (buttons, inputs, alerts, dialogs, icons, etc.) to have a more cohesive design with the custom users UI.
Replace the current Svelte SPA with a framework that doesn't require a JavaScript build step.
I haven't decided on what we'll use but most likely it will be either Vue.js or Alpine.js (the Admin UI will still be a plain static browser application).
Provide client-side hooks/injection-points for registering custom user content (menu items, custom collection fields, custom app settings, etc.).
Summary
There are a lot of other smaller changes that will be introduced together with the refactoring:
database/sql
interface but for the time being I'm not planning officially supporting other SQL dialects)While most of the planned changes may look cosmetic on the surface, they require a lot of intertwined modifications and practically rewriting most of the existing tests, which will take some time.
The short-term plan for now is:
Release PocketBase v0.22.0 with the latest changes from the
develop
branch (+ eventually maybe the back/indirect relation filtering), in the next couple weeks. This will be the last major release before the refactoring, meaning that there will be temporary feature freeze.Start working on finalizing the refactoring of the server-side changes and rewrite the necessary tests.
Add migration guide and update the docs to reflect the new changes
Create a HTML/CSS UI components library, rewrite the Admin UI with Vue.js/Alpine.js and add support for client-side hooks.
Feel free to share your suggestions below if you have something else in mind. I may not reply immediately on it but rest assured that I'll take it in consideration during the refactoring.
Regards,
Gani
Beta Was this translation helpful? Give feedback.
All reactions