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

Add details to the "what changed" when changing settings #212

Merged
merged 2 commits into from
Nov 20, 2023
Merged
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 @@ -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