Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 21, 2022
2 parents f465e91 + 1e1666a commit 4c8bf5d
Show file tree
Hide file tree
Showing 88 changed files with 875 additions and 687 deletions.
6 changes: 6 additions & 0 deletions gui/admin-gui/src/frontend/scss/_admin-lte-overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@
color: darken($button-default-color, 10%);
}
}

// this is a fix for card widget with tool buttons which is inside of tab panel
.card.card-outline-tabs .card-tools {
margin: 0;
margin-right: -0.625rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright (c) 2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.api;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;

/**
* Created by Viliam Repan (lazyman).
*/
public class AdminLTESkin {
private static final Map<String, String> ORIGINAL_SKINS;

static {
Map<String, String> map = new HashMap<>();
map.put("skin-blue", "blue");
map.put("skin-blue-light", "lightblue");
map.put("skin-yellow", "yellow");
map.put("skin-yellow-light", "yellow");
map.put("skin-green", "green");
map.put("skin-green-light", "green");
map.put("skin-purple", "purple");
map.put("skin-purple-light", "purple");
map.put("skin-red", "red");
map.put("skin-red-light", "red");
map.put("skin-black", "black");
map.put("skin-black-light", "black");

ORIGINAL_SKINS = Collections.unmodifiableMap(map);
}

public static final AdminLTESkin SKIN_DEFAULT = new AdminLTESkin("lightblue", "skin-blue-light");

private String cssColorClass;

private String originalSkinName;

private AdminLTESkin(String cssColorClass, String originalSkinName) {
this.cssColorClass = cssColorClass;
this.originalSkinName = originalSkinName;
}

public String getOriginalSkinName() {
return "skin-" + originalSkinName;
}

public String getNavbarCss() {
return "navbar-" + cssColorClass;
}

public String getSidebarCss(boolean dark) {
return dark ? getSidebarDarkCss() : getSidebarLightCss();
}

public String getSidebarLightCss() {
if ("black".equals(cssColorClass)) {
return getSidebarDarkCss();
}

return "sidebar-light-" + cssColorClass;
}

public String getSidebarDarkCss() {
return "sidebar-dark-" + cssColorClass;
}

public String getAccentCss() {
return "accent-" + cssColorClass;
}

public String getBackgroundCss() {
return "bg-" + cssColorClass;
}

public static @NotNull AdminLTESkin create(String originalSkin) {
if (StringUtils.isEmpty(originalSkin)) {
return SKIN_DEFAULT;
}

String css = ORIGINAL_SKINS.get(originalSkin);
if (StringUtils.isEmpty(css)) {
css = originalSkin;
}

return new AdminLTESkin(css, originalSkin);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<h2 class="mb-3" wicket:id="text"/>
<h5 class="text-secondary mb-5" wicket:id="subText"/>
<div class="col-12">
<div wicket:id="feedbackContainer" class="feedbackContainer">
<div wicket:id="feedback" class="messagePanel"/>
</div>
<wicket:child/>
</div>
<div class="d-flex gap-3 justify-content-center" wicket:id="buttonsContainer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.evolveum.midpoint.gui.impl.page.admin.resource.ResourceDetailsModel;
import com.evolveum.midpoint.web.component.AjaxIconButton;
import com.evolveum.midpoint.web.component.breadcrumbs.Breadcrumb;
import com.evolveum.midpoint.web.component.message.FeedbackAlerts;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.page.admin.resources.PageResources;

Expand All @@ -36,6 +37,8 @@ public abstract class AbstractWizardBasicPanel extends BasePanel {
private static final String ID_BC_NAME = "bcName";
private static final String ID_TEXT = "text";
private static final String ID_SUBTEXT = "subText";
private static final String ID_FEEDBACK_CONTAINER = "feedbackContainer";
private static final String ID_FEEDBACK = "feedback";
private static final String ID_BUTTONS = "buttons";
private static final String ID_BUTTONS_CONTAINER = "buttonsContainer";

Expand Down Expand Up @@ -112,6 +115,16 @@ protected void populateItem(ListItem<Breadcrumb> item) {
secondaryText.add(new VisibleBehaviour(() -> getSubTextModel().getObject() != null));
add(secondaryText);

WebMarkupContainer feedbackContainer = new WebMarkupContainer(ID_FEEDBACK_CONTAINER);
feedbackContainer.setOutputMarkupId(true);
feedbackContainer.setOutputMarkupPlaceholderTag(true);
add(feedbackContainer);

FeedbackAlerts feedbackList = new FeedbackAlerts(ID_FEEDBACK);
feedbackList.setOutputMarkupId(true);
feedbackList.setOutputMarkupPlaceholderTag(true);
feedbackContainer.add(feedbackList);

WebMarkupContainer buttonsContainer = new WebMarkupContainer(ID_BUTTONS_CONTAINER);
buttonsContainer.setOutputMarkupId(true);
add(buttonsContainer);
Expand Down Expand Up @@ -166,4 +179,8 @@ protected IModel<String> getSubTextModel(){
protected IModel<String> getTextModel(){
return getPageBase().createStringResource(getClass().getSimpleName() + ".subText");
}

protected WebMarkupContainer getFeedback() {
return (WebMarkupContainer) get(ID_FEEDBACK_CONTAINER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ public abstract class PageAdminLTE extends WebPage implements ModelServiceLocato
private static final String ID_SUBSCRIPTION_MESSAGE = "subscriptionMessage";
private static final String ID_COPYRIGHT_MESSAGE = "copyrightMessage";

private static final String CLASS_DEFAULT_SKIN = "skin-blue-light";

public static final String ID_FEEDBACK_CONTAINER = "feedbackContainer";
private static final String ID_FEEDBACK = "feedback";

Expand Down Expand Up @@ -269,8 +267,7 @@ protected void onInitialize() {
private void initLayout() {
TransparentWebMarkupContainer body = new TransparentWebMarkupContainer(ID_BODY);
body.add(AttributeAppender.append("class", () -> getSessionStorage().getMode() == SessionStorage.Mode.DARK ? "dark-mode" : null));
// body.add(new AttributeAppender("class", "hold-transition ", " "));
// body.add(new AttributeAppender("class", "custom-hold-transition ", " "));
// body.add(AttributeAppender.append("class", () -> WebComponentUtil.getMidPointSkin().getAccentCss()));

addDefaultBodyStyle(body);
add(body);
Expand All @@ -284,20 +281,7 @@ private void initLayout() {
}

protected void addDefaultBodyStyle(TransparentWebMarkupContainer body) {
body.add(AttributeAppender.append("class", new IModel<String>() {

private static final long serialVersionUID = 1L;

@Override
public String getObject() {
DeploymentInformationType info = MidPointApplication.get().getDeploymentInfo();
if (info == null || StringUtils.isEmpty(info.getSkin())) {
return CLASS_DEFAULT_SKIN;
}

return info.getSkin();
}
}));
}

private void addFooter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<wicket:extend>
<div wicket:id="mainPopup"/>
<div class="wrapper">
<nav wicket:id="mainHeader" class="main-header navbar navbar-expand navbar-dark navbar-lightblue border-bottom-0">
<nav wicket:id="mainHeader" class="main-header navbar navbar-expand navbar-dark border-bottom-0">
<ul class="navbar-nav">
<li class="nav-item">
<a wicket:id="menuToggle" class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
Expand Down Expand Up @@ -81,9 +81,9 @@
<aside class="main-sidebar" wicket:id="sidebarMenu"/>
</wicket:enclosure>

<div class="content-wrapper" style="min-height: 916px;">
<div class="content-wrapper" style="min-height: 916px; padding: 15px 0">
<section class="content">
<div class="container-fluid" style="margin-top: 0.75rem;">
<div class="container-fluid">
<div wicket:id="feedbackContainer" class="feedbackContainer">
<div wicket:id="feedback" class="messagePanel"/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@
import com.evolveum.midpoint.common.validator.EventHandler;
import com.evolveum.midpoint.common.validator.EventResult;
import com.evolveum.midpoint.common.validator.LegacyValidator;
import com.evolveum.midpoint.gui.api.AdminLTESkin;
import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.component.result.MessagePanel;
import com.evolveum.midpoint.gui.api.component.wizard.WizardModel;
import com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.gui.impl.component.menu.LeftMenuPanel;
import com.evolveum.midpoint.gui.impl.page.self.PageRequestAccess;
Expand Down Expand Up @@ -355,6 +357,7 @@ public void onClick(AjaxRequestTarget target) {

private void initLayout() {
WebMarkupContainer mainHeader = new WebMarkupContainer(ID_MAIN_HEADER);
mainHeader.add(AttributeAppender.append("class", () -> WebComponentUtil.getMidPointSkin().getNavbarCss()));
mainHeader.setOutputMarkupId(true);
add(mainHeader);

Expand Down Expand Up @@ -386,7 +389,12 @@ public String getObject() {

LeftMenuPanel sidebarMenu = new LeftMenuPanel(ID_SIDEBAR_MENU);
sidebarMenu.add(AttributeAppender.append("class",
() -> getSessionStorage().getMode() == SessionStorage.Mode.DARK ? "sidebar-dark-lightblue" : "sidebar-light-lightblue"));
() -> {
boolean dark = getSessionStorage().getMode() == SessionStorage.Mode.DARK;

AdminLTESkin skin = WebComponentUtil.getMidPointSkin();
return skin.getSidebarCss(dark);
}));
sidebarMenu.add(createUserStatusBehaviour());
add(sidebarMenu);

Expand All @@ -407,24 +415,13 @@ public String getObject() {
}

public static AttributeAppender createHeaderColorStyleModel(boolean checkSkinUsage) {
return new AttributeAppender("style", new IModel<String>() {

private static final long serialVersionUID = 1L;

@Override
public String getObject() {
DeploymentInformationType info = MidPointApplication.get().getDeploymentInfo();
if (info == null || StringUtils.isEmpty(info.getHeaderColor())) {
return null;
}

// TODO fix for MID-4897
// if (checkSkinUsage && StringUtils.isEmpty(info.getSkin())) {
// return null;
// }

return "background-color: " + info.getHeaderColor() + " !important;";
return AttributeAppender.append("style", () -> {
DeploymentInformationType info = MidPointApplication.get().getDeploymentInfo();
if (info == null || StringUtils.isEmpty(info.getHeaderColor())) {
return null;
}

return "background-color: " + info.getHeaderColor() + " !important;";
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import com.evolveum.midpoint.authentication.api.authorization.PageDescriptor;
import com.evolveum.midpoint.authentication.api.util.AuthUtil;
import com.evolveum.midpoint.common.LocalizationService;
import com.evolveum.midpoint.gui.api.AdminLTESkin;
import com.evolveum.midpoint.gui.api.GuiStyleConstants;
import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.MainObjectListPanel;
Expand Down Expand Up @@ -360,7 +361,7 @@ private static String emptyIfNull(String s) {
}

public static String getReferencedObjectDisplayNameAndName(Referencable ref, boolean loadObject, PageBase pageBase) {
if (ref == null) {
if (ref == null || ref.asReferenceValue().isEmpty()) {
return "";
}
if (ref.getOid() != null && ref.asReferenceValue().getObject() == null && !loadObject) {
Expand Down Expand Up @@ -5202,7 +5203,7 @@ public static List<DisplayableValue<?>> getAllowedValues(ExpressionType expressi
} catch (Exception e) {
LOGGER.error("Couldn't execute expression " + expression, e);
if (modelServiceLocator instanceof PageBase) {
((PageBase)modelServiceLocator).error(PageBase.createStringResourceStatic("FilterSearchItem.message.error.evaluateAllowedValuesExpression", expression).getString());
((PageBase) modelServiceLocator).error(PageBase.createStringResourceStatic("FilterSearchItem.message.error.evaluateAllowedValuesExpression", expression).getString());
}
return allowedValues;
}
Expand All @@ -5213,7 +5214,7 @@ public static List<DisplayableValue<?>> getAllowedValues(ExpressionType expressi
if (!(value instanceof Set)) {
LOGGER.error("Exception return unexpected type, expected Set<PPV<DisplayableValue>>, but was " + (value == null ? null : value.getClass()));
if (modelServiceLocator instanceof PageBase) {
((PageBase)modelServiceLocator).error(PageBase.createStringResourceStatic("FilterSearchItem.message.error.wrongType", expression).getString());
((PageBase) modelServiceLocator).error(PageBase.createStringResourceStatic("FilterSearchItem.message.error.wrongType", expression).getString());
}
return allowedValues;
}
Expand All @@ -5223,7 +5224,7 @@ public static List<DisplayableValue<?>> getAllowedValues(ExpressionType expressi
|| !(((PrismPropertyValue) (((Set<?>) value).iterator().next())).getValue() instanceof DisplayableValue)) {
LOGGER.error("Exception return unexpected type, expected Set<PPV<DisplayableValue>>, but was " + (value == null ? null : value.getClass()));
if (modelServiceLocator instanceof PageBase) {
((PageBase)modelServiceLocator).error(PageBase.createStringResourceStatic("FilterSearchItem.message.error.wrongType", expression).getString());
((PageBase) modelServiceLocator).error(PageBase.createStringResourceStatic("FilterSearchItem.message.error.wrongType", expression).getString());
}
return allowedValues;
}
Expand Down Expand Up @@ -5524,4 +5525,14 @@ public static IResource createJpegPhotoResource(FocusType focus) {

return new ByteArrayResource("image/jpeg", photo);
}

public static AdminLTESkin getMidPointSkin() {
DeploymentInformationType info = MidPointApplication.get().getDeploymentInfo();
if (info == null || StringUtils.isEmpty(info.getSkin())) {
return AdminLTESkin.SKIN_DEFAULT;
}

String skin = info.getSkin();
return AdminLTESkin.create(skin);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,41 @@ public static ProvenanceAcquisitionType createAcquition() {
acquisitionType.setTimestamp(app.getClock().currentTimeXMLGregorianCalendar());
return acquisitionType;
}

public static boolean isValueFromResourceTemplate(PrismValue valueFromDelta, PrismContainer parent) {
if (valueFromDelta instanceof PrismObjectValue) {
return false;
}

if (hasValueMetadata(valueFromDelta)) {
return true;
}
Item<PrismValue, ItemDefinition> item = parent.findItem(valueFromDelta.getParent().getPath());
PrismContainerValue<?> value = item.getParent();
while (!(value instanceof PrismObjectValue)) {
if (hasValueMetadata(value)) {
return true;
}
value = value.getParentContainerValue();
}
return false;
}

private static boolean hasValueMetadata(PrismValue value) {
if (value.hasValueMetadata()) {
List<PrismContainerValue<Containerable>> metadataValues = value.getValueMetadata().getValues();

if (metadataValues.size() == 1) {
ProvenanceMetadataType provenance = ((ValueMetadataType) metadataValues.get(0).asContainerable()).getProvenance();
if (provenance != null) {
List<ProvenanceAcquisitionType> acquisitionValues = provenance.getAcquisition();
if (acquisitionValues.size() == 1) {
ObjectReferenceType originRef = acquisitionValues.get(0).getOriginRef();
return originRef != null && StringUtils.isNotEmpty(originRef.getOid());
}
}
}
}
return false;
}
}

0 comments on commit 4c8bf5d

Please sign in to comment.