Skip to content

Commit

Permalink
adding configuration for visibility of error stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Dec 19, 2023
1 parent a90be13 commit 4a53204
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 6 deletions.
19 changes: 17 additions & 2 deletions docs/admin-gui/admin-gui-config/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ It can be used to point the user to other services in your deployment.

* `*preferredDataLanguage*`: (since midPoint 3.6) Defines the data language that will use used by the user interface to display content of objects (XML, JSON or YAML)

* `*feedbackMessagesHook*`: Script hook configuration which can be used to modify operation results shown in GUI.
* `*feedbackMessagesHook*`: Configuration for modifying of feedback messages showed in GUI.

Since midPoint 4.4, the look and feel of GUI has been significantly changed. The aim was to provide better user experience and more configuration options. The old look is still available in midPoint for preview. It can be turned on in adminGuiConfiguration setting `useNewDesign` property to _false_. However, bugs and improvements will be fixed and implemented only for the new look and the old look will be completely removed in release 4.6. Old look is no more supported in 4.4. Please, migrate your configuration as soon as possible.

Expand Down Expand Up @@ -1851,8 +1851,10 @@ However, the authorizations and the admin GUI configuration work together in sev
E.g. end-users and administrators, both have the `basic` panel in the profile visible, but the attributes which are seen by end-users or administrators might differ.

== Feedback Messages Hook
Feedback messages hook configures operation result shown in GUI. Contains elements 'operationResultHook' and 'stackTraceVisibility'.

Feedback messages hook configuration allows operation result preprocessing before it's shown in GUI.
=== Operation Result Hook
'operationResultHook' attribute allows operation result preprocessing before it's shown in GUI.
Currently processed OperationResultType is set as "input" variable available in script.
Script should return OperationResultType.
If script returns null, then result is dropped and not shown on page.
Expand Down Expand Up @@ -1894,6 +1896,19 @@ To see changes made in this part of configuration, user needs to do logout/login
</adminGuiConfiguration>
----

=== Stack Trace Visibility
'stackTraceVisibility' attribute configure visibility for stack trace in feedback messages of GUI.
Relevant values are 'visible' and 'hidden'. Default value is 'visible'.

[source,xml]
----
<adminGuiConfiguration>
<feedbackMessagesHook>
<stackTraceVisibility>hidden</stackTraceVisibility>
</feedbackMessagesHook>
</adminGuiConfiguration>
----

== Customizing classpath scanning

Different panels and pages are searched via annotations on classes, e.g. `@PageDescriptor`, `@PanelInstance`, and others.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import java.util.Locale;

import com.evolveum.midpoint.gui.impl.util.DetailsPageUtil;

import com.evolveum.midpoint.xml.ns._public.common.common_3.FeedbackMessagesHookType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserInterfaceElementVisibilityType;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.AttributeModifier;
Expand Down Expand Up @@ -375,7 +379,7 @@ private void initError(WebMarkupContainer details) {
errorContainer.add(errorMessage);

Label errorStackTrace = new Label(ID_ERROR_STACK_TRACE, () -> getModelObject().getExceptionsStackTrace());
errorStackTrace.add(new VisibleBehaviour(() -> getModelObject().isShowError()));
errorStackTrace.add(new VisibleBehaviour(() -> getModelObject().isShowError() && isStackTraceVisible()));
errorContainer.add(errorStackTrace);

Label linkText = new Label("linkText", () -> {
Expand All @@ -395,9 +399,32 @@ public void onClick(AjaxRequestTarget target) {
}
};
errorStackTraceLink.add(linkText);
errorStackTraceLink.add(new VisibleBehaviour(() -> isStackTraceVisible()));
errorContainer.add(errorStackTraceLink);
}

private boolean isStackTraceVisible() {
UserInterfaceElementVisibilityType stackTraceVisibility = null;
FeedbackMessagesHookType feedbackConfig = getPageBase().getCompiledGuiProfile().getFeedbackMessagesHook();
if (feedbackConfig != null) {
stackTraceVisibility = feedbackConfig.getStackTraceVisibility();
}

if (stackTraceVisibility == null) {
stackTraceVisibility = UserInterfaceElementVisibilityType.VISIBLE;
}

if (stackTraceVisibility == UserInterfaceElementVisibilityType.VISIBLE) {
return true;
}

if (stackTraceVisibility == UserInterfaceElementVisibilityType.HIDDEN) {
return false;
}

return true;
}

private void showHideAll(final boolean show, AjaxRequestTarget target) {
getModelObject().setShowMoreAll(show);
getModelObject().setAlreadyShown(false); // hack to be able to expand/collapse OpResult after rendered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@
<xsd:annotation>
<xsd:documentation>
<p>
Specifies scripting hook which can modify operation results or messages
before they are shown in UI.
Specifies configuration that can modify messages before they are shown in UI.
</p>
</xsd:documentation>
<xsd:appinfo>
Expand Down Expand Up @@ -3568,11 +3567,26 @@
<xsd:sequence>
<xsd:element name="operationResultHook" type="tns:ExpressionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Specifies scripting hook which can modify operation results or messages
before they are shown in UI.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>FeedbackMessagesHookType.operationResultHook</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="stackTraceVisibility" type="tns:UserInterfaceElementVisibilityType" default="visible">
<xsd:annotation>
<xsd:documentation>
Visibility for stack trace in feedback messages of GUI.
Relevant values are 'visible' and 'hidden'. Default value is 'visible'.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>FeedbackMessagesHookType.stackTraceVisibility</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private void applyAdminGuiConfiguration(CompiledGuiProfile composite, AdminGuiCo
}

if (adminGuiConfiguration.getFeedbackMessagesHook() != null) {
composite.setFeedbackMessagesHook(adminGuiConfiguration.getFeedbackMessagesHook().clone());
mergeFeedbackMessagesHook(composite, adminGuiConfiguration.getFeedbackMessagesHook());
}

if (adminGuiConfiguration.getRoleManagement() != null &&
Expand Down Expand Up @@ -425,6 +425,19 @@ private void applyAdminGuiConfiguration(CompiledGuiProfile composite, AdminGuiCo
}
}

private void mergeFeedbackMessagesHook(CompiledGuiProfile composite, FeedbackMessagesHookType feedbackMessagesHook) {
if (composite.getFeedbackMessagesHook() == null) {
composite.setFeedbackMessagesHook(feedbackMessagesHook.clone());
return;
}
if (feedbackMessagesHook.getOperationResultHook() != null) {
composite.getFeedbackMessagesHook().setOperationResultHook(feedbackMessagesHook.getOperationResultHook());
}
if (feedbackMessagesHook.getStackTraceVisibility() != null) {
composite.getFeedbackMessagesHook().setStackTraceVisibility(feedbackMessagesHook.getStackTraceVisibility());
}
}

private HomePageType getHomePageByFocusType(List<HomePageType> homePageList, QName type) {
if (CollectionUtils.isEmpty(homePageList)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@
</object>
</authorization>
<adminGuiConfiguration>
<feedbackMessagesHook>
<stackTraceVisibility>hidden</stackTraceVisibility>
</feedbackMessagesHook>
<homePage id="34">
<type>UserType</type>
<widget id="35">
Expand Down

0 comments on commit 4a53204

Please sign in to comment.