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
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
"shortcut": "c",
"command": "export IS_SANDBOX=1 && claude --dangerously-skip-permissions",
"useVsCodeApi": false
},
{
"name": "Rebuild",
"color": "orange",
"command": "just rebuild",
"useVsCodeApi": false
}
],
"quickCommandButtons.refreshButton": {
Expand Down
20 changes: 0 additions & 20 deletions public/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,3 @@
color: white;
vertical-align: middle;
}

.status-backlog {
background-color: #6e7781;
}

.status-ready {
background-color: #0969da;
}

.status-in-progress {
background-color: #bf8700;
}

.status-in-review {
background-color: #8250df;
}

.status-done {
background-color: #1a7f37;
}
13 changes: 3 additions & 10 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@
pat: string;
};

type ProjectStatus =
| "Backlog"
| "Ready"
| "In progress"
| "In review"
| "Done";

type IssueStatus = {
number: number;
status: ProjectStatus | null;
status: string | null;
};

type GraphQLResponse = {
Expand Down Expand Up @@ -96,7 +89,7 @@
};

const buildIssueStatusMap = (issues: IssueNode[]) => {
const issueStatusMap = new Map<number, ProjectStatus>();
const issueStatusMap = new Map<number, string>();

issues.forEach((issue) => {
if (!issue.number || !issue.projectItems.nodes.length) return;
Expand All @@ -107,7 +100,7 @@
);

if (statusField?.name) {
issueStatusMap.set(issue.number, statusField.name as ProjectStatus);
issueStatusMap.set(issue.number, statusField.name);
}
});

Expand Down
38 changes: 25 additions & 13 deletions src/content.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
(() => {
type ProjectStatus =
| "Backlog"
| "Ready"
| "In progress"
| "In review"
| "Done";

type IssueStatus = {
number: number;
status: ProjectStatus | null;
status: string | null;
};

const GITHUB_ISSUES_URL_PATTERN =
/https:\/\/github\.com\/[^/]+\/[^/]+\/issues/;
const BADGE_CLASS = "project-status-badge";

const STATUS_COLORS = [
"#0969da", // blue
"#1a7f37", // green
"#bf8700", // yellow
"#8250df", // purple
"#cf222e", // red
"#fb8500", // orange
"#0550ae", // dark blue
"#116329", // dark green
"#6e7781", // gray
];

const getStatusColor = (status: string): string => {
let hash = 0;
for (let i = 0; i < status.length; i++) {
hash = (hash << 5) - hash + status.charCodeAt(i);
hash = hash & hash;
}
return STATUS_COLORS[Math.abs(hash) % STATUS_COLORS.length];
};
Comment thread
kubrickcode marked this conversation as resolved.

const getIssueNumbers = (): number[] => {
const issueElements = document.querySelectorAll(
'[data-testid="issue-pr-title-link"]'
Expand Down Expand Up @@ -43,7 +57,7 @@
return numbers;
};

const addStatusBadge = (issueNumber: number, status: ProjectStatus) => {
const addStatusBadge = (issueNumber: number, status: string) => {
const issueLinks = document.querySelectorAll(
'[data-testid="issue-pr-title-link"]'
);
Expand All @@ -68,11 +82,9 @@
}

const badge = document.createElement("span");
badge.className = `${BADGE_CLASS} status-${status
.toLowerCase()
.replace(/\s+/g, "-")}`;
badge.className = BADGE_CLASS;
badge.textContent = status;
badge.style.marginLeft = "8px";
badge.style.backgroundColor = getStatusColor(status);

parent.appendChild(badge);
console.log(
Expand Down