Skip to content

fix(products): a product without a panel no longer shows resources it was never given - #188

Merged
Panelica merged 3 commits into
Panelica:mainfrom
ertugrulkeyvan:fix/product-resources-panel-only
Oct 12, 2026
Merged

Panelica merged 3 commits into
Panelica:mainfrom
ertugrulkeyvan:fix/product-resources-panel-only

Conversation

@ertugrulkeyvan

Copy link
Copy Markdown
Contributor

What

A product without a module no longer picks up Panelica's default limits by being saved, and the price list no longer offers them.

The product edit page has a Panelica resources card. It is shown for Panelica products and for products with no module yet, and every number in it was filled in with the panel's default: 1024 MB RAM, 100% CPU, 5120 MB disk, 51200 MB bandwidth, 1 website, and so on.

On a product without a module, nobody chose those numbers, but saving the product for any reason wrote them into config_options. Product::resourceSummary() then listed them on the price list and the order page: "1 GB RAM · 1 vCPU · 5 GB disk · 50 GB bandwidth · 1 website". This shows on a product that is, say, a manually delivered VPS with 8 GB, or a service with no server at all.

We hit it while drafting a catalogue: the moment a description was edited, every plan card showed the same 1 GB / 1 vCPU / 5 GB. The disk and bandwidth numbers are also the limits overage billing falls back to.

After this:

  • Without a module (or "Custom/No Module"): the card shows the defaults as placeholders and leaves the fields empty. Empty fields are not saved, so nothing reaches the price list until someone types a limit in. A limit that is typed in is kept, as before.
  • Panelica products: the defaults are still filled in. When left empty, PanelicaModule applies the same defaults itself, so creating an account is unchanged either way.
  • Other modules (cPanel, Proxmox, …): the update no longer writes Panelica limits to such a product, even when the request carries the card. The browser already disables it there; a request that bypasses that no longer counts.

Products that already carry such numbers keep them. They cannot be told apart from limits someone chose, so this does not remove them.

How

  • admin/products/edit.blade.php: a field's value is the saved one, else the default only on a Panelica product, else empty; the default is always shown as the placeholder.
  • ProductController::update: the res_section block runs only for '', custom and panelica, the modules the card is shown for, plus custom, which the existing tests save resources on.

The work is split into three commits: the form, the controller and the tests.

Tests

tests/Feature/ProductResourceDefaultsTest.php, 5 tests:

  • Edit form: on a product without a module, the RAM field is empty with 1024 as the placeholder.
  • Untouched card: saving a product without a module with exactly what its edit form shows leaves no limits, and resourceSummary() is empty.
  • Typed-in limit: one typed in on such a product is kept.
  • Panelica product: still shows 1024 filled in.
  • cPanel request: a cPanel product saved with the card in the request gets no Panelica limits.

Three of them fail on main. ProductResourceConfigTest and ProductTest pass unchanged.

Full suite: 4162 passed. The one failure is the CurrencyAndBackupTest db backup test, which fails on main too in my local setup.

@Panelica
Panelica merged commit a5750c6 into Panelica:main Oct 12, 2026
1 check passed
@Panelica

Copy link
Copy Markdown
Owner

Thank you, @ertugrulkeyvan, merged. A product without a module no longer picks up the panel's default limits just by being saved, so the price list stops offering resources nobody chose, and a product of another panel can no longer be given Panelica limits through a crafted request.

Checked before merging: an empty field is never written, the type check runs after the product is updated (so switching a product to Panelica in the same save still keeps its limits), the defaults the Panelica module falls back to are the same eighteen numbers the form shows, only the edit page has this card, three of your tests fail on main and all pass here, and the full suite passes.

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.

2 participants