Skip to content

Commit 15dc70a

Browse files
committed
Show checksums on release management page
1 parent c9b5f95 commit 15dc70a

File tree

5 files changed

+193
-34
lines changed

5 files changed

+193
-34
lines changed

warehouse/static/js/warehouse/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,18 @@ docReady(formUtils.submitTriggers);
6565

6666
docReady(Statuspage);
6767

68-
// Copy handler for the pip command on package detail page
68+
// Copy handler for
69+
// - the pip command on package detail page
70+
// - the copy checksum on package detail page
71+
// - the copy checksum on release maintainers page
6972
docReady(() => {
7073
let setCopiedTooltip = (e) => {
7174
e.trigger.setAttribute("aria-label", "Copied!");
7275
e.clearSelection();
7376
};
7477

7578
new Clipboard(".-js-copy-pip-command").on("success", setCopiedTooltip);
76-
new Clipboard(".-js-copy-sha256-link").on("success", setCopiedTooltip);
79+
new Clipboard(".-js-copy-checksum").on("success", setCopiedTooltip);
7780

7881
// Get all elements with class "tooltipped" and bind to focousout and
7982
// mouseout events. Change the "aria-label" to "original-label" attribute
@@ -162,3 +165,14 @@ docReady(() => {
162165
}
163166
}
164167
});
168+
169+
// Copy handler for checksum modal on release management page
170+
171+
//docReady(() => {
172+
// let setCopiedText = (e) => {
173+
// e.trigger.innerHTML = "Copied";
174+
// e.clearSelection();
175+
// };
176+
//
177+
// new Clipboard(".-js-copy-checksum").on("success", setCopiedText);
178+
//});

warehouse/static/sass/blocks/_modal.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171

7272
&__title {
7373
font-size: 1.5rem;
74+
padding-right: 20px; // Avoid overlap with close button
7475
}
7576

7677
&__footer {
@@ -121,4 +122,10 @@
121122
margin: 0;
122123
}
123124
}
125+
126+
&--wide {
127+
.modal__content {
128+
width: 850px;
129+
}
130+
}
124131
}

warehouse/static/sass/blocks/_table.scss

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,87 @@
330330
}
331331
}
332332

