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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 49 additions & 34 deletions src/components/StatusWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { gitIcon } from '../style/icons';
import {
badgeClass,
statusAnimatedIconClass,
statusIconClass
statusIconClass,
currentBranchNameClass
} from '../style/StatusWidget';
import { toolbarButtonClass } from '../style/Toolbar';
import { IGitExtension } from '../tokens';
Expand All @@ -27,6 +28,8 @@ export class StatusWidget extends ReactWidget {
super();
this._model = model;
this._trans = trans;

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

/**
Expand All @@ -41,39 +44,51 @@ export class StatusWidget extends ReactWidget {

render(): JSX.Element {
return (
<UseSignal
signal={this._model.credentialsRequiredChanged}
initialArgs={false}
>
{(_, needsCredentials) => (
<Badge
className={badgeClass}
variant="dot"
invisible={!needsCredentials}
data-test-id="git-credential-badge"
>
<ActionButton
className={classes(
toolbarButtonClass,
this._status !== 'idle'
? statusAnimatedIconClass
: statusIconClass
)}
icon={gitIcon}
onClick={
needsCredentials
? async () => this._showGitOperationDialog()
: undefined
}
title={
needsCredentials
? `Git: ${this._trans.__('credentials required')}`
: `Git: ${this._trans.__(this._status)}`
}
/>
</Badge>
)}
</UseSignal>
<>
<UseSignal
signal={this._model.credentialsRequiredChanged}
initialArgs={false}
>
{(_, needsCredentials) => (
<Badge
className={badgeClass}
variant="dot"
invisible={!needsCredentials}
data-test-id="git-credential-badge"
>
<ActionButton
className={classes(
toolbarButtonClass,
this._status !== 'idle'
? statusAnimatedIconClass
: statusIconClass
)}
icon={gitIcon}
onClick={
needsCredentials
? async () => this._showGitOperationDialog()
: undefined
}
title={
needsCredentials
? `Git: ${this._trans.__('credentials required')}`
: `Git: ${this._trans.__(this._status)}`
}
/>
</Badge>
)}
</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.

👍

{() =>
this._model.currentBranch && (
<span className={currentBranchNameClass}>
{this._model.currentBranch.name}
</span>
)
}
</UseSignal>
</>
);
}

Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ async function activate(
change: IChangedArgs<string>
) => {
gitExtension.pathRepository = change.newValue;
gitExtension.refreshBranch();
};

// Whenever the file browser path changes, sync the Git extension path
Expand Down
5 changes: 5 additions & 0 deletions src/style/StatusWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ export const badgeClass = style({
}
}
});

export const currentBranchNameClass = style({
fontSize: 'var(--jp-ui-font-size1)',
lineHeight: '100%'
});
1 change: 1 addition & 0 deletions style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
@import url('diff-nb.css');
@import url('diff-text.css');
@import url('variables.css');
@import url('status-widget.css');
4 changes: 4 additions & 0 deletions style/status-widget.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.jp-git-StatusWidget {
display: flex;
align-items: center;
}