mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-18 18:51:26 +00:00
Feature: revamp health workflow init (#1695)
* Add health tab to vault options: * health tool is started from there * health tool closes old Window and creates new one * added info and remarks about health tool * adds confirmation checkbox before starting health tool * close vault options window when starting health workflow * Remove AutoLock tab, move options to general tab Co-authored-by: Snyk bot <snyk-bot@snyk.io> Co-authored-by: Tobias Hagemann <tobias.hagemann@skymatic.de> Co-authored-by: Sebastian Stenzel <sebastian.stenzel@skymatic.de >
This commit is contained in:
@@ -39,7 +39,7 @@ public enum FontAwesome5Icon {
|
||||
REDO("\uF01E"), //
|
||||
SEARCH("\uF002"), //
|
||||
SPINNER("\uF110"), //
|
||||
STOPWATCH("\uF2F2"), //
|
||||
STETHOSCOPE("\uF0f1"), //
|
||||
SYNC("\uF021"), //
|
||||
TIMES("\uF00D"), //
|
||||
TRASH("\uF1F8"), //
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxmlFile;
|
||||
import org.cryptomator.ui.common.FxmlScene;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
@@ -17,6 +18,9 @@ public interface HealthCheckComponent {
|
||||
@HealthCheckWindow
|
||||
Stage window();
|
||||
|
||||
@Named("windowToClose")
|
||||
Stage windowToClose();
|
||||
|
||||
@FxmlScene(FxmlFile.HEALTH_START)
|
||||
Lazy<Scene> scene();
|
||||
|
||||
@@ -24,6 +28,7 @@ public interface HealthCheckComponent {
|
||||
Stage stage = window();
|
||||
stage.setScene(scene().get());
|
||||
stage.show();
|
||||
windowToClose().close();
|
||||
return stage;
|
||||
}
|
||||
|
||||
@@ -33,6 +38,9 @@ public interface HealthCheckComponent {
|
||||
@BindsInstance
|
||||
Builder vault(@HealthCheckWindow Vault vault);
|
||||
|
||||
@BindsInstance
|
||||
Builder windowToClose(@Named("windowToClose") Stage window);
|
||||
|
||||
HealthCheckComponent build();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ import org.cryptomator.ui.keyloading.KeyLoadingComponent;
|
||||
import org.cryptomator.ui.keyloading.KeyLoadingStrategy;
|
||||
import org.cryptomator.ui.mainwindow.MainWindow;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Provider;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
@@ -86,10 +88,10 @@ abstract class HealthCheckModule {
|
||||
@HealthCheckScoped
|
||||
static Stage provideStage(StageFactory factory, @MainWindow Stage owner, ResourceBundle resourceBundle, ChangeListener<Boolean> showingListener) {
|
||||
Stage stage = factory.create();
|
||||
stage.setTitle(resourceBundle.getString("health.title"));
|
||||
stage.setResizable(true);
|
||||
stage.initModality(Modality.WINDOW_MODAL);
|
||||
stage.initOwner(owner);
|
||||
stage.setTitle(resourceBundle.getString("health.title"));
|
||||
stage.setResizable(true);
|
||||
stage.showingProperty().addListener(showingListener); // bind masterkey lifecycle to window
|
||||
return stage;
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package org.cryptomator.ui.vaultoptions;
|
||||
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.controls.NumericTextField;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
@VaultOptionsScoped
|
||||
public class AutoLockVaultOptionsController implements FxController {
|
||||
|
||||
private final Vault vault;
|
||||
|
||||
public CheckBox lockAfterTimeCheckbox;
|
||||
public NumericTextField lockTimeInMinutesTextField;
|
||||
|
||||
@Inject
|
||||
AutoLockVaultOptionsController(@VaultOptionsWindow Vault vault) {
|
||||
this.vault = vault;
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
lockAfterTimeCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().autoLockWhenIdle());
|
||||
Bindings.bindBidirectional(lockTimeInMinutesTextField.textProperty(), vault.getVaultSettings().autoLockIdleSeconds(), new IdleTimeSecondsConverter());
|
||||
}
|
||||
|
||||
private static class IdleTimeSecondsConverter extends StringConverter<Number> {
|
||||
|
||||
@Override
|
||||
public String toString(Number seconds) {
|
||||
int minutes = seconds.intValue() / 60; // int-truncate
|
||||
return Integer.toString(minutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number fromString(String string) {
|
||||
try {
|
||||
int minutes = Integer.valueOf(string);
|
||||
return minutes * 60;
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,10 +3,11 @@ package org.cryptomator.ui.vaultoptions;
|
||||
import org.cryptomator.common.settings.WhenUnlocked;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.health.HealthCheckComponent;
|
||||
import org.cryptomator.ui.controls.NumericTextField;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.beans.Observable;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
@@ -23,18 +24,18 @@ public class GeneralVaultOptionsController implements FxController {
|
||||
|
||||
private final Stage window;
|
||||
private final Vault vault;
|
||||
private final HealthCheckComponent.Builder healthCheckWindow;
|
||||
private final ResourceBundle resourceBundle;
|
||||
|
||||
public TextField vaultName;
|
||||
public CheckBox unlockOnStartupCheckbox;
|
||||
public ChoiceBox<WhenUnlocked> actionAfterUnlockChoiceBox;
|
||||
public CheckBox lockAfterTimeCheckbox;
|
||||
public NumericTextField lockTimeInMinutesTextField;
|
||||
|
||||
@Inject
|
||||
GeneralVaultOptionsController(@VaultOptionsWindow Stage window, @VaultOptionsWindow Vault vault, HealthCheckComponent.Builder healthCheckWindow, ResourceBundle resourceBundle) {
|
||||
GeneralVaultOptionsController(@VaultOptionsWindow Stage window, @VaultOptionsWindow Vault vault, ResourceBundle resourceBundle) {
|
||||
this.window = window;
|
||||
this.vault = vault;
|
||||
this.healthCheckWindow = healthCheckWindow;
|
||||
this.resourceBundle = resourceBundle;
|
||||
}
|
||||
|
||||
@@ -47,6 +48,8 @@ public class GeneralVaultOptionsController implements FxController {
|
||||
actionAfterUnlockChoiceBox.getItems().addAll(WhenUnlocked.values());
|
||||
actionAfterUnlockChoiceBox.valueProperty().bindBidirectional(vault.getVaultSettings().actionAfterUnlock());
|
||||
actionAfterUnlockChoiceBox.setConverter(new WhenUnlockedConverter(resourceBundle));
|
||||
lockAfterTimeCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().autoLockWhenIdle());
|
||||
Bindings.bindBidirectional(lockTimeInMinutesTextField.textProperty(), vault.getVaultSettings().autoLockIdleSeconds(), new IdleTimeSecondsConverter());
|
||||
}
|
||||
|
||||
private void trimVaultNameOnFocusLoss(Observable observable, Boolean wasFocussed, Boolean isFocussed) {
|
||||
@@ -64,12 +67,6 @@ public class GeneralVaultOptionsController implements FxController {
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void showHealthCheck() {
|
||||
healthCheckWindow.vault(vault).build().showHealthCheckWindow();
|
||||
}
|
||||
|
||||
|
||||
private static class WhenUnlockedConverter extends StringConverter<WhenUnlocked> {
|
||||
|
||||
private final ResourceBundle resourceBundle;
|
||||
@@ -89,4 +86,22 @@ public class GeneralVaultOptionsController implements FxController {
|
||||
}
|
||||
}
|
||||
|
||||
private static class IdleTimeSecondsConverter extends StringConverter<Number> {
|
||||
|
||||
@Override
|
||||
public String toString(Number seconds) {
|
||||
int minutes = seconds.intValue() / 60; // int-truncate
|
||||
return Integer.toString(minutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number fromString(String string) {
|
||||
try {
|
||||
int minutes = Integer.valueOf(string);
|
||||
return minutes * 60;
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.cryptomator.ui.vaultoptions;
|
||||
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.health.HealthCheckComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
@VaultOptionsScoped
|
||||
public class HealthVaultOptionsController implements FxController {
|
||||
|
||||
@Inject
|
||||
public HealthVaultOptionsController(@VaultOptionsWindow Stage window, @VaultOptionsWindow Vault vault, HealthCheckComponent.Builder healthCheckWindow) {
|
||||
this.window = window;
|
||||
this.vault = vault;
|
||||
this.healthCheckWindow = healthCheckWindow;
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void startHealthCheck(ActionEvent event) {
|
||||
healthCheckWindow.vault(vault).windowToClose(window).build().showHealthCheckWindow();
|
||||
}
|
||||
|
||||
private final Stage window;
|
||||
private final Vault vault;
|
||||
private final HealthCheckComponent.Builder healthCheckWindow;
|
||||
}
|
||||
@@ -23,7 +23,11 @@ public enum SelectedVaultOptionsTab {
|
||||
|
||||
/**
|
||||
* Show Auto-Lock tab
|
||||
*
|
||||
*/
|
||||
AUTOLOCK,
|
||||
|
||||
/**
|
||||
* Show health tab
|
||||
*/
|
||||
HEALTH;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ public class VaultOptionsController implements FxController {
|
||||
public Tab mountTab;
|
||||
public Tab keyTab;
|
||||
public Tab autoLockTab;
|
||||
public Tab healthTab;
|
||||
|
||||
@Inject
|
||||
VaultOptionsController(@VaultOptionsWindow Stage window, ObjectProperty<SelectedVaultOptionsTab> selectedTabProperty) {
|
||||
@@ -49,6 +50,7 @@ public class VaultOptionsController implements FxController {
|
||||
case MOUNT -> mountTab;
|
||||
case KEY -> keyTab;
|
||||
case AUTOLOCK -> autoLockTab;
|
||||
case HEALTH -> healthTab;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,6 @@ abstract class VaultOptionsModule {
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@FxControllerKey(AutoLockVaultOptionsController.class)
|
||||
abstract FxController bindAutoLockVaultOptionsController(AutoLockVaultOptionsController controller);
|
||||
|
||||
@FxControllerKey(HealthVaultOptionsController.class)
|
||||
abstract FxController bindHealthOptionsController(HealthVaultOptionsController controller);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user