Skip to content

Add create tag dialog - #9440

Merged
outofambit merged 20 commits into
developmentfrom
feature/add-create-tag-dialog
Apr 16, 2020
Merged

outofambit merged 20 commits into
developmentfrom
feature/add-create-tag-dialog

Conversation

@rafeca

@rafeca rafeca commented Apr 2, 2020 •

Copy link
Copy Markdown
Contributor

Closes #9429

This PR is based on #9432 since it needs to use the createTag() method.

Description

This PR contains the UI changes to display a dialog that allows users to create tags.

Steps to complete this PR:

  • Add entry points that trigger the dialog by calling dispatcher.showCreateTagDialog()
  • Implement the dialog UI.
  • Plug the dialog logic to the createTag() method added in Add createTag() method to git library wrapper #9432.
  • Sanitize tag names.
  • Handle errors when creating a tag.
  • Early warnings when trying to create a tag with a name that already exists.
  • Add feature flag to not expose the dialog before release.

Screenshots

The current design of the dialog, mimicking the create branch dialog and following the design specs:

Screenshot 2020-04-02 at 18 44 29

Screenshot 2020-04-02 at 18 45 10

Screenshot 2020-04-03 at 18 37 49

Release notes

Notes: no-notes

@rafeca rafeca linked an issue Apr 3, 2020 that may be closed by this pull request
@rafeca
rafeca force-pushed the feature/add-create-tag-method branch from 29c478e to dc0e1c5 Compare April 3, 2020 09:06
@rafeca
rafeca force-pushed the feature/add-create-tag-dialog branch 3 times, most recently from a6b1b2a to 9fb14ba Compare April 3, 2020 16:37
@rafeca
rafeca changed the base branch from feature/add-create-tag-method to development April 6, 2020 12:18
@rafeca
rafeca force-pushed the feature/add-create-tag-dialog branch from 9fb14ba to 1d0574c Compare April 6, 2020 12:21
@rafeca
rafeca force-pushed the feature/add-create-tag-dialog branch from 1d0574c to 8279876 Compare April 7, 2020 16:29
@rafeca

rafeca commented Apr 7, 2020

Copy link
Copy Markdown
Contributor Author

Regarding Handle errors when creating a tag., we're only going to handle the case where a user types a tag that already exists.

In that case we're going to show a message on the same dialog (see screenshot on the PR description) and disable the button.

If for some reason this detection mechanism is not available (it can rarely happen if fetching the list of tags takes a long time), the following error will be displayed after clicking on "Create tag":

Screenshot 2020-04-07 at 18 28 30

@rafeca rafeca changed the title WIP: Add create tag dialog Add create tag dialog Apr 8, 2020
@rafeca
rafeca marked this pull request as ready for review April 8, 2020 08:16
ampinsk
ampinsk previously approved these changes Apr 8, 2020

@ampinsk ampinsk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great design wise!

@bush2769

This comment has been minimized.

@tierninho tierninho left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test for Mac + Windows:

  • Option can be selected in context menu from a commit
  • Modal can be closed with X, Cancel button or clicking the background
  • Name field prevents invalid characters; converts to - with inline error messaging
  • Duplicate names throw inline error messaging; prevents user from using them
  • Delete an existing tag in CL and recreate same tag in Desktop; use -d
  • Updated tag in CL is reflected in Desktop; use -f
  • Light/dark mode check

NOTES/ISSUES:

  • There is no limit to the tag length. We should have a cap as Github.com has some limits but just serves up a generic message "Invalid tag name".
  • The modal expands as you type. Repro: type a long string with spaces and invalid characters and watch it grow.
  • If there are multiple tags for one commit, I cannot see them all especially if they are long in length. Is a tool tip needed?
  • I can create a tag on Github.com and the same tag on Desktop and there is no collision. Is this intended or just not implemented yet?
  • When multiple tags are added the order of is not arranged by timestamp. Repro with multiple alpha and numeric tags.
  • Should user be able to create tag on commit that hasn’t been pushed to the remote yet? Steps: create tag on such a commit, undo the commit. Tags are deleted on Desktop but not in git tag —list. If you commit again, the tags cannot be duplicated.
  • If I delete an existing tag in Desktop with -d, then I update the same tag with -f, should that tag reappear for the same commit?

@rafeca

rafeca commented Apr 14, 2020

Copy link
Copy Markdown
Contributor Author

Great observations @tierninho ! Thanks for investigating into these edge cases!

There is no limit to the tag length. We should have a cap as Github.com has some limits but just serves up a generic message "Invalid tag name".

