-
Notifications
You must be signed in to change notification settings - Fork 602
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
Prototype admin console #6353
Closed
Closed
Prototype admin console #6353
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0a2cb03
models: add initial user model bits for defining admins
LawnGnome 7e45d98
WIP of initial wiring for admin
LawnGnome 1752bb5
Fix admin route.
LawnGnome 30f1462
WIP.
LawnGnome 1c09e9c
Minimal caddy setup.
LawnGnome d8c7360
Various admin template improvements.
LawnGnome 9db3203
Improve admin display and code layout.
LawnGnome 7edcc1a
More admin improvements.
LawnGnome 6a98a3d
Rough WIP pre-pagination.
LawnGnome 7b80677
Clean up Cargo.toml after rebase.
LawnGnome 988d0fc
Implement pagination.
LawnGnome File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
http://localhost:4200, http://127.0.0.1:4200 { | ||
@backend { | ||
path /api/* /admin/* /git/* | ||
} | ||
|
||
reverse_proxy @backend 127.0.0.1:8888 | ||
reverse_proxy 127.0.0.1:4201 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<span title='{{this.absolute}}'>{{this.human}}</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{{#if this.paginated}} | ||
<nav> | ||
<ul class="pagination"> | ||
{{#if this.previous}} | ||
<li class="page-item"> | ||
<a class="page-link" href="{{ this.previous }}"> | ||
<span>«</span> | ||
</a> | ||
</li> | ||
{{/if}} | ||
{{#each this.pages}} | ||
<li class="page-item"> | ||
<a class="page-link {{#if this.active}}active{{/if}}" href="{{ this.url }}"> | ||
<span>{{ this.number }}</span> | ||
</a> | ||
</li> | ||
{{/each}} | ||
{{#if this.next}} | ||
<li class="page-item"> | ||
<a class="page-link" href="{{ this.next }}"> | ||
<span>»</span> | ||
</a> | ||
</li> | ||
{{/if}} | ||
</ul> | ||
</nav> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<a href='/users/{{this.username}}'> | ||
{{#if this.avatar}} | ||
<img | ||
src='{{this.avatar}}' | ||
alt='{{this.username}}' | ||
aria-hidden='true' | ||
width='32' | ||
height='32' | ||
class='d-inline-block me-1' | ||
/> | ||
{{~/if~}} | ||
{{~this.username}} | ||
</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{{#*inline "body"}} | ||
<div class="d-flex align-items-end mt-3 mb-3"> | ||
<h1 class="me-auto">{{> title}}</h1> | ||
<form class="d-flex align-items-center" method="GET"> | ||
<input class="form-control" name="q" type="search" placeholder="crate name" spellcheck="false" value="{{this.q}}"> | ||
</form> | ||
</div> | ||
|
||
<table class="table align-middle"> | ||
<thead> | ||
<tr> | ||
<th>Crate</th> | ||
<th>Version</th> | ||
<th>Published</th> | ||
<th/> | ||
<tr> | ||
</thead> | ||
<tbody> | ||
{{#each this.versions}} | ||
<tr> | ||
<td> | ||
<div> | ||
<a href="/crates/{{this.name}}"> | ||
{{#if this.yanked}} | ||
<s>{{this.name}}</s> | ||
{{~else}} | ||
{{this.name}} | ||
{{/if~}} | ||
</a> | ||
{{#if this.yanked}}<i title="Yanked" class="bi bi-trash-fill"></i>{{/if}} | ||
</div> | ||
<div style="font-size: 80%"><a href="https://index.crates.io/{{crate-index-path this.name}}">View in sparse index</a></div> | ||
</td> | ||
<td>{{this.num}}</td> | ||
<td> | ||
<em>{{> components/datetime this.created_at}}</em> | ||
by | ||
{{> components/user this.publisher }} | ||
</td> | ||
<td class="text-end"> | ||
{{#if this.yanked}} | ||
<button type="button" class="btn btn-outline-primary unyank" data-unyank-name="{{this.name}}" data-unyank-version="{{this.num}}">Unyank</button> | ||
{{else}} | ||
<button type="button" class="btn btn-danger yank" data-yank-name="{{this.name}}" data-yank-version="{{this.num}}">Yank</button> | ||
{{/if}} | ||
</td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
|
||
{{> components/page this.page}} | ||
|
||
<script> | ||
window.addEventListener("DOMContentLoaded", () => { | ||
document.querySelectorAll("[data-yank-name]").forEach(btn => { | ||
const name = btn.getAttribute("data-yank-name"); | ||
const version = btn.getAttribute("data-yank-version"); | ||
|
||
btn.addEventListener("click", async event => { | ||
event.preventDefault(); | ||
if (confirm(`Are you sure you want to yank ${name} ${version}?`)) { | ||
btn.disabled = true; | ||
btn.innerHTML = "<div class='spinner-border' role='status'></div>"; | ||
|
||
try { | ||
const response = await fetch(`/api/v1/crates/${name}/${version}/yank`, { | ||
method: "DELETE", | ||
}); | ||
|
||
if (response.status >= 400){ | ||
throw `Unexpected status code: ${response.status}`; | ||
} | ||
|
||
// Errors can also be returned as a top level errors field. | ||
const data = await response.json(); | ||
if ("errors" in data) { | ||
throw data.errors.map(error => error.detail).join("; "); | ||
} | ||
|
||
window.location.reload(); | ||
} catch (e) { | ||
btn.innerHTML = `<span data-bs-toggle="tooltip"><i class="bi bi-exclamation-octagon-fill"></i> Error</span>`; | ||
const error = document.createElement("div"); | ||
error.innerText = e.toString(); | ||
btn.parentElement.appendChild(error); | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
</script> | ||
{{/inline}} | ||
|
||
{{#*inline "title"}}Crates{{/inline}} | ||
|
||
{{> page}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>{{> title}} :: crates.io</title> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" integrity="sha384-LrVLJJYk9OiJmjNDakUBU7kS9qCT8wk1j2OU7ncpsfB3QS37UPdkCuq3ZD1MugNY" crossorigin="anonymous"> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script> | ||
</head> | ||
<body> | ||
<nav class="navbar sticky-top navbar-expand-lg bg-dark" data-bs-theme="dark"> | ||
<div class="container-fluid"> | ||
<a class="navbar-brand" href="/admin/">crates.io admin</a> | ||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<div class="collapse navbar-collapse" id="navbarSupportedContent"> | ||
<ul class="navbar-nav me-auto mb-2 mb-lg-0"> | ||
<li class="nav-item"> | ||
<a class="nav-link" href="/admin/crates/">Recent uploads</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> | ||
<div class="container"> | ||
{{> body}} | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't taken a look at the whole PR, but please use GitHub IDs rather than usernames. Usernames can change and the old username can be taken over by another user.