Pulse/frontend-modern/src/constants/apiScopes.ts
rcourtman 6eb1a10d9b Refactor: Code cleanup and localStorage consolidation
This commit includes comprehensive codebase cleanup and refactoring:

## Code Cleanup
- Remove dead TypeScript code (types/monitoring.ts - 194 lines duplicate)
- Remove unused Go functions (GetClusterNodes, MigratePassword, GetClusterHealthInfo)
- Clean up commented-out code blocks across multiple files
- Remove unused TypeScript exports (helpTextClass, private tag color helpers)
- Delete obsolete test files and components

## localStorage Consolidation
- Centralize all storage keys into STORAGE_KEYS constant
- Update 5 files to use centralized keys:
  * utils/apiClient.ts (AUTH, LEGACY_TOKEN)
  * components/Dashboard/Dashboard.tsx (GUEST_METADATA)
  * components/Docker/DockerHosts.tsx (DOCKER_METADATA)
  * App.tsx (PLATFORMS_SEEN)
  * stores/updates.ts (UPDATES)
- Benefits: Single source of truth, prevents typos, better maintainability

## Previous Work Committed
- Docker monitoring improvements and disk metrics
- Security enhancements and setup fixes
- API refactoring and cleanup
- Documentation updates
- Build system improvements

## Testing
- All frontend tests pass (29 tests)
- All Go tests pass (15 packages)
- Production build successful
- Zero breaking changes

Total: 186 files changed, 5825 insertions(+), 11602 deletions(-)
2025-11-04 21:50:46 +00:00

64 lines
1.9 KiB
TypeScript

export interface APIScopeOption {
value: string;
label: string;
description?: string;
group: 'Monitoring' | 'Agents' | 'Settings';
}
export const HOST_AGENT_SCOPE = 'host-agent:report';
export const DOCKER_REPORT_SCOPE = 'docker:report';
export const DOCKER_MANAGE_SCOPE = 'docker:manage';
export const MONITORING_READ_SCOPE = 'monitoring:read';
export const MONITORING_WRITE_SCOPE = 'monitoring:write';
export const SETTINGS_READ_SCOPE = 'settings:read';
export const SETTINGS_WRITE_SCOPE = 'settings:write';
export const API_SCOPE_OPTIONS: APIScopeOption[] = [
{
value: MONITORING_READ_SCOPE,
label: 'Dashboards & alerts (read)',
description: 'View monitoring data, dashboards, and alert history.',
group: 'Monitoring',
},
{
value: MONITORING_WRITE_SCOPE,
label: 'Alert actions (write)',
description: 'Acknowledge, silence, and clear alerts.',
group: 'Monitoring',
},
{
value: DOCKER_REPORT_SCOPE,
label: 'Container agent reporting',
description: 'Allow the container agent to submit host and runtime telemetry.',
group: 'Agents',
},
{
value: DOCKER_MANAGE_SCOPE,
label: 'Container lifecycle management',
description: 'Enable agent-triggered runtime commands and host actions.',
group: 'Agents',
},
{
value: HOST_AGENT_SCOPE,
label: 'Host agent reporting',
description: 'Allow the host agent to send OS, CPU, and disk metrics.',
group: 'Agents',
},
{
value: SETTINGS_READ_SCOPE,
label: 'Settings (read)',
description: 'Fetch configuration snapshots such as nodes and security posture.',
group: 'Settings',
},
{
value: SETTINGS_WRITE_SCOPE,
label: 'Settings (write)',
description: 'Modify configuration, manage tokens, and trigger updates.',
group: 'Settings',
},
];
export const API_SCOPE_LABELS = API_SCOPE_OPTIONS.reduce<Record<string, string>>((acc, option) => {
acc[option.value] = option.label;
return acc;
}, {});