Dashboard-Plugin
Docs HomeDashboard plugins and appsInfomakerNaviga global
  • About
  • Intro
  • Getting started
  • The anatomy of a plugin
  • Manifest structure
  • Getting started
    • Get Dashboard-Plugin
    • Build
  • What's new
  • Components
    • Agent
      • Actions
    • Application
    • Widget
    • Health
    • Modal
    • Settings
  • API and GUI
    • API
      • Overview
      • register
        • Reducers
        • Portals
        • Requirements
        • Permissions
        • Default config
        • Config Modifiers
      • cache
      • store
      • encrypt
      • decrypt
      • createUUID
      • getLanguage
      • getTextDirection
      • getTimeFormat
      • getKeyCharFromCode
      • getKeyCodeFromChar
      • event
      • Logger
      • buildRouteUrlWithDispatchableEvent
      • getUser
      • getAction
      • getPortal
      • getConfig
      • getLocalize
      • getAvailableActions
      • getAvailablePortals
      • request
      • setHealth
      • openModal
      • closeModal
      • confirm
      • notifications
      • hasPermission
      • standalone
      • withUser
      • useModal
      • useSheet
      • useUser
      • useConfig
      • useLocalize
      • useApplication
      • useMappings
      • useStandalone
    • GUI
      • Core GUI
      • Style-Guide
    • Modules
      • GUI
      • Utility
      • NavigaID
        • getUserToken
        • getApplicationToken
        • getGroupsFromToken
  • Mappings
  • Plugins deployments
  • S3 upload
  • Deprecations
    • 4.1.0
    • 4.0.0
    • 2.1.0
Powered by GitBook
On this page

Was this helpful?

  1. API and GUI
  2. API

hasPermission

PreviousnotificationsNextstandalone

Last updated 4 years ago

Was this helpful?

hasPermission is a helper function to check for signed in users permissions.

This method is built along with Permissions to check for the configured permissions for mapped ids

hasPermission is a function that takes in the ID for the permission you want to match against, then checks which roles are mapped to it and determines if the current user has this role, then returns a boolean value depending on the outcome.

How to use

import { Plugin } from '@root'

import CreateButton from '@components/CreateButton'
import UpdateButton from '@components/UpdateButton'

import {
    Wrapper
} from './style'

const MyApplication = () => {
    return (
        <Wrapper>
            {
                Plugin.hasPermission('PERMISSION_TO_CREATE_ID') && (
                    <CreateButton/>
                )
            }
            
            {
                Plugin.hasPermission('PERMISSION_TO_UPDATE_ID') && (
                    <UpdateButton/>
                )
            }
        </Wrapper>
    )
}

export {
    MyApplication
}

PERMISSION_TO_CREATE_ID and PERMISSION_TO_UPDATE_ID are ids that has been registered with permissionKeys with Plugin.register() method

Permissions