Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear Story Points (Jira Server & Azure Dev Ops) #478

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,14 @@ public void updateIssue(String tokenIdentifier, UserStory story) {
if (story.getEstimation() != null) {
try {
Map<String, Object> updateEstimation = new HashMap<>();
updateEstimation.put("op", "replace");
updateEstimation.put("path", fieldPrefix + API_FIELD_ESTIMATION);
updateEstimation.put("value", Double.parseDouble(story.getEstimation()));
if (story.getEstimation().equals("?")) {
updateEstimation.put("op", "remove");
updateEstimation.put("path", fieldPrefix + API_FIELD_ESTIMATION);
} else {
updateEstimation.put("op", "replace");
updateEstimation.put("path", fieldPrefix + API_FIELD_ESTIMATION);
updateEstimation.put("value", Double.parseDouble(story.getEstimation()));
}
content.add(updateEstimation);
} catch (NumberFormatException e) {
LOGGER.error("Failed to parse estimation into double!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
package io.diveni.backend.service.projectmanagementproviders.jiraserver;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.api.client.http.*;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.api.client.auth.oauth.OAuthAuthorizeTemporaryTokenUrl;
import com.google.api.client.auth.oauth.OAuthParameters;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpContent;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.http.json.JsonHttpContent;
import com.google.api.client.json.gson.GsonFactory;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.diveni.backend.Utils;
import io.diveni.backend.model.JiraRequestToken;
import io.diveni.backend.model.Project;
Expand Down Expand Up @@ -250,7 +250,11 @@ public void updateIssue(String tokenIdentifier, UserStory story) {
fields.put("description", story.getDescription());
if (story.getEstimation() != null) {
try {
fields.put(ESTIMATION_FIELD, Double.parseDouble(story.getEstimation()));
if (story.getEstimation().equals("?")) {
fields.put(ESTIMATION_FIELD, null);
} else {
fields.put(ESTIMATION_FIELD, Double.parseDouble(story.getEstimation()));
}
} catch (NumberFormatException e) {
LOGGER.error("Failed to parse estimation into double!");
throw new ResponseStatusException(
Expand All @@ -259,6 +263,14 @@ public void updateIssue(String tokenIdentifier, UserStory story) {
}
content.put("fields", fields);
try {

GsonBuilder builder = new GsonBuilder();
builder.serializeNulls();
Gson gson = builder.create();
HttpContent httpContent =
new ByteArrayContent(
"application/json", gson.toJson(content).getBytes(StandardCharsets.UTF_8));

JiraOAuthClient jiraOAuthClient = new JiraOAuthClient(JIRA_HOME);
OAuthParameters parameters =
jiraOAuthClient.getParameters(
Expand All @@ -268,7 +280,7 @@ public void updateIssue(String tokenIdentifier, UserStory story) {
parameters,
new GenericUrl(getJiraUrl() + "/issue/" + story.getId()),
"PUT",
new JsonHttpContent(GsonFactory.getDefaultInstance(), content));
httpContent);

LOGGER.debug("<-- updateIssue() {}", response.parseAsString());
} catch (Exception e) {
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/components/UserStoryDescriptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
:text="(userStories[idx].estimation ? userStories[idx].estimation : '?') + ' '"
>
<b-dropdown-item
v-for="num in filteredCardSet"
v-for="num in cardSet"
:key="num"
:disabled="!editDescription"
:value="num"
Expand Down Expand Up @@ -103,11 +103,6 @@ export default defineComponent({
}>,
};
},
computed: {
filteredCardSet(): Array<unknown> {
return this.cardSet.filter((card) => card !== "?");
},
},
watch: {
initialStories() {
this.userStories = this.initialStories as Array<{
Expand Down
13 changes: 1 addition & 12 deletions frontend/src/views/SessionPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ export default defineComponent({
},
},
async created() {
this.copyPropsToData();
this.store.clearStoreWithoutUserStories();
if (!this.sessionID || !this.adminID) {
//check for cookie
Expand All @@ -477,6 +476,7 @@ export default defineComponent({
}
if (this.voteSetJson) {
this.voteSet = JSON.parse(this.voteSetJson);
this.voteSet = ["?"].concat(this.voteSet);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to concat the '?' to our voteset here, or would it be better to directly set the '?' as an activeValue for the allCardSetsWithJiraMode in the CardSetComponent.vue ?

}
if (this.sessionState === Constants.memberUpdateCommandStartVoting) {
this.planningStart = true;
Expand Down Expand Up @@ -527,17 +527,6 @@ export default defineComponent({
}
}
},
copyPropsToData() {
// if (this.adminID) {
// this.session_adminID = this.adminID;
// this.session_sessionID = this.sessionID;
// this.session_sessionState = this.sessionState;
// this.session_timerSecondsString = this.timerSecondsString;
// this.session_voteSetJson = this.voteSetJson;
// this.session_userStoryMode = this.userStoryMode;
// this.session_hostVoting = String(this.hostVoting).toLowerCase() === "true";
// }
},
assignSessionToData(session) {
if (Object.keys(session).length !== 0) {
this.adminID = session.adminID;
Expand Down
Loading