React frontend for the PIM-Perms permission management system.
This repository contains the frontend implementation:
- pim-perms-ui-core - Base hooks, components, and API client
- pim-perms-ui-rbac - Role & Permission Management pages (8 pages)
- pim-perms-ui-audit - Audit log viewer
- Node.js 18+
- npm 9+
- pim-perms-api running (backend)
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build for production
npm run build
# Run tests
npm test
# Run E2E tests
npm run test:e2epim-perms-ui/
├── package.json
├── packages/
│ ├── pim-perms-ui-core/ # Base library
│ │ ├── src/
│ │ │ ├── hooks/ # usePermissions, useSession
│ │ │ ├── components/ # PermissionGate, Layout
│ │ │ └── api/ # API client
│ │ └── __tests__/
│ ├── pim-perms-ui-rbac/ # RBAC management
│ │ ├── src/pages/
│ │ │ ├── UsersPage.tsx
│ │ │ ├── GroupsPage.tsx
│ │ │ ├── RolesPage.tsx
│ │ │ ├── PermissionExplorerPage.tsx
│ │ │ ├── PermissionMatrixPage.tsx
│ │ │ ├── JitAccessPage.tsx
│ │ │ ├── DelegationPage.tsx
│ │ │ └── SettingsPage.tsx
│ │ └── e2e/ # Playwright tests
│ └── pim-perms-ui-audit/ # Audit viewer
├── test-utils/ # Shared test utilities
└── e2e/ # E2E test configuration
Central Documentation: pim-perms-docs
UI-Specific:
Control UI visibility based on user permissions:
import { PermissionGate } from '@pim-perms/ui-core';
function MyComponent() {
return (
<PermissionGate resource="client" action="delete">
<Button>Delete Client</Button>
</PermissionGate>
);
}Check permissions programmatically:
import { usePermissions } from '@pim-perms/ui-core';
function MyComponent() {
const { can, loading } = usePermissions();
const canDelete = can('client', 'delete');
return <Button disabled={!canDelete}>Delete</Button>;
}Automatic session monitoring:
import { useSession } from '@pim-perms/ui-core';
function App() {
const { user, expiresIn, extend } = useSession();
// Shows warning at 2 minutes before timeout
// Auto-logs out on token reuse detection
// Monitors for MITM attacks
return <YourApp />;
}- DataGrid of all users
- Search/filter by provider, status, role
- User details dialog with 6 tabs:
- Overview, Direct Roles, Group Memberships, Effective Permissions, Temporary Permissions, Audit Log
- Assign/revoke roles
- List all groups (LDAP/AD/Local/OAuth)
- Sync from LDAP/AD button
- Group details with 5 tabs
- Assign roles to groups
- Card/table view of roles
- Create/Edit role wizard
- Permission selector (tree with checkboxes)
- Role details with assignment tracking
- Tree view of all permissions
- Details panel showing role grants and user assignments
- Search and filter
- Spreadsheet view: Users × Permissions
- Visual indicators: ✓ (has), ⏰ (temporary), 👥 (inherited)
- Export to CSV/Excel
- Request temporary permissions
- Approve/deny requests
- View active grants
- Full history
- Create permission delegations
- View delegations I've created/received
- Revoke or extend
- Default roles
- Approval requirements
- LDAP/AD sync configuration
- Audit retention
# Run all unit tests
npm test
# Run with coverage
npm run test:coverage
# Watch mode
npm run test:watchTarget: 85%+ coverage
# Run E2E tests
npm run test:e2e
# Run specific test
npx playwright test users-management
# Debug mode
npx playwright test --debug# Check linting
npm run lint
# Auto-fix
npm run lint:fix
# Check types
npm run typecheck
# Format code
npm run formatGitHub Actions automatically:
- ✅ Runs ESLint (fail on warnings)
- ✅ Runs TypeScript type checking
- ✅ Runs unit tests with coverage check (85%+)
- ✅ Runs E2E tests with Playwright
- ✅ Auto-fixes ESLint and Prettier issues (commits back to PR)
# Option 1: Use deployed backend API
VITE_API_URL=https://api.example.com npm run dev
# Option 2: Use local backend
VITE_API_URL=http://localhost:8080 npm run dev
# Option 3: Use mock API (for development without backend)
npm run dev:mock- Create page component in
packages/pim-perms-ui-rbac/src/pages/ - Add route in router
- Add permission gates
- Write unit tests
- Write E2E test
- Update documentation
Use MSW (Mock Service Worker) for development without backend:
// src/__mocks__/handlers.ts
import { rest } from 'msw';
export const handlers = [
rest.get('/api/perms/users', (req, res, ctx) => {
return res(ctx.json({ users: [...] }));
}),
];Depends on backend API:
- REST API endpoints from
pim-perms-api - WebSocket for real-time updates
- Create feature branch
- Implement changes
- Write tests (maintain 85%+ coverage)
- Run
npm run lint:fixandnpm run format - Push and create PR
- CI will auto-fix minor issues
- Address review comments
- Merge when approved
- Framework: React 18 + TypeScript
- State: Zustand + TanStack Query
- UI: Material-UI (MUI) + MUI DataGrid
- Testing: Jest + React Testing Library + Playwright
- Build: Vite
- Linting: ESLint + Prettier
See main PIM-Perms Documentation for project overview.