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

[Home Page] Modify the home page #602

Open
1 of 4 tasks
catmorales opened this issue Feb 21, 2023 · 6 comments
Open
1 of 4 tasks

[Home Page] Modify the home page #602

catmorales opened this issue Feb 21, 2023 · 6 comments

Comments

@catmorales
Copy link
Collaborator

catmorales commented Feb 21, 2023

Description

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

  • reduce the home page to contexts and dashboards only and
  • not allow non administrators to create maps, contexts, dashboards and geostories.

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 :

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

image

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

image

Documentation section involved

  • User Guide
  • Administrator Guide
  • Developer Guide
  • Configuration guide

Other useful information

Bugs ans documentation

@tdipisa
Copy link
Collaborator

tdipisa commented Feb 22, 2023

@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
Copy link
Collaborator Author

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

@catmorales
Copy link
Collaborator Author

catmorales commented Feb 23, 2023

@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
Copy link
Collaborator

tdipisa commented Feb 24, 2023

@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
Copy link
Collaborator Author

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

@landryb
Copy link
Member

landryb commented Feb 27, 2023

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

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

No branches or pull requests

3 participants