Presets Tool
Overview
Section titled “Overview”The Presets Tool allows developers to save and quickly load complete toolbar configurations. A preset can include feature flags, language settings, permissions, and app features — creating a complete testing environment with a single click.
Use Cases
Section titled “Use Cases”- Testing Scenarios: Save configurations for different test scenarios (Basic User, Admin, Enterprise Demo, etc.)
- Team Collaboration: Share preset configurations with team members for consistent testing environments
- Quick Environment Switching: Switch between different user roles or license tiers instantly without manual configuration
- Demo Preparation: Create presets for different demo scenarios and switch between them seamlessly
Quick Start
Section titled “Quick Start”import { Component, inject } from '@angular/core';import { ToolbarPresetsService } from 'ngx-dev-toolbar';
@Component({ selector: 'app-root', template: '<router-outlet />'})export class AppComponent { private presetsService = inject(ToolbarPresetsService);
ngOnInit() { // Subscribe to preset changes this.presetsService.getForcedValues().subscribe(presets => { console.log('Active presets:', presets); // Presets automatically apply settings to all tools }); }}Preset Configuration Structure
Section titled “Preset Configuration Structure”// Create a preset programmaticallyconst enterprisePreset: ToolbarPreset = { id: 'enterprise-demo', name: 'Enterprise Demo', description: 'All premium features enabled for demos', createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), config: { featureFlags: { enabled: ['dark-mode', 'advanced-search'], disabled: [] }, language: 'en', permissions: { granted: ['can-edit', 'can-delete', 'can-admin'], denied: [] }, appFeatures: { enabled: ['analytics', 'advanced-reporting', 'white-label'], disabled: [] } }};
// Presets are managed through the toolbar UI// This example shows the data structure onlyHow Presets Work
Section titled “How Presets Work”Presets automatically apply configurations to all other tools in the toolbar. When you load a preset:
- Feature flags are set according to the preset’s
featureFlagsconfiguration - Language is changed to the preset’s
languagevalue - Permissions are granted/denied according to the preset’s
permissionsconfiguration - App features are enabled/disabled according to the preset’s
appFeaturesconfiguration
All tools listen to preset changes and update their state accordingly.
Related Tools
Section titled “Related Tools”- Feature Flags Tool — Managed by presets
- i18n Tool — Managed by presets
- Permissions Tool — Managed by presets
- App Features Tool — Managed by presets