Release v1.0.11 - Add dev mode with test prompt button on all headers
- Add Dev Mode toggle to settings that persists in vault metadata - Add test permission prompt button (✨) to all page headers when dev mode enabled - Move devMode and onTestPrompt to NavComponent base class for inheritance - Refactor all home components to extend NavComponent - Simplify permission prompt layout: remove duplicate domain from header - Convert permission descriptions to flowing single paragraphs - Update header-buttons styling for consistent lock/magic button layout Files modified: - projects/common/src/lib/common/nav-component.ts (devMode, onTestPrompt) - projects/common/src/lib/services/storage/types.ts (devMode property) - projects/common/src/lib/services/storage/signer-meta-handler.ts (setDevMode) - projects/common/src/lib/styles/_common.scss (header-buttons styling) - projects/*/src/app/components/home/*/settings.component.* (dev mode UI) - projects/*/src/app/components/home/*/*.component.* (extend NavComponent) - projects/*/public/prompt.html (simplified layout) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,29 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { StorageService } from '../services/storage/storage.service';
|
||||
import { Buffer } from 'buffer';
|
||||
|
||||
declare const chrome: {
|
||||
windows: {
|
||||
create: (options: {
|
||||
type: string;
|
||||
url: string;
|
||||
width: number;
|
||||
height: number;
|
||||
left: number;
|
||||
top: number;
|
||||
}) => void;
|
||||
};
|
||||
};
|
||||
|
||||
export class NavComponent {
|
||||
readonly #router = inject(Router);
|
||||
protected readonly storage = inject(StorageService);
|
||||
devMode = false;
|
||||
|
||||
constructor() {
|
||||
this.devMode = this.storage.getSignerMetaHandler().signerMetaData?.devMode ?? false;
|
||||
}
|
||||
|
||||
navigateBack() {
|
||||
window.history.back();
|
||||
@@ -11,4 +32,32 @@ export class NavComponent {
|
||||
navigate(path: string) {
|
||||
this.#router.navigate([path]);
|
||||
}
|
||||
|
||||
onTestPrompt() {
|
||||
const testEvent = {
|
||||
kind: 1,
|
||||
content: 'This is a test note for permission prompt preview.',
|
||||
tags: [],
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
};
|
||||
const base64Event = Buffer.from(JSON.stringify(testEvent, null, 2)).toString('base64');
|
||||
const currentIdentity = this.storage.getBrowserSessionHandler().browserSessionData?.identities.find(
|
||||
i => i.id === this.storage.getBrowserSessionHandler().browserSessionData?.selectedIdentityId
|
||||
);
|
||||
const nick = currentIdentity?.nick ?? 'Test Identity';
|
||||
|
||||
const width = 375;
|
||||
const height = 600;
|
||||
const left = Math.round((screen.width - width) / 2);
|
||||
const top = Math.round((screen.height - height) / 2);
|
||||
|
||||
chrome.windows.create({
|
||||
type: 'popup',
|
||||
url: `prompt.html?method=signEvent&host=example.com&id=test-${Date.now()}&nick=${encodeURIComponent(nick)}&event=${base64Event}`,
|
||||
width,
|
||||
height,
|
||||
left,
|
||||
top,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export abstract class SignerMetaHandler {
|
||||
|
||||
#signerMetaData?: SignerMetaData;
|
||||
|
||||
readonly metaProperties = ['syncFlow', 'vaultSnapshots', 'maxBackups', 'recklessMode', 'whitelistedHosts', 'bookmarks'];
|
||||
readonly metaProperties = ['syncFlow', 'vaultSnapshots', 'maxBackups', 'recklessMode', 'whitelistedHosts', 'bookmarks', 'devMode'];
|
||||
readonly DEFAULT_MAX_BACKUPS = 5;
|
||||
/**
|
||||
* Load the full data from the storage. If the storage is used for storing
|
||||
@@ -58,6 +58,21 @@ export abstract class SignerMetaHandler {
|
||||
await this.saveFullData(this.#signerMetaData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets dev mode and immediately saves it.
|
||||
*/
|
||||
async setDevMode(enabled: boolean): Promise<void> {
|
||||
if (!this.#signerMetaData) {
|
||||
this.#signerMetaData = {
|
||||
devMode: enabled,
|
||||
};
|
||||
} else {
|
||||
this.#signerMetaData.devMode = enabled;
|
||||
}
|
||||
|
||||
await this.saveFullData(this.#signerMetaData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a host to the whitelist and immediately saves it.
|
||||
*/
|
||||
|
||||
@@ -202,6 +202,9 @@ export interface SignerMetaData {
|
||||
|
||||
// User bookmarks
|
||||
bookmarks?: Bookmark[];
|
||||
|
||||
// Dev mode: show test permission prompt button in settings
|
||||
devMode?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,9 +16,16 @@
|
||||
letter-spacing: 0.1rem;
|
||||
}
|
||||
|
||||
.lock-btn {
|
||||
.header-buttons {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.lock-btn,
|
||||
.header-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
padding: 8px;
|
||||
@@ -37,6 +44,12 @@
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility with single lock-btn
|
||||
> .lock-btn {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.sam-footer-grid-2 {
|
||||
|
||||
Reference in New Issue
Block a user