Skip to content

#11165: Option to deny app context for normal users#11183

Merged
allyoucanmap merged 4 commits intogeosolutions-it:masterfrom
mahmoudadel54:issue_11165
Jun 27, 2025
Merged

#11165: Option to deny app context for normal users#11183
allyoucanmap merged 4 commits intogeosolutions-it:masterfrom
mahmoudadel54:issue_11165

Conversation

@mahmoudadel54
Copy link
Copy Markdown
Contributor

@mahmoudadel54 mahmoudadel54 commented Jun 10, 2025

Description

In this PR, we introduce a new cfg called 'resourceTypes' for plugin 'ResourcesGrid' to control browse resources in the new home page, it is a dictionary contains resources for ADMIN, USER, anonymous for example:

{
    "name": "ResourcesGrid",
    "cfg": {
        "id": "catalog",
        "titleId": "resources.contents.title",
        "queryPage": true,
        "resourceTypes":  {
            "ADMIN": ["MAP", "DASHBOARD", "GEOSTORY", "CONTEXT"],
            "USER": ["MAP", "DASHBOARD", "GEOSTORY"],
            "anonymous": ["MAP", "DASHBOARD", "GEOSTORY"]
        }
    }
}

each array is the available resources to browse for user and anonymous is for guest user [Anonymous user]. So this is for browse contexts point in requirements if we provide a list without CONTEXT the shown/fetched resouces will be only the provided ones. The default value for resourceTypes is

"resourceTypes": ["MAP", "DASHBOARD", "GEOSTORY", "CONTEXT"]

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Issue

What is the current behavior?
#11165

What is the new behavior?

We can manage the browse resources in new home page using by the new cfg 'resourceTypes' into plugin 'ResourcesGrid'. To manage hiding edit/create/filter context from new home page UI, we can do that using the same cfg 'resourceTypes' for plugins 'ResourcesGrid' of catalog and 'ResourcesFiltersForm' like the clarification above.

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

Description:
- introduce a new cfg called 'cateogries' for plugin 'ResourcesGrid' to control browse resources in the new home page, it is a dictionary contains resources for ADMIN, USER, COMMON
- add unit tests
@mahmoudadel54 mahmoudadel54 added this to the 2025.01.01 milestone Jun 10, 2025
@mahmoudadel54 mahmoudadel54 self-assigned this Jun 10, 2025
@mahmoudadel54 mahmoudadel54 linked an issue Jun 10, 2025 that may be closed by this pull request
6 tasks
Copy link
Copy Markdown
Contributor

@allyoucanmap allyoucanmap left a comment

Choose a reason for hiding this comment

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

I created a proposal for some changes on this branch https://github.com/allyoucanmap/MapStore2/tree/issue_11165 (2625543253bf9a05dfeff9b3e8e7633b58e89baf). Here major changes:

  • ranamed catagories to resourceTypes
  • stored resourceTypes in the redux state
  • make resourceTypes accessible from the monitored state
  • include a new context requires function called isResourceTypeSupported usable inside the localConfig as expression
  • add disabledIf expression to prevent some item to be shown if a specific resource type is not available (eg. "disableIf": "{!context.isResourceTypeSupported('CONTEXT', state('resourceTypes'), state('userrole'))}")
  • added disableIf to default configuration of filter panel

before proceed I would like a feedback (cc @tdipisa )

@allyoucanmap
Copy link
Copy Markdown
Contributor

@mahmoudadel54 I just pushed some code I reviewed with @offtherailz, most of the implementation now on the resourceTypes (before categories). This same resourceTypes is used to filter menu item that exposes the resourceType key.
The resourceTypes can be a flat array or an object where each key is a user role, anonymous will act as default.
Still are missing following parts:

  • review existing unit test
  • add unit tests for new selector and utils
  • add in migration guidelines changes needed in localConfig

- add migration guides to 2025.01.01
- add missing unit tests for 'getSupportedResourceTypes', 'isMenuItemSupportedSupported' utils
- add missing unit tests for 'getAvailableResourceTypes'
@allyoucanmap allyoucanmap merged commit 0975f1b into geosolutions-it:master Jun 27, 2025
6 checks passed
@allyoucanmap
Copy link
Copy Markdown
Contributor

@ElenaGallo please test this on a local instance of mapstore using master because you need to configure localConfig.json as described in the PR description, then let us know if we can backport on 2025.01.xx, thanks

@tdipisa tdipisa added the BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch label Jun 30, 2025
@ElenaGallo
Copy link
Copy Markdown
Contributor

Test passed, @mahmoudadel54 please backport to 2025.01.xx. Thanks

mahmoudadel54 added a commit to mahmoudadel54/MapStore2 that referenced this pull request Jul 1, 2025
…eosolutions-it#11183)

---------

Co-authored-by: allyoucanmap <stefano.bovio@geosolutionsgroup.com>
@mahmoudadel54
Copy link
Copy Markdown
Contributor Author

Test passed, @mahmoudadel54 please backport to 2025.01.xx. Thanks

Backport is done --> #11262

tdipisa pushed a commit that referenced this pull request Jul 1, 2025
---------

Co-authored-by: allyoucanmap <stefano.bovio@geosolutionsgroup.com>
@mahmoudadel54 mahmoudadel54 removed the BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch label Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to deny app context for normal users

4 participants