Commit 04ef397
authored
feat(admin): let instances choose which pad types are offered (#177)
* feat(admin): let instances choose which pad types are offered
Add two settings, Protected pads and Public pads, both enabled by default
so existing installations are unaffected. The labels keep the vocabulary
the API and the binding table already use.
Enforcement is server-side, matching allow_external_pads:
PadCreationService covers the API and embed-create paths,
materializeTemplateInto() the templates, and PadBootstrapService guards
its `binding === null` branch -- otherwise an empty .pad plus /initialize
was a way around the setting. The check deliberately stays out of
provisionPadId(), which also re-initialises files that already have a
binding.
Existing pads of a disabled type keep working; only creation is affected.
Turning both off is allowed. A template carrying a disabled mode is
created in the enabled mode rather than failing, and Nextcloud's own
"+ New pad" entry is hidden when protected pads are off, since it always
produces one. External pads stay independent.
The setting decides what the app offers -- it is not a hard boundary
against hand-crafted .pad files. Recovering an orphaned pad from its
snapshot still re-provisions the mode recorded in the file, because
rescuing existing content wins.
Includes de/es/fr translations and doc updates.
Closes #175.
* fix(api): return a stable code instead of the exception message
PadControllerErrorMapper documents that RuntimeException messages are not
exposed to clients, but the new PadTypeDisabledException branch forwarded
its message verbatim. That coupled the HTTP contract to service-layer
prose.
Carry the access mode on the exception as data instead, and let the mapper
build the payload: a fixed message plus `code: pad_type_disabled` and,
when a single type is to blame, `access_mode`. This matches how
`missing_binding` and `legacy_collision_no_access` already work, and gives
clients something stable to branch on.
* fix: fall back instead of stranding empty .pad files
initializeMissingFrontmatter hard-required protected pads, so a `.pad`
that arrived outside the UI -- over WebDAV, from another integration, or
from before the setting changed -- failed every open attempt with 403
when protected pads were off, even though public pads were available.
There was no way out for the user: recovery needs frontmatter the file
doesn't have.
Use the same fallback the template path already uses. It still closes the
`/initialize` bypass (nothing enabled means an exception), but produces an
openable pad whenever some type is allowed.
Rename resolveForTemplate() to resolveCreatableMode(), since it now serves
both callers, and note in its docblock that the fallback can widen access:
a protected template becomes a public pad when protected pads are off.
README, api-reference and templates docs say so too.
* fix(admin): actually hide the "no pad type enabled" hint
The hint carries Nextcloud's `.settings-hint` class alongside ours, and
that rule sets `display`, so it beat the user-agent `[hidden]` default --
the hint showed permanently, even with both pad types enabled.
Toggle `display` instead, matching how the external-allowlist rows in the
same file already work, and set the initial state from PHP so nothing
flashes before the script runs.1 parent 0751fa0 commit 04ef397
54 files changed
Lines changed: 1020 additions & 33 deletions
File tree
- docs
- js
- l10n
- lib
- Controller
- Exception
- Listeners
- Service
- Settings
- src
- files
- lib
- templates
- tests
- js/files
- phpunit
- stubs/OCP/Files/Template
- unit
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
101 | 129 | | |
102 | 130 | | |
103 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
74 | 91 | | |
75 | 92 | | |
76 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| |||
86 | 90 | | |
87 | 91 | | |
88 | 92 | | |
89 | | - | |
| 93 | + | |
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
| |||
249 | 253 | | |
250 | 254 | | |
251 | 255 | | |
| 256 | + | |
252 | 257 | | |
253 | 258 | | |
254 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| 94 | + | |
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments