Skip to content

Commit c41df7b

Browse files
committed
fixes #100: -edit assignee & reporter
1 parent 214a256 commit c41df7b

File tree

3 files changed

+11
-66
lines changed

3 files changed

+11
-66
lines changed

issue.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66

77
$key = $_GET['key'];
88

9-
if ( isset($_POST['summary'], $_POST['description'], $_POST['reporter'], $_POST['issuetype'], $_POST['priority'], $_POST['comment']) ) {
9+
if ( isset($_POST['summary'], $_POST['description'], $_POST['issuetype'], $_POST['priority'], $_POST['comment']) ) {
1010
$summary = trim($_POST['summary']);
1111
$description = trim($_POST['description']);
12-
$reporter = trim($_POST['reporter']);
1312
$issuetype = trim($_POST['issuetype']);
1413
$priority = trim($_POST['priority']);
1514
$comment = trim($_POST['comment']);
@@ -21,9 +20,6 @@
2120
'issuetype' => ['id' => $issuetype],
2221
'priority' => ['id' => $priority],
2322
);
24-
if ( $reporter ) {
25-
$fields['reporter'] = ['name' => $reporter];
26-
}
2723
if ( $comment ) {
2824
$update['comment'] = [['add' => ['body' => $comment]]];
2925
}
@@ -150,7 +146,6 @@
150146
// Description
151147
// Issue type
152148
// Priority
153-
// Reporter
154149

155150
$meta = jira_get('issue/' . $key . '/editmeta', array('expand' => 'projects.issuetypes.fields'), $error, $info);
156151

@@ -172,8 +167,6 @@
172167
echo ' <p>Issue type: <select name="issuetype">' . html_options($issuetypes, $fields->issuetype->id) . '</select></p>';
173168
echo ' <p>Priority: <select name="priority">' . html_options($priorities, @$fields->priority->id, '?') . '</select></p>';
174169

175-
echo ' <p>Reporter (' . $fields->reporter->name . '): <input name="reporter" /></p>';
176-
177170
echo ' <p>Add comment: <textarea name="comment" rows="4"></textarea><br><button type="button" data-preview="textarea[name=comment]">Preview</button></p>';
178171

179172
echo ' <p><input type="submit" /></p>';

tpl.issueheader.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
$actions = array();
88
$actions['Edit'] = 'issue.php?key=' . $key . '&edit';
9-
$actions['Assign'] = $actionPath . 'assign';
109
foreach ( $issue->transitions AS $transition ) {
1110
$actions[$transition->name] = $actionPath . $transition->id;
1211
}
@@ -49,7 +48,7 @@
4948
}
5049
$meta[] = html($fields->reporter->displayName) . ' (' . date(FORMAT_DATETIME, $issue->created) . ')';
5150
$meta[] = html_icon($fields->status, 'status') . ' <strong>' . html($fields->status->name) . $resolution . '</strong>';
52-
$meta[] = '<em>' . ( html(@$fields->assignee->displayName) ?: 'No assignee' ) . '</em>';
51+
$meta[] = '<em>' . html($fields->assignee->displayName ?? 'No assignee') . '</em>';
5352
if ( $fields->labels ) {
5453
$meta[] = html_labels($fields->labels);
5554
}

transition.php

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -14,57 +14,19 @@
1414
$resolution = trim(@$_POST['resolution']);
1515
$comment = trim($_POST['comment']);
1616

17-
$assigneetype = trim(@$_POST['assigneetype']);
18-
$assignee = trim(@$_POST['assignee']);
19-
if ( $assigneetype == 'unassign' ) {
20-
$assignee = null;
21-
}
22-
else if ( $assigneetype == 'me' ) {
23-
$assignee = JIRA_USER;
24-
}
25-
2617
$update = array();
2718

28-
// ASSIGN
29-
if ( $status == 'assign' ) {
30-
if ( $assignee === '' ) {
31-
echo "Must enter assignee username.";
32-
exit;
33-
}
34-
35-
// Add comment
36-
if ( $comment ) {
37-
$response = jira_post('issue/' . $key . '/comment', array('body' => $comment), $error, $info);
38-
}
39-
else {
40-
$error = false;
41-
}
42-
43-
// Only move forward if that worked, since this action requires 2 API calls =(
44-
if ( !$error ) {
45-
// Change assignee
46-
$update['name'] = $assignee === null ? null : explode('@', $assignee)[0];
47-
$response = jira_put('issue/' . $key . '/assignee', $update, $error, $info);
48-
}
19+
if ( $comment ) {
20+
$update['update']['comment'][0]['add']['body'] = $comment;
4921
}
50-
51-
// TRANSITION
52-
else {
53-
if ( $comment ) {
54-
$update['update']['comment'][0]['add']['body'] = $comment;
55-
}
56-
if ( $assignee !== '' ) {
57-
$update['fields']['assignee']['name'] = $assignee;
58-
}
59-
if ( $resolution ) {
60-
$update['fields']['resolution']['name'] = $resolution;
61-
}
62-
if ( $status ) {
63-
$update['transition']['id'] = $status;
64-
}
65-
66-
$response = jira_post('issue/' . $key . '/transitions', $update, $error, $info);
22+
if ( $resolution ) {
23+
$update['fields']['resolution']['name'] = $resolution;
6724
}
25+
if ( $status ) {
26+
$update['transition']['id'] = $status;
27+
}
28+
29+
$response = jira_post('issue/' . $key . '/transitions', $update, $error, $info);
6830

6931
if ( !$error ) {
7032
return do_redirect('issue', array('key' => $key));
@@ -84,7 +46,6 @@
8446

8547
$actions = $transitionsById = array();
8648
$actions[''] = '-- No change';
87-
$actions['assign'] = 'Assign';
8849
foreach ( $transitions->transitions AS $transition ) {
8950
$transitionsById[$transition->id] = $transition;
9051
$actions[$transition->id] = $transition->name;
@@ -112,14 +73,6 @@
11273
}
11374
echo '<p>Comment:<br><textarea name="comment" rows="8"></textarea><br><button type="button" data-preview="textarea[name=comment]">Preview</button></p>';
11475

115-
if ( $action == 'assign' || isset($transitionsById[$action]->fields->assignee) ) {
116-
echo '<p>Change assignee?<br />';
117-
echo '<input type="radio" name="assigneetype" value="unassign" /> Unassign<br />';
118-
echo '<input type="radio" name="assigneetype" value="me" /> Assign to me<br />';
119-
echo '<input type="radio" name="assigneetype" value="other" checked /> No change, or assign to: <input name="assignee" style="width: 7em" placeholder="username" />';
120-
echo '</p>';
121-
}
122-
12376
echo '<p><input type="submit" /></p>';
12477
echo '</form>';
12578
echo '</div>';

0 commit comments

Comments
 (0)