333+
&--checksums {
334+
margin-top: $spacing-unit / 2;
335+
336+
.table__algorithm,
337+
.table__checksum {
338+
padding-right: 20px;
339+
}
340+
341+
td.table__algorithm {
342+
font-weight: 600;
343+
}
344+
345+
td.table__checksum {
346+
word-break: break-all;
347+
}
348+
349+
.table__copy {
350+
width: 75px;
351+
text-align: right;
352+
}
353+
354+
@media only screen and (max-width: $mobile) {
355+
margin-top: 0;
356+
357+
thead {
358+
display: none;
359+
}
360+
361+
tbody tr,
362+
tbody tr:nth-child(2n) {
363+
display: block;
364+
padding: 20px 0;
365+
border-bottom: 1px solid $base-grey;
366+
}
367+
368+
tbody tr:last-of-type {
369+
border-bottom: 0;
370+
}
371+
372+
.table__algorithm,
373+
.table__checksum,
374+
.table__copy {
375+
display: block;
376+
text-align: left;
377+
border-bottom: 0;
378+
padding: 4px 0;
379+
}
380+
381+
.table__copy {
382+
width: 100%;
383+
384+
.button {
385+
display: block;
386+
text-align: center;
387+
388+
// Change direction of the copy tooltip on mobile
389+
$tooltip-background-color: transparentize($black, 0.3) !default;
390+
391+
&::after {
392+
top: 100%;
393+
right: 50%;
394+
margin-top: 5px;
395+
margin-right: auto;
396+
bottom: auto;
397+
transform: translate(50%, 0);
398+
}
399+
400+
&::before {
401+
top: auto;
402+
left: auto;
403+
right: 50%;
404+
bottom: -5px;
405+
margin-right: -5px;
406+
border-color: transparent;
407+
border-bottom-color: $tooltip-background-color;
408+
}
409+
}
410+
}
411+
}
412+
}
413+
333414
&--collaborators {
334415
.table__user {
335416
padding-right: 20px;

warehouse/templates/manage/release.html

Lines changed: 83 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ <h2 class="heading-wsubtitle__heading">Release Version {{ release.version }}</h2
7070
<i class="fa fa-download" aria-hidden="true"></i>
7171
Download
7272
</a>
73-
<a href="{{ request.route_url('packaging.file', path=file.path) }}" class="dropdown__link -js-copy-sha256-link">
74-
<i class="fa fa-copy" aria-hidden="true"></i>
75-
Copy Checksum
73+
<a href="#copy-checksum-modal-{{ loop.index }}" class="dropdown__link">
74+
<i class="fa fa-hashtag" aria-hidden="true"></i>
75+
View Checksums
7676
</a>
7777
<a href="#delete-file-modal-{{ loop.index }}" class="dropdown__link">
7878
<i class="fa fa-trash" aria-hidden="true"></i>
@@ -141,33 +141,87 @@ <h3 class="modal__title">Delete Release {{ release.version }}?</h3>
141141
</div>
142142

143143
{% if files %}
144-
{% for file in files %}
145-
<div id="delete-file-modal-{{ loop.index }}" class="modal">
146-
{% set project_name = project.normalized_name %}
147-
<div class="modal__content" role="dialog">
148-
<form method="POST" class="modal__form" action="{{ request.current_route_path() }}">
149-
<input name="csrf_token" type="hidden" value="{{ request.session.get_csrf_token() }}">
150-
<input name="file_id" type="hidden" value="{{ file.id }}">
151-
<a href="#modal-close" title="Close" class="modal__close">
152-
<i class="fa fa-times" aria-hidden="true"></i>
153-
<span class="sr-only">close</span>
154-
</a>
155-
<div class="modal__body">
156-
<h3 class="modal__title">Delete {{ file.filename }}?</h3>
157-
<div class="callout-block callout-block--danger callout-block--bottom-margin no-top-margin">
158-
<p>Warning: This action cannot be undone!</p>
144+
{% for file in files %}
145+
<div id="delete-file-modal-{{ loop.index }}" class="modal">
146+
{% set project_name = project.normalized_name %}
147+
<div class="modal__content" role="dialog">
148+
<form method="POST" class="modal__form" action="{{ request.current_route_path() }}">
149+
<input name="csrf_token" type="hidden" value="{{ request.session.get_csrf_token() }}">
150+
<input name="file_id" type="hidden" value="{{ file.id }}">
151+
<a href="#modal-close" title="Close" class="modal__close">
152+
<i class="fa fa-times" aria-hidden="true"></i>
153+
<span class="sr-only">close</span>
154+
</a>
155+
<div class="modal__body">
156+
<h3 class="modal__title">Delete {{ file.filename }}?</h3>
157+
<div class="callout-block callout-block--danger callout-block--bottom-margin no-top-margin">
158+
<p>Warning: This action cannot be undone!</p>
159+
</div>
160+
<p>Confirm the project name to continue.</p>
161+
<label for="confirm_filename">File name</label>
162+
<input name="confirm_filename" type="text" placeholder="Confirm file name" autocomplete="off" autocorrect="off" autocapitalize="off">
159163
</div>
160-
<p>Confirm the project name to continue.</p>
161-
<label for="confirm_filename">File name</label>
162-
<input name="confirm_filename" type="text" placeholder="Confirm file name" autocomplete="off" autocorrect="off" autocapitalize="off">
163-
</div>
164-
<div class="modal__footer">
165-
<a href="#modal-close" class="button modal__action">Cancel</a>
166-
<button class="button button--primary modal__action" type="submit">Delete File</button>
167-
</div>
168-
</form>
164+
<div class="modal__footer">
165+
<a href="#modal-close" class="button modal__action">Cancel</a>
166+
<button class="button button--primary modal__action" type="submit">Delete File</button>
167+
</div>
168+
</form>
169+
</div>
169170
</div>
170-
</div>
171-
{% endfor %}
171+
172+
<div id="copy-checksum-modal-{{ loop.index }}" class="modal modal--wide">
173+
<div class="modal__content" role="dialog">
174+
<a href="#modal-close" title="Close" class="modal__close">
175+
<i class="fa fa-times" aria-hidden="true"></i>
176+
<span class="sr-only">close</span>
177+
</a>
178+
<div class="modal__body">
179+
<h3 class="modal__title">Checksums for {{ file.filename }}</h3>
180+
<table class="table table--light table--checksums">
181+
<thead>
182+
<tr>
183+
<th class="table__algorithm">Algorithm</th>
184+
<th class="table__checksum">Checksum</th>
185+
<th class="table__copy"></th>
186+
</tr>
187+
</thead>
188+
<tbody>
189+
<tr>
190+
<td class="table__algorithm">SHA256</td>
191+
<td class="table__checksum">{{ file.sha256_digest }}</td>
192+
<td class="table__copy">
193+
<a class="button button--primary -js-copy-checksum tooltipped tooltipped-w" aria-label="Copy to clipboard" data-original-label="Copy to clipboard" data-clipboard-text="{{ file.sha256_digest }}">
194+
Copy
195+
</a>
196+
</td>
197+
</tr>
198+
<tr>
199+
<td class="table__algorithm">MD5</td>
200+
<td class="table__checksum">{{ file.md5_digest }}</td>
201+
<td class="table__copy">
202+
<a class="button button--primary -js-copy-checksum tooltipped tooltipped-w" aria-label="Copy to clipboard" data-original-label="Copy to clipboard" data-clipboard-text="{{ file.md5_digest }}">
203+
Copy
204+
</a>
205+
</td>
206+
</tr>
207+
<tr>
208+
<td class="table__algorithm">BLAKE2-256</td>
209+
<td class="table__checksum">{{ file.blake2_256_digest }}</td>
210+
<td class="table__copy">
211+
<a class="button button--primary -js-copy-checksum tooltipped tooltipped-w" aria-label="Copy to clipboard" data-original-label="Copy to clipboard" data-clipboard-text="{{ file.blake2_256_digest }}">
212+
Copy
213+
</a>
214+
</td>
215+
</tr>
216+
</tbody>
217+
</table>
218+
</div>
219+
<div class="modal__footer">
220+
<a href="#modal-close" class="button button--primary modal__action">Ok</a>
221+
</div>
222+
</form>
223+
</div>
224+
</div>
225+
{% endfor %}
172226
{% endif %}
173227
{% endblock %}

warehouse/templates/packaging/detail.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,13 @@ <h2 class="page-title">Download Files</h2>
305305
<tbody>
306306
{% for file in files %}
307307
<tr>
308-
<td><a href="{{ request.route_url('packaging.file', path=file.path) }}">
309-
{{ file.filename }}</a>
308+
<td>
309+
<a href="{{ request.route_url('packaging.file', path=file.path) }}">
310+
{{ file.filename }}
311+
</a>
312+
<br>
310313
{% if file.size %} ({{ file.size|filesizeformat() }}){% endif %}
311-
<a class="-js-copy-sha256-link table__sha256-link tooltipped tooltipped-s" aria-label="Copy to clipboard" data-original-label="Copy to clipboard" data-clipboard-text="{{ file.sha256_digest }}">
314+
<a class="-js-copy-checksum table__sha256-link tooltipped tooltipped-s" aria-label="Copy to clipboard" data-original-label="Copy to clipboard" data-clipboard-text="{{ file.sha256_digest }}">
312315
<i class="fa fa-copy" aria-hidden="true"></i>
313316
<span class="sr-only">Copy SHA256 Checksum</span>
314317
SHA256

0 commit comments

Comments
 (0)