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

Side by Side Diff: appengine/chromium_rietveld/new_static/components/cr-patchset-edit-dialog.html

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
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 <link rel="import" href="cr-butterbar.html"> 5 <link rel="import" href="cr-butterbar.html">
6 <link rel="import" href="cr-button.html"> 6 <link rel="import" href="cr-button.html">
7 <link rel="import" href="cr-dialog.html"> 7 <link rel="import" href="cr-dialog.html">
8 <link rel="import" href="cr-toolbar.html"> 8 <link rel="import" href="cr-toolbar.html">
9 9
10 <polymer-element name="cr-patchset-title-dialog" attributes="patchset"> 10 <polymer-element name="cr-patchset-edit-dialog" attributes="patchset">
11 <template> 11 <template>
12 <link rel="stylesheet" href="common.css"> 12 <link rel="stylesheet" href="common.css">
13 <link rel="stylesheet" href="forms.css"> 13 <link rel="stylesheet" href="forms.css">
14 14
15 <style>
16 img {
17 display: block;
18 }
19
20 .delete-action {
21 flex: 1;
22 display: flex;
23 justify-content: flex-end;
24 }
25
26 .delete-action > cr-button {
27 margin-right: 0;
28 }
29
30 .delete-confirmation {
31 display: flex;
32 align-items: center;
33 border: 1px solid #dcdcdc;
34 margin-left: -1px;
35 }
36
37 .delete-confirmation div {
38 display: flex;
39 align-items: center;
40 margin: 0 16px;
41 }
42
43 .delete-confirmation cr-button {
44 height: 20px;
45 }
46 </style>
47
15 <dialog is="cr-dialog" id="dialog" on-cancel="{{ cancel }}"> 48 <dialog is="cr-dialog" id="dialog" on-cancel="{{ cancel }}">
16 <cr-butterbar message="{{ butterbarMessage }}"></cr-butterbar> 49 <cr-butterbar message="{{ butterbarMessage }}"></cr-butterbar>
17 50
18 <h1>Edit patchset {{ patchset.sequence }}</h1> 51 <h1>Edit patchset {{ patchset.sequence }}</h1>
19 52
20 <fieldset class="form-fields" disabled?="{{ disabled }}"> 53 <fieldset class="form-fields" disabled?="{{ sending }}">
21 <div class="form-row"> 54 <div class="form-row">
22 <label class="form-label" for="title">Title</label> 55 <label class="form-label" for="title">Title</label>
23 <div class="form-field"> 56 <div class="form-field">
24 <input type="text" id="title" value="{{ title }}" autoco mplete="off"> 57 <input type="text" id="title" value="{{ title }}" autoco mplete="off">
25 </div> 58 </div>
26 </div> 59 </div>
27 </fieldset> 60 </fieldset>
28 61
29 <cr-toolbar> 62 <cr-toolbar>
30 <cr-button primary on-tap="{{ save }}">Save</cr-button> 63 <cr-button primary on-tap="{{ save }}">Save</cr-button>
31 <cr-button on-tap="{{ cancel }}">Cancel</cr-button> 64 <cr-button on-tap="{{ cancel }}">Cancel</cr-button>
65 <template if="{{ patchset.issue.patchsets.length > 1 }}">
66 <div class="delete-action">
67 <cr-button on-tap="{{ toggleDeleteAction }}" icon>
68 <img src="../images/delete_icon_36.png" height="25">
69 </cr-button>
70 <template if="{{ showDeleteAction }}">
71 <div class="delete-confirmation">
72 <div>Permanently delete this patch?</div>
73 <cr-button create on-tap="{{ deletePatchset }}"> Delete</cr-button>
74 <cr-button on-tap="{{ toggleDeleteAction }}">No< /cr-button>
75 </div>
76 </template>
77 </div>
78 </template>
32 </cr-toolbar> 79 </cr-toolbar>
33 </dialog> 80 </dialog>
34 </template> 81 </template>
35 <script> 82 <script>
36 Polymer("cr-patchset-title-dialog", { 83 Polymer("cr-patchset-edit-dialog", {
37 created: function() { 84 created: function() {
38 this.patchset = null; 85 this.patchset = null;
39 this.commit = true; 86 this.commit = true;
40 this.butterbarMessage = ""; 87 this.butterbarMessage = "";
41 this.sending = false; 88 this.sending = false;
42 this.title = ""; 89 this.title = "";
90 this.showDeleteAction = false;
91 },
92 toggleDeleteAction: function() {
93 this.showDeleteAction = !this.showDeleteAction;
94 },
95 deletePatchset: function() {
96 this.sending = true;
97 this.patchset.delete()
98 .then(this.deleteSuccess.bind(this))
99 .catch(this.displayError.bind(this));
100 },
101 deleteSuccess: function() {
102 this.fire("issue-refresh");
103 this.close();
43 }, 104 },
44 cancel: function(event) { 105 cancel: function(event) {
45 this.close(); 106 this.close();
46 }, 107 },
47 reset: function() { 108 reset: function() {
48 this.sending = false; 109 this.sending = false;
49 this.butterbarMessage = ""; 110 this.butterbarMessage = "";
50 this.commit = true; 111 this.commit = true;
51 this.title = this.patchset ? this.patchset.title : ""; 112 this.title = this.patchset ? this.patchset.title : "";
113 this.showDeleteAction = false;
52 }, 114 },
53 close: function() { 115 close: function() {
54 this.reset(); 116 this.reset();
55 this.$.dialog.close(); 117 this.$.dialog.close();
56 }, 118 },
57 save: function() { 119 save: function() {
58 this.sending = true; 120 this.sending = true;
59 this.butterbarMessage = "Saving..."; 121 this.butterbarMessage = "Saving...";
60 this.patchset.setTitle(this.title) 122 this.patchset.setTitle(this.title)
61 .then(this.saveSuccess.bind(this)) 123 .then(this.saveSuccess.bind(this))
62 .catch(this.saveFailure.bind(this)); 124 .catch(this.displayError.bind(this));
63 }, 125 },
64 saveSuccess: function() { 126 saveSuccess: function() {
65 this.close(); 127 this.close();
66 }, 128 },
67 saveFailure: function(error) { 129 displayError: function(error) {
68 // TODO(esprehn): We should show an better error message. 130 // TODO(esprehn): We should show an better error message.
69 this.sending = false; 131 this.sending = false;
70 this.butterbarMessage = "Error: " + error.message; 132 this.butterbarMessage = "Error: " + error.message;
71 }, 133 },
72 showModal: function() { 134 showModal: function() {
73 if (!this.patchset) 135 if (!this.patchset)
74 return; 136 return;
75 this.reset(); 137 this.reset();
76 this.$.dialog.showModal(); 138 this.$.dialog.showModal();
77 }, 139 },
78 }); 140 });
79 </script> 141 </script>
80 </polymer-element> 142 </polymer-element>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698