Skip to content

Commit 4b18965

Browse files
committed
UY-1571 upgrade change status dialog
1 parent 2b682e6 commit 4b18965

3 files changed

Lines changed: 44 additions & 18 deletions

File tree

console/src/main/java/io/imunity/console/views/directory_browser/identities/ChangeEntityStateDialog.java

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,25 @@
44
*/
55
package io.imunity.console.views.directory_browser.identities;
66

7+
import static io.imunity.vaadin.elements.CssClassNames.MEDIUM_VAADIN_FORM_ITEM_LABEL;
8+
79
import java.time.Instant;
810
import java.time.LocalDateTime;
911
import java.time.ZoneId;
1012
import java.util.Date;
1113
import java.util.Locale;
1214

1315
import com.vaadin.flow.component.checkbox.Checkbox;
16+
import com.vaadin.flow.component.confirmdialog.ConfirmDialog;
1417
import com.vaadin.flow.component.datetimepicker.DateTimePicker;
1518
import com.vaadin.flow.component.formlayout.FormLayout;
1619
import com.vaadin.flow.component.formlayout.FormLayout.FormItem;
20+
import com.vaadin.flow.component.html.Span;
1721
import com.vaadin.flow.component.select.Select;
1822

1923
import io.imunity.console.views.directory_browser.EntityWithLabel;
2024
import io.imunity.vaadin.elements.DialogWithActionFooter;
25+
import io.imunity.vaadin.endpoint.common.api.HtmlTooltipFactory;
2126
import pl.edu.icm.unity.base.entity.EntityInformation;
2227
import pl.edu.icm.unity.base.entity.EntityScheduledOperation;
2328
import pl.edu.icm.unity.base.entity.EntityState;
@@ -28,6 +33,7 @@ class ChangeEntityStateDialog extends DialogWithActionFooter
2833
{
2934
private static final Locale EUROPEAN_TIME_FORMAT = Locale.forLanguageTag("DE");
3035

36+
private final HtmlTooltipFactory htmlTooltipFactory;
3137
private final MessageSource msg;
3238
private final EntityWithLabel entity;
3339
private final Callback callback;
@@ -37,14 +43,16 @@ class ChangeEntityStateDialog extends DialogWithActionFooter
3743
private Select<EntityScheduledOperation> entityScheduledChange;
3844
private DateTimePicker changeTime;
3945
private DateTimePicker removalTime;
40-
private FormLayout.FormItem changeTimeFormItem;
46+
private FormItem changeTimeFormItem;
4147

4248
private FormItem removalFormItem;
4349

44-
ChangeEntityStateDialog(MessageSource msg, EntityWithLabel entity, Callback callback)
50+
ChangeEntityStateDialog(MessageSource msg, HtmlTooltipFactory htmlTooltipFactory, EntityWithLabel entity,
51+
Callback callback)
4552
{
4653
super(msg::getMessage);
4754
this.msg = msg;
55+
this.htmlTooltipFactory = htmlTooltipFactory;
4856
this.entity = entity;
4957
this.callback = callback;
5058
setHeaderTitle(msg.getMessage("ChangeEntityStateDialog.caption"));
@@ -113,18 +121,16 @@ private FormLayout getContents()
113121
});
114122

115123
FormLayout main = new FormLayout();
124+
main.addClassName(MEDIUM_VAADIN_FORM_ITEM_LABEL.getName());
116125
main.setResponsiveSteps(new FormLayout.ResponsiveStep("0", 1));
117-
FormLayout embedded = new FormLayout();
118-
embedded.setResponsiveSteps(new FormLayout.ResponsiveStep("0", 1));
119-
embedded.addFormItem(entityScheduledChange, msg.getMessage("ChangeEntityStateDialog.scheduledOperation"));
120-
changeTimeFormItem = embedded.addFormItem(changeTime,
121-
msg.getMessage("ChangeEntityStateDialog.scheduledChangeTime"));
122-
123126
main.addFormItem(entityState, msg.getMessage("ChangeEntityStateDialog.newState"));
124-
removalFormItem = main.addFormItem(removalTime, msg.getMessage("ChangeEntityStateDialog.removalTime"));
127+
removalFormItem = main.addFormItem(removalTime, msg.getMessage("ChangeEntityStateDialog.removalGracePeriodEnd"));
128+
removalFormItem.add(htmlTooltipFactory.get(msg.getMessage("ChangeEntityStateDialog.removalGracePeriodEndDescription")));
125129
removalFormItem.setVisible(false);
126-
main.addFormItem(scheduleEnable, "");
127-
main.addFormItem(embedded, "");
130+
main.addFormItem(scheduleEnable, "");
131+
main.addFormItem(entityScheduledChange, msg.getMessage("ChangeEntityStateDialog.scheduledOperation"));
132+
changeTimeFormItem = main.addFormItem(changeTime,
133+
msg.getMessage("ChangeEntityStateDialog.scheduledChangeTime"));
128134
main.setSizeFull();
129135

