georchestra / mapstore2-georchestra

geOrchestra newest viewer
Other
6 stars 23 forks source link

[Home Page] Modify the home page #602

Open catmorales opened 1 year ago

catmorales commented 1 year ago

Description

We will allow users to access the home page on March 1st. In a first time we want to

For the last point it is OK, it is possible to restrict to ADMINISTRATORS this functionnalities with "cfg.allowedRoles" as described in https://mapstore.geosolutionsgroup.com/mapstore/docs/api/plugins#plugins.CreateNewMap Documentation missing : Documentation don't speak about geostories but it seems to be the same behaviour as maps and dashboards

For the first point we didn't see how to restrict maps and geostories tabs to ADMIN only. Is this possible ? This should be the best manner to restrict the tabs.

Bugs: In the localConfig.json we have been able to quit all the lines about geostories and maps but something is wrong :

image

image

Documentation section involved

Other useful information

Bugs ans documentation

tdipisa commented 1 year ago

@catmorales

For the first point we didn't see how to restrict maps and geostories tabs to ADMIN only. Is this possible ?

You can hide/show a plugin using disablePluginIf in configuration. For Contexts plugin (the tab) you can configure it as following:

{
    "name": "Contexts",
    "cfg": {
        "disablePluginIf": "{!!(state('userrole') !== 'ADMIN')}",
        "mapsOptions": {
            "start": 0,
            "limit": 12
        },
        "fluid": true
    }
},

There is no new default tab , so user needs to click on one of the tabs to see its contents,

This is effectively not explcitly allowed by the configuration options available. You can workaround this problem by configuring the "Dashboards" plugin in localConfig.json like this by adding the override part:

{

    "name": "Dashboards",
    "override": {
        "ContentTabs": {
            "key": "maps"
        }
    },
    ...

if the dashboard is empty, Mapstore suggest to create one despite the restriction defined in localConfig

You can hide the button in "Dashboards" tab by setting showCreateButton to false in "Dashboards" plugin cfg to make it disappear. Documented here. After these 2 changes, you Dashboards plugin configuration will look like this:

{

    "name": "Dashboards",
    "override": {
        "ContentTabs": {
            "key": "maps"
        }
    },
    "cfg": {
        "showCreateButton": false,
        "mapsOptions": {
            "start": 0,
            "limit": 12
        },
        "fluid": true
    }
}
catmorales commented 1 year ago

@tdipisa , thank you so much, I will try.

catmorales commented 1 year ago

@tdipisa I 've tested yet and disable "Maps" but enable "Dashboards , Geostories and Contexts " with the option "disablePluginIf": "{!!(state('userrole') !== 'ADMIN')}", applied on geostories:

"maps": 
        [
            "Login",
            "HomeDescription", "Fork",
            "MapSearch",
            {"name": "CreateNewMap", "cfg": {"allowedRoles": ["ADMIN" ]}},
            "FeaturedMaps", "ContentTabs",
            {
                "name": "Header",
                "cfg": {
                    "page": "mapstore-home"
                }
            },
                    {
                "name": "Contexts",
                "cfg": {
                    "mapsOptions": {
                        "start": 0,
                        "limit": 12
                    },
                "fluid": true
                   }
            },
                       {
                "name": "Dashboards",
                                 "override": {
                                      "ContentTabs": {
                                         "key": "maps"
                                      }
                                  },
                "cfg": {
                                     "showCreateButton": false,
                      "mapsOptions": {
                        "start": 0,
                        "limit": 12
                    },
                "fluid": true
                  }
           },
                  {
                            "name": "GeoStories",
                            "cfg": {
                                 "disablePluginIf": "{!!(state('userrole') !== 'ADMIN')}",    
                                 "mapsOptions": {
                                      "start": 0,
                                      "limit": 12
                                   },
                               "fluid": true
                            }
                  }
        ],

Result is : _As c.morales,(geOrchestra's rôle = ADMIN of Mapstore) image

Filter is applied and I don't see Geostories why I am MAPSTORE_ADMIN Why ? Is it a bug ?

As c.piton (User only) image

Filter is applied and I don't see Geostories (OK) , I don't see buttons for editing (OK),

Another question : Is it possible to change the tabs's order ? I'd like to have contexts first.

tdipisa commented 1 year ago

@catmorales

Filter is applied and I don't see Geostories why I am MAPSTORE_ADMIN Why ? Is it a bug ?

you can try by including the following line in the monitorState property in localConfig:

{"name": "userrole", "path": "security.user.role"}

Probably the reason is this and it should allow you to use the role for disablePluginIf.

As far as the order of tabs is concerned, you could try to override the current position by setting the Contexts tab as the first one as follow in configuration:

 {
          "name": "Contexts",
          "cfg": {
            "mapsOptions": {
              "start": 0,
              "limit": 12
            },
            "fluid": true
          },
+          "override": {
+           "ContentTabs": {
+              "position": -1
+            }
          }
}],
catmorales commented 1 year ago

Thank you so much, I've tested this parameters and it works 👍 .

landryb commented 1 year ago

@catmorales please put that somewhere in the future documentation :)