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-13

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

## [Opens notification discussion links] - 2024-04-08

- Opens GitHub links for notifications that point to a discussion directly.
Expand Down
15 changes: 13 additions & 2 deletions extensions/github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"xilopaint",
"antonengelhardt",
"johanthorell",
"dennis_zoma"
"dennis_zoma",
"dmitrii_mitrofanov"
],
"categories": [
"Developer Tools",
Expand All @@ -43,7 +44,17 @@
"name": "search-pull-requests",
"title": "Search Pull Requests",
"description": "Search recent pull requests globally in all repositories.",
"mode": "view"
"mode": "view",
"preferences": [
{
"type": "checkbox",
"label": "Open in Browser shortcut",
"name": "openInBrowser",
"description": "Open in browser as a default action.",
"default": false,
"required": false
}
]
},
{
"name": "create-pull-request",
Expand Down
2 changes: 0 additions & 2 deletions extensions/github/src/components/PullRequestActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ export default function PullRequestActions({
<ActionPanel title={`#${pullRequest.number} in ${pullRequest.repository.nameWithOwner}`}>
{children}

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

<Action.Push
icon={Icon.Document}
title="Add Review"
Expand Down
25 changes: 19 additions & 6 deletions extensions/github/src/components/PullRequestListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Action, Icon, List } from "@raycast/api";
import { Action, Icon, List, getPreferenceValues } from "@raycast/api";
import { MutatePromise } from "@raycast/utils";
import { format } from "date-fns";
import { useMemo } from "react";
Expand Down Expand Up @@ -67,6 +67,22 @@ export default function PullRequestListItem({ pullRequest, viewer, mutateList }:
keywords.push(pullRequest.author.login);
}

const isOpenInBrowserDefault = getPreferenceValues<Preferences.SearchPullRequests>().openInBrowser;

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

const showDetailsAction = (
<Action.Push
title="Show Details"
icon={Icon.Sidebar}
target={<PullRequestDetail initialPullRequest={pullRequest} viewer={viewer} mutateList={mutateList} />}
/>
);

const [primaryAction, secondaryAction] = isOpenInBrowserDefault
? [openInBrowserAction, showDetailsAction]
: [showDetailsAction, openInBrowserAction];

return (
<List.Item
key={pullRequest.id}
Expand All @@ -77,11 +93,8 @@ export default function PullRequestListItem({ pullRequest, viewer, mutateList }:
accessories={accessories}
actions={
<PullRequestActions pullRequest={pullRequest} viewer={viewer} mutateList={mutateList}>
<Action.Push
title="Show Details"
icon={Icon.Sidebar}
target={<PullRequestDetail initialPullRequest={pullRequest} viewer={viewer} mutateList={mutateList} />}
/>
{primaryAction}
{secondaryAction}
</PullRequestActions>
}
/>
Expand Down
Loading