add hub specific tab to vault options

This commit is contained in:
Armin Schrenk
2023-02-21 23:05:47 +01:00
parent 2a70e2f0f4
commit 268c66a108
7 changed files with 66 additions and 3 deletions

View File

@@ -29,8 +29,8 @@ import java.util.concurrent.ExecutionException;
public class HubKeyLoadingStrategy implements KeyLoadingStrategy {
private static final String SCHEME_PREFIX = "hub+";
static final String SCHEME_HUB_HTTP = SCHEME_PREFIX + "http";
static final String SCHEME_HUB_HTTPS = SCHEME_PREFIX + "https";
public static final String SCHEME_HUB_HTTP = SCHEME_PREFIX + "http";
public static final String SCHEME_HUB_HTTPS = SCHEME_PREFIX + "https";
private final Stage window;
private final KeychainManager keychainManager;

View File

@@ -0,0 +1,20 @@
package org.cryptomator.ui.vaultoptions;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.ui.common.FxController;
import javax.inject.Inject;
import javafx.stage.Stage;
public class HubOptionsController implements FxController {
private final Vault vault;
private final Stage window;
@Inject
public HubOptionsController(@VaultOptionsWindow Vault vault, @VaultOptionsWindow Stage window) {
this.vault = vault;
this.window = window;
}
}

View File

@@ -21,4 +21,9 @@ public enum SelectedVaultOptionsTab {
*/
KEY,
/**
* Show hub tab
*/
HUB
}

View File

@@ -2,6 +2,8 @@ package org.cryptomator.ui.vaultoptions;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.ui.common.FxController;
import org.cryptomator.ui.keyloading.hub.HubKeyLoadingStrategy;
import org.cryptomator.ui.keyloading.masterkeyfile.MasterkeyFileLoadingStrategy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -25,6 +27,7 @@ public class VaultOptionsController implements FxController {
public Tab generalTab;
public Tab mountTab;
public Tab keyTab;
public Tab hubTab;
@Inject
VaultOptionsController(@VaultOptionsWindow Stage window, @VaultOptionsWindow Vault vault, ObjectProperty<SelectedVaultOptionsTab> selectedTabProperty) {
@@ -38,9 +41,13 @@ public class VaultOptionsController implements FxController {
window.setOnShowing(this::windowWillAppear);
selectedTabProperty.addListener(observable -> this.selectChosenTab());
tabPane.getSelectionModel().selectedItemProperty().addListener(observable -> this.selectedTabChanged());
if(!vault.getVaultConfigCache().getUnchecked().getKeyId().getScheme().equals("masterkeyfile")){
var vaultScheme = vault.getVaultConfigCache().getUnchecked().getKeyId().getScheme();
if(!vaultScheme.equals(MasterkeyFileLoadingStrategy.SCHEME)){
tabPane.getTabs().remove(keyTab);
}
if(!(vaultScheme.equals(HubKeyLoadingStrategy.SCHEME_HUB_HTTP) || vaultScheme.equals(HubKeyLoadingStrategy.SCHEME_HUB_HTTPS))){
tabPane.getTabs().remove(hubTab);
}
}
private void selectChosenTab() {
@@ -53,6 +60,7 @@ public class VaultOptionsController implements FxController {
case ANY, GENERAL -> generalTab;
case MOUNT -> mountTab;
case KEY -> keyTab;
case HUB -> hubTab;
};
}

View File

@@ -84,4 +84,9 @@ abstract class VaultOptionsModule {
@IntoMap
@FxControllerKey(MasterkeyOptionsController.class)
abstract FxController bindMasterkeyOptionsController(MasterkeyOptionsController controller);
@Binds
@IntoMap
@FxControllerKey(HubOptionsController.class)
abstract FxController bindHubOptionsController(HubOptionsController controller);
}

View File

@@ -36,5 +36,13 @@
<fx:include source="vault_options_masterkey.fxml"/>
</content>
</Tab>
<Tab fx:id="hubTab" id="HUB" text="Recovery"> <!-- is removed in controller, when config.keyid.scheme is not cryptomator-hub -->
<graphic>
<FontAwesome5IconView glyph="KEY"/>
</graphic>
<content>
<fx:include source="vault_options_hub.fxml"/>
</content>
</Tab>
</tabs>
</TabPane>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import org.cryptomator.ui.controls.FontAwesome5IconView?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.VBox?>
<VBox xmlns:fx="http://javafx.com/fxml"
xmlns="http://javafx.com/javafx"
fx:controller="org.cryptomator.ui.vaultoptions.HubOptionsController"
spacing="6"
alignment="TOP_CENTER">
<padding>
<Insets topRightBottomLeft="12"/>
</padding>
</VBox>