Good point! I've checked and GitHub allows a maximum tag length of 245 (since refs/tags/ + the tag name should not exceed 255 chars).

Also, the tag name length can be limited locally by the operating system (seems like all modern operating systems support filenames of up to 255 characters).

We can add a check for the length and limit it to 245 characters to prevent the issues when pushing.

The modal expands as you type. Repro: type a long string with spaces and invalid characters and watch it grow.

Ups, that's a bug, gonna fix it!

If there are multiple tags for one commit, I cannot see them all especially if they are long in length. Is a tool tip needed?

You mean in the commit details header?

Screenshot 2020-04-14 at 13 06 19

Yeah, I can add a tooltip there, although if the list of tags is very large (large enough to fill all horizontal space) I'm not sure if a tooltip is going to help much. Gonna check this with @ampinsk

I can create a tag on Github.com and the same tag on Desktop and there is no collision. Is this intended or just not implemented yet?

This is a really good point! This is not intended and can definitely cause issues to some users.

I cannot see an easy way to fix this at the moment though (we can't know which tags are in the remote repository until we fetch it, same should happen at the moment with branches).

Should we mark this as a current limitation and find a way to address this for both branches and tags in a similar way?

When multiple tags are added the order of is not arranged by timestamp. Repro with multiple alpha and numeric tags.

Oh yes! We're currently displaying the tags in the same order that git log returns them, which seems to be anti-alphabetical (which is a bit weird tbh 😅).

Unfortunately, I don't think we can consistently sort the tags in a chronological order: we are not able to know when a lightweight tag was created since this information is not stored.

I think that a good approach here would be to sort the tags alphabetically, which will be easy to do and easy to understand for users.

Should user be able to create tag on commit that hasn’t been pushed to the remote yet? Steps: create tag on such a commit, undo the commit. Tags are deleted on Desktop but not in git tag —list. If you commit again, the tags cannot be duplicated.

Interesting point that we haven't thought about yet! IMHO users should be able to create tags on unpushed commits (that a quite common use-case).

I can see two options here:

  • We can disable undoing commits that have an associated tag.
  • We can still allow users to undo these commits but warn them that the tag will get deleted (and then delete the tag).

We obviously shouldn't delete the tag if it's been pushed to the remote, but if a commit is "undoable" I think we have the guarantee that any associated tag has not been pushed.

What are your thoughts @billygriffin?

(to be clear, when undoing a commit we currently don't delete any associated tag: it's just that the tag is not visible from Desktop since that commit is not reachable anymore).

If I delete an existing tag in Desktop with -d, then I update the same tag with -f, should that tag reappear for the same commit?

What do you mean by updating the tag with -f?

@rafeca

rafeca commented Apr 14, 2020 •

Copy link
Copy Markdown
Contributor Author

Some of the appreciations in #9440 (review) (which are gold!) are related to displaying tags, so I'm gonna address the creation-related things here and the rest in separate PRs!

@tierninho

Copy link
Copy Markdown
Contributor

@rafeca Thanks for all the comments. It looks like you have addressed them all or in progress to do so ⚡

As for:

What do you mean by updating the tag with -f?

Here are the steps:

  • Add a tag to a commit
  • Go to cmd line and delete the tag with -d
  • In Desktop, the tag disappears from the commit as expected
  • Go to cmd line, update the deleted tag with the -f, (force) cmd.
  • In Desktop, the tag reappears for the commit, but is updated

I think the tag shouldn't reappear for the commit as it was deleted, but I am not 100%. 🤔

We might want to wait for this to surface organically as it might be too much of an edge case. Seems to be more of a Git issue and not so much Desktop.

Comment thread app/src/ui/history/commit-list-item.tsx Resolved
@rafeca
rafeca dismissed a stale review via 7a8f6ae April 16, 2020 13:36
if (sanitizedTagName.length > MaxTagNameLength) {
return new Error(
`The tag name cannot be longer than ${MaxTagNameLength} characters`
private getCurrentError(): JSX.Element | null {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved this method to return JSX elements now, this way we can have nice rendering of tag names inside errors (it was a bit weird anyways that the method returned an Error object).

@rafeca
rafeca requested a review from outofambit April 16, 2020 13:40

@outofambit outofambit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @rafeca ! this is a really nice refactor! :)

@outofambit outofambit self-assigned this Apr 16, 2020
@outofambit
outofambit merged commit 5c0df17 into development Apr 16, 2020
@outofambit
outofambit deleted the feature/add-create-tag-dialog branch April 16, 2020 17:54
@billygriffin
billygriffin requested review from billygriffin and removed request for billygriffin April 17, 2020 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

git tag creation popup flow

5 participants