Skip to content

Add interactive select in gist view#3008

Merged
vilmibm merged 5 commits intocli:trunkfrom
ganboonhong:interactive-gist-view
Mar 1, 2021
Merged

Add interactive select in gist view#3008
vilmibm merged 5 commits intocli:trunkfrom
ganboonhong:interactive-gist-view

Conversation

@ganboonhong
Copy link
Contributor

@ganboonhong ganboonhong commented Feb 22, 2021

Fix #2999

@ganboonhong ganboonhong changed the title Add interactive select in gist view [WIP] Add interactive select in gist view Feb 22, 2021
@ganboonhong ganboonhong force-pushed the interactive-gist-view branch 2 times, most recently from 8e90495 to 68d7277 Compare February 23, 2021 08:09
@ganboonhong ganboonhong changed the title [WIP] Add interactive select in gist view Add interactive select in gist view Feb 23, 2021
@ganboonhong
Copy link
Contributor Author

ganboonhong commented Feb 23, 2021

Hi @vilmibm, this PR is ready to review now. Thanks!

The format would be like:

? Select a gist  [Use arrows to move, type to filter]
> foo.txt (about 13 minutes ago)
  gistfile.txt (about 13 minutes ago)

}

if gistID == "" {
return nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since gist list simply return when there are no any gists, so I keep the behavior consistent in gist command.
Or message like "There are no gists from [username]" should be returned?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think a message saying that the user has no gists would be a nice improvement, here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be better to display current username? Or just "There are no gists from current user".
If showing username is preferred, is there any way to access current username other than passing in parameter to viewRun?

@vilmibm vilmibm self-requested a review February 23, 2021 18:34
Copy link
Contributor

@vilmibm vilmibm left a comment

Choose a reason for hiding this comment

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

just noted potential for some improvements, nice work

)

func listGists(client *http.Client, hostname string, limit int, visibility string) ([]shared.Gist, error) {
func ListGists(client *http.Client, hostname string, limit int, visibility string) ([]shared.Gist, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is going to be shared it should be moved to pkg/cmd/gist/shared/shared.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already moved to correct location.

}

if gistID == "" {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a message saying that the user has no gists would be a nice improvement, here.

}
}
gistTime := utils.FuzzyAgo(time.Since(gist.UpdatedAt))
opt := fmt.Sprintf("%s (%s)", text.ReplaceExcessiveWhitespace(description), gistTime)
Copy link
Contributor

Choose a reason for hiding this comment

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

It's still possible for description to end up blank which looks weird in the prompt; how about we try setting description to something like "<no description>" if it still ends up empty at this point?

Copy link
Contributor Author

@ganboonhong ganboonhong Feb 24, 2021

Choose a reason for hiding this comment

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

Updated gist view

Screen Shot 2021-02-24 at 3 02 13 PM
Question:
I use gistfile1.txt as filename since no filename was not provided by user when creating gist. Which prevents from showing blank at the beginning of the row. Or should I use something like "<no filename>" instead of meaningless gistfile1.txt?


Current gist list

Question:
Also, I found current gist list won't show anything if both filename and description are empty. Is it desired result?
Screen Shot 2021-02-24 at 3 03 20 PM


GitHub UI gists

Reference:
GitHub UI gists listing page uses gist:[node_name] when there's no filename:
Screen Shot 2021-02-24 at 3 27 42 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

My concern was the blank at the start of the line; just using gistfile is fine for now.

}
}

func Test_promptGists(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

these are good tests 👍 please also add one test to the gist view tests just to ensure that we go into interactive mode when no ID is supplied (it doesn't have to test anything beyond that since you're doing that here).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests added. Could you please have a look? Thanks.

@ganboonhong ganboonhong force-pushed the interactive-gist-view branch from 68d7277 to 2956840 Compare February 24, 2021 07:04
Copy link
Contributor

@vilmibm vilmibm left a comment

Choose a reason for hiding this comment

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

I went ahead and resolved the merge conflict and resolved the final small tweaks myself. Thank you!

@vilmibm vilmibm merged commit 953855c into cli:trunk Mar 1, 2021
@ganboonhong ganboonhong deleted the interactive-gist-view branch March 2, 2021 01:56
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.

interactive select in gist view

3 participants