Giter VIP home page Giter VIP logo

Comments (6)

joas8211 avatar joas8211 commented on August 22, 2024 3

I have published update (v1.2.0) that adds support for globals. In fact globals are now tenant isolated by default, so take that into account when updating. More information can be found from readme.

from payload-tenancy.

matthijs166 avatar matthijs166 commented on August 22, 2024 1

What about the solution I proposed here: #payloadcms/payload/discussions/3268

  1. Create a globals collection with the same structure as your global
  2. Add a field to this collection for the scope (your domain, for example)
  3. Add in the global a new hook beforeChange
  4. In this hook store the values via the internal payload API to the globals collection (with scope)
  5. Add a new hook beforeRead or afterRead
  6. Fetch based on the scope the value from the globals collection and return the data within this hook

It does not seem hard to implement and users can use the singleton focused UI instead of having an extra step where only one item is in the collection.

from payload-tenancy.

joas8211 avatar joas8211 commented on August 22, 2024

Isolating globals per tenant is not supported because I haven't figured out how that could be accomplished. If you know a way it can be done, please tell and I will add support for it. Collections have been isolated using access rules that restrict actions to documents that have matching value in tenant field (hidden field added by the plugin). But globals seems to only have one document which is the global, so having a global document for each tenant wouldn't work logically.

Now that I'm writing this, I can think one way this could be maybe done. What if the plugin adds a collection for globals that cannot be accessed by any users. That collection holds data for all globals and correct document is returned when global is read or written to. I'll look into this if it's possible. How does that sound to you? Any comments?

from payload-tenancy.

DaniloArantesF avatar DaniloArantesF commented on August 22, 2024

Yes, that makes sense to me. Both the issue and your solution. I'm not too sure how that would work since I'm not too familiar with Payload integrations, unfortunately. If that's possible, I think it would be a great improvement. Thank you.

from payload-tenancy.

silveltman avatar silveltman commented on August 22, 2024

Now that I'm writing this, I can think one way this could be maybe done. What if the plugin adds a collection for globals that cannot be accessed by any users. That collection holds data for all globals and correct document is returned when global is read or written to. I'll look into this if it's possible. How does that sound to you? Any comments?

I think your idea makes sense. Having a 'globals' collection in which the data is set, and then have the global file act as some kind of middleware, mapping the request to the right doc in the collection.

But wouldn't this make the UI look different than regular globals? Showing a 'collection of globals' to the /admin user. If so, al alternative approach could be:

Auto-generating globals with slugs like 'globalname-tenantname' for each tenant. Then have the base 'globalname' map to the correct 'globalname-tenantname'.

from payload-tenancy.

matthijs166 avatar matthijs166 commented on August 22, 2024

@joas8211 Maybe something to include into this plugin? Looks very clean and easy payloadcms/payload#3268 (reply in thread)

from payload-tenancy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.