Commit Graph
106 Commits
Author SHA1 Message Date
Sky Mulleyandrobert dennis 71dd1911a5 Implement native support for hooking into forms with extensions (#7256)
## Problem

Extensions can render content before and after most admin pages, but not
inside the forms on them. The only exception was
`panel.users.detail.form`, and it could only re-render or validate the
user's existing fields. An extension had no way to add a field of its
own, because the Panel's save requests had nowhere to carry the value
and nothing loaded it back.

## Changes

### Slots inside every admin form

The create and edit forms for users, nodes, servers, eggs, locations,
mounts and database hosts each render a slot inside the form, such as
`panel.servers.create.form` and `panel.servers.detail.details.form`. The
slot receives the native `form`, the form's `kind` (`admin.server`), and
`mode` (`'create'` or `'edit'`). Edit slots also receive the saved
`resource`. Contributed `form.AppField` controls share the form's
validation, pending state and submit action.

### Extension-owned fields

An extension registers fields in its provider:

```php
$this->registerFormFields('admin.user', ['plan' => ['required', 'in:free,pro']]);

$this->registerFormFields(
    'admin.node',
    ['region' => ['required', 'string', 'max:32']],
    fn (Node $node): array => ['region' => NodeRegion::for($node)],
    fn (Node $node, array $values) => NodeRegion::store($node, $values['region']),
);
```

The 14 create and update endpoints accept an optional `extensions: {
[extensionId]: { [field]: value } }` body field. Each extension's rules
are applied as `extensions.{id}.{field}`, and only when the request
includes that extension's values. The extension's `save` callback runs
in the same database transaction as the core change, so a failure rolls
both back.

Server creation is the exception. Wings reads the new server while
provisioning it, so extension values are saved after provisioning
succeeds, outside the transaction.

For Node updates when Wings is unreachable. `UpdateNode` saves the node
and then throws `ConfigurationNotPersistedException` as a warning. The
node controller defers that exception until the extension values are
saved, so the node update is no longer rolled back.

`GET /api/admin/extensions/forms/{form}/{id}` returns every extension's
current values. It requires the resource's read permission. Edit pages
fetch it before rendering the form, but only when an extension has
registered fields for that form; the bootstrap payload now lists them
per extension in `forms`.

For users and servers the callbacks are optional, and values are stored
in the extension's scoped settings (`settings()->forUser($user)`,
`forServer($server)`). Values are limited to strings, numbers, booleans,
`null`, or lists of strings and numbers, which keeps the OpenAPI schema
and generated types concrete.

A `load` callback that throws, or returns an invalid value, is recorded
against the extension in the `form` phase. The frontend then hides that
extension's slot contributions on the edit page, so a save cannot
overwrite its stored values with defaults. Fields of a disabled or
failed extension are neither validated, saved nor loaded.

---------

