Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add current branch name on status bar #1131

Merged
merged 4 commits into from
Jun 17, 2022

Conversation

BoscoCHW
Copy link
Contributor

@BoscoCHW BoscoCHW commented Jun 10, 2022

Fixes #1100

@fcollonval
Added current branch name on the status bar
I managed to style it but I'm not sure how to center the text vertically.
I should make the parent element a flex box and do align-item: center but I don't know how to select the parent class.
Also I'm not sure how to change the padding of the git icon so that the text could be closer to the icon.

Another issue is when navigate to another repo (change file directory), the branch name stays unless you click on the git extension icon on the left menu bar, which is a bit weird.


Edited to link the related issue.

@welcome
Copy link

welcome bot commented Jun 10, 2022

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@github-actions
Copy link

Binder 👈 Launch a binder notebook on branch BoscoCHW/jupyterlab-git/current-branch-on-status-bar

Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

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

Thanks @BoscoCHW

Added current branch name on the status bar I managed to style it but I'm not sure how to center the text vertically. I should make the parent element a flex box and do align-item: center but I don't know how to select the parent class. Also I'm not sure how to change the padding of the git icon so that the text could be closer to the icon.

You can add a class in StatusWidget (the parent element) within the constructor by adding the following line:

this.addClass('jp-git-StatusWidget')

Note: by design it is not possible to select parent of an element with CSS selectors.

Another issue is when navigate to another repo (change file directory), the branch name stays unless you click on the git extension icon on the left menu bar, which is a bit weird.

The default behavior is to not refresh the Git model status when the sidebar is hidden to avoid useless calls to the backend. You could solve this by forcing refreshing the branch calling GitExtension.refreshBranch when we set a new repository.

Comment on lines 77 to 81
{this._model.currentBranch && (
<span className={currentBranchClass}>
{this._model.currentBranch.name}*
</span>
)}
Copy link
Member

Choose a reason for hiding this comment

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

You should place this outside the UseSignal component as it does not need to be refreshed if the credentials status of the extension changes.

But you should wrap it in another UseSignal component to listen to this._model.headChanged to react when the git head is changed.

@BoscoCHW
Copy link
Contributor Author

@fcollonval

I managed to style the status widget by adding a class like you suggested, but I was unable to reduce the right-padding of the git icon on the status bar because I'm afraid overriding the pre-set would lead to unexpected results.

)}
</UseSignal>

<UseSignal signal={this._model.headChanged}>
Copy link
Member

Choose a reason for hiding this comment

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

👍

@fcollonval
Copy link
Member

Thanks for the update @BoscoCHW

I was unable to reduce the right-padding of the git icon on the status bar because I'm afraid overriding the pre-set would lead to unexpected results.

Let's discuss that on Thursday's meeting.

Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

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

Let's remove the star next to the branch name. And it is good to go.

src/components/StatusWidget.tsx Outdated Show resolved Hide resolved
Co-authored-by: Frédéric Collonval <[email protected]>
Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

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

Thanks @BoscoCHW

@fcollonval fcollonval merged commit 9b035bf into jupyterlab:master Jun 17, 2022
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 branch name in the status bar
2 participants