Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: appengine/chromium_rietveld/new_static/model/patch_set.js

Issue 873593007: Add the ability to delete patchsets. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix |sending| Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/chromium_rietveld/new_static/images/delete_icon_36.png ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 "use strict"; 5 "use strict";
6 6
7 // https://codereview.chromium.org/api/148223004/70001/?comments=true 7 // https://codereview.chromium.org/api/148223004/70001/?comments=true
8 function PatchSet(issue, id, sequence) 8 function PatchSet(issue, id, sequence)
9 { 9 {
10 this.files = []; // Array<PatchFile> 10 this.files = []; // Array<PatchFile>
11 this.sourceFiles = []; // Array<PatchFile> 11 this.sourceFiles = []; // Array<PatchFile>
12 this.testFiles = []; // Array<PatchFile> 12 this.testFiles = []; // Array<PatchFile>
13 this.tryJobResults = []; // Array<tryJobResults> 13 this.tryJobResults = []; // Array<tryJobResults>
14 this.created = ""; // Date 14 this.created = ""; // Date
15 this.messageCount = 0; 15 this.messageCount = 0;
16 this.draftCount = 0; 16 this.draftCount = 0;
17 this.lastModified = ""; // Date 17 this.lastModified = ""; // Date
18 this.issue = issue || null; 18 this.issue = issue || null;
19 this.owner = null // User 19 this.owner = null // User
20 this.title = ""; 20 this.title = "";
21 this.id = id || 0; 21 this.id = id || 0;
22 this.sequence = sequence || 0; 22 this.sequence = sequence || 0;
23 this.commit = false; 23 this.commit = false;
24 this.mostRecent = false; 24 this.mostRecent = false;
25 this.active = false; 25 this.active = false;
26 } 26 }
27 27
28 PatchSet.DETAIL_URL = "/api/{1}/{2}/?comments=true" 28 PatchSet.DETAIL_URL = "/api/{1}/{2}/?comments=true";
29 PatchSet.REVERT_URL = "/api/{1}/{2}/revert"; 29 PatchSet.REVERT_URL = "/api/{1}/{2}/revert";
30 PatchSet.DELETE_URL = "/{1}/patchset/{2}/delete";
30 PatchSet.TITLE_URL = "/{1}/patchset/{2}/edit_patchset_title"; 31 PatchSet.TITLE_URL = "/{1}/patchset/{2}/edit_patchset_title";
31 32
32 PatchSet.prototype.getDetailUrl = function() 33 PatchSet.prototype.getDetailUrl = function()
33 { 34 {
34 return PatchSet.DETAIL_URL.assign( 35 return PatchSet.DETAIL_URL.assign(
35 encodeURIComponent(this.issue.id), 36 encodeURIComponent(this.issue.id),
36 encodeURIComponent(this.id)); 37 encodeURIComponent(this.id));
37 }; 38 };
38 39
39 PatchSet.prototype.getRevertUrl = function() 40 PatchSet.prototype.getRevertUrl = function()
40 { 41 {
41 return PatchSet.REVERT_URL.assign( 42 return PatchSet.REVERT_URL.assign(
42 encodeURIComponent(this.issue.id), 43 encodeURIComponent(this.issue.id),
43 encodeURIComponent(this.id)); 44 encodeURIComponent(this.id));
44 }; 45 };
45 46
46 PatchSet.prototype.getEditTitleUrl = function() 47 PatchSet.prototype.getEditTitleUrl = function()
47 { 48 {
48 return PatchSet.TITLE_URL.assign( 49 return PatchSet.TITLE_URL.assign(
49 encodeURIComponent(this.issue.id), 50 encodeURIComponent(this.issue.id),
50 encodeURIComponent(this.id)); 51 encodeURIComponent(this.id));
51 }; 52 };
52 53
54 PatchSet.prototype.getDeleteUrl = function()
55 {
56 return PatchSet.DELETE_URL.assign(
57 encodeURIComponent(this.issue.id),
58 encodeURIComponent(this.id));
59 };
60
53 PatchSet.prototype.loadDetails = function() 61 PatchSet.prototype.loadDetails = function()
54 { 62 {
55 var patchset = this; 63 var patchset = this;
56 return loadJSON(this.getDetailUrl()).then(function(data) { 64 return loadJSON(this.getDetailUrl()).then(function(data) {
57 patchset.parseData(data); 65 patchset.parseData(data);
58 return patchset; 66 return patchset;
59 }); 67 });
60 }; 68 };
61 69
62 PatchSet.prototype.revert = function(options) 70 PatchSet.prototype.revert = function(options)
(...skipping 24 matching lines...) Expand all
87 return sendFormData(patchset.getEditTitleUrl(), { 95 return sendFormData(patchset.getEditTitleUrl(), {
88 xsrf_token: user.xsrfToken, 96 xsrf_token: user.xsrfToken,
89 patchset_title: value, 97 patchset_title: value,
90 }); 98 });
91 }).then(function() { 99 }).then(function() {
92 patchset.title = value; 100 patchset.title = value;
93 return value; 101 return value;
94 }); 102 });
95 }; 103 };
96 104
105 PatchSet.prototype.delete = function()
106 {
107 var patchset = this;
108 return User.loadCurrentUser().then(function(user) {
109 return sendFormData(patchset.getDeleteUrl(), {
110 xsrf_token: user.xsrfToken,
111 });
112 });
113 };
114
97 PatchSet.prototype.parseData = function(data) 115 PatchSet.prototype.parseData = function(data)
98 { 116 {
99 var patchset = this; 117 var patchset = this;
100 118
101 if (!this.issue || data.issue != this.issue.id || data.patchset != this.id) { 119 if (!this.issue || data.issue != this.issue.id || data.patchset != this.id) {
102 throw new Error("Invalid patchset loaded " + data.issue + " != " + this. issue.id 120 throw new Error("Invalid patchset loaded " + data.issue + " != " + this. issue.id
103 + " or " + data.patchset + " != " + this.id); 121 + " or " + data.patchset + " != " + this.id);
104 } 122 }
105 123
106 this.owner = new User(data.owner); 124 this.owner = new User(data.owner);
(...skipping 24 matching lines...) Expand all
131 .map(function(builder) { 149 .map(function(builder) {
132 var jobSet = new TryJobResultSet(builder); 150 var jobSet = new TryJobResultSet(builder);
133 jobSet.results = tryResults[builder].map(function(resultData) { 151 jobSet.results = tryResults[builder].map(function(resultData) {
134 var result = new TryJobResult(); 152 var result = new TryJobResult();
135 result.parseData(resultData); 153 result.parseData(resultData);
136 return result; 154 return result;
137 }).reverse(); 155 }).reverse();
138 return jobSet; 156 return jobSet;
139 }); 157 });
140 }; 158 };
OLDNEW
« no previous file with comments | « appengine/chromium_rietveld/new_static/images/delete_icon_36.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698