Skip to content

✨ Batch share an item from an imported contacts file#784

Open
NathanVss wants to merge 4 commits into
mainfrom
feat/import-users-share
Open

✨ Batch share an item from an imported contacts file#784
NathanVss wants to merge 4 commits into
mainfrom
feat/import-users-share

Conversation

@NathanVss

@NathanVss NathanVss commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Purpose

Sharing an item with a large group means inviting people one by one.
This lets administrators and owners import a CSV or XLSX contacts file
(email, role) from the share modal to batch share an item. The feature
is opt-in per environment through a new ALLOW_SHARE_IMPORT_FILE
setting.

CleanShot.2026-07-20.at.17.22.18.mp4

Proposal

  • ✨ add the ALLOW_SHARE_IMPORT_FILE setting (default off), exposed by
    the config endpoint so the frontend shows or hides the import entry,
    and enforced server side by the new route
  • ✨ add POST /api/v1.0/items/<item_id>/batch-share/: every row is
    validated before any database write (a user cannot grant a role higher
    than their own); emails are resolved server side — registered users
    get an access, unknown emails an invitation; already shared or invited
    contacts are skipped and reported in the response; notification emails
    behave like single sharing
  • ♻️ extract the share helpers into core/services/accesses.py
  • ✨ wire the ui-kit contacts import in the share modal: flag-gated menu
    entry, async import that closes the modal on success and renders the
    backend error inside the import modal on failure
  • ✅ backend tests for the new route and config flag, plus e2e coverage
    (hidden entry, successful import, failed import)

Notes

  • Draft until the next @gouvfr-lasuite/ui-kit release ships the share
    import modal: package.json must be bumped from 0.26.0 before review
    (the branch was developed against a local ui-kit checkout).
  • The e2e backend environment (env.d/development/common.e2e) enables
    the flag so the success scenario exercises the real endpoint.

The descendants access synchronization logic was private to the accesses
viewset. Extracting it into core/services/accesses.py lets the upcoming
batch share endpoint reuse it without reaching into viewset internals.
Sharing a folder with many contacts one call at a time is slow and can
leave a partial state when one of them fails. This endpoint accepts a
list of email/role rows, validates them all before any write, then
creates accesses for known users and invitations for unknown emails.
Rows targeting users already covered by an equal or higher role are
skipped and reported so the client can inform the user.

The feature is disabled by default and gated by the new
ALLOW_SHARE_IMPORT_FILE setting exposed in the config endpoint.
Plug the ui-kit share modal file import onto the new batch share
endpoint. The option only shows up when ALLOW_SHARE_IMPORT_FILE is
enabled in the config. Errors are rendered inside the import modal
instead of the global toast so the user can fix the file and retry
without losing context.

The e2e environment enables the flag to cover the flow end to end.
The share import modal needs ui-kit changes and cunningham 4.4.0 that
are not published yet, so the ui-kit dependency points to a local
checkout for now. To be replaced by a released version before merge.
@NathanVss
NathanVss force-pushed the feat/import-users-share branch from 7131990 to 0c7aeb1 Compare July 23, 2026 15:02
@sonarqubecloud

Copy link
Copy Markdown

@NathanVss
NathanVss marked this pull request as ready for review July 23, 2026 15:04
@NathanVss
NathanVss requested a review from kernicPanel July 23, 2026 15:04
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.

1 participant