Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f43d902297 | ||
|
|
2129708819 |
No files matched your search
@@ -2,6 +2,29 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## 1.21.1 - 2026-10-01
|
||||
|
||||
Changes since 1.21.0:
|
||||
|
||||
### Changed
|
||||
|
||||
- The credential page hides the credential data when it opens; a Reveal button shows it and Hide hides it again. The data is not rendered on the page until revealed.
|
||||
|
||||
### Added
|
||||
|
||||
- A `RevealableCodeBlock` UI component (a CodeBlock that starts hidden behind a Reveal/Hide button), with a Storybook story.
|
||||
|
||||
## 1.21.0 - 2026-10-01
|
||||
|
||||
Changes since 1.20.2:
|
||||
|
||||
### Added
|
||||
|
||||
- UUID badges show a small colored circle in front of the short id. Its color comes from the first 6 hex digits of the UUID, so the same id always gets the same color, and its border uses the badge text color to stay visible in both themes.
|
||||
- UUID badges get lighter on hover to show they can be clicked.
|
||||
- `Badge` accepts an optional `className`.
|
||||
- A Storybook "Colors" story for UuidBadge with six sample ids and a button to randomize them.
|
||||
|
||||
## 1.20.2 - 2026-09-30
|
||||
|
||||
Changes since 1.20.1:
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { expect, userEvent, within } from 'storybook/test';
|
||||
import { RevealableCodeBlock } from '../../src/ui/RevealableCodeBlock/RevealableCodeBlock';
|
||||
|
||||
const meta: Meta<typeof RevealableCodeBlock> = {
|
||||
title: 'UI/RevealableCodeBlock',
|
||||
component: RevealableCodeBlock,
|
||||
parameters: { layout: 'padded' },
|
||||
tags: ['autodocs'],
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof RevealableCodeBlock>;
|
||||
|
||||
export const Default: Story = {
|
||||
args: {
|
||||
language: 'json',
|
||||
code: JSON.stringify({ username: 'admin', password: 's3cr3t-p4ss' }, null, 2),
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
// The code is not rendered until revealed, and hidden again on the second click
|
||||
const canvas = within(canvasElement);
|
||||
const toggle = canvas.getByRole('button');
|
||||
await expect(canvasElement).not.toHaveTextContent('s3cr3t-p4ss');
|
||||
await expect(toggle).toHaveAttribute('aria-expanded', 'false');
|
||||
|
||||
await userEvent.click(toggle);
|
||||
await expect(canvasElement.querySelector('code')).toHaveTextContent('s3cr3t-p4ss');
|
||||
await expect(toggle).toHaveAttribute('aria-expanded', 'true');
|
||||
|
||||
await userEvent.click(toggle);
|
||||
await expect(canvasElement).not.toHaveTextContent('s3cr3t-p4ss');
|
||||
},
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react-vite';
|
||||
import { useState } from 'react';
|
||||
import { expect, within } from 'storybook/test';
|
||||
import { Button } from '../../src/ui/Button/Button';
|
||||
import { UuidBadge } from '../../src/ui/UuidBadge/UuidBadge';
|
||||
|
||||
const meta: Meta<typeof UuidBadge> = {
|
||||
@@ -19,3 +21,43 @@ export const Default: Story = {
|
||||
await expect(badge).toHaveTextContent('61d2…0b2e');
|
||||
},
|
||||
};
|
||||
|
||||
const SAMPLE_IDS = [
|
||||
'61d2b1c2-7664-4dca-974f-436c2ee90b2e',
|
||||
'e83f0a5d-1b9c-4f27-8d6e-2a4c9b7f1e03',
|
||||
'0c7a94f1-3e52-4b8d-a1f6-9d2e5c8b4a70',
|
||||
'f4b21e8c-9a07-4c63-b5d2-7e1f0a3c6d98',
|
||||
'8d5e3a10-c4f7-4e29-9b81-5f6a2d0c7e14',
|
||||
'2a9fc067-58d3-4a1e-86b4-c3e7f19d5b2a',
|
||||
];
|
||||
|
||||
function Gallery() {
|
||||
const [ids, setIds] = useState(SAMPLE_IDS);
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 12 }}>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 16 }}>
|
||||
{ids.map((id) => (
|
||||
<UuidBadge key={id} id={id} />
|
||||
))}
|
||||
</div>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => setIds(ids.map(() => crypto.randomUUID()))}
|
||||
>
|
||||
Randomize
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const Colors: Story = {
|
||||
render: () => <Gallery />,
|
||||
play: async ({ canvasElement }) => {
|
||||
// Each sample id gets its own badge
|
||||
const canvas = within(canvasElement);
|
||||
for (const id of SAMPLE_IDS) {
|
||||
await expect(canvas.getByTitle(id)).toBeInTheDocument();
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -229,6 +229,11 @@
|
||||
"light_mode": "Light mode",
|
||||
"dark_mode": "Dark mode"
|
||||
},
|
||||
"revealable": {
|
||||
"hidden": "Hidden so secrets aren't exposed on screen.",
|
||||
"reveal": "Reveal",
|
||||
"hide": "Hide"
|
||||
},
|
||||
"pagination": {
|
||||
"prev": "Previous page",
|
||||
"next": "Next page",
|
||||
|
||||
@@ -3,11 +3,18 @@ import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePageTitle } from '../../hooks/usePageTitle';
|
||||
import { Upload, Pencil, Trash2, KeyRound } from 'lucide-react';
|
||||
import { CodeBlock } from '../../ui';
|
||||
import { stringify as yamlStringify } from 'yaml';
|
||||
import { credentials } from '../../api';
|
||||
import type { Credential } from '../../api';
|
||||
import { Breadcrumbs, Button, Card, DescriptionList, Timestamp, UuidBadge } from '../../ui';
|
||||
import {
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Card,
|
||||
DescriptionList,
|
||||
RevealableCodeBlock,
|
||||
Timestamp,
|
||||
UuidBadge,
|
||||
} from '../../ui';
|
||||
import { DeleteConfirmationModal } from '../../components/modals';
|
||||
import styles from '../Page.module.css';
|
||||
|
||||
@@ -117,7 +124,8 @@ export function CredentialDetailPage() {
|
||||
<div className={styles.stepsSection}>
|
||||
<h2 className={styles.sectionHeading}>{t('credentials.section_data')}</h2>
|
||||
<Card>
|
||||
<CodeBlock
|
||||
<RevealableCodeBlock
|
||||
key={credential.id}
|
||||
language="json"
|
||||
code={(() => {
|
||||
try {
|
||||
|
||||
@@ -6,12 +6,13 @@ export type BadgeVariant = 'success' | 'error' | 'warning' | 'info' | 'neutral'
|
||||
export interface BadgeProps {
|
||||
variant?: BadgeVariant;
|
||||
dot?: boolean;
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export function Badge({ variant = 'neutral', dot = false, children }: BadgeProps) {
|
||||
export function Badge({ variant = 'neutral', dot = false, className, children }: BadgeProps) {
|
||||
return (
|
||||
<span className={[styles.badge, styles[variant]].join(' ')}>
|
||||
<span className={[styles.badge, styles[variant], className].filter(Boolean).join(' ')}>
|
||||
{dot && <span className={styles.dot} aria-hidden="true" />}
|
||||
{children}
|
||||
</span>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
.wrapper {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
margin: 0;
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--font-size-sm);
|
||||
line-height: 1.6;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Eye, EyeOff } from 'lucide-react';
|
||||
import { Button } from '../Button/Button';
|
||||
import { CodeBlock } from '../CodeBlock/CodeBlock';
|
||||
import styles from './RevealableCodeBlock.module.css';
|
||||
|
||||
export interface RevealableCodeBlockProps {
|
||||
code: string;
|
||||
language?: string;
|
||||
}
|
||||
|
||||
/** A CodeBlock that starts hidden; the code is only rendered after the user reveals it. */
|
||||
export function RevealableCodeBlock({ code, language }: RevealableCodeBlockProps) {
|
||||
const { t } = useTranslation();
|
||||
const [revealed, setRevealed] = useState(false);
|
||||
|
||||
return (
|
||||
<div className={styles.wrapper}>
|
||||
<div className={styles.content}>
|
||||
{revealed ? (
|
||||
<CodeBlock code={code} language={language} />
|
||||
) : (
|
||||
<p className={styles.placeholder}>{t('revealable.hidden')}</p>
|
||||
)}
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
aria-expanded={revealed}
|
||||
onClick={() => setRevealed((r) => !r)}
|
||||
>
|
||||
{revealed ? <EyeOff size={14} /> : <Eye size={14} />}
|
||||
{revealed ? t('revealable.hide') : t('revealable.reveal')}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -4,6 +4,23 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.badge {
|
||||
transition: background var(--transition);
|
||||
}
|
||||
|
||||
.badge:hover {
|
||||
background: color-mix(in srgb, var(--color-neutral-bg) 85%, white);
|
||||
}
|
||||
|
||||
.swatch {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid currentColor;
|
||||
box-sizing: border-box;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.button {
|
||||
all: unset;
|
||||
cursor: pointer;
|
||||
|
||||
@@ -7,9 +7,15 @@ export interface UuidBadgeProps {
|
||||
id: string;
|
||||
}
|
||||
|
||||
function uuidColor(id: string): string | null {
|
||||
const hex = id.replace(/-/g, '').slice(0, 6);
|
||||
return /^[0-9a-f]{6}$/i.test(hex) ? `#${hex}` : null;
|
||||
}
|
||||
|
||||
export function UuidBadge({ id }: UuidBadgeProps) {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const short = `${id.slice(0, 4)}…${id.slice(-4)}`;
|
||||
const color = uuidColor(id);
|
||||
|
||||
const handleClick = (e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
@@ -21,7 +27,10 @@ export function UuidBadge({ id }: UuidBadgeProps) {
|
||||
|
||||
return (
|
||||
<span className={styles.wrapper} title={copied ? 'Copied!' : id}>
|
||||
<Badge variant="neutral">
|
||||
<Badge variant="neutral" className={styles.badge}>
|
||||
{color && (
|
||||
<span className={styles.swatch} style={{ background: color }} aria-hidden="true" />
|
||||
)}
|
||||
<button type="button" className={styles.button} onClick={handleClick}>
|
||||
{short}
|
||||
</button>
|
||||
|
||||
@@ -43,6 +43,9 @@ export type { SearchProps } from './Search/Search';
|
||||
export { CodeBlock } from './CodeBlock/CodeBlock';
|
||||
export type { CodeBlockProps } from './CodeBlock/CodeBlock';
|
||||
|
||||
export { RevealableCodeBlock } from './RevealableCodeBlock/RevealableCodeBlock';
|
||||
export type { RevealableCodeBlockProps } from './RevealableCodeBlock/RevealableCodeBlock';
|
||||
|
||||
export { CodeEditor } from './CodeEditor/CodeEditor';
|
||||
export type { CodeEditorProps } from './CodeEditor/CodeEditor';
|
||||
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "liqa",
|
||||
"version": "1.20.2",
|
||||
"version": "1.21.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "liqa",
|
||||
"version": "1.20.2",
|
||||
"version": "1.21.1",
|
||||
"workspaces": [
|
||||
"server",
|
||||
"client"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "liqa",
|
||||
"version": "1.20.2",
|
||||
"version": "1.21.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=24"
|
||||
|
||||
Reference in new issue
Block a user