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

Wire up Preferences #86

Closed
jackmcdade opened this issue Nov 27, 2018 · 7 comments
Closed

Wire up Preferences #86

jackmcdade opened this issue Nov 27, 2018 · 7 comments
Assignees

Comments

@jackmcdade
Copy link
Member

jackmcdade commented Nov 27, 2018

Preferences are settings that you manage in the control panel. There should be defaults that you can override on a per-user (or user group?) level.

@jesseleite
Copy link
Member

Jason mentioned something for future discussion. If we have default preferences for user groups, how might we handle users who are part of multiple groups?

@jasonvarga
Copy link
Member

Putting aside the UI for setting your preferences, this is how I think it should work:

The preferences are stored on the user as an array. We'll treat it just like Laravel's config. (You could probably even use a ConfigRepository under the hood)

title: John Smith
email: john@smith.com
preferences:
  active_site: english
  columns:
    collection_blog:
      - title
      - slug

That translates pretty well to other user stores. DB could have a preferences json column, or depending on their custom implementation, they can do whatever.

Basically $user->preferences() should return an array that could be fed into the config.

Then we can retrieve a preference with a fallback, again, just like config.

Statamic\API\Preference::get('active_site', 'fallback');

Don't get fancy with the fallback - don't try to automatically look in the config. If we want to fallback to a config, we can pass one in.

Preference::get('locale', config('statamic.cp.locale'));

Then there should be a way to set them.

Preference::set('locale', 'en');
// which might do something like...
$user->preferences($updatedPreferences)->save();

Eventually, for setting preferences, I think we could make a form that just has a bunch of fields, then do Preference::set([ array of what was submitted ]); But let's leave that for now.

@jackmcdade
Copy link
Member Author

jackmcdade commented Jan 26, 2019 via email

@jesseleite
Copy link
Member

If we have default preferences for user groups, how might we handle users who are part of multiple groups?

What if the user inherited from the first group in their groups array? Then in UX we could potentially allow them to drag group order, and message that the user will inherit group preferences from the first attached group with preferences?

@jackmcdade
Copy link
Member Author

That makes sense - and then we just array merge them from bottom to top.

OR, we give them an "additive" or "subtractive" mode, where we can loop through each permission and override it one way or the other depending on how they should stack?

@jesseleite
Copy link
Member

I like! Yeah additive, if we loop through groups from bottom up (least important to most important group), setting/overriding preferences in that order, and then finally set/override from the user yaml, precedence should work itself out 👍

@jackmcdade
Copy link
Member Author

jackmcdade commented Feb 9, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants