Skip to content

feat(s3-explorer): make rows draggable so objects can be dragged out - #1089

Open
idemery wants to merge 1 commit into
InseeFrLab:mainfrom
idemery:feat/drag-objects-out
Open

idemery wants to merge 1 commit into
InseeFrLab:mainfrom
idemery:feat/drag-objects-out

Conversation

@idemery

@idemery idemery commented Sep 26, 2026

Copy link
Copy Markdown

What

Rows in the S3 explorer become draggable, so an object or a prefix can be dragged out and dropped somewhere else.

Why

The explorer accepts a drop of files from the desktop, but nothing can be dragged out of it. Anyone who wants an object's URI elsewhere — a notebook cell, a chat box, a form field, an application embedding Onyxia — has to open the row menu, copy the URI, and paste it.

What a drag carries

Two formats, always both:

  • text/plain, newline separated. This is what makes a drop onto an ordinary text field useful without the target knowing anything about Onyxia.
  • application/x-onyxia-s3-objects, JSON. For a consumer that needs to tell "these are S3 objects" from "the user dropped some text".

Nothing is read and nothing is modified — only the URIs travel.

Three details that are easy to get wrong

They are pure functions with tests rather than logic inside the component, following the existing convention in src/ui of testing functions rather than rendering:

  • Which rows a drag carries is not "the selection". Dragging an unselected row drags that row alone and leaves the selection untouched. Returning the selection there would carry files the user cannot see they had selected, since the list is virtualized.
  • Rows mid-upload or mid-delete are not draggable, and are dropped from a multi-row drag rather than refusing the whole gesture.
  • Detection during dragover reads types, never getData(). The DataTransfer is in protected mode while a drag is in flight, so every value reads back empty. A check written against getData() passes its unit test and refuses every real drag.

A drag beginning on the row checkbox or a row action button is that control's gesture and does not become a row drag.

Notes

  • No new prop and no configuration: a draggable row is inert unless something is listening.
  • S3ExplorerMainView.spec.md updated.
  • 19 new tests; tsc, eslint and vite build clean.

The explorer accepts a drop of files from the desktop, but nothing can be
dragged out of it. Anyone who wants an object's URI somewhere else — a notebook
cell, a chat box, a form field, an application embedding Onyxia — has to open
the row menu, copy the URI, and paste it.

Rows are now draggable. A drag publishes the S3 URIs twice: as `text/plain`,
newline separated, which is what makes a drop onto an ordinary text field
useful without the target knowing anything about Onyxia; and as
`application/x-onyxia-s3-objects`, JSON, for a consumer that needs to tell
"these are S3 objects" from "the user dropped some text".

Nothing is read and nothing is modified — only the URIs travel.

Three details that are easy to get wrong, so they are pure functions with tests
rather than logic inside the component:

- Which rows a drag carries is not "the selection". Dragging an unselected row
  drags that row alone; returning the selection there would carry files the user
  cannot see they had selected, since this list is virtualized.
- Rows mid-upload or mid-delete are not draggable, and are dropped from a
  multi-row drag rather than refusing the whole gesture.
- Detection during dragover reads `types` and never `getData()`. The
  DataTransfer is in protected mode while a drag is in flight, so every value
  reads back empty — a check written against `getData()` passes its unit test
  and refuses every real drag.

A drag beginning on the row checkbox or a row action button is that control's
gesture and does not become a row drag.

Signed-off-by: Islam Eldemery <islam.eldemery@gmail.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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