Skip to content

Commit c1d623d

Browse files
committed
Adds yank button to the web UI (initial)
1 parent 44773ef commit c1d623d

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

app/controllers/crate/version.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,8 @@ export default Controller.extend({
152152
loadDocsBuilds: task(function* () {
153153
return yield ajax(`https://docs.rs/crate/${this.crate.name}/${this.currentVersion.num}/builds.json`);
154154
}),
155+
156+
yankVersionTask: task(function* (version) {
157+
return version.yank.perform();
158+
}),
155159
});

app/models/version.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,14 @@ export default class Version extends Model {
6060
}
6161
}).keepLatest())
6262
loadReadmeTask;
63+
64+
@(task(function* () {
65+
let response = yield fetch(`/api/v1/crates/${this.crate.id}/${this.num}/yank`, { method: 'DELETE' });
66+
if (!response.ok) {
67+
throw new Error(`Yank request for ${this.crateName} v${this.num} failed`);
68+
}
69+
70+
return yield response.text();
71+
}).keepLatest())
72+
yank;
6373
}

app/templates/crate/version.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@
171171
{{#if version.yanked}}
172172
<span local-class='yanked'>yanked</span>
173173
{{/if}}
174+
{{#if isOwner}}
175+
<button type="button" local-class="remove-button" {{on "click" (perform this.yankVersionTask version)}}>Yank</button>
176+
{{/if}}
174177
</li>
175178
{{/each}}
176179
</ul>

0 commit comments

Comments
 (0)