Skip to content

feat(chen): add and duplicate rows in results that carry the whole table - #2010

Open
adriadam10 wants to merge 2 commits into
jumpserver:devfrom
adriadam10:feat/chen-add-duplicate-rows
Open

adriadam10 wants to merge 2 commits into
jumpserver:devfrom
adriadam10:feat/chen-add-duplicate-rows

Conversation

@adriadam10

Copy link
Copy Markdown
Contributor

Builds on #2009 (its first commit is that PR). Server side: jumpserver/chen#369.

Add row was only shown for a table opened from the tree. Copying an existing row into a new one (as other database clients allow) had no direct way either: pasting a copied row also carries its primary key, and the save fails.

  • Add row is shown whenever chen marks columns insertable, which with feat(edit): add rows from query results that carry the whole table chen#369 includes SELECT * results of one table.
  • New Duplicate row (result toolbar and row context menu): stages the selected rows as new rows with every insertable value, so only what must differ is edited. Generated and identity columns, such as an auto-increment key, are left to the database. The insert goes through the usual preview and save.
  • DuplicateRow added to every locale; vitest for stageDuplicateRows.

Delete row was only shown when the table was opened from the tree. A
query result whose source is proven to be one table with a primary key
can already update rows by that key, and chen now accepts deleting them
too. Show Delete row in the toolbar and in the row context menu for those
results; adding rows still needs a table browse result.
Add row was shown only for a table opened from the tree. Show it whenever
chen marks columns insertable, which now includes SELECT * results of one
table, and add Duplicate row (toolbar and row menu): it stages the
selected rows as new ones with every insertable value, leaving generated
columns such as an auto-increment key to the database.
@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2026

Copy link
Copy Markdown

@ibuler

ibuler commented Dec 5, 2026

Copy link
Copy Markdown
Member

Nice addition! Besides waiting on the server-side changes in jumpserver/chen#368 and jumpserver/chen#369, two UI state edge cases in Duplicate row worth fixing:

  1. duplicateRows() desynchronizes selected from GoResultGrid's visual selection (ui/chen/v1/GoWritePanel.vue#L274-L279, ui/chen/v1/GoResultGrid.client.vue#L526-L530)

    • duplicateRows() clears selected.value = [] in GoWritePanel, while GoResultGrid keeps its visual selection and internal selectedRows cache unchanged (and only re-emits @selection when the selected row set changes). After duplicating row 0, row 0 remains highlighted as selected in the grid, yet Duplicate row, Delete row, and Update rows stay disabled in both the toolbar and the row context menu (even when clicking other columns in row 0) until the user selects a different row first.
  2. Duplicating an existing row ignores staged cell edits on that row (ui/chen/v1/GoWritePanel.vue#L276, ui/chen/v1/dataEditing.ts#L117-L129)

    • stageDuplicateRows reads source cell values from props.query.rows rather than the current draft view (rows.value / editDraftRows), so if a user edits cells on an existing row and then clicks Duplicate row, the newly inserted copy silently reverts those edited columns back to their pre-edit values. (Also worth clearing draft.status = "" and draft.saveError = undefined when staging inserts/duplicates, matching stageEditCell.)

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.

2 participants