130136

@@ -184,8 +190,23 @@ private void onConfirm()
184190
newInfo.setScheduledOperationTime(zonedDate);
185191
}
186192

187-
if (callback.onChanged(newInfo))
188-
close();
193+
if (newInfo.getScheduledOperation() != null && newInfo.getRemovalByUserTime() != null)
194+
{
195+
ConfirmDialog confirm = new ConfirmDialog();
196+
confirm.setConfirmButton(msg.getMessage("ok"), e ->
197+
{
198+
if (callback.onChanged(newInfo))
199+
close();
200+
});
201+
confirm.setCancelable(true);
202+
confirm.add(new Span(msg.getMessage("ChangeEntityStateDialog.warningScheduledChangeAndRemoval")));
203+
confirm.open();
204+
205+
} else
206+
{
207+
if (callback.onChanged(newInfo))
208+
close();
209+
}
189210
}
190211

191212
interface Callback

console/src/main/java/io/imunity/console/views/directory_browser/identities/ChangeEntityStateHandler.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import io.imunity.console.views.directory_browser.EntityWithLabel;
1414
import io.imunity.vaadin.elements.NotificationPresenter;
1515
import io.imunity.vaadin.elements.grid.SingleActionHandler;
16+
import io.imunity.vaadin.endpoint.common.api.HtmlTooltipFactory;
1617
import pl.edu.icm.unity.base.entity.EntityInformation;
1718
import pl.edu.icm.unity.base.entity.EntityParam;
1819
import pl.edu.icm.unity.base.entity.EntityState;
@@ -25,13 +26,15 @@ class ChangeEntityStateHandler
2526
private final EntityManagement identitiesMan;
2627
private final MessageSource msg;
2728
private final NotificationPresenter notificationPresenter;
28-
29+
private final HtmlTooltipFactory htmlTooltipFactory;
30+
2931
ChangeEntityStateHandler(EntityManagement identitiesMan, MessageSource msg,
30-
NotificationPresenter notificationPresenter)
32+
NotificationPresenter notificationPresenter, HtmlTooltipFactory htmlTooltipFactory)
3133
{
3234
this.identitiesMan = identitiesMan;
3335
this.msg = msg;
3436
this.notificationPresenter = notificationPresenter;
37+
this.htmlTooltipFactory = htmlTooltipFactory;
3538
}
3639

3740
SingleActionHandler<IdentityEntry> getAction(Runnable refreshCallback)
@@ -47,7 +50,7 @@ SingleActionHandler<IdentityEntry> getAction(Runnable refreshCallback)
4750
private void showDialog(Set<IdentityEntry> selection, Runnable refreshCallback)
4851
{
4952
EntityWithLabel entity = selection.iterator().next().getSourceEntity();
50-
new ChangeEntityStateDialog(msg, entity, newState ->
53+
new ChangeEntityStateDialog(msg, htmlTooltipFactory, entity, newState ->
5154
setEntityStatus(entity.getEntity().getId(), newState, refreshCallback)
5255
).open();
5356
}

console/src/main/resources/messages/console/messages.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,9 @@ ChangeEntityStateDialog.newState=New status:
11041104
ChangeEntityStateDialog.enableScheduled=Schedule entity change in future
11051105
ChangeEntityStateDialog.scheduledOperation=Scheduled operation:
11061106
ChangeEntityStateDialog.scheduledChangeTime=Operation time:
1107-
ChangeEntityStateDialog.removalTime=Removal time:
1107+
ChangeEntityStateDialog.removalGracePeriodEnd=Removal grace period end:
1108+
ChangeEntityStateDialog.removalGracePeriodEndDescription=This time is usually set by the user, when deleting own account. Entity will be removed after this time, unless user sings-in before. In such case the status of the entity will be reset to VALID.
1109+
ChangeEntityStateDialog.warningScheduledChangeAndRemoval=Both user controlled account removal and admin-scheduled status change are set. Only the action with earlier time will be executed, unless user signs-in before this time.
11081110

11091111
EntityCreation.caption=New entity creation
11101112
EntityCreation.addToGroup=After creation add to group {0}
@@ -1324,7 +1326,7 @@ EntityScheduledOperation.DISABLE=Disable
13241326
EntityState.valid=ENABLED
13251327
EntityState.authenticationDisabled=LOGIN DISABLED
13261328
EntityState.disabled=DISABLED
1327-
EntityState.onlyLoginPermitted=DISABLED, ONLY LOGIN PERMITTED
1329+
EntityState.onlyLoginPermitted=DISABLED, TO BE RMOVED
13281330

13291331
IdentityDetails.entityDetailsCaption=Entity details
13301332
IdentityDetails.id=Displayed name:

0 commit comments

Comments
 (0)