Skip to content

Conversation

mariusorani
Copy link

Summary

This PR adds preset management capabilities to the Migration Bundle extension, allowing users to save and load migration configurations using Directus native presets/bookmarks system.

Problem

Currently, users need to re-enter migration details (URL, token, options) every time they use the migration tool. This leads to:

  • Repetitive manual input for frequent migrations
  • Risk of errors from incorrect URLs or tokens
  • No way to share configurations between team members
  • Difficulty in maintaining consistent migration setups

Solution

This PR implements a comprehensive preset management system:

1. Environment Variable Defaults

MIGRATION_BUNDLE_DEFAULT_URL=https://staging.example.com
MIGRATION_BUNDLE_DEFAULT_TOKEN=your-admin-token
MIGRATION_BUNDLE_DEFAULT_OPTIONS=content,users,flows

2. User Presets/Bookmarks

- Save current configuration as a named preset
- Load saved presets from dropdown
- Update existing presets when changes are made
- Delete presets no longer needed

3. Modern UI/UX

- Integrated preset selector with bookmark icon
- Visual feedback when preset has unsaved changes
- Smooth animations for update button
- Clean, modern design matching Directus UI

Changes

Backend (migration-endpoint/index.ts)

- ✨ Added /defaults endpoint for ENV-based configuration
- ✨ Added /presets GET endpoint to fetch user presets
- ✨ Added /presets POST endpoint to create/update presets
- ✨ Added /presets/:id DELETE endpoint to remove presets
- 🔒 Proper permission checks (admin only)
- 💾 Presets stored in directus_presets table

Frontend (module.vue)

- ✨ Preset selector dropdown with "Load from Environment Defaults" option
- ✨ Save button to create new presets (bookmark icon)
- ✨ Update button appears when preset has changes
- ✨ Visual indicators for unsaved changes
- 🗑️ Removed localStorage implementation completely
- 🎨 Modern UI with smooth transitions

Types (extension.ts)

- 🏷️ Added MigrationConfig interface
- 🏷️ Updated type definitions

Screenshots

[Add screenshots showing:
1. Preset selector dropdown
2. Save preset dialog
3. Update button when changes detected
4. ENV defaults loaded]

Testing

1. Test ENV defaults:
# Set in .env
MIGRATION_BUNDLE_DEFAULT_URL=https://test.com
MIGRATION_BUNDLE_DEFAULT_TOKEN=test-token
MIGRATION_BUNDLE_DEFAULT_OPTIONS=content,users
  - Navigate to /admin/migration
  - Verify defaults are loaded
2. Test preset creation:
  - Fill in migration details
  - Click bookmark button
  - Save with name "Production Config"
  - Verify preset appears in dropdown
3. Test preset loading:
  - Select different presets from dropdown
  - Verify configuration updates
4. Test preset updates:
  - Load a preset
  - Change some values
  - Verify update button appears
  - Click update and verify changes are saved
5. Test preset deletion:
  - Create test preset
  - Delete it
  - Verify it's removed from dropdown

Breaking Changes

None. This is fully backward compatible.

Migration

No database migrations required - uses existing directus_presets table.

Marius Orhan added 3 commits June 13, 2025 15:45
…tions

  - Add support for saving/loading migration configurations as Directus presets
  - Add ENV variable support for default configuration values
  - Implement preset selector dropdown with update functionality
  - Add modern UI for preset management with visual change indicators
  - Remove localStorage implementation in favor of native Directus presets
  - Add API endpoints for preset CRUD operations

  This allows admins to set default migration configurations via ENV variables
  while users can save and manage their own presets through the UI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant