Repository navigation
feat(chen): replace a saved SQL snippet and give its name more room - #2004
Open
adriadam10 wants to merge 1 commit into
Open
adriadam10 wants to merge 1 commit into
adriadam10 wants to merge 1 commit into
Conversation
Saving SQL under a name the user already has failed with "The fields name, creator must make a unique set", and there was no way to update a saved snippet, so users kept saving copies under new names. - Before creating, look up the user's own snippet with that exact name. If it exists, the save dialog asks to replace it and the confirm button turns into "Replace", which PATCHes the snippet. A shared snippet stays shared. - In the select dialog the name had a fixed 9rem and was cut off, while the text buttons took another 9rem: the name gets 45% of the width and Insert and Delete become icon buttons with tooltips.
|
Member
|
Nice UX improvement! Two edge cases worth addressing before merging:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
AdHochasunique_together = [('name', 'creator')]), so users end up keeping several copies under different names.w-36and long names are cut off, while the text buttons ("Insert", "Delete") take anotherw-36and the content preview takes the rest.Change
useChenSqlSnippets.save()first looks up the user's own snippet with that exact name (GET /api/v1/ops/adhocs/?name=…&only_mine=true). If it exists it returns"exists"instead of creating; the save dialog then explains it and the confirm button becomes "Replace", which sendsPATCH /api/v1/ops/adhocs/<id>/. Renaming in the dialog after the warning goes back to a normal save. Replacing a shared snippet keeps it shared.aria-label.Chen.ReplaceSqlandChen.ReplaceSqlConfirmin every locale.useChenSqlSnippets.test.ts).No core change:
nameis an exact filter inAdHocFilterSet,only_mineis already handled byAdHocViewSet, andIsOwnerOrAdminWritablelets the creator update the snippet.Testing
oxfmt,oxlint,eslint,nuxt typecheckandvitest(the repository's pre-commit) pass.only_mine=truereturns only the user's snippet, and a prefix does not match.