Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds new ability to search for a GitLab MR in the _Launchpad_ — closes [#3788](https://github.com/gitkraken/vscode-gitlens/issues/3788)
- Adds go to home view button to the commit graph title section — closes [#3873](https://github.com/gitkraken/vscode-gitlens/issues/3873)
- Adds a _Contributors_ section to comparison results in the views
- Adds a new Hidden Branches dropdown next to the Branch Visibility dropdown in the graph toolbar — closes [#3101](https://github.com/gitkraken/vscode-gitlens/issues/3101)

### Changed

Expand Down
85 changes: 85 additions & 0 deletions src/webviews/apps/plus/graph/GraphWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ import type { GraphMinimapDaySelectedEventDetail } from './minimap/minimap';
import { GlGraphMinimapContainer } from './minimap/minimap-container.react';
import { GlGraphSideBar } from './sidebar/sidebar.react';

function getRemoteIcon(type: string | number) {
switch (type) {
case 'head':
return 'vm';
case 'remote':
return 'cloud';
case 'tag':
return 'tag';
default:
return '';
}
}
Comment on lines +103 to +114
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be using the remote's avatar icon for a remote branch in this list if the avatars are enabled in the graph's settings. Always using a generic cloud icon feels like a regression

image


export interface GraphWrapperProps {
nonce?: string;
state: State;
Expand Down Expand Up @@ -873,7 +886,25 @@ export function GraphWrapper({
onChangeColumns?.(graphColumnsConfig);
};

// dirty trick to avoid mutations on the GraphContainer side
const fixedExcludeRefsById = useMemo(() => ({ ...excludeRefsById }), [excludeRefsById]);
const handleOnToggleRefsVisibilityClick = (_event: any, refs: GraphRefOptData[], visible: boolean) => {
if (!visible) {
document.getElementById('hiddenRefs')?.animate(
[
{ offset: 0, background: 'transparent' },
{
offset: 0.4,
background: 'var(--vscode-statusBarItem-warningBackground)',
},
{ offset: 1, background: 'transparent' },
],
{
duration: 1000,
iterations: !Object.keys(fixedExcludeRefsById ?? {}).length ? 2 : 1,
},
);
}
onChangeRefsVisibility?.(refs, visible);
};

Expand Down Expand Up @@ -1347,6 +1378,60 @@ export function GraphWrapper({
<SlOption value="current">Current Branch</SlOption>
</SlSelect>
</GlTooltip>
<div className={`shrink ${!Object.values(excludeRefsById ?? {}).length && 'hidden'}`}>
<GlPopover
className="popover"
placement="bottom-start"
trigger="click focus"
arrow={false}
distance={0}
>
<GlTooltip placement="top" slot="anchor">
<button type="button" id="hiddenRefs" className="action-button">
<CodeIcon icon={`eye-closed`} />
{Object.values(excludeRefsById ?? {}).length}
<CodeIcon
className="action-button__more"
icon="chevron-down"
aria-hidden="true"
/>
</button>
<span slot="content">Hidden Branches / Tags</span>
</GlTooltip>
<div slot="content">
<MenuLabel>Hidden Branches / Tags</MenuLabel>
{excludeRefsById &&
Object.keys(excludeRefsById).length &&
[...Object.values(excludeRefsById), null].map(ref =>
ref ? (
<MenuItem
// key prop is skipped intentionally. It allows me to not hide the dropdown after click (I don't know why)
onClick={event => {
handleOnToggleRefsVisibilityClick(event, [ref], true);
}}
className="flex-gap"
>
<CodeIcon icon={getRemoteIcon(ref.type)}></CodeIcon>
<span>{ref.name}</span>
</MenuItem>
) : (
// One more weird case. If I render it outside the listed items, the dropdown is hidden after click on the last item
<MenuItem
onClick={event => {
handleOnToggleRefsVisibilityClick(
event,
Object.values(excludeRefsById ?? {}),
true,
);
}}
>
Show All
</MenuItem>
),
)}
</div>
</GlPopover>
</div>
<GlPopover
className="popover"
placement="bottom-start"
Expand Down
20 changes: 20 additions & 0 deletions src/webviews/apps/plus/graph/graph.scss
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,20 @@ button:not([disabled]),
--button-foreground: var(--color-foreground);
}

.shrink {
max-width: fit-content;
transition: all .2s;

&.hidden {
max-width: 0;
overflow: hidden;
.titlebar__group &:not(:first-child) {
// compensate the parent gap
margin-left: -0.5rem;
}
}
}

.action-button {
position: relative;
appearance: none;
Expand Down Expand Up @@ -475,6 +489,12 @@ button:not([disabled]),
z-index: 1040;
}

.flex-gap {
display: flex;
gap: 0.5em;
align-items: center;
}

.alert {
--alert-foreground: var(--color-alert-foreground);
--alert-background: var(--color-alert-infoBackground);
Expand Down
Loading