panel icon indicating copy to clipboard operation
panel copied to clipboard

feat: Add toggle for automatic allocation creation in panel settings

Open PalmarHealer opened this issue 1 month ago • 6 comments

  • Introduced create_new configuration to control automatic allocation behavior.
  • Updated allocation service logic to respect the create_new toggle.
  • Enhanced panel settings UI to include the new create_new toggle option.
  • Added helper text for better clarity on configuration options.

Supersedes #1852

PalmarHealer avatar Nov 09 '25 23:11 PalmarHealer

📝 Walkthrough

Walkthrough

Adds a runtime feature flag and admin toggle to control whether the allocation service may create new allocations when no unassigned allocation exists; the config, translations, Filament settings UI, and allocation service behavior are updated accordingly.

Changes

Cohort / File(s) Summary
Settings UI & Translations
app/Filament/Admin/Pages/Settings.php, lang/en/admin/setting.php
Added new boolean toggle PANEL_CLIENT_ALLOCATIONS_CREATE_NEW to misc settings (visible only when allocations are enabled) and added translation keys misc.auto_allocation.create_new and misc.auto_allocation.create_new_help.
Configuration
config/panel.php
Added client_features.allocations.create_new config option backed by PANEL_CLIENT_ALLOCATIONS_CREATE_NEW (default true).
Allocation Service
app/Services/Allocations/FindAssignableAllocationService.php
Service now reads client_features.allocations.create_new and: returns an existing unassigned allocation if found; if none found, creates a new allocation when enabled or throws NoAutoAllocationSpaceAvailableException when disabled. Docblock/comments updated.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant Service as FindAssignableAllocationService
    participant Repo as AllocationRepo
    participant Config

    Caller->>Service: findAssignableAllocation()
    Service->>Repo: query for unassigned allocation
    Repo-->>Service: allocation or null

    alt Unassigned allocation exists
        Service-->>Caller: return allocation
    else No unassigned allocation
        Service->>Config: read client_features.allocations.create_new
        Config-->>Service: boolean

        alt create_new = true
            rect rgb(200,220,255)
            Note over Service,Repo: create allocation within configured port range
            Service->>Repo: create allocation
            Repo-->>Service: new allocation
            Service-->>Caller: return allocation
            end
        else create_new = false
            rect rgb(255,220,200)
            Note over Service: throw NoAutoAllocationSpaceAvailableException
            Service-->>Caller: throw exception
            end
        end
    end

Possibly related PRs

  • pelican-dev/panel#1882 — Modifies the same allocation service and port-range allocation behavior; likely related to allocation creation and lookup changes.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a toggle for automatic allocation creation in panel settings, which is reflected across all modified files.
Description check ✅ Passed The description is directly related to the changeset, listing four specific modifications that align with the actual changes made to settings, service logic, and translations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a886e1de05b1693854d747f2dccaca39c6f2d718 and 00348680c11713bcd0c7f419ab07688e89b79e12.

📒 Files selected for processing (2)
  • app/Filament/Admin/Pages/Settings.php (1 hunks)
  • app/Services/Allocations/FindAssignableAllocationService.php (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/Services/Allocations/FindAssignableAllocationService.php
  • app/Filament/Admin/Pages/Settings.php

[!TIP]

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions: | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context. Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 09 '25 23:11 coderabbitai[bot]

@coderabbitai review

PalmarHealer avatar Nov 09 '25 23:11 PalmarHealer

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot] avatar Nov 09 '25 23:11 coderabbitai[bot]

Doesn't seem worth adding, if an allocation is created by an admin it will be locked by default already.

rmartinoscar avatar Nov 10 '25 15:11 rmartinoscar

But if I provide a large port range and want to exclude certain ports from being assigned, this comes in very handy because I can create the assignable ports beforehand and then use this option.

see more Or, in my use case, I have two nodes and can have different port ranges for each one by creating the ports beforehand and then giving a range that includes all and using this option to prevent ports I don't want from being used.

I know it's a small change and can be seen as not needed, but I would benefit greatly from this, and I think others can appreciate it as well.

PalmarHealer avatar Nov 10 '25 16:11 PalmarHealer

@PalmarHealer Please resolve conflicts.

rmartinoscar avatar Nov 27 '25 22:11 rmartinoscar