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

Show GitHub issue milestones on the repo detail page #3706

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
34 changes: 34 additions & 0 deletions website/templates/projects/repo_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,40 @@ <h3 class="text-lg font-semibold text-gray-900 mb-4 flex items-center">
</div>
</div>
</section>
<!-- Milestone Section -->
<section class="bg-white rounded-xl shadow-lg border border-gray-200 overflow-hidden">
<div class="p-6">
<div class="flex items-center justify-between mb-6">
<h2 class="text-xl font-bold text-gray-900 flex items-center">
<svg class="w-6 h-6 text-red-500 mr-2"
fill="currentColor"
viewBox="0 0 20 20">
<path d="M10 2a6 6 0 00-6 6c0 2.42 1.14 4.08 2.29 5.12.38.33.71.6.95.93.22.29.35.61.37 1.01.02.41.34.74.75.74h4.68c.41 0 .73-.33.75-.74.02-.4.15-.72.37-1.01.24-.33.57-.6.95-.93C14.86 12.08 16 10.42 16 8a6 6 0 00-6-6zM7 17a1 1 0 000 2h6a1 1 0 000-2H7z" />
</svg>
Milestones
</h2>
</div>
<div class="space-y-6">
{% if milestones %}
{% for milestone in milestones %}
<div class="p-4 bg-gray-50 rounded-lg border border-gray-200">
<h3 class="text-lg font-semibold text-gray-900">{{ milestone.title }}</h3>
<p class="text-gray-600">{{ milestone.description }}</p>
<div class="flex items-center justify-between mt-4">
<div class="text-sm text-gray-500">Due: {{ milestone.due_on|date:"M d, Y" }}</div>
<div class="text-sm text-gray-500">{{ milestone.open_issues }} open / {{ milestone.closed_issues }} closed</div>
<div class="text-sm text-gray-500">
{{ milestone.closed_issues|divisibleby:milestone.open_issues|floatformat:2 }}% complete
</div>
</div>
</div>
{% endfor %}
{% else %}
<div class="text-gray-500 text-center py-4">No milestones available</div>
{% endif %}
</div>
</div>
</section>
</div>
<!-- Sidebar -->
<div class="space-y-8">
Expand Down
17 changes: 16 additions & 1 deletion website/views/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,24 @@ def post(self, request, *args, **kwargs):
# Handle other section refreshes...
return JsonResponse({"status": "error", "message": "Invalid section"}, status=400)

def fetch_github_milestones(self, repo):
"""
Fetch milestones from the GitHub API for the given repository.
"""
milestones_url = f"https://api.github.com/repos/{repo.repo_url.split('github.com/')[-1]}/milestones"
headers = {
"Accept": "application/vnd.github.v3+json",
"Authorization": f"token {settings.GITHUB_TOKEN}",
}
response = requests.get(milestones_url, headers=headers)
if response.status_code == 200:
return response.json()
return []

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
# ... existing context data ...
repo = self.get_object()
context["milestones"] = self.fetch_github_milestones(repo)
return context


Expand Down
Loading