Skip to content

Commit

Permalink
Show vault title in unlock prompt - fixes #1319
Browse files Browse the repository at this point in the history
  • Loading branch information
perry-mitchell committed Apr 1, 2024
1 parent ba8d225 commit 2ae9a1d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
23 changes: 21 additions & 2 deletions source/renderer/components/PasswordPrompt.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useMemo, useState } from "react";
import React, { Fragment, useCallback, useEffect, useMemo, useState } from "react";
import { useSingleState } from "react-obstate";
import { Button, Classes, Colors, Dialog, FormGroup, InputGroup, Intent, NonIdealState } from "@blueprintjs/core";
import { Layerr } from "layerr";
Expand All @@ -12,6 +12,7 @@ import { getVaultSettings, saveVaultSettings } from "../services/vaultSettings";
import { showError } from "../services/notifications";
import { logErr, logInfo } from "../library/log";
import { t } from "../../shared/i18n/trans";
import { useSourceDetails } from "../hooks/vault";
import { VAULT_SETTINGS_DEFAULT } from "../../shared/symbols";
import { VaultSettingsLocal } from "../../shared/types";

Expand All @@ -29,6 +30,15 @@ const FallbackText = styled.i`
display: block;
margin-bottom: 12px;
`;
const TitleSeparator = styled.span`
color: ${Colors.GRAY1};
font-weight: bold;
padding: 0px 6px;
`;
const VaultName = styled.span`
font-weight: 600;
font-style: italic;
`;

export function PasswordPrompt() {
const emitter = useMemo(getPasswordEmitter, []);
Expand All @@ -37,6 +47,7 @@ export function PasswordPrompt() {
const [currentPassword, setCurrentPassword] = useState("");
const [showPassword, setShowPassword] = useState(false);
const [sourceID] = useSingleState(VAULTS_STATE, "currentVault");
const [sourceDetails] = useSourceDetails(sourceID);
const [settings, setSettings] = useState<VaultSettingsLocal | null>(null);
const [promptedBiometrics, setPromptedBiometrics] = useState<boolean>(false);
// Callbacks
Expand Down Expand Up @@ -145,7 +156,15 @@ export function PasswordPrompt() {
// Render
return (
<Dialog isOpen={showPrompt} onClose={closePrompt}>
<div className={Classes.DIALOG_HEADER}>{t("dialog.password-prompt.title")}</div>
<div className={Classes.DIALOG_HEADER}>
<span>{t("dialog.password-prompt.title")}</span>
{sourceDetails && (
<Fragment>
<TitleSeparator></TitleSeparator>
<VaultName>{sourceDetails.name}</VaultName>
</Fragment>
)}
</div>
<div className={Classes.DIALOG_BODY}>
{promptType === PromptType.Password && (
<>
Expand Down
10 changes: 8 additions & 2 deletions source/renderer/hooks/vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ import { logErr } from "../library/log";
import { showError } from "../services/notifications";
import { VaultSourceDescription } from "../types";

export function useSourceDetails(sourceID: VaultSourceID): [VaultSourceDescription, () => void] {
const [details, setDetails] = useState<VaultSourceDescription>(null);
export function useSourceDetails(
sourceID: VaultSourceID | null
): [VaultSourceDescription | null, () => void] {
const [details, setDetails] = useState<VaultSourceDescription | null>(null);
const updateDescription = useCallback(() => {
if (sourceID === null) {
setDetails(null);
return;
}
ipcRenderer
.invoke("get-vault-description", sourceID)
.then((desc: VaultSourceDescription) => {
Expand Down

0 comments on commit 2ae9a1d

Please sign in to comment.