Co-authored-by: robert dennis <31261583+robertdrakedennis@users.noreply.github.com>
2026-10-09 01:26:45 -04:00
robert dennis bc50a8bbeb backend cleanup 2026-10-08 17:22:14 -04:00
robert dennis 368b4bf6a6 regex fixes 2026-10-06 20:11:59 -04:00
Anthony e52fdfd416 Fix extension translations staying cached after an extension update
Fixes #7245
2026-10-06 00:18:41 -05:00
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00
Matthew Penner 8ca098940a chore: update composer dependencies (#5198)
Signed-off-by: Matthew Penner <me@matthewp.io>
2024-10-21 19:18:20 -06:00
Matthew Penner 1d38b4f0e2 Laravel 10 (#4706) 2023-02-23 12:30:16 -07:00
Matthew PennerandDaneEveritt cbcf62086f Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
2022-10-14 10:59:20 -06:00
DaneEveritt 4d3362b24f Perform a bit of code cleanup 2022-05-22 17:23:48 -04:00
DaneEveritt e9c633fd03 Update transformers and controllers to no longer pull an API key attribute 2022-05-22 15:37:39 -04:00
Dane Everitt e8a8405899 Remove tests 2021-11-03 21:22:14 -07:00
Dane Everitt e30a765071 Simplify logic when a server is in an unsupported state 2021-01-30 13:28:31 -08:00
Dane Everitt c449ca5155 Use more standardized phpcs 2021-01-23 12:33:34 -08:00
Dane EverittandMatthew Penner a043071e3c Update to Laravel 8
Co-authored-by: Matthew Penner <me@matthewp.io>
2021-01-23 12:12:54 -08:00
Dane Everitt 44575439d6 💣 2020-12-24 10:22:32 -08:00
Dane Everitt f300577963 Nuke useless tests 2020-12-24 09:16:30 -08:00
Dane Everitt 2f2d105a4f Fix test cases 2020-11-10 20:13:55 -08:00
Dane Everitt 756a21ff04 Remove unused code 2020-06-24 20:38:13 -07:00
Dane Everitt 536180ed0c Return Http test cases to a passing state 2020-06-23 21:59:37 -07:00
devfrey 2fecba2500 Fix tests by adding required return type hints 2020-05-09 18:00:52 +02:00
Dane Everitt 867dbf3bd2 Update all the client API endpoints to use new permissions codes 2019-11-03 17:13:47 -08:00
Dane Everitt 56640253b9 Merge branch 'release/v0.7.14' into feature/react 2019-06-22 12:28:44 -07:00
Dane Everitt 6d01b79372 Fix broken test 2019-06-21 22:01:42 -07:00
Dane Everitt 21ffa08d66 Merge branch 'develop' into feature/vuejs 2018-12-16 14:20:35 -08:00
Dane Everitt 8dd31f895e Fix test, update changelog 2018-11-10 15:30:11 -08:00
ayan4m1 c8ac013b65 add simple MailControllerTest (index only) 2018-10-13 21:31:08 -04:00
Dane Everitt 5ca13839cf Merge branch 'develop' into feature/vue-serverview 2018-09-05 21:34:59 -07:00
Dane Everitt fd49e524c8 Update middleware code 2018-09-03 15:17:53 -07:00
Dane Everitt 4d62e4c7b9 Merge branch 'develop' into pr/1128 2018-09-03 15:10:23 -07:00
Dane Everitt a7943553d3 Fix namespacing 2018-09-03 14:04:16 -07:00
Dane Everitt 8bbe6bc279 Add test, fix behavior of model creation 2018-07-14 22:58:33 -07:00
Dane Everitt eafc4408eb Fix broken unit tests 2018-07-14 21:49:49 -07:00
Dane Everitt c82f273d85 Fix remaining broken tests 2018-07-04 19:38:23 -07:00
Dane Everitt 6c20ea9881 Add tests for changed controllers 2018-07-04 19:20:33 -07:00
Dane Everitt 304d947536 Allow creating subuser with no permissions 2018-06-30 18:25:46 -07:00
Dane Everitt 974318ffb4 Logout other sessions when password is changed
closes #1222
2018-06-30 17:50:58 -07:00
Dane Everitt 969b16a563 Apply fixes from StyleCI
[ci skip] [skip ci]
2018-06-02 21:32:26 +00:00
stanjg b56f3a8671 Expanded the middleware test 2018-06-01 16:22:06 +02:00
stanjg 3bb9e5e8a8 Merge branch 'develop' of https://github.com/stanjg/panel into feature/user-specific-language 2018-06-01 15:58:09 +02:00
Dane Everitt fd8d7c3571 Merge pull request #1130 from stanjg/feature/stats-page
Added a statistics page to monitor the panel usage
2018-05-31 22:56:58 -07:00
stanjg ccf3e3511f Renamed middleware, and fixed the test 2018-05-31 16:40:18 +02:00
stanjg 60e1ffa564 Added a test for the controller and cleaned up the controller 2018-05-27 00:16:13 +02:00
Dane Everitt e648e50d90 Write some example tests for @stanjg 2018-05-26 11:00:28 -07:00
Dane Everitt 37a5e29db9 Merge branch 'develop' into feature/exception-tests 2018-05-20 16:26:18 -07:00
Lance Pioch a17570c1cb Fix styling 2018-05-13 18:33:51 -04:00
Lance Pioch 06229a328f Fix the description of the tests 2018-05-13 17:49:36 -04:00
Lance Pioch a6bca34677 Add more exception tests 2018-05-13 17:49:31 -04:00
Lance Pioch 038e5e1b7d Add exception tests 2018-05-13 17:49:25 -04:00
Lance Pioch 78b40a8055 Spelling mistakes for tests 2018-05-13 11:12:54 -04:00
stanjg f5a15c4039 Fixed the test 2018-05-04 13:58:39 +02:00