From e82d9b24ef0e08f7f4e1cde79e7e30f539a4d0b3 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 17 Aug 2016 16:25:57 +0200 Subject: [client] Allow deletion of expired image versions The menu entry was grayed out for expired versions, making it impossible to delete such versions. --- .../org/openslx/dozmod/gui/window/ImageDetailsWindow.java | 5 ++--- .../src/main/java/org/openslx/dozmod/thrift/Session.java | 13 ++++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'dozentenmodul/src/main/java') diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java index 0b602984..32adaf24 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java @@ -251,7 +251,7 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe pop.addMenuItem(mnuDownload); pop.addSeparator(); pop.addMenuItem(mnuDelete); - if (Session.isSuperUser()) { + if (Session.canExtendImageExpiry()) { pop.addSeparator(); pop.addMenuItem(mnuExtendExpiryDate); } @@ -307,8 +307,7 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout implements UiFe && ImagePerms.canLink(image)); mnuDownload.setEnabled(!multiSelection && tblVersions.getSelectedItem().isValid && ImagePerms.canDownload(image)); - mnuDelete.setEnabled(tblVersions.getSelectedItem().isValid - && ImagePerms.canEdit(image)); + mnuDelete.setEnabled(ImagePerms.canEdit(image)); mnuExtendExpiryDate.setEnabled(multiSelection || tblVersions.getSelectedItem().isValid); pop.show(e.getComponent(), e.getX(), e.getY()); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java index a2677638..6eb91fe7 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/thrift/Session.java @@ -24,7 +24,8 @@ public class Session { private static SatelliteConfig satConf = null; - public static void initialize(WhoamiInfo whoami, String satAddress, String satToken, String masToken, long satApiVersion) { + public static void initialize(WhoamiInfo whoami, String satAddress, String satToken, String masToken, + long satApiVersion) { if (whoami == null || whoami.user == null || whoami.user.userId == null) { throw new IllegalArgumentException( "Cannot initialize session: whoami-Information from satellite incomplete"); @@ -134,14 +135,16 @@ public class Session { } /** - * @return true if the satellite's API version supports publications of images (version 3 and above), false otherwise + * @return true if the satellite's API version supports publications of + * images (version 3 and above), false otherwise */ public static boolean isImagePublishSupported() { return satelliteApiVersion >= 3; } /** - * @return true if the satellite's API version supports netrules, internet blocking, exam mode (version 4 and above), false otherwise + * @return true if the satellite's API version supports netrules, internet + * blocking, exam mode (version 4 and above), false otherwise */ public static boolean isNetrulesSupported() { return satelliteApiVersion >= 4; @@ -172,4 +175,8 @@ public class Session { } } + public static boolean canExtendImageExpiry() { + return isSuperUser() && satelliteApiVersion >= 3; + } + } -- cgit v1.2.3-55-g7522