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 Jan 18, 2024
2 parents 6f38ce3 + 9c2ba73 commit f5cc4d5
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 78 deletions.
21 changes: 21 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 @@ -5,6 +5,27 @@
* and European Union Public License. See LICENSE file for details.
*/

.main-sidebar .sidebar > .user-panel {
& > .image {
padding-left: 0.8rem;
position: relative;
width: 100%;
min-width: 2.85rem;
max-width: 3.5rem;
transition: all ease 0.08s !important;
-webkit-transition: all ease 0.08s !important;

& > .user-image {
background-size: cover;
background-repeat: no-repeat;
background-position: center;
position: relative;
height: 0;
padding-bottom: 100%;
}
}
}

.user-panel {
border-bottom: 0 !important;

Expand Down
44 changes: 43 additions & 1 deletion gui/admin-gui/src/frontend/scss/midpoint.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,20 @@ span.tree-content > table tr td:first-child {
font-size: 12px;
padding-bottom: 5px;
}
/*.show-empty-button {
text-align:center;
background-color:none;
border: none;
border-radius:0.25rem;
&:hover {
background-color:inherit;
color: $primary;
background-color: mix(#ffffff, $primary, 90%);
border-color: mix(#ffffff, $primary, 20%);
}
}*/


// This will make the tooltip respect new lines.
// Lines will still wrap if they are longer than the default max-width of the container.
Expand Down Expand Up @@ -1988,13 +2002,41 @@ div[role="heading"]:focus-visible,
input:focus-visible,
select:focus-visible
{
outline: 2px orange;
outline: 2px #ffa836;
outline-style: auto;
outline-offset: 3px;
z-index: 1001;
@include smooth-transition(0.03s);
}

#skip-link {
position: fixed;
left: 0;
top: 0;
width: 100%;
margin-left: 0;
text-align: center;
z-index: 1040;
}
#skip-link a {
position: absolute;
left: -99999px;
top: -35px;
-webkit-transition: top .2s ease-out;
transition: top .2s ease-out;
}
#skip-link a:focus, #skip-link a:active {
position: relative;
top: 0;
left: 0;
padding: 6px 10px;
border-radius: 0 0 .2rem .2rem;
color: $primary;
background: #fff;
-webkit-transition: top .2s ease-in;
transition: top .2s ease-in;
}

