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

GitHub: Set Open in Browser as a primary action #11798

Merged
merged 13 commits into from
Apr 22, 2024
Merged
4 changes: 4 additions & 0 deletions extensions/github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# GitHub Changelog

## [Open in Browser as primary action setting] - 2024-04-22

- You can now set Open in Browser as a primary action for Pull Request searches.

## [Fix various icons and colors] - 2024-04-22

- Fixes icons for issues and pull requests in `Notifications` and `Unread Notifications` commands.
Expand Down
12 changes: 11 additions & 1 deletion extensions/github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"antonengelhardt",
"johanthorell",
"dennis_zoma",
"litomore"
"litomore",
"dmitrii_mitrofanov"
],
"categories": [
"Developer Tools",
Expand Down Expand Up @@ -365,6 +366,15 @@
"title": "Number of search results",
"description": "For searching repositories, issues, discussions or pull requests, this is the number of results to request. Less will be faster.",
"placeholder": "50"
},
{
"type": "checkbox",
"title": "Actions",
"label": "Open PRs in browser by default",
"name": "isOpenInBrowser",
"description": "If checked, pull requests will be opened in the browser by default instead of viewing them within Raycast.",
"default": false,
"required": false
}
],
"dependencies": {
Expand Down
15 changes: 11 additions & 4 deletions extensions/github/src/components/PullRequestActions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Action, ActionPanel, Color, Icon, Toast, showToast } from "@raycast/api";
import { Action, ActionPanel, Color, Icon, Toast, getPreferenceValues, showToast } from "@raycast/api";
import { MutatePromise, useCachedPromise } from "@raycast/utils";
import { useState } from "react";

Expand Down Expand Up @@ -172,11 +172,18 @@ export default function PullRequestActions({

const isAssignedToMe = pullRequest.assignees.nodes?.some((assignee) => assignee?.isViewer);

const { isOpenInBrowser } = getPreferenceValues<Preferences>();

const openInBrowserAction = <Action.OpenInBrowser url={pullRequest.permalink} />;

const [primaryAction, secondaryAction] = isOpenInBrowser
? [openInBrowserAction, children]
: [children, openInBrowserAction];

return (
<ActionPanel title={`#${pullRequest.number} in ${pullRequest.repository.nameWithOwner}`}>
{children}

<Action.OpenInBrowser url={pullRequest.permalink} />
{primaryAction}
{secondaryAction}

<Action.Push
icon={Icon.Document}
Expand Down