Skip to content

Add setting to toggle PR icons in Graph#2450

Merged
ramin-t merged 8 commits intomainfrom
feature/graph-pr-icons-setting
Jan 18, 2023
Merged

Add setting to toggle PR icons in Graph#2450
ramin-t merged 8 commits intomainfrom
feature/graph-pr-icons-setting

Conversation

@ramin-t
Copy link
Contributor

@ramin-t ramin-t commented Jan 16, 2023

We had a setting to enable/disable upstream status for local branches in the graph. This adds a setting to toggle the other metadata type: Pull Requests.

This also combines all the active metadata from settings into a single array to send to the graph. This requires a graph library update after the breaking change lands: https://github.com/gitkraken/GitKrakenComponents/pull/189

Once that merges, the dependency will be updated in this PR and it can leave draft state.

@ramin-t ramin-t requested a review from eamodio January 16, 2023 21:47
@ramin-t ramin-t added the area-graph Issues or features related to the Commit Graph label Jan 16, 2023
package.json Outdated
"scope": "window",
"order": 26
},
"gitlens.graph.showPullRequests": {
Copy link
Member

Choose a reason for hiding this comment

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

Lets call it gitlens.graph.pullRequests.enabled to align with the other PR related options

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit: Rename setting

Comment on lines +45 to +48
export const GraphRefMetadataTypes = {
Upstream: 'upstream',
PullRequest: 'pullRequests',
};
Copy link
Contributor Author

@ramin-t ramin-t Jan 16, 2023

Choose a reason for hiding this comment

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

A note on this piece: I originally had it pulling these strings directly from the graph library. However, this caused the GitLens extension to fail to load entirely when debugging, producing a document is not defined error:
image

I'm guessing it's because I was attempting to pull constants out of a typedef file, but not sure exactly why it failed (it built successfully).

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, can't use consts as values from d.ts files. d.ts are just types/shapes and are not available at runtime.

That's why https://github.dev/gitkraken/vscode-gitlens/blob/52d8b0ad6b5a0d33781410dae49af11c5fba1dc8/src/%40types/vscode.git.enums.ts#L1 exists, I had to separate out certain consts from the vscode.git.d.ts file so that they would get compiled in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! We'll definitely want an enums export in the Graph in general then - I'll add that in as a separate task.

Copy link
Member

Choose a reason for hiding this comment

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

I would also suggest changing this to:

export enum GraphRefMetadataTypes {
	Upstream = 'upstream',
	PullRequest = 'pullRequests',
}

export const supportedRefMetadataTypes: GraphRefMetadataType[] = Object.values(GraphRefMetadataTypes);

To avoid having to call Object.values each time when checking the metadata, and that will also make sure that enum stays in sync with the types, since the supportedRefMetadataTypes will fail if an enum/type value don't change together

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit: Use enum and values array

>Show associated pull requests on remote branches</label
>
</div>
</div>
Copy link
Member

Choose a reason for hiding this comment

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

Add

<p class="setting__hint hidden" data-visibility="currentLine.pullRequests.enabled">
	<i class="icon icon__info"></i>Requires a connection to a supported remote service (e.g. GitHub)
</p>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Should I add that for the upstream indicator setting as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@eamodio eamodio Jan 17, 2023

Choose a reason for hiding this comment

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

Upstream, doesn't need an integration -- just the PRs

Upstream we get completely from Git, but the PRs require a rich integration to pull the details from GitHub/GitLab

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks! Fixed in commit: Remove remote service hint from upstream setting

</div>
</div>

<div class="setting">
Copy link
Member

Choose a reason for hiding this comment

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

Can do it outside this PR, but we should look at the UX/UI of the graph settings and group some of them up to make them easier for users to understand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wrote up a task for it, thanks!

@ramin-t ramin-t marked this pull request as ready for review January 17, 2023 16:47
@ramin-t
Copy link
Contributor Author

ramin-t commented Jan 17, 2023

@eamodio The dependency on the graph side has been merged. Bumped the graph version in this PR to match it.

@ramin-t ramin-t requested a review from eamodio January 17, 2023 16:48
Copy link
Member

@eamodio eamodio left a comment

Choose a reason for hiding this comment

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

Looks good!

@ramin-t ramin-t merged commit 3992bc8 into main Jan 18, 2023
@ramin-t ramin-t deleted the feature/graph-pr-icons-setting branch January 18, 2023 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-graph Issues or features related to the Commit Graph

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants