Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

feat(CnFilesTab+CnSchemaFormDialog): schema-driven default for "Automatically publish" toggle#455

Open
WilcoLouwerse wants to merge 3 commits into
betafrom
feature/files-tab-auto-share
Open

feat(CnFilesTab+CnSchemaFormDialog): schema-driven default for "Automatically publish" toggle#455
WilcoLouwerse wants to merge 3 commits into
betafrom
feature/files-tab-auto-share

Conversation

@WilcoLouwerse

@WilcoLouwerse WilcoLouwerse commented May 26, 2026

Copy link
Copy Markdown

Summary

  • Read-side (CnFilesTab): adds an NcCheckboxRadioSwitch above the dropzone that controls the share flag sent on multipart upload (matches the OpenRegister filesMultipart endpoint's share field).
  • Write-side (CnSchemaFormDialog): adds a boolean checkbox under the Schema-configuration section so admins can set configuration.defaultAutoShare per schema. Default false; lifts via the standard {...defaults, ...item} spread so the value survives schema edits.
  • New CnFilesTab props (all backward-compatible, safe defaults):
    • showShareToggle: Boolean = true — hide to force share=false
    • defaultShare: Boolean|null = null — initial value; null triggers schema lookup
    • shareLabel: String — toggle label, translatable
  • When defaultShare === null, the component fetches apiBase/schemas/{schema} and seeds from configuration.defaultAutoShare. Any failure (network, missing key, non-boolean value) keeps the safe default (off).

Why

Closes the library half of ConductionNL/opencatalogi#577. The previous attachment-upload toggle lived in opencatalogi/src/modals/generic/UploadFiles.vue, which is no longer mounted in the manifest-driven shell. CnFilesTab is the active surface (rendered inside CnObjectSidebar's Files tab), so the user-facing fix belongs here.

The sibling opencatalogi PR (ConductionNL/opencatalogi#723) keeps the legacy modal in lockstep so a future re-wire — or any legacy consumer still importing it — lands the same behaviour. Backend persistence of the new configuration.defaultAutoShare key requires ConductionNL/openregister#1944 (whitelists the key in Schema::validateConfigurationArray()).

Backward compatibility

  • All three new CnFilesTab props have safe defaults: showShareToggle: true, defaultShare: null, shareLabel: t('nextcloud-vue', 'Automatically publish').
  • Without register/schema/objectId the lookup short-circuits, exactly as today.
  • Existing consumers (CnObjectSidebar with default tabs) render the toggle on; schemas that don't opt in via configuration.defaultAutoShare keep the toggle off — net behaviour matches today's no-toggle default.
  • Pass :show-share-toggle="false" to opt out of the toggle entirely; share is then omitted from the upload form data.
  • CnSchemaFormDialog checkbox is additive — schemas without an explicit defaultAutoShare continue to render with the field unset.

Test plan

  • npm test — 2619 / 2619 pass
  • npm run check:jsdoc — green at baseline
  • npm run check:docs — green
  • prebuild:docs regenerated docs/components/_generated/CnFilesTab.md (committed)
  • Manual smoke after merge: on a schema with configuration.defaultAutoShare: true, open the Files tab on an object of that schema → toggle is on; flip off, upload → backend receives share=false. On a schema without the key, toggle is off. From the schema-edit dialog, the new checkbox round-trips correctly.

🤖 Generated with Claude Code

Review feedback

Review feedback Remko & Thijn verwerkt in 88f323a — prop type, watcher dedupe, l10n, docgen path.

Adds an `NcCheckboxRadioSwitch` above the dropzone that controls the
`share` flag sent on multipart upload (matches the OpenRegister
`filesMultipart` endpoint's `share` field).

New props (all backward-compatible, safe defaults):
- `showShareToggle: Boolean = true`  — hide to force `share=false`
- `defaultShare: Boolean|null = null` — initial value; `null` triggers
  schema lookup
- `shareLabel: String` — toggle label, translatable

When `defaultShare` is `null`, the component fetches the active
schema (`apiBase/schemas/{schema}`) and reads
`configuration.defaultAutoShare`. A truthy value seeds the toggle on;
network failures or a missing key keep the safe default (off). A
non-null `defaultShare` always wins over the schema lookup so
consumers can override.

`share=…` is appended to the upload `FormData` only when the toggle
is visible; with `showShareToggle=false` the parameter is omitted
(equivalent to "don't auto-publish").

Addresses ConductionNL/opencatalogi#577 — the previous toggle lived
in opencatalogi's UploadFiles.vue, which is no longer mounted in the
manifest-driven shell. CnFilesTab is the active surface (rendered
inside CnObjectSidebar's Files tab), so the user-facing fix belongs
here.

Tests: 2619 / 2619 pass; check:jsdoc green at baseline; check:docs
covers the regenerated CnFilesTab.md partial.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pairs with the read-side CnFilesTab change earlier on this branch:
the admin can now flip `configuration.defaultAutoShare` directly in
the Configuration tab of the schema editor, instead of needing to
hit the OpenRegister schemas API by hand.

Changes:
- `CnSchemaConfigurationTab.vue`: NcCheckboxRadioSwitch bound to
  `schema.configuration.defaultAutoShare`, placed under the existing
  `autoPublish` toggle.
- `CnSchemaFormDialog.vue`: add `defaultAutoShare: false` to both
  `data().schemaItem.configuration` and the `initializeSchemaItem()`
  defaults block; add the matching `=== undefined → false` shim so
  legacy schemas without the key render the checkbox unchecked
  (not undefined → "indeterminate" state).

Backward-compatible: schemas that don't opt in keep the toggle off
exactly as before; existing whitelisted keys (allowFiles,
autoPublish, …) are untouched.

Tests: 2619 / 2619 pass. JSDoc baseline holds. No new docs partial
generated (the change is v-model + data() — no public prop / slot /
event surface).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@WilcoLouwerse WilcoLouwerse changed the title feat(CnFilesTab): "Automatically publish" toggle + schema-driven default feat(CnFilesTab+CnSchemaFormDialog): schema-driven default for "Automatically publish" toggle May 26, 2026
rubenvdlinde pushed a commit to ConductionNL/openregister that referenced this pull request May 27, 2026
…1944)

`Schema::validateConfigurationArray()` strips any configuration key not
in its allow-list. Adds `defaultAutoShare` to the `$boolFields`
whitelist so schemas can persist the new key without it being silently
dropped on save.

Read by the attachment-upload dialog (CnFilesTab in
@conduction/nextcloud-vue, and UploadFiles.vue in opencatalogi) to
seed the "Automatically publish" toggle. true = toggle on by default;
absent / false = toggle off (existing behaviour). Users can override
per upload — the schema value never coerces the final submitted
`share` field.

Companion to:
- ConductionNL/nextcloud-vue#455 (CnFilesTab share toggle)
- ConductionNL/opencatalogi#723 (UploadFiles legacy modal parity)

Closes ConductionNL/opencatalogi#577 (backend half).

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread src/components/CnObjectSidebar/CnFilesTab.vue
Comment thread src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue
Comment thread src/components/CnObjectSidebar/CnFilesTab.vue Outdated
Comment thread src/components/CnObjectSidebar/CnFilesTab.vue Outdated
Comment thread src/components/CnObjectSidebar/CnFilesTab.vue Outdated
Comment thread docs/components/_generated/CnFilesTab.md
…l10n, docgen path

- defaultShare: replace `type: Boolean` (rejected `null`) with a
  `validator` that accepts `null | boolean`. Vue 2 now stops emitting
  `Invalid prop` warnings when a consumer passes `:default-share="null"`.
- Watchers: fold the schema + defaultShare immediate watchers into the
  single `objectId` watcher every other CnObjectSidebar tab uses, so
  the schema lookup fires once on mount instead of twice concurrently.
- applyShareDefault: log the swallowed fetch error so a missing toggle
  default is debuggable — matches every other catch in this file.
- l10n: add the two new strings ("Automatically publish", "Default
  \"Automatically publish\" toggle …") to en.json + nl.json so the
  translation tooling no longer flags them as missing.
- docgen: stamp the real SFC path (resolved against componentsRoot)
  instead of the assumed `src/components/<displayName>/...` pattern,
  which was wrong for every nested component (CnFilesTab,
  CnAiInput, every CnObjectSidebar/* tab, …). Regenerated all
  partials so the stamps are now accurate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants