RoleEditorModal Documentation
Overview
The RoleEditorModal component in the Vantage analytics and data platform provides an interface for creating or editing user roles within the system. It allows administrators to define role-specific permissions and settings pertaining to dashboard access, workflows, AI features, and billing management. This component is pivotal for managing user access levels and ensuring that each user has the appropriate permissions aligned with their roles.
Purpose
The main purpose of the RoleEditorModal is to facilitate the management of user roles by allowing administrators to:
- Create new roles from scratch or based on predefined templates.
- Edit existing roles, adjusting permissions as needed.
- Configure budget and overage parameters for each role.
Settings
The RoleEditorModal comprises several settings related to role management. Below is an exhaustive breakdown of each accessible setting.
1. Role Templates
- Name:
ROLE_TEMPLATES - Input Type: Array of objects (templates).
- Description: Predefined role templates that can be used as a base for creating new roles. Templates include 'Admin', 'Manager', 'Analyst', 'Viewer', and 'Billing Manager', each providing a specific set of permissions and settings. Selecting a template pre-fills the modal with the corresponding role’s data.
- Default Value: None (requires user selection).
2. Role Name
- Name:
name - Input Type: String.
- Description: Specifies the name of the role being created or edited. It is crucial for identifying the role within the system.
- Default Value: Empty string.
3. Role Description
- Name:
description - Input Type: String.
- Description: Provides a detailed explanation of the role's purpose and responsibilities. This assists other administrators in understanding the role's intent.
- Default Value: Empty string.
4. Context
- Name:
context - Input Type: Dropdown (default value).
- Description: Defines the context under which the role operates. Currently, the default value is 'organization', indicating that roles are tied to the organizational structure within Vantage.
- Default Value: 'organization'.
5. Permissions
- Name:
permissions - Input Type: Object with boolean properties.
- Description: A collection of permissions that dictate what users assigned this role can view and modify in the application. Permissions are grouped by categories such as Pages, Settings, Features, AI Features, Integrations, Organization, and Billing. Changing the permissions can significantly affect what users can do within the Vantage platform.
- Default Value: Empty object.
6. Credit Budget
- Name:
creditBudget - Input Type: Number or null.
- Description: Sets a monthly budget for the role in terms of credits available for usage in the platform. This is essential for roles that have limits on operating costs.
- Default Value: null (indicating no budget limit).
7. Budget Period
- Name:
budgetPeriod - Input Type: Dropdown (string).
- Description: Defines the time period over which the credit budget applies, typically set to 'monthly'. Roles can be adjusted to have different budget periods as necessary.
- Default Value: 'monthly'.
8. Overage Action
- Name:
overageAction - Input Type: Dropdown (string).
- Description: Determines the action taken when the role exceeds its credit budget. Options can include 'warn', 'block', or 'notify_admin', allowing for different strategies on how to handle budget overages.
- Default Value: 'warn'.
Functionality
When the RoleEditorModal component is rendered, it either opens a form for creating a new role or editing an existing one based on the isOpen prop. The modal’s state is managed via internal state management. The permissions can be toggled using checkboxes, and any changes to form input values are captured and reflected in the component’s state. Upon submitting the form, the onSave callback is triggered, passing the new or updated role data back to the parent component.
Expected Data
The data expected to be received by the RoleEditorModal includes:
isOpen: A boolean indicating whether the modal is displayed.onClose: A function to close the modal.role: An object containing the role's current data (if editing an existing role).onSave: A callback function triggered to save the role data.
Use Cases & Examples
Use Cases
-
Creating New User Roles: An organization wants to implement a new role for content editors with specific editing permissions. The
RoleEditorModalallows creating this role while selecting from a template and modifying permissions. -
Editing Existing Roles: A company undergoes a change in its structure and needs to alter the permissions of existing roles, such as reducing a 'Manager's' capabilities to avoid unauthorized access to sensitive data.
-
Managing Billing and Budgeting: A finance team needs to create a role for billing managers that includes permissions for managing payment methods. The credit budget feature allows for budgeting management within these roles to avoid overspending.
Example Configuration
Use Case: Creating a new Content Editor role:
- Role Name: Content Editor.
- Description: Responsible for creating and editing content on the platform.
- Context: organization (default).
- Permissions (configured):
- View Dashboard: true
- Edit Dashboard: true
- View Workflows: true
- Edit Workflows: true
- Export Data: true
- Credit Budget: 1000 (monthly).
- Budget Period: monthly.
- Overage Action: warn.
Sample Configuration Object:
{
"name": "Content Editor",
"description": "Responsible for creating and editing content on the platform.",
"context": "organization",
"permissions": {
"view_dashboard": true,
"edit_dashboard": true,
"view_workflows": true,
"edit_workflows": true,
"export_data": true
},
"creditBudget": 1000,
"budgetPeriod": "monthly",
"overageAction": "warn"
}Using this detailed guide, administrators can effectively understand and utilize the RoleEditorModal to manage user roles efficiently within the Vantage platform.