Skip to content

Commit

Permalink
#4714 Fix display of disabled RunAs users
Browse files Browse the repository at this point in the history
  • Loading branch information
stroomdev66 committed Jan 23, 2025
1 parent 86d8e42 commit 155dad5
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import stroom.data.client.presenter.ColumnSizeConstants;
import stroom.data.client.presenter.CriteriaUtil;
import stroom.data.client.presenter.RestDataProvider;
import stroom.data.client.presenter.UserRefCell.UserRefProvider;
import stroom.data.grid.client.DataGridSelectionEventManager;
import stroom.data.grid.client.EndColumn;
import stroom.data.grid.client.MyDataGrid;
Expand All @@ -35,11 +36,14 @@
import stroom.dispatch.client.RestFactory;
import stroom.docref.DocRef;
import stroom.preferences.client.DateTimeFormatter;
import stroom.security.client.api.ClientSecurityContext;
import stroom.security.shared.UserFields;
import stroom.svg.client.SvgPresets;
import stroom.util.client.DataGridUtil;
import stroom.util.shared.CriteriaFieldSort;
import stroom.util.shared.GwtNullSafe;
import stroom.util.shared.ResultPage;
import stroom.util.shared.UserRef;
import stroom.util.shared.UserRef.DisplayType;
import stroom.widget.button.client.ButtonView;
import stroom.widget.util.client.MultiSelectEvent;
import stroom.widget.util.client.MultiSelectionModelImpl;
Expand All @@ -55,6 +59,7 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.Optional;
import java.util.function.Consumer;

public class ScheduledProcessListPresenter
Expand All @@ -69,6 +74,7 @@ public class ScheduledProcessListPresenter
private final RestDataProvider<ExecutionSchedule, ResultPage<ExecutionSchedule>> dataProvider;
private final RestFactory restFactory;
private final DateTimeFormatter dateTimeFormatter;
private final ClientSecurityContext securityContext;
private final ButtonView addButton;
private final ButtonView editButton;
private final ButtonView removeButton;
Expand All @@ -80,10 +86,12 @@ public class ScheduledProcessListPresenter
public ScheduledProcessListPresenter(final EventBus eventBus,
final PagerView view,
final RestFactory restFactory,
final DateTimeFormatter dateTimeFormatter) {
final DateTimeFormatter dateTimeFormatter,
final ClientSecurityContext securityContext) {
super(eventBus, view);
this.restFactory = restFactory;
this.dateTimeFormatter = dateTimeFormatter;
this.securityContext = securityContext;

final CriteriaFieldSort defaultSort = new CriteriaFieldSort(ExecutionScheduleFields.ID, true, true);
request = ExecutionScheduleRequest.builder().sortList(Collections.singletonList(defaultSort)).build();
Expand Down Expand Up @@ -186,13 +194,26 @@ public String getValue(final ExecutionSchedule row) {
}
}, ExecutionScheduleFields.SCHEDULE, ColumnSizeConstants.DATE_COL);

dataGrid.addResizableColumn(
new Column<ExecutionSchedule, String>(new TextCell()) {
@Override
public String getValue(final ExecutionSchedule row) {
return GwtNullSafe.get(row, ExecutionSchedule::getRunAsUser, UserRef::toDisplayString);
}
}, ExecutionScheduleFields.RUN_AS_USER, ColumnSizeConstants.DATE_COL);

final Column<ExecutionSchedule, UserRefProvider<ExecutionSchedule>> runAsCol = DataGridUtil
.userRefColumnBuilder(
ExecutionSchedule::getRunAsUser,
getEventBus(),
securityContext,
true,
DisplayType.AUTO)
.withSorting(UserFields.FIELD_DISPLAY_NAME, true)
.enabledWhen(executionSchedule ->
Optional.ofNullable(executionSchedule)
.map(ExecutionSchedule::getRunAsUser)
.map(UserRef::isEnabled)
.orElse(true))
.build();
dataGrid.addResizableColumn(runAsCol,
DataGridUtil.headingBuilder(ExecutionScheduleFields.RUN_AS_USER)
.withToolTip("The processor will run with the same permissions as the Run As User.")
.build(),
ColumnSizeConstants.USER_DISPLAY_NAME_COL);

