mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-22 04:31:27 +00:00
Added success screen to add vault workflow
This commit is contained in:
@@ -13,6 +13,7 @@ import javafx.scene.image.Image;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FXMLLoaderFactory;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.common.FxControllerKey;
|
||||
@@ -63,6 +64,15 @@ public abstract class AddVaultModule {
|
||||
return new SimpleStringProperty("");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@AddVaultWizard
|
||||
@AddVaultWizardScoped
|
||||
static ObjectProperty<Vault> provideVault() {
|
||||
return new SimpleObjectProperty<>();
|
||||
}
|
||||
|
||||
// ------------------
|
||||
|
||||
@Provides
|
||||
@FxmlScene(FxmlFile.ADDVAULT_WELCOME)
|
||||
@AddVaultWizardScoped
|
||||
@@ -98,6 +108,13 @@ public abstract class AddVaultModule {
|
||||
return fxmlLoaders.createScene("/fxml/addvault_new_password.fxml");
|
||||
}
|
||||
|
||||
@Provides
|
||||
@FxmlScene(FxmlFile.ADDVAULT_SUCCESS)
|
||||
@AddVaultWizardScoped
|
||||
static Scene provideCreateNewVaultSuccessScene(@AddVaultWizard FXMLLoaderFactory fxmlLoaders) {
|
||||
return fxmlLoaders.createScene("/fxml/addvault_success.fxml");
|
||||
}
|
||||
|
||||
// ------------------
|
||||
|
||||
@Binds
|
||||
@@ -124,4 +141,9 @@ public abstract class AddVaultModule {
|
||||
@IntoMap
|
||||
@FxControllerKey(CreateNewVaultPasswordController.class)
|
||||
abstract FxController bindCreateNewVaultPasswordController(CreateNewVaultPasswordController controller);
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@FxControllerKey(AddVaultSuccessController.class)
|
||||
abstract FxController bindAddVaultSuccessController(AddVaultSuccessController controller);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.cryptomator.ui.addvaultwizard;
|
||||
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.stage.Stage;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.ui.common.FxController;
|
||||
import org.cryptomator.ui.fxapp.FxApplication;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@AddVaultWizardScoped
|
||||
public class AddVaultSuccessController implements FxController {
|
||||
|
||||
private final FxApplication fxApplication;
|
||||
private final Stage window;
|
||||
private final ReadOnlyObjectProperty<Vault> vault;
|
||||
|
||||
@Inject
|
||||
AddVaultSuccessController(FxApplication fxApplication, @AddVaultWizard Stage window, @AddVaultWizard ObjectProperty<Vault> vault) {
|
||||
this.fxApplication = fxApplication;
|
||||
this.window = window;
|
||||
this.vault = vault;
|
||||
}
|
||||
|
||||
public void unlockAndClose(ActionEvent actionEvent) {
|
||||
close(actionEvent);
|
||||
fxApplication.showUnlockWindow(vault.get());
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void close(ActionEvent actionEvent) {
|
||||
window.close();
|
||||
}
|
||||
|
||||
/* Observables */
|
||||
|
||||
public ReadOnlyObjectProperty<Vault> vaultProperty() {
|
||||
return vault;
|
||||
}
|
||||
|
||||
public Vault getVault() {
|
||||
return vault.get();
|
||||
}
|
||||
}
|
||||
@@ -24,17 +24,21 @@ public class ChooseExistingVaultController implements FxController {
|
||||
|
||||
private final Stage window;
|
||||
private final Lazy<Scene> welcomeScene;
|
||||
private final Lazy<Scene> successScene;
|
||||
private final ObjectProperty<Path> vaultPath;
|
||||
private final ObservableList<Vault> vaults;
|
||||
private final ObjectProperty<Vault> vault;
|
||||
private final VaultFactory vaultFactory;
|
||||
private final ResourceBundle resourceBundle;
|
||||
|
||||
@Inject
|
||||
ChooseExistingVaultController(@AddVaultWizard Stage window, @FxmlScene(FxmlFile.ADDVAULT_WELCOME) Lazy<Scene> welcomeScene, ObjectProperty<Path> vaultPath, ObservableList<Vault> vaults, VaultFactory vaultFactory, ResourceBundle resourceBundle) {
|
||||
ChooseExistingVaultController(@AddVaultWizard Stage window, @FxmlScene(FxmlFile.ADDVAULT_WELCOME) Lazy<Scene> welcomeScene, @FxmlScene(FxmlFile.ADDVAULT_SUCCESS) Lazy<Scene> successScene, ObjectProperty<Path> vaultPath, ObservableList<Vault> vaults, @AddVaultWizard ObjectProperty<Vault> vault, VaultFactory vaultFactory, ResourceBundle resourceBundle) {
|
||||
this.window = window;
|
||||
this.welcomeScene = welcomeScene;
|
||||
this.successScene = successScene;
|
||||
this.vaultPath = vaultPath;
|
||||
this.vaults = vaults;
|
||||
this.vault = vault;
|
||||
this.vaultFactory = vaultFactory;
|
||||
this.resourceBundle = resourceBundle;
|
||||
}
|
||||
@@ -45,7 +49,7 @@ public class ChooseExistingVaultController implements FxController {
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void chooseFileAndFinish() {
|
||||
public void chooseFileAndNext() {
|
||||
//TODO: error handling & cannot unlock added vault
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
fileChooser.setTitle(resourceBundle.getString("addvaultwizard.existing.filePickerTitle"));
|
||||
@@ -55,9 +59,11 @@ public class ChooseExistingVaultController implements FxController {
|
||||
vaultPath.setValue(file.toPath().toAbsolutePath().getParent());
|
||||
VaultSettings vaultSettings = VaultSettings.withRandomId();
|
||||
vaultSettings.path().setValue(vaultPath.get());
|
||||
vaults.add(vaultFactory.get(vaultSettings));
|
||||
Vault newVault = vaultFactory.get(vaultSettings);
|
||||
vaults.add(newVault);
|
||||
vault.set(newVault);
|
||||
//TODO: error handling?
|
||||
window.close();
|
||||
window.setScene(successScene.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.stage.Stage;
|
||||
import org.cryptomator.common.settings.VaultSettings;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
@@ -42,10 +41,12 @@ public class CreateNewVaultPasswordController implements FxController {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CreateNewVaultPasswordController.class);
|
||||
|
||||
private final Stage window;
|
||||
private final Lazy<Scene> previousScene;
|
||||
private final Lazy<Scene> chooseLocationScene;
|
||||
private final Lazy<Scene> successScene;
|
||||
private final StringProperty vaultName;
|
||||
private final ObjectProperty<Path> vaultPath;
|
||||
private final ObservableList<Vault> vaults;
|
||||
private final ObjectProperty<Vault> vault;
|
||||
private final VaultFactory vaultFactory;
|
||||
private final ResourceBundle resourceBundle;
|
||||
private final PasswordStrengthUtil strengthRater;
|
||||
@@ -62,12 +63,14 @@ public class CreateNewVaultPasswordController implements FxController {
|
||||
public CheckBox finalConfirmationCheckbox;
|
||||
|
||||
@Inject
|
||||
CreateNewVaultPasswordController(@AddVaultWizard Stage window, @FxmlScene(FxmlFile.ADDVAULT_NEW_LOCATION) Lazy<Scene> previousScene, StringProperty vaultName, ObjectProperty<Path> vaultPath, ObservableList<Vault> vaults, VaultFactory vaultFactory, ResourceBundle resourceBundle, PasswordStrengthUtil strengthRater) {
|
||||
CreateNewVaultPasswordController(@AddVaultWizard Stage window, @FxmlScene(FxmlFile.ADDVAULT_NEW_LOCATION) Lazy<Scene> chooseLocationScene, @FxmlScene(FxmlFile.ADDVAULT_SUCCESS) Lazy<Scene> successScene, StringProperty vaultName, ObjectProperty<Path> vaultPath, ObservableList<Vault> vaults, @AddVaultWizard ObjectProperty<Vault> vault, VaultFactory vaultFactory, ResourceBundle resourceBundle, PasswordStrengthUtil strengthRater) {
|
||||
this.window = window;
|
||||
this.previousScene = previousScene;
|
||||
this.chooseLocationScene = chooseLocationScene;
|
||||
this.successScene = successScene;
|
||||
this.vaultName = vaultName;
|
||||
this.vaultPath = vaultPath;
|
||||
this.vaults = vaults;
|
||||
this.vault = vault;
|
||||
this.vaultFactory = vaultFactory;
|
||||
this.resourceBundle = resourceBundle;
|
||||
this.strengthRater = strengthRater;
|
||||
@@ -97,11 +100,11 @@ public class CreateNewVaultPasswordController implements FxController {
|
||||
|
||||
@FXML
|
||||
public void back() {
|
||||
window.setScene(previousScene.get());
|
||||
window.setScene(chooseLocationScene.get());
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void finish() {
|
||||
public void next() {
|
||||
VaultSettings vaultSettings = VaultSettings.withRandomId();
|
||||
vaultSettings.path().setValue(vaultPath.get());
|
||||
Vault newVault = vaultFactory.get(vaultSettings);
|
||||
@@ -116,8 +119,10 @@ public class CreateNewVaultPasswordController implements FxController {
|
||||
}
|
||||
try {
|
||||
newVault.create(passwordField.getCharacters());
|
||||
LOG.info("Created new vault at path {}", vaultPath.get());
|
||||
vault.set(newVault);
|
||||
vaults.add(newVault);
|
||||
window.close();
|
||||
window.setScene(successScene.get());
|
||||
} catch (IOException e) {
|
||||
// TODO show generic error screen
|
||||
LOG.error("", e);
|
||||
|
||||
@@ -6,6 +6,7 @@ public enum FxmlFile {
|
||||
ADDVAULT_NEW_NAME("/fxml/addvault_new_name.fxml"), //
|
||||
ADDVAULT_NEW_LOCATION("/fxml/addvault_new_location.fxml"), //
|
||||
ADDVAULT_NEW_PASSWORD("/fxml/addvault_new_password.fxml"), //
|
||||
ADDVAULT_SUCCESS("/fxml/addvault_success.fxml"), //
|
||||
CHANGEPASSWORD("/fxml/changepassword.fxml"), //
|
||||
MAIN_WINDOW("/fxml/main_window.fxml"), //
|
||||
PREFERENCES("/fxml/preferences.fxml"), //
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
|
||||
<Region VBox.vgrow="ALWAYS"/>
|
||||
|
||||
<ButtonBar buttonMinWidth="120" buttonOrder="B+I">
|
||||
<ButtonBar buttonMinWidth="120" buttonOrder="B+X">
|
||||
<buttons>
|
||||
<Button text="%generic.button.back" ButtonBar.buttonData="BACK_PREVIOUS" onAction="#back"/>
|
||||
<Button fx:id="finishButton" text="%addvaultwizard.existing.chooseBtn" ButtonBar.buttonData="FINISH" onAction="#chooseFileAndFinish" defaultButton="true"/>
|
||||
<Button fx:id="finishButton" text="%addvaultwizard.existing.chooseBtn" ButtonBar.buttonData="NEXT_FORWARD" onAction="#chooseFileAndNext" defaultButton="true"/>
|
||||
</buttons>
|
||||
</ButtonBar>
|
||||
</children>
|
||||
|
||||
@@ -47,10 +47,10 @@
|
||||
|
||||
<Region VBox.vgrow="ALWAYS"/>
|
||||
|
||||
<ButtonBar buttonMinWidth="120" buttonOrder="B+I">
|
||||
<ButtonBar buttonMinWidth="120" buttonOrder="B+X">
|
||||
<buttons>
|
||||
<Button text="%generic.button.back" ButtonBar.buttonData="BACK_PREVIOUS" onAction="#back"/>
|
||||
<Button fx:id="finishButton" text="%generic.button.create" ButtonBar.buttonData="FINISH" onAction="#finish" defaultButton="true"/>
|
||||
<Button fx:id="finishButton" text="%generic.button.next" ButtonBar.buttonData="NEXT_FORWARD" onAction="#next" defaultButton="true"/>
|
||||
</buttons>
|
||||
</ButtonBar>
|
||||
</children>
|
||||
|
||||
43
main/ui/src/main/resources/fxml/addvault_success.fxml
Normal file
43
main/ui/src/main/resources/fxml/addvault_success.fxml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Region?>
|
||||
<?import javafx.scene.layout.StackPane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.shape.Circle?>
|
||||
<?import org.cryptomator.ui.controls.FontAwesome5IconView?>
|
||||
<?import org.cryptomator.ui.controls.FormattedLabel?>
|
||||
<?import javafx.scene.control.ButtonBar?>
|
||||
<VBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="org.cryptomator.ui.addvaultwizard.AddVaultSuccessController"
|
||||
prefWidth="400.0"
|
||||
prefHeight="400.0"
|
||||
spacing="12.0"
|
||||
alignment="TOP_CENTER">
|
||||
<padding>
|
||||
<Insets top="24" right="24" bottom="24" left="24"/>
|
||||
</padding>
|
||||
<children>
|
||||
<StackPane alignment="CENTER" HBox.hgrow="NEVER">
|
||||
<VBox.margin>
|
||||
<Insets topRightBottomLeft="24"/>
|
||||
</VBox.margin>
|
||||
<Circle styleClass="glyph-icon-primary" radius="36"/>
|
||||
<FontAwesome5IconView styleClass="glyph-icon-main-bg" glyph="CHECK" glyphSize="36"/>
|
||||
</StackPane>
|
||||
|
||||
<FormattedLabel format="%addvaultwizard.success.nextStepsInstructions" arg1="${controller.vault.displayableName}" wrapText="true" textAlignment="LEFT" HBox.hgrow="ALWAYS"/>
|
||||
|
||||
<Region VBox.vgrow="ALWAYS"/>
|
||||
|
||||
<ButtonBar buttonMinWidth="120" buttonOrder="+UI">
|
||||
<buttons>
|
||||
<Button text="%addvaultwizard.success.unlockNow" ButtonBar.buttonData="OTHER" onAction="#unlockAndClose"/>
|
||||
<Button text="%generic.button.done" ButtonBar.buttonData="FINISH" onAction="#close" defaultButton="true"/>
|
||||
</buttons>
|
||||
</ButtonBar>
|
||||
</children>
|
||||
</VBox>
|
||||
@@ -18,13 +18,14 @@
|
||||
<Insets top="24" right="24" bottom="24" left="24"/>
|
||||
</padding>
|
||||
<children>
|
||||
<Region prefHeight="24" VBox.vgrow="NEVER"/>
|
||||
|
||||
<ImageView fitHeight="128.0" preserveRatio="true" smooth="true" cache="true">
|
||||
<ImageView VBox.vgrow="ALWAYS" fitHeight="128.0" preserveRatio="true" smooth="true" cache="true">
|
||||
<VBox.margin>
|
||||
<Insets top="24"/>
|
||||
</VBox.margin>
|
||||
<Image url="/bot_welcome.png"/>
|
||||
</ImageView>
|
||||
|
||||
<Region prefHeight="12" VBox.vgrow="NEVER"/>
|
||||
<Region VBox.vgrow="ALWAYS"/>
|
||||
|
||||
<VBox alignment="CENTER" spacing="9">
|
||||
<Button styleClass="button-large" text="%addvaultwizard.welcome.newButton" onAction="#createNewVault">
|
||||
|
||||
@@ -42,6 +42,9 @@ addvaultwizard.new.finalConfirmation=I understand that I will not be able to rec
|
||||
addvaultwizard.existing.instruction=Choose the "masterkey.cryptomator" file of your existing vault.
|
||||
addvaultwizard.existing.chooseBtn=Choose…
|
||||
addvaultwizard.existing.filePickerTitle=Select Masterkey File
|
||||
## Success
|
||||
addvaultwizard.success.nextStepsInstructions=Added vault "%s". \nYou need to unlock this vault to access or add contents. Alternatively you can unlock it at any later point in time.
|
||||
addvaultwizard.success.unlockNow=Unlock Now
|
||||
|
||||
# Remove Vault
|
||||
removeVault.title=Remove Vault
|
||||
|
||||
Reference in New Issue
Block a user