*:focus:not(:focus-visible) {
outline:none !important;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<wicket:extend>
<div wicket:id="mainPopup"/>
<div class="wrapper">
<div id="skip-link">
<a href="#main-content" class="btn-sm"><wicket:message key="Accessibility.PageBase.skiplink.title"/></a>
</div>
<nav wicket:id="mainHeader" class="main-header navbar navbar-expand border-bottom-0">
<div class="navbar-nav">
<a wicket:id="menuToggle" class="nav-link" data-widget="pushmenu" href="#" role="button" wicket:message="title:Accessibility.PageBase.pushmenu.title"><i class="fas fa-bars"></i></a>
Expand Down Expand Up @@ -78,7 +81,7 @@
<aside class="main-sidebar" wicket:id="sidebarMenu"/>
</wicket:enclosure>

<main class="content-wrapper" style="min-height: 916px; padding: 15px 0">
<main class="content-wrapper" id="main-content" role="main" style="min-height: 916px; padding: 15px 0">
<section class="content">
<div class="container-fluid">
<div wicket:id="feedbackContainer" class="feedbackContainer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;

import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.exception.CommonException;
import com.evolveum.midpoint.util.exception.SystemException;

import org.apache.wicket.Component;
import org.apache.wicket.model.IModel;

Expand Down Expand Up @@ -105,6 +109,18 @@ public void setCompiledObjectCollectionView(CompiledObjectCollectionView objectC
this.objectCollectionView = objectCollectionView;
}

protected void setupUserFriendlyMessage(OperationResult result, Throwable ex) {
if (ex instanceof CommonException) {
result.setUserFriendlyMessage(((CommonException) ex).getUserFriendlyMessage());
return;
}

if (ex instanceof SystemException) {
Throwable subError = ex.getCause();
setupUserFriendlyMessage(result, subError);
}
}

@Override
public void detach() {
super.detach();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@

import com.evolveum.midpoint.gui.impl.component.search.Search;

import com.evolveum.midpoint.util.exception.CommonException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.web.component.data.TypedCacheKey;
import com.evolveum.midpoint.web.component.util.SelectableBean;

import com.evolveum.midpoint.web.component.util.SelectableBeanImpl;

import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseException;

import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.PrismObject;
Expand All @@ -31,7 +32,6 @@
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.page.error.PageError;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import org.apache.wicket.model.IModel;
Expand Down Expand Up @@ -122,14 +122,18 @@ public Iterator<W> internalIterator(long first, long count) {
getAvailableData().add(createDataObjectWrapper(object));
}
} catch (Exception ex) {
setupUserFriendlyMessage(result, ex);
result.recordFatalError(getPageBase().createStringResource("ObjectDataProvider.message.listObjects.fatalError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list objects", ex);
} finally {
result.computeStatusIfUnknown();
}

if (!WebComponentUtil.isSuccessOrHandledError(result)) {
handleNotSuccessOrHandledErrorInIterator(result);
LOGGER.trace("end (with error)::iterator()");
//TODO later, however check all the places where used and where we rely that the object in selectable bean cannot be null
// return handleNotSuccessOrHandledErrorInIterator(result);
getPageBase().showResult(result);
}

LOGGER.trace("end::iterator()");
Expand All @@ -141,11 +145,16 @@ protected boolean checkOrderingSettings() {
return true;
}

protected void handleNotSuccessOrHandledErrorInIterator(OperationResult result) {
getPageBase().showResult(result);
throw new RestartResponseException(PageError.class);
protected Iterator<W> handleNotSuccessOrHandledErrorInIterator(OperationResult result) {
List<SelectableBean<O>> errorList = new ArrayList<>(1);
SelectableBean<O> bean = new SelectableBeanImpl<>();
bean.setResult(result);
errorList.add(bean);
return (Iterator<W>) errorList.iterator();
}



public W createDataObjectWrapper(PrismObject<O> obj) {
SelectableBean<O> selectable = new SelectableBeanImpl<>(Model.of(obj.asObjectable()));
if (selected.contains(obj.asObjectable())) {
Expand All @@ -163,6 +172,7 @@ protected int internalSize() {
Task task = getPageBase().createSimpleTask(OPERATION_COUNT_OBJECTS);
count = getModelService().countObjects(getType(), getQuery(), getOptionsToUse(), task, result);
} catch (Exception ex) {
setupUserFriendlyMessage(result, ex);
result.recordFatalError(getPageBase().createStringResource("ObjectDataProvider.message.countObjects.fatalError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count objects", ex);
} finally {
Expand All @@ -171,7 +181,8 @@ protected int internalSize() {

if (!WebComponentUtil.isSuccessOrHandledError(result) && !OperationResultStatus.NOT_APPLICABLE.equals(result.getStatus())) {
getPageBase().showResult(result);
throw new RestartResponseException(PageError.class);
// Let us do nothing. The error will be shown on the page and a count of 0 will be used.
// Redirecting to the error page does more harm than good (see also MID-4306).
}

LOGGER.trace("end::internalSize(): {}", count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public Iterator<SelectableBean<T>> internalIterator(long offset, long pageSize)
getAvailableData().addAll(createDataObjectWrappers(getType(), query, optionsBuilder.build(), task, result));

} catch (Exception ex) {
setupUserFriendlyMessage(result, ex);
result.recordFatalError(getPageBase().createStringResource("ObjectDataProvider.message.listObjects.fatalError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list objects", ex);
return handleNotSuccessOrHandledErrorInIterator(result);
Expand Down Expand Up @@ -234,6 +235,7 @@ protected int internalSize() {
Integer counted = countObjects(getType(), getQuery(), currentOptions, task, result);
count = defaultIfNull(counted, defaultCountIfNull);
} catch (Exception ex) {
setupUserFriendlyMessage(result, ex);
result.recordFatalError(getPageBase().createStringResource("ObjectDataProvider.message.countObjects.fatalError").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count objects", ex);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,13 @@ protected void appendOptionHtml(AppendingStringBuffer buffer, T choice, int inde
buffer.append("\n<option ");
setOptionAttributes(buffer, choice, index, selected);
buffer.append("style=\"display:none;\">");
buffer.append(label);
buffer.append("</option>");

String advancedLabel = LocalizationUtil.translate(display.getLabel());
buffer.append("\n<option ");
setOptionAttributes(buffer, choice, index, null);
buffer.append(">");
buffer.append(advancedLabel);
if (label.equals(advancedLabel)) {
buffer.append(label);
} else {
buffer.append(advancedLabel);
}
buffer.append("</option>");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Object getDisplayValue(QName qname) {
key = WebComponentUtil.createEnumResourceKey(ot);
} catch (Exception e) {
key = ObjectType.class.getSimpleName() + "." + qname.getLocalPart(); //HACK exception occurs during the attempt to find ObjectTypes value for
// containerable (not objectable) type. therefore generate key in this way
// containerable (not objectable) type. therefore generate key in this way
}
return new StringResourceModel(key).setDefaultValue(key).getString();
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<wicket:panel>
<div class="user-panel pb-2 pt-3 d-flex align-items-center">
<div class="image">
<img wicket:id="menuPhoto" class="user-image img-circle elevation-1" wicket:message="alt:SideBarMenuPanel.loginUserPhoto"/>
<div wicket:id="menuPhoto" class="user-image img-circle elevation-1" wicket:message="alt:SideBarMenuPanel.loginUserPhoto"/>
</div>
<div class="info" tabindex="0" role="region">
<div class="sr-only"><wicket:message key="SideBarMenuPanel.loginUser"/></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.io.IOException;
import java.net.URL;
import java.util.Base64;
import java.util.List;
import java.util.Map;

Expand All @@ -20,14 +21,11 @@
import org.apache.wicket.behavior.Behavior;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.image.NonCachingImage;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.resource.AbstractResource;
import org.apache.wicket.request.resource.ByteArrayResource;
import org.springframework.security.core.context.SecurityContextHolder;

import com.evolveum.midpoint.authentication.api.util.AuthUtil;
Expand Down Expand Up @@ -72,8 +70,13 @@ protected void onInitialize() {
}

protected void initLayout() {
NonCachingImage img = new NonCachingImage(ID_MENU_PHOTO, loadJpegPhotoModel());
add(img);
//NonCachingImage img = new NonCachingImage(ID_MENU_PHOTO, loadJpegPhotoUrlModel());
//add(img);
IModel<String> photoUrlModel = loadJpegPhotoUrlModel();
WebMarkupContainer photoContainer = new WebMarkupContainer("menuPhoto");
photoContainer.add(AttributeAppender.append("style", "background-image: url('" + photoUrlModel.getObject() + "');"));
add(photoContainer);


Label username = new Label(ID_USERNAME, () -> getShortUserName());
add(username);
Expand Down Expand Up @@ -125,7 +128,7 @@ private String getShortUserName() {
return principal.toString();
}

private IModel<AbstractResource> loadJpegPhotoModel() {
private IModel<String> loadJpegPhotoUrlModel() {
return () -> {
GuiProfiledPrincipal principal = AuthUtil.getPrincipalUser();
if (principal == null) {
Expand All @@ -146,8 +149,8 @@ private IModel<AbstractResource> loadJpegPhotoModel() {
return null;
}
}

return new ByteArrayResource("image/jpeg", jpegPhoto);
String base64Encoded = Base64.getEncoder().encodeToString(jpegPhoto);
return "data:image/jpeg;base64," + base64Encoded;
};
}

Expand Down

0 comments on commit f5cc4d5

Please sign in to comment.