@tsteur opened this Issue on February 10th 2022 Member

On cloud in javascripts/account.js we are listening to some events when eg a site gets added and then check if the user is allowed to create another user or site.

We just noticed in tests this may be broken / no longer working. Likely because of vue.js.

We're doing in the code things like

    $rootScope.$on('Segmentation.initAddSegment', function (event, parameters) {
        parameters.isAllowed = checkIsFeatureAllowed('segments');
    });

    $rootScope.$on('Goals.initAddGoal', function (event, parameters) {
        parameters.isAllowed = checkIsFeatureAllowed('goals');
    });

    $rootScope.$on('TagManager.initAddContainer', function (event, parameters) {
        parameters.isAllowed = checkIsFeatureAllowed('tagmanager');
    });

    $rootScope.$on('UsersManager.initAddUser', function (event, parameters) {
        parameters.isAllowed = checkIsFeatureAllowed('users');
    });

    $rootScope.$on('CustomDimensions.initAddDimension', function (event, parameters) {
        ...
    });
    $rootScope.$on('SitesManager.initAddSite', function (event, parameters) {
     ...
...

Can we check if these events are still triggered? Eg I couldn't find any event named UsersManager.initAddUser in the code. And how would we listen to these events now assuming they aren't triggered on angular $rootScope anymore.

They were triggered eg when clicking on the "add new user" button and then we would check if the user can create a new user and if not, show a popover explaining the issue that limit was reached.

cc @diosmosis

@diosmosis commented on February 10th 2022 Member

@tsteur on my 4.5.0 checkout I can't find UsersManager.initAddUser. The other events should still triggered. I tested locally and if I add:

  window.piwikHelper.getAngularDependency('$rootScope').$on('Segmentation.initAddSegment', function (event, parameters) {
    console.log('sdkjlfsjdf');
  });

to some JS, then try to add a segment, I will see the output. It's possible the initAddUser method was removed some time in the past. I'll see if it's in any older files.

@diosmosis commented on February 10th 2022 Member

@tsteur the UsersManager.initAddUser event was removed in the users management rewrite, added it back to #18583 in https://github.com/matomo-org/matomo/pull/18583/commits/9a50c8626e7dd31f67ec9656166f7134c45ad04b.

@diosmosis commented on February 10th 2022 Member

The other events should work as long as they are present.

@tsteur commented on February 10th 2022 Member

great 👍 thanks a lot

@sgiehl commented on February 14th 2022 Member

@tsteur Anything else needed here?

@tsteur commented on February 14th 2022 Member

That's all 👍

This Issue was closed on February 15th 2022
Powered by GitHub Issue Mirror