Skip to content

Commit

Permalink
Add details to the "what changed" when changing settings (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-richardson authored Nov 20, 2023
1 parent bdb91e6 commit 2213204
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import jetbrains.buildServer.controllers.SimpleView;
import jetbrains.buildServer.serverSide.*;
import jetbrains.buildServer.web.openapi.WebControllerManager;
import jetbrains.buildServer.web.util.SessionUser;
import org.apache.log4j.Logger;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -63,20 +64,24 @@ protected void doPost(@NotNull HttpServletRequest request, @NotNull HttpServletR
if (settingsRequest.mode.isPresent() && settingsRequest.mode.get().equals(SaveMode.RESET)) {
if (!feature.isEmpty()) {
project.removeFeature(feature.stream().findFirst().get().getId());
project.persist();
var cause = project.createConfigAction(SessionUser.getUser(request), String.format("OpenTelemetry settings for '%s' were reset to their inherited values.", project.getName()));
project.persist(cause);
ActionMessages.getOrCreateMessages(request).addMessage("featureReset", "Feature was reset to the inherited settings.");
} else {
LOG.warn(String.format("Got a request to reset settings, but the settings didn't exist on project %s?", project.getProjectId()));
LOG.warn(String.format("Got a request to reset settings, but the settings didn't exist on project '%s'?", project.getProjectId()));
}
} else {
ConfigAction cause;
if (feature.isEmpty()) {
project.addFeature(PLUGIN_NAME, settingsRequest.AsParams());
cause = project.createConfigAction(SessionUser.getUser(request), String.format("OpenTelemetry settings for added for '%s'", project.getName()));
} else {
var featureId = feature.stream().findFirst().get().getId();
project.updateFeature(featureId, PLUGIN_NAME, settingsRequest.AsParams());
cause = project.createConfigAction(SessionUser.getUser(request), String.format("OpenTelemetry settings for updated for '%s'", project.getName()));
}

project.persist();
project.persist(cause);

ActionMessages.getOrCreateMessages(request).addMessage("featureUpdated", "Feature was updated.");
}
Expand Down

0 comments on commit 2213204

Please sign in to comment.