--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.issue;
+
+import org.sonar.api.ServerComponent;
+import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.internal.DefaultIssue;
+import org.sonar.core.issue.workflow.IssueWorkflow;
+import org.sonar.server.user.UserSession;
+
+import java.util.List;
+import java.util.Map;
+
+public class TransitionAction extends Action implements ServerComponent {
+
+ public static final String PLAN_ACTION_KEY = "transition";
+
+ private final IssueWorkflow workflow;
+
+ public TransitionAction(IssueWorkflow workflow) {
+ super(PLAN_ACTION_KEY);
+ this.workflow = workflow;
+ }
+
+ @Override
+ public boolean verify(Map<String, Object> properties, List<Issue> issues, UserSession userSession) {
+ return true;
+ }
+
+ @Override
+ public boolean execute(Map<String, Object> properties, Context context) {
+ return workflow.doTransition((DefaultIssue) context.issue(), transition(properties), context.issueChangeContext());
+ }
+
+ private String transition(Map<String, Object> properties) {
+ return (String) properties.get("transition");
+ }
+
+}
\ No newline at end of file
servicesContainer.addSingleton(PlanAction.class);
servicesContainer.addSingleton(SetSeverityAction.class);
servicesContainer.addSingleton(CommentAction.class);
+ servicesContainer.addSingleton(TransitionAction.class);
// rules
servicesContainer.addSingleton(RubyRuleService.class);
<a href='#' onclick="return issueForm('assign', this)" class="link-action"><%= message('assigned_to') -%></a> <%= h @issue_results.user(issue.assignee).name -%>
<% else %>
<a href='#' onclick="return issueForm('assign', this)" class="link-action"><%= message('issue.assign.formlink') -%></a>
- <% if issue.assignee!=current_user.login %>
+ <% if issue.assignee != current_user.login %>
[<a href="#" onclick="return assignIssueToMe(this)" class="link-action"><%= message('issue.assign.to_me') -%></a>]
<% end %>
<% end %>
</span>
- <% end %>
-
- <% unless issue.resolution %>
<img src="<%= ApplicationController.root_context -%>/images/sep12.png"/>
<span class="spacer-right">
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.issue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.issue.Issue;
+import org.sonar.api.issue.internal.DefaultIssue;
+import org.sonar.api.issue.internal.IssueChangeContext;
+import org.sonar.core.issue.workflow.IssueWorkflow;
+
+import java.util.Map;
+
+import static com.google.common.collect.Maps.newHashMap;
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.*;
+
+public class TransitionActionTest {
+
+ private TransitionAction action;
+
+ private IssueWorkflow workflow = mock(IssueWorkflow.class);
+
+ @Before
+ public void before() {
+ action = new TransitionAction(workflow);
+ }
+
+ @Test
+ public void should_execute() {
+ String transition = "reopen";
+ Map<String, Object> properties = newHashMap();
+ properties.put("transition", transition);
+ DefaultIssue issue = mock(DefaultIssue.class);
+
+ Action.Context context = mock(Action.Context.class);
+ when(context.issue()).thenReturn(issue);
+
+ action.execute(properties, context);
+ verify(workflow).doTransition(eq(issue), eq(transition), any(IssueChangeContext.class));
+ }
+
+ @Test
+ public void should_support_all_issues() {
+ assertThat(action.supports(new DefaultIssue().setResolution(null))).isTrue();
+ assertThat(action.supports(new DefaultIssue().setResolution(Issue.RESOLUTION_FIXED))).isTrue();
+ }
+
+}