Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show vault title in unlock prompt #1321

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading