Skip to content

Commit

Permalink
🐛 fix: #115 Ensure popout windows arent closed when clicking links
Browse files Browse the repository at this point in the history
Also added the actual url to an authors page when rendering it in the table.

Closes: #115
  • Loading branch information
nathonius committed Jun 16, 2024
1 parent 4ca024e commit 38091a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/inline/inline.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { PullResponse } from "src/github/response";
import { IssueStatus, getIssueStatus, getPRStatus } from "src/github/response";
import { getIssue, getPullRequest } from "../github/github";
import { setIssueIcon, setPRIcon, setPRMergeableIcon } from "src/icon";

import type { ParsedUrl } from "../github/url-parse";
import { parseUrl } from "../github/url-parse";
import { setIcon } from "obsidian";
import { setIssueIcon, setPRIcon, setPRMergeableIcon } from "src/icon";
import { PluginSettings } from "src/plugin";
import type { PullResponse } from "src/github/response";
import { RequestError } from "src/util";
import { parseUrl } from "../github/url-parse";
import { setIcon } from "obsidian";

interface TagConfig {
icon: HTMLSpanElement;
Expand All @@ -16,7 +16,7 @@ interface TagConfig {

export function createTag(href: string): HTMLAnchorElement {
const parsedUrl = parseUrl(href);
const container = createEl("a", { cls: "github-link-inline", href });
const container = createEl("a", { cls: "github-link-inline", href, attr: { target: "_blank" } });
const config: TagConfig = {
icon: createSpan({ cls: ["github-link-status-icon", "github-link-inline-icon"] }),
sections: [],
Expand Down
13 changes: 9 additions & 4 deletions src/query/column/base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { IssueSearchResponse } from "src/github/response";
import { parseUrl, repoAPIToBrowserUrl } from "src/github/url-parse";

import { DateFormat } from "src/util";
import type { IssueSearchResponse } from "src/github/response";

export interface ColumnGetter<T> {
header: string;
Expand Down Expand Up @@ -32,7 +33,7 @@ export const CommonIssuePRColumns: ColumnsMap<IssueSearchResponse["items"][numbe
header: "Number",
cell: (row, el) => {
el.classList.add("github-link-table-issue-number");
el.createEl("a", { text: `#${row.number}`, href: row.html_url });
el.createEl("a", { text: `#${row.number}`, href: row.html_url, attr: { target: "_blank" } });
},
},
repo: {
Expand All @@ -41,13 +42,17 @@ export const CommonIssuePRColumns: ColumnsMap<IssueSearchResponse["items"][numbe
el.classList.add("github-link-table-repo");
const url = repoAPIToBrowserUrl(row.repository_url);
const parsed = parseUrl(url);
el.createEl("a", { text: parsed.repo, href: url });
el.createEl("a", { text: parsed.repo, href: url, attr: { target: "_blank" } });
},
},
author: {
header: "Author",
cell: (row, el) => {
const anchor = el.createEl("a", { cls: "github-link-table-author" });
const anchor = el.createEl("a", {
cls: "github-link-table-author",
href: row.user?.html_url,
attr: { target: "_blank" },
});
if (row.user?.avatar_url) {
anchor.createEl("img", { cls: "github-link-table-avatar", attr: { src: row.user.avatar_url } });
}
Expand Down
1 change: 1 addition & 0 deletions src/query/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function renderTable<T extends { items: unknown[] } | unknown[]>(
cls: "github-link-table-refresh-external-link",
text: "View on GitHub",
href: externalLink,
attr: { target: "_blank" },
});
}
const refreshButton = refresh.createEl("button", {
Expand Down

0 comments on commit 38091a5

Please sign in to comment.