Skip to content

Commit

Permalink
Add details to the "what changed" when changing settings
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-richardson committed Nov 19, 2023
1 parent c9fac66 commit d028e7e
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,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 @@ -62,20 +63,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);
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);

//todo: figure out how to get these messages to show in the ui.
getOrCreateMessages(request).addMessage("featureUpdated", "Feature was updated.");
Expand Down

0 comments on commit d028e7e

Please sign in to comment.