dataGrid.addAutoResizableColumn(
new OrderByColumn<ExecutionSchedule, String>(
Expand All @@ -206,19 +227,19 @@ public String getValue(final ExecutionSchedule row) {
if (bounds.getStartTimeMs() != null && bounds.getEndTimeMs() != null) {
if (bounds.getStartTimeMs().equals(bounds.getEndTimeMs())) {
return "On " +
dateTimeFormatter.format(bounds.getStartTimeMs());
dateTimeFormatter.format(bounds.getStartTimeMs());
} else {
return "Between " +
dateTimeFormatter.format(bounds.getStartTimeMs()) +
" and " +
dateTimeFormatter.format(bounds.getEndTimeMs());
dateTimeFormatter.format(bounds.getStartTimeMs()) +
" and " +
dateTimeFormatter.format(bounds.getEndTimeMs());
}
} else if (bounds.getStartTimeMs() != null) {
return "After " +
dateTimeFormatter.format(bounds.getStartTimeMs());
dateTimeFormatter.format(bounds.getStartTimeMs());
} else if (bounds.getEndTimeMs() != null) {
return "Until " +
dateTimeFormatter.format(bounds.getEndTimeMs());
dateTimeFormatter.format(bounds.getEndTimeMs());
}
}
return "Unbounded";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
import stroom.svg.client.SvgPresets;
import stroom.util.client.DataGridUtil;
import stroom.util.shared.Expander;
import stroom.util.shared.GwtNullSafe;
import stroom.util.shared.TreeRow;
import stroom.util.shared.UserRef;
import stroom.util.shared.UserRef.DisplayType;
import stroom.widget.popup.client.presenter.PopupPosition;
import stroom.widget.tooltip.client.presenter.TooltipPresenter;
Expand All @@ -75,6 +75,7 @@
import com.google.web.bindery.event.shared.EventBus;
import com.gwtplatform.mvp.client.MyPresenterWidget;

import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;

Expand Down Expand Up @@ -550,10 +551,11 @@ private void addRunAsUserColumn() {
(ProcessorListRow row) -> {
if (row instanceof ProcessorFilterRow) {
final ProcessorFilterRow processorFilterRow = (ProcessorFilterRow) row;
return GwtNullSafe.get(
processorFilterRow,
ProcessorFilterRow::getProcessorFilter,
ProcessorFilter::getRunAsUser);
return Optional
.of(processorFilterRow)
.map(ProcessorFilterRow::getProcessorFilter)
.map(ProcessorFilter::getRunAsUser)
.orElse(null);
} else {
return null;
}
Expand All @@ -562,6 +564,19 @@ private void addRunAsUserColumn() {
securityContext,
true,
DisplayType.AUTO)
.enabledWhen((ProcessorListRow row) -> {
if (row instanceof ProcessorFilterRow) {
final ProcessorFilterRow processorFilterRow = (ProcessorFilterRow) row;
return Optional
.of(processorFilterRow)
.map(ProcessorFilterRow::getProcessorFilter)
.map(ProcessorFilter::getRunAsUser)
.map(UserRef::isEnabled)
.orElse(true);
} else {
return true;
}
})
.build(),
DataGridUtil.headingBuilder("Run As User")
.withToolTip("The processor will run with the same permissions as the Run As User.")
Expand Down
24 changes: 24 additions & 0 deletions unreleased_changes/20250123_101802_280__4714.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
* Issue **#4714** : Fix display of disabled `RunAs` users.


```sh
# ********************************************************************************
# Issue title: Processor Tab, no visual indication that current Run As User is not enabled
# Issue link: https://github.com/gchq/stroom/issues/4714
# ********************************************************************************

# ONLY the top line will be included as a change entry in the CHANGELOG.
# The entry should be in GitHub flavour markdown and should be written on a SINGLE
# line with no hard breaks. You can have multiple change files for a single GitHub issue.
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than
# 'Fixed nasty bug'.
#
# Examples of acceptable entries are:
#
#
# * Issue **123** : Fix bug with an associated GitHub issue in this repository
#
# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository
#
# * Fix bug with no associated GitHub issue.
```

0 comments on commit 155dad5

Please sign in to comment.