parkuman / pocketcms

MIT License
17 stars 3 forks source link

UI enhancements #1

Closed moalamri closed 5 months ago

moalamri commented 5 months ago

It's my first time writing in Go so please review my method to create the pcms__users collection before serving, I will add the other collection pcms__collections if my method is the correct way. It will make it easier for users to just run and start adding contents

I also add a script to run and serve main.go

moalamri commented 5 months ago

I added some UI enhancements.

parkuman commented 5 months ago

I won’t be home till Monday then I’ll take a look at the changes! From what I can see you’re tackling all the right issues. Cheers man!

parkuman commented 5 months ago

tried running the new version, but ran into an error while running.

this is my current list of collections in PocketBase:

image

this is the error I'm getting:

image

After looking at the approach, I think a better method might be to initialise all of the important base pcms__ collections using the same installer method used in the PocketBase UI when first logging in.

take a look at this: https://github.com/pocketbase/pocketbase/blob/1682db5c7215b6766c6e569833000f27932357e2/ui/src/components/PageIndex.svelte#L6

and this https://github.com/pocketbase/pocketbase/blob/1682db5c7215b6766c6e569833000f27932357e2/ui/src/components/base/Installer.svelte#L4

Then when first visiting the PocketCMS UI it will set up all the right collections. Do you think this approach would be better?

The steps I think it could follow are:

  1. load PocketBase for the first time, complete installer, load in.

  2. the default PocketBase collections are now created

  3. load PocketCMS for the first time, complete installer

  4. the installer will make requests to PocketBase to create the following collections

  5. pcms__collections - a view collection used by PocketCMS to view all the PocketCMS collections. This is required because you must be authenticated as a PocketBase admin in order to list collections, this allows a regular user to view the PCMS ones. The current view collection query I have is:

    SELECT id, name, schema, listRule, viewRule, createRule, updateRule, deleteRule
    FROM _collections
    WHERE name LIKE 'pcms|_%' ESCAPE '|'
    AND name NOT LIKE 'pcms|_|_%' ESCAPE '|';
  6. pcms__users - an auth collection containing all the users than can log in to PocketCMS

moalamri commented 5 months ago

Hey @parkuman Thank you for testing this out, I honestly didn't test it as a new init setup. You're totally right, we should use the native method the original maintainer used with the correct steps. My pr was to make it easy for users to just clone and jump right into using pocketcms, but I surely had it missing most of the necessary collections (I haven't had it working yet in my end, maybe because I used regular non-admin account). Do you think it is better to have a new PR with the complete auto setup for pocketcms? We better close this one? Also we could bypass the account type limitation if we used hooks to setup the init collections?

parkuman commented 5 months ago

Hey @parkuman Thank you for testing this out, I honestly didn't test it as a new init setup. You're totally right, we should use the native method the original maintainer used with the correct steps. My pr was to make it easy for users to just clone and jump right into using pocketcms, but I surely had it missing most of the necessary collections (I haven't had it working yet in my end, maybe because I used regular non-admin account). Do you think it is better to have a new PR with the complete auto setup for pocketcms? We better close this one? Also we could bypass the account type limitation if we used hooks to setup the init collections?

Making a new PR would be good! The work you did on the UI with collections looks great though, maybe we could just rebase this PR to have those UI changes and do the collection setup in a new one. Is that something you want to tackle? If not, I am happy to do it! I am planning on updating the README with better setup instructions in addition to adding some ideas we could build out.

moalamri commented 5 months ago

Sounds good 👍🏻 I will rename this PR to highlight the UI enhancements.

parkuman commented 5 months ago

cool! I think if we revert the changes to the main.go file as well I will approve :)

moalamri commented 5 months ago

Done :)