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

Show all sites item only if multi sites is enabled #14936

Merged
merged 2 commits into from Oct 2, 2019
Merged

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Oct 1, 2019

To prevent showing a not working link to the all sites page.

There are a few more usages of siteselector but they aren't as important and visible for now. Also sometimes I think they don't link to the all sites page but handle it differently.

@tsteur tsteur added the Needs Review PRs that need a code review label Oct 1, 2019
@tsteur tsteur added this to the 3.12.0 milestone Oct 1, 2019
@tsteur tsteur added the Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. label Oct 1, 2019
@kniziol
Copy link

kniziol commented Oct 2, 2019

Is the issue fixed or still available to work on it?

@tsteur
Copy link
Member Author

tsteur commented Oct 2, 2019

The issue should be fixed afterwards.

@@ -751,6 +751,7 @@ protected function setBasicVariablesNoneAdminView($view)

$pluginManager = Plugin\Manager::getInstance();
$view->relativePluginWebDirs = (object) $pluginManager->getWebRootDirectoriesForCustomPluginDirs();
$view->isMultiSitesEnabled = Manager::getInstance()->isPluginActivated('MultiSites');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you've got a boolean value:

$view->isMultiSitesEnabled = (bool)Manager::getInstance()->isPluginActivated('MultiSites');

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw the method always returns a bool

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OKay. So the (bool) is not necessary.

@@ -1,3 +1,3 @@
<div class="top_bar_sites_selector piwikTopControl">
<div piwik-siteselector show-selected-site="true" class="sites_autocomplete"></div>
<div piwik-siteselector show-selected-site="true" show-all-sites-item="{{ (isMultiSitesEnabled|default) ? 'true' : 'false' }}" class="sites_autocomplete"></div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and the default filter won't be necessary:

<div
    class="sites_autocomplete"
    piwik-siteselector show-selected-site="true"
    show-all-sites-item="{{ isMultiSitesEnabled ? 'true' : 'false' }}">
</div>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the default in there as I couldn't guarantee the basic variables method in the controller is always called so just wanted to be sure to not break anything. I could remove it as it's likely not needed. It just means if someone did like $view = new View('...'); $view->render() without calling the basic variables in the controller then things could break when embedding that template. From what I see it shouldn't be needed though. Will check again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see it can be removed indeed cheers 👍 will wait for the tests to confirm it

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! :)

@kniziol
Copy link

kniziol commented Oct 2, 2019

@tsteur I've reviewed your 539e39a commit

@tsteur tsteur merged commit a4b19cf into 3.x-dev Oct 2, 2019
@tsteur tsteur deleted the siteselectormulti branch October 2, 2019 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants