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
8.x 1.x config ui domain switch #294
8.x 1.x config ui domain switch #294
Conversation
Looks promising. A few general comments:
edit: removed line about moving to modules. PEBCAK |
@zerolab regarding your comments: DI for the domain.negotiator service
Does this work with settings overrides?
Other issues:
|
I merged this to the config-ui branch for testing. First note, when enabled:
|
Ah, array class constants are new in PHP 7, your fix looks better |
services: | ||
domain_config_ui.manager: | ||
class: Drupal\domain_config_ui\DomainConfigUIManager | ||
arguments: ['@config.storage', '@domain.loader', '@language_manager'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm no longer extending the domain config overrider or negotiator. DomainConfigUIManager service will now manage the language/domain switching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a specific code reason that made doing so necessary?
Ideally, we'd handle all of the negotiation inside the DomainConfigOverrider, or, if needed, create a DomainConfigManager service for this.
My thought here is that the UI piece should not handle any of the negotiation logic, just the form handling, so that it could be swapped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason was to keep the loading of config that's being edited as self-contained as possible.
Spoofing the requested domain for the negotiator meant that all the config on the page also got swapped. It didn't seem right to have an admin tool overriding the negotiator and change its behaviour.
I'm also not sure if we want setting overrides to be applied to editable values?
I can change this back if you think swapping all config on the page is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thoughts, I am swapping all allowed config with the manager so it might not be helping much.
I can change back to extending the negotiator as before and see what problems I encounter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it back to use the negotiator on a new branch here https://github.com/davidgrayston/domain/tree/8.x-1.x-config_ui_domain_switch_negotiator
Diff with current pull request branch: davidgrayston/domain@8.x-1.x-config_ui_domain_switch...8.x-1.x-config_ui_domain_switch_negotiator
I had to make some changes to DomainConfigOverrider to make this work:
- Setters to allow the domain and language to be set
- Changed protected getDomainConfigName method to be public
This doesn't seem like the correct solution in its current state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't had a chance to really dive into this code. The part that bothers me is the introduction of config handling to the DomainNegotiator. That class/service should not really be Config aware.
I have no problem making getDomainConfigName public, but I haven't worked through the pro-con.
In general:
- The core Domain module and its classes should handle domain registration and negotiation. That's all.
- Domain Config should handle storage and retrieval of config overrides.
- Domain Config UI should put a form in from of the read/write aspects of Domain Config.
Put another way, we should be able to programatically write an override through Domain Config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to the saving of configuration not being tied to forms in a standardised way, and there being no definitive way of knowing which forms/pages handle config, it's quite tricky to implement this.
I don't think there's a neat way of loading the config overrides only for forms values (and admin pages), so we have to swap the config on the entire page - it's essentially swapping the domain being viewed. This is why I initially made a global domain switcher (sticky form), to make it clear that you were changing the selected domain globally.
Now that I'm altering "known" config forms, the user will not know which domain is currently selected until they go to an admin form with the switcher field. Perhaps we should go back the the domain switch implementation but make the form much more prominent (e.g. a fixed strap at the top of the page)?
It might be quicker if you take these ideas as a proof of concept and implement as you have described above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on finishing other parts of the alpha/beta release, so speed isn't something I can provide.
I need to take a deeper look at what you've done and the problems you define and try to give some better direction.
Using a config_ui_manager to handle forms makes sense. I just don't want that to bleed over into handling save/load.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's really tricky place, d.o core has a lot of "config override bleeding" issues fixed, also working on domain_lang module it became clear that priority of loading overrides highly coupled to language manager initialization.
Also some overrides can be done via settings.php and somehow that should affect in UI
- { name: service_collector, tag: 'config.factory.override', call: addOverride } | ||
arguments: ['@config.storage', '@event_dispatcher', '@config.typed'] | ||
calls: | ||
- [setDomainConfigUIManager, ['@domain_config_ui.manager']] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config UI manager is being passed to the config factory so that it can be used to load up selected domain/language configuration.
/** | ||
* Load only overrides for selected domain and language. | ||
*/ | ||
public function loadOverrides($names) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config UI manager loads overrides for the current selected domain/language
], | ||
]; | ||
|
||
// Add language select field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Language can now be selected
…h form for unconventional admin forms e.g. theme
…h form for unconventional admin forms e.g. theme
@@ -0,0 +1,113 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've re-introduced the switch form for use on pages that aren't conventional config forms, such as the theme settings page. This form will reload the page when the domain is switched.
$cache_key = $this->getConfigCacheKey($name, $immutable); | ||
|
||
if (isset($module_overrides[$name])) { | ||
$this->cache[$cache_key]->setModuleOverride($module_overrides[$name]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've applied the domain overrides on immutable config so that unconventional admin pages (like theme settings) show the domain domain specific config
I still need to go through the known paths/forms/config that should be added to the allowed list by default. The |
Here's addition to show widget with permission only skilld-labs#1 |
For the last few days before I saw this I was working on the solving this problem on my own. I'll try to describe my approach to this. So what I did was:
So far everything is working pretty well. I can edit all simple configuration blocks and views its really early to tell if I can achive everything I want this way but looks promising. Of course I'm also not sure If Drupal community would accept to have that hook in config save. What do you think about that approach? If it was not clear enough. You basically visit the site from domain you want to change config and make changes in usual places as if you were building a normal Drupal site. |
I'm also thinking about making a domain template so you could inherit configuration from template and then introduce minor changes on domain it self so we don't have so many config files. |
@dmiric Use events instead of hooks for config, see |
I tried to do it using config::save event, but I could not figure out how
to avoid saving the base site configuration. Would you happen to know how I
could do that?
…On Sun, Feb 26, 2017, 12:37 Andy Postnikov ***@***.***> wrote:
@dmiric <https://github.com/dmiric> Use events instead of hooks for
config, see ConfigEvents core class
BTW we using this branch on a project and we are going to add language &
number of overrides to the floating block, also looks toolbar is a proper
place for that
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#294 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABEu-PvU61T-zfXR2koX5CcYlD-GbeLWks5rgWQDgaJpZM4K_AYj>
.
|
After trial on this UI following bugs found
|
One more core change in this area https://www.drupal.org/node/2930829 |
Hooray! That change was a long time coming. |
I created a new PR for this as #426 which (apart from unrelated 8.6 issues) merges and builds successfully. |
Actually instead of 2 PRs better to create repo like we used to hack https://github.com/skilld-labs/domain_config_ui and re-do it Core in progress of CMI 2.0 so that may affect domain_config itself (I still looking to move domain overrides to own collections instead of prefixing) |
@andypost Apologies, but I don't really understand "create repo like we used to hack...and re-do": I'm still finding my way around here. [My intent here was only to use travis to check the patch again, given it has been a while since it was pushed. I intend to close the PR. ] |
I'm going to pull https://github.com/skilld-labs/domain_config_ui into a new branch here for testing. |
Happy to apply the changes to the branch on this PR if that helps? |
Well, I moved things to #434 so that it would be part of the main repo. So new changes would go there. |
#15 proof-of-concept