Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(settings): vault rows open a detail with remove / edit, site logos, outlined filters (#23696)

Lobehub Coderad75bf22cfe3
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index 24751b85b44..9703a4ba1e7 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -466,15 +466,19 @@
"creds.actions.deleteConfirm.content": "This credential will be permanently deleted. This action cannot be undone.",
"creds.actions.deleteConfirm.ok": "Delete",
"creds.actions.deleteConfirm.title": "Delete Credential?",
+ "creds.actions.done": "Done",
"creds.actions.edit": "Edit",
+ "creds.actions.remove": "Remove",
"creds.actions.view": "View",
- "creds.create": "New Credential",
+ "creds.create": "Add",
"creds.createModal.titles.file": "New credential file",
"creds.createModal.titles.kv-env": "New environment variable",
"creds.createModal.titles.kv-header": "New HTTP header",
"creds.createModal.titles.oauth": "New OAuth credential",
+ "creds.detail.account": "Account",
"creds.empty": "No credentials configured yet",
"creds.errors.createFailed": "Failed to create the credential. Please try again.",
+ "creds.errors.deleteFailed": "Failed to delete the credential. Please try again.",
"creds.errors.multiOrgShareDisabled": "Sharing one credential into several workspaces is not available yet. Remove its other share first.",
"creds.errors.privateCredExists": "You already have a private credential with this key in this workspace. Remove it before making this one private.",
"creds.errors.privateCredsDisabled": "Private workspace credentials are not available yet. Please try again later.",
@@ -548,8 +552,10 @@
"creds.types.kv-header": "Header",
"creds.types.oauth": "OAuth",
"creds.view.error": "Failed to load credential",
+ "creds.view.hide": "Hide",
"creds.view.noValues": "No Values",
"creds.view.oauthNote": "OAuth credentials are managed by the connected service.",
+ "creds.view.show": "Show",
"creds.view.title": "View Credential: {{name}}",
"creds.view.values": "Credential Values",
"creds.view.warning": "These values are sensitive. Do not share them with others.",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index 01eb40f4da7..ea9dd537f56 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -466,15 +466,19 @@
"creds.actions.deleteConfirm.content": "此凭证将被永久删除,此操作无法撤销。",
"creds.actions.deleteConfirm.ok": "删除",
"creds.actions.deleteConfirm.title": "确定删除凭证?",
+ "creds.actions.done": "完成",
"creds.actions.edit": "编辑",
+ "creds.actions.remove": "移除",
"creds.actions.view": "查看",
- "creds.create": "新建凭证",
+ "creds.create": "添加",
"creds.createModal.titles.file": "新建凭证文件",
"creds.createModal.titles.kv-env": "新建环境变量",
"creds.createModal.titles.kv-header": "新建 HTTP 请求头",
"creds.createModal.titles.oauth": "新建 OAuth 凭证",
+ "creds.detail.account": "账户",
"creds.empty": "暂无凭证配置",
"creds.errors.createFailed": "创建凭证失败,请重试。",
+ "creds.errors.deleteFailed": "删除凭证失败,请重试。",
"creds.errors.multiOrgShareDisabled": "暂不支持把同一个凭证共享到多个工作区,请先取消它在其他工作区的共享。",
"creds.errors.privateCredExists": "你在此工作区已有同一键名的私人凭证,请先移除它再将此凭证设为私人。",
"creds.errors.privateCredsDisabled": "工作区私人凭证暂未开放,请稍后再试。",
@@ -548,8 +552,10 @@
"creds.types.kv-header": "请求头",
"creds.types.oauth": "OAuth",
"creds.view.error": "加载凭证失败",
+ "creds.view.hide": "隐藏",
"creds.view.noValues": "无值",
"creds.view.oauthNote": "OAuth 凭证由连接的服务管理。",
+ "creds.view.show": "显示",
"creds.view.title": "查看凭证:{{name}}",
"creds.view.values": "凭证值",
"creds.view.warning": "这些值是敏感信息,请勿与他人分享。",
diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.ts
index de20823a800..c354efc9cbb 100644
--- a/packages/locales/src/default/setting.ts
+++ b/packages/locales/src/default/setting.ts
@@ -761,15 +761,19 @@ export default {
'This credential will be permanently deleted. This action cannot be undone.',
'creds.actions.deleteConfirm.ok': 'Delete',
'creds.actions.deleteConfirm.title': 'Delete Credential?',
+ 'creds.actions.done': 'Done',
'creds.actions.edit': 'Edit',
+ 'creds.actions.remove': 'Remove',
'creds.actions.view': 'View',
- 'creds.create': 'New Credential',
+ 'creds.create': 'Add',
'creds.createModal.titles.file': 'New credential file',
'creds.createModal.titles.kv-env': 'New environment variable',
'creds.createModal.titles.kv-header': 'New HTTP header',
'creds.createModal.titles.oauth': 'New OAuth credential',
+ 'creds.detail.account': 'Account',
'creds.empty': 'No credentials configured yet',
'creds.errors.createFailed': 'Failed to create the credential. Please try again.',
+ 'creds.errors.deleteFailed': 'Failed to delete the credential. Please try again.',
'creds.errors.multiOrgShareDisabled':
'Sharing one credential into several workspaces is not available yet. Remove its other share first.',
'creds.errors.privateCredExists':
@@ -857,8 +861,10 @@ export default {
'creds.types.kv-header': 'Header',
'creds.types.oauth': 'OAuth',
'creds.view.error': 'Failed to load credential',
+ 'creds.view.hide': 'Hide',
'creds.view.noValues': 'No Values',
'creds.view.oauthNote': 'OAuth credentials are managed by the connected service.',
+ 'creds.view.show': 'Show',
'creds.view.title': 'View Credential: {{name}}',
'creds.view.values': 'Credential Values',
'creds.view.warning': 'These values are sensitive. Do not share them with others.',
diff --git a/src/components/Skeleton/Settings/tabs/Creds.tsx b/src/components/Skeleton/Settings/tabs/Creds.tsx
index c366fb0891e..b039595bd8b 100644
--- a/src/components/Skeleton/Settings/tabs/Creds.tsx
+++ b/src/components/Skeleton/Settings/tabs/Creds.tsx
@@ -2,7 +2,7 @@
import { cssVar, Flexbox } from '@lobehub/ui';
-import { useDensity, useDensityTokens } from '@/styles/density';
+import { useDensity } from '@/styles/density';
import SkeletonBar from '../../Bar';
import type { SettingsTabSkeleton } from './types';
@@ -16,13 +16,12 @@ const ROW_WIDTHS = [
/**
* Credential rows as `CredItem` lays them out: 12px block padding, a 48px icon
- * tile, a name + type-tag line over a key line, and the "..." menu button. Rows
- * sit edge to edge (gap 0), like the settled list.
+ * tile and a name + type-tag line over a key line. Rows sit edge to edge
+ * (gap 0), like the settled list.
*/
export const CredsListSkeleton = ({ rows = 4 }: { rows?: number }) => {
// Compact `CredItem`: 6px padding, 36px tile, 22px title line + 2 + 18px key line = 54px.
const { compact, tokens } = useDensity();
- const { controlHeight } = useDensityTokens();
return (
<Flexbox aria-busy data-testid={'settings-creds-skeleton'} gap={0} width={'100%'}>
@@ -53,7 +52,6 @@ export const CredsListSkeleton = ({ rows = 4 }: { rows?: number }) => {
</Flexbox>
</Flexbox>
</Flexbox>
- <SkeletonBar height={controlHeight} width={controlHeight} />
</Flexbox>
);
})}
@@ -61,8 +59,8 @@ export const CredsListSkeleton = ({ rows = 4 }: { rows?: number }) => {
);
};
-/** The small primary "Create" button the page portals into the header. */
-const PageActions = () => <SkeletonBar height={32} width={96} />;
+/** The small primary "Add" button the page portals into the header. */
+const PageActions = () => <SkeletonBar height={32} width={72} />;
const CredsSkeleton: SettingsTabSkeleton = { Body: () => <CredsListSkeleton />, PageActions };
diff --git a/src/features/Settings/creds/features/CreateCredModal/FileCredForm.tsx b/src/features/Settings/creds/features/CreateCredModal/FileCredForm.tsx
index 5e17b215b1b..7ab5e192918 100644
--- a/src/features/Settings/creds/features/CreateCredModal/FileCredForm.tsx
+++ b/src/features/Settings/creds/features/CreateCredModal/FileCredForm.tsx
@@ -116,7 +116,7 @@ const FileCredForm: FC<FileCredFormProps> = ({ credsApi, disabled, onCancel, onS
</span>
<Button
size="small"
- type="text"
+ type="fill"
onClick={() => {
setFileHashId(null);
setFileName('');
@@ -153,7 +153,9 @@ const FileCredForm: FC<FileCredFormProps> = ({ credsApi, disabled, onCancel, onS
</Form.Field>
<CredFormFooter>
- <Button onClick={onCancel}>{t('creds.form.cancel')}</Button>
+ <Button type="fill" onClick={onCancel}>
+ {t('creds.form.cancel')}
+ </Button>
<Button
disabled={!fileHashId || disabled}
htmlType="submit"
diff --git a/src/features/Settings/creds/features/CreateCredModal/KVCredForm.tsx b/src/features/Settings/creds/features/CreateCredModal/KVCredForm.tsx
index 4254a73a09a..3c81edb44c1 100644
--- a/src/features/Settings/creds/features/CreateCredModal/KVCredForm.tsx
+++ b/src/features/Settings/creds/features/CreateCredModal/KVCredForm.tsx
@@ -103,7 +103,9 @@ const KVCredForm: FC<KVCredFormProps> = ({ credsApi, type, disabled, onCancel, o
</Form.Field>
<CredFormFooter>
- <Button onClick={onCancel}>{t('creds.form.cancel')}</Button>
+ <Button type="fill" onClick={onCancel}>
+ {t('creds.form.cancel')}
+ </Button>
<Button
disabled={disabled}
htmlType="submit"
diff --git a/src/features/Settings/creds/features/CreateCredModal/OAuthCredForm.tsx b/src/features/Settings/creds/features/CreateCredModal/OAuthCredForm.tsx
index b799243ca8f..ea40fc5fc3f 100644
--- a/src/features/Settings/creds/features/CreateCredModal/OAuthCredForm.tsx
+++ b/src/features/Settings/creds/features/CreateCredModal/OAuthCredForm.tsx
@@ -97,7 +97,9 @@ const OAuthCredForm: FC<OAuthCredFormProps> = ({ credsApi, disabled, onCancel, o
<Flexbox gap={16}>
<Empty description={t('creds.oauth.noConnections')} />
<CredFormFooter>
- <Button onClick={onCancel}>{t('creds.form.cancel')}</Button>
+ <Button type="fill" onClick={onCancel}>
+ {t('creds.form.cancel')}
+ </Button>
</CredFormFooter>
</Flexbox>
);
@@ -142,7 +144,9 @@ const OAuthCredForm: FC<OAuthCredFormProps> = ({ credsApi, disabled, onCancel, o
</Form.Field>
<CredFormFooter>
- <Button onClick={onCancel}>{t('creds.form.cancel')}</Button>
+ <Button type="fill" onClick={onCancel}>
+ {t('creds.form.cancel')}
+ </Button>
<Button
disabled={disabled}
htmlType="submit"
diff --git a/src/features/Settings/creds/features/CredIcon.test.ts b/src/features/Settings/creds/features/CredIcon.test.ts
new file mode 100644
index 00000000000..797c0fff35c
--- /dev/null
+++ b/src/features/Settings/creds/features/CredIcon.test.ts
@@ -0,0 +1,44 @@
+import { COMPOSIO_APP_TYPES, LOBEHUB_SKILL_PROVIDERS } from '@lobechat/const';
+import { type UserCredSummary } from '@lobechat/types';
+import { describe, expect, it } from 'vitest';
+
+import { credSiteIcon } from './CredIcon';
+
+const cred = (patch: Partial<UserCredSummary>): UserCredSummary => ({
+ createdAt: '2026-11-01T00:00:00Z',
+ id: 1,
+ key: 'key',
+ name: 'name',
+ type: 'kv-env',
+ updatedAt: '2026-11-01T00:00:00Z',
+ ...patch,
+});
+
+const connector = (id: string) => LOBEHUB_SKILL_PROVIDERS.find((p) => p.id === id)!.icon;
+
+describe('credSiteIcon', () => {
+ it("shows an OAuth item's provider logo", () => {
+ expect(credSiteIcon(cred({ key: 'gh-main', oauthProvider: 'github', type: 'oauth' }))).toBe(
+ connector('github'),
+ );
+ expect(credSiteIcon(cred({ key: 'x-main', oauthProvider: 'Linear', type: 'oauth' }))).toBe(
+ connector('linear'),
+ );
+ });
+
+ it('reads the site from the key, whole or by its first word', () => {
+ expect(credSiteIcon(cred({ key: 'notion' }))).toBe(connector('notion'));
+ expect(credSiteIcon(cred({ key: 'GITHUB_TOKEN' }))).toBe(connector('github'));
+ expect(credSiteIcon(cred({ key: 'x' }))).toBe(connector('twitter'));
+ expect(credSiteIcon(cred({ key: 'google-calendar', type: 'kv-header' }))).toBe(
+ COMPOSIO_APP_TYPES.find((app) => app.identifier === 'google-calendar')!.icon,
+ );
+ });
+
+ it('has no site for an item that names none', () => {
+ expect(credSiteIcon(cred({ key: 'my-api-key' }))).toBeUndefined();
+ expect(
+ credSiteIcon(cred({ key: 'acme', oauthProvider: 'acme', type: 'oauth' })),
+ ).toBeUndefined();
+ });
+});
diff --git a/src/features/Settings/creds/features/CredIcon.tsx b/src/features/Settings/creds/features/CredIcon.tsx
new file mode 100644
index 00000000000..15acc70230e
--- /dev/null
+++ b/src/features/Settings/creds/features/CredIcon.tsx
@@ -0,0 +1,57 @@
+'use client';
+
+import { type IconType } from '@icons-pack/react-simple-icons';
+import { COMPOSIO_APP_TYPES, LOBEHUB_SKILL_PROVIDERS } from '@lobechat/const';
+import { type UserCredSummary } from '@lobechat/types';
+import { Avatar, Icon } from '@lobehub/ui';
+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
+import { memo } from 'react';
+
+import { CRED_TYPE_ICONS } from './credTypes';
+
+/** Lowercase letters and digits only, so `GitHub`, `GITHUB` and `google-calendar` meet. */
+const slug = (value?: string) => value?.toLowerCase().replaceAll(/[^\da-z]/g, '') ?? '';
+
+/** Every site with a known logo, by slug; a LobeHub connector wins over a Composio app. */
+const SITE_ICONS = new Map<string, string | IconType>([
+ ...COMPOSIO_APP_TYPES.map((app) => [slug(app.identifier), app.icon] as const),
+ ...LOBEHUB_SKILL_PROVIDERS.map((provider) => [slug(provider.id), provider.icon] as const),
+ ['x', LOBEHUB_SKILL_PROVIDERS.find((provider) => provider.id === 'twitter')!.icon],
+]);
+
+const findSite = (value?: string) => SITE_ICONS.get(slug(value));
+
+/**
+ * The website a vault item belongs to, when it names one: an OAuth item's
+ * provider, else the item's key (`notion`) or its first word (`GITHUB_TOKEN`).
+ */
+export const credSiteIcon = (cred: UserCredSummary) =>
+ (cred.type === 'oauth' ? findSite(cred.oauthProvider) : undefined) ??
+ findSite(cred.key) ??
+ findSite(cred.key.split(/[_.-]/)[0]);
+
+interface CredIconProps {
+ /** Size of the OAuth account avatar fallback; defaults to 1.5 × `size`. */
+ avatarSize?: number;
+ cred: UserCredSummary;
+ size?: number;
+}
+
+/**
+ * A vault item's icon: the website's logo when it belongs to one, the OAuth
+ * account avatar when the provider is unknown, else the type icon.
+ */
+const CredIcon = memo<CredIconProps>(({ avatarSize, cred, size = 18 }) => {
+ const site = credSiteIcon(cred);
+
+ if (typeof site === 'string') return <Avatar avatar={site} shape={'square'} size={size} />;
+ if (site) return <Icon fill={cssVar.colorText} icon={site} size={size} />;
+ if (cred.type === 'oauth' && cred.oauthAvatar)
+ return <Avatar avatar={cred.oauthAvatar} size={avatarSize ?? Math.round(size * 1.5)} />;
+
+ return <Icon color={cssVar.colorTextSecondary} icon={CRED_TYPE_ICONS[cred.type]} size={size} />;
+});
+
+CredIcon.displayName = 'CredIcon';
+
+export default CredIcon;
diff --git a/src/features/Settings/creds/features/CredItem.tsx b/src/features/Settings/creds/features/CredItem.tsx
index 95547811325..7df9edc0de8 100644
--- a/src/features/Settings/creds/features/CredItem.tsx
+++ b/src/features/Settings/creds/features/CredItem.tsx
@@ -1,155 +1,69 @@
'use client';
import { type UserCredSummary } from '@lobechat/types';
-import {
- ActionIcon,
- Avatar,
- confirmModal,
- type DropdownItem,
- DropdownMenu,
- Flexbox,
- Icon,
- stopPropagation,
-} from '@lobehub/ui';
+import { Flexbox } from '@lobehub/ui';
import * as stylex from '@stylexjs/stylex';
-import { Eye, MoreHorizontalIcon, Pencil, Trash2 } from 'lucide-react';
-import { type FC, memo } from 'react';
-import { useTranslation } from 'react-i18next';
+import { type FC, memo, type ReactNode } from 'react';
import { useDensity } from '@/styles/density';
-import { CRED_TYPE_ICONS } from './credTypes';
+import CredIcon from './CredIcon';
import { styles } from './style';
interface CredItemProps {
- /** Whether the view / edit / delete handlers may run; they render disabled otherwise. */
- canManage: boolean;
cred: UserCredSummary;
- /** Row-specific actions (publish, share…) listed before view / edit / delete. */
- extraMenuItems?: DropdownItem[];
- /**
- * Action handlers are optional: omit one to leave its item out. A row with
- * no items renders no "..." menu.
- */
- onDelete?: (id: number) => void;
- onEdit?: (cred: UserCredSummary) => void;
- onView?: (cred: UserCredSummary) => void;
+ /** Opens the item's detail, which holds its edit, remove and sharing actions. */
+ onClick: (cred: UserCredSummary) => void;
/** Tags shown after the name (owner, sharing state). */
- tags?: React.ReactNode;
+ tags?: ReactNode;
/** Inline marker right after the name, e.g. the private lock in the workspace list. */
- titleSuffix?: React.ReactNode;
+ titleSuffix?: ReactNode;
}
-const CredItem: FC<CredItemProps> = memo(
- ({ canManage, cred, extraMenuItems = [], onEdit, onDelete, onView, tags, titleSuffix }) => {
- const { t } = useTranslation(['setting', 'common']);
- const { compact, tokens } = useDensity();
+/**
+ * One vault item: the website's logo (else the OAuth avatar or the type icon),
+ * the name with its markers, and the description. The whole row opens it.
+ */
+const CredItem: FC<CredItemProps> = memo(({ cred, onClick, tags, titleSuffix }) => {
+ const { compact, tokens } = useDensity();
- const handleDelete = () => {
- if (!canManage) return;
-
- confirmModal({
- content: t('creds.actions.deleteConfirm.content'),
- okButtonProps: { danger: true },
- okText: t('creds.actions.deleteConfirm.ok'),
- onOk: () => onDelete?.(cred.id),
- title: t('creds.actions.deleteConfirm.title'),
- });
- };
-
- const canView = canManage && (cred.type === 'kv-env' || cred.type === 'kv-header');
-
- const menuItems: DropdownItem[] = [
- ...extraMenuItems,
- ...(onView && canView
- ? [
- {
- icon: <Icon icon={Eye} />,
- key: 'view',
- label: t('creds.actions.view'),
- onClick: () => onView(cred),
- },
- ]
- : []),
- ...(onEdit
- ? [
- {
- icon: <Icon icon={Pencil} />,
- key: 'edit',
- label: t('creds.actions.edit'),
- disabled: !canManage,
- onClick: () => onEdit(cred),
- },
- ]
- : []),
- ...(onDelete
- ? [
- {
- danger: true,
- disabled: !canManage,
- icon: <Icon icon={Trash2} />,
- key: 'delete',
- label: t('creds.actions.delete'),
- onClick: handleDelete,
- },
- ]
- : []),
- ];
-
- const renderAvatar = () => {
- if (cred.type === 'oauth' && cred.oauthAvatar) {
- return <Avatar avatar={cred.oauthAvatar} size={tokens.controlHeight} />;
+ return (
+ <Flexbox
+ horizontal
+ align="center"
+ gap={tokens.sectionGap}
+ role="button"
+ tabIndex={0}
+ className={
+ stylex.props(styles.container, compact && styles.containerCompact, styles.clickable)
+ .className
}
- return (
- // `display: flex` collapses the inline span's line box so the svg sits
- // dead-center in the 48px container instead of on the text baseline.
- <span style={{ color: 'var(--lobe-color-text-secondary)', display: 'flex' }}>
- <Icon icon={CRED_TYPE_ICONS[cred.type]} size={20} />
- </span>
- );
- };
-
- return (
- <Flexbox
- horizontal
- align="center"
- className={stylex.props(styles.container, compact && styles.containerCompact).className}
- gap={tokens.sectionGap}
- justify="space-between"
- >
- <Flexbox
- horizontal
- align="center"
- gap={tokens.sectionGap}
- style={{ flex: 1, overflow: 'hidden' }}
- >
- <div {...stylex.props(styles.icon, compact && styles.iconCompact)}>{renderAvatar()}</div>
- <Flexbox gap={compact ? 2 : 4} style={{ flex: 1, minWidth: 0, overflow: 'hidden' }}>
- <Flexbox horizontal align="center" gap={8}>
- <span {...stylex.props(styles.title, compact && styles.titleCompact)}>
- {cred.name}
- </span>
- {titleSuffix}
- {tags}
- </Flexbox>
- {cred.description && (
- <span {...stylex.props(styles.description, compact && styles.descriptionCompact)}>
- {cred.description}
- </span>
- )}
- </Flexbox>
- </Flexbox>
- <Flexbox horizontal align="center" gap={8} onClick={stopPropagation}>
- {menuItems.length > 0 && (
- <DropdownMenu items={menuItems} placement="bottomRight">
- <ActionIcon icon={MoreHorizontalIcon} title={t('more', { ns: 'common' })} />
- </DropdownMenu>
- )}
+ onClick={() => onClick(cred)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ onClick(cred);
+ }
+ }}
+ >
+ <div {...stylex.props(styles.icon, compact && styles.iconCompact)}>
+ <CredIcon avatarSize={tokens.controlHeight} cred={cred} size={20} />
+ </div>
+ <Flexbox gap={compact ? 2 : 4} style={{ flex: 1, minWidth: 0, overflow: 'hidden' }}>
+ <Flexbox horizontal align="center" gap={8}>
+ <span {...stylex.props(styles.title, compact && styles.titleCompact)}>{cred.name}</span>
+ {titleSuffix}
+ {tags}
</Flexbox>
+ {cred.description && (
+ <span {...stylex.props(styles.description, compact && styles.descriptionCompact)}>
+ {cred.description}
+ </span>
+ )}
</Flexbox>
- );
- },
-);
+ </Flexbox>
+ );
+});
CredItem.displayName = 'CredItem';
diff --git a/src/features/Settings/creds/features/CredModalTitle.tsx b/src/features/Settings/creds/features/CredModalTitle.tsx
index 17cc6daf465..2b8ae2e30a1 100644
--- a/src/features/Settings/creds/features/CredModalTitle.tsx
+++ b/src/features/Settings/creds/features/CredModalTitle.tsx
@@ -1,11 +1,12 @@
'use client';
-import { type CredType } from '@lobechat/types';
+import { type CredType, type UserCredSummary } from '@lobechat/types';
import { Flexbox, Icon } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import { type FC } from 'react';
+import CredIcon from './CredIcon';
import { CRED_TYPE_ICONS } from './credTypes';
const styles = stylex.create({
@@ -19,6 +20,7 @@ const styles = stylex.create({
borderWidth: '1px',
borderStyle: 'solid',
borderColor: cssVar.colorBorderSecondary,
+ overflow: 'hidden',
borderRadius: cssVar.borderRadius,
color: cssVar.colorTextSecondary,
backgroundColor: cssVar.colorFillQuaternary,
@@ -33,19 +35,21 @@ const styles = stylex.create({
});
interface CredModalTitleProps {
+ /** An existing item: its website's logo replaces the type icon when it has one. */
+ cred?: UserCredSummary;
title: string;
type: CredType;
}
/**
* The header of the create, edit and view modals: the credential type's icon
- * beside the title, so the modal says which kind of secret it holds before
- * any field does.
+ * (an existing item's website logo) beside the title, so the modal says which
+ * kind of secret it holds before any field does.
*/
-const CredModalTitle: FC<CredModalTitleProps> = ({ title, type }) => (
+const CredModalTitle: FC<CredModalTitleProps> = ({ cred, title, type }) => (
<Flexbox horizontal align={'center'} gap={12} style={{ minWidth: 0 }}>
<span {...stylex.props(styles.icon)}>
- <Icon icon={CRED_TYPE_ICONS[type]} size={16} />
+ {cred ? <CredIcon cred={cred} size={16} /> : <Icon icon={CRED_TYPE_ICONS[type]} size={16} />}
</span>
<span {...stylex.props(styles.title)}>{title}</span>
</Flexbox>
diff --git a/src/features/Settings/creds/features/CredsList.tsx b/src/features/Settings/creds/features/CredsList.tsx
index 151d4824891..49761286d07 100644
--- a/src/features/Settings/creds/features/CredsList.tsx
+++ b/src/features/Settings/creds/features/CredsList.tsx
@@ -1,7 +1,7 @@
'use client';
import { type UserCredSummary } from '@lobechat/types';
-import { Empty, Flexbox, Icon, Tag } from '@lobehub/ui';
+import { Empty, Flexbox, Tag } from '@lobehub/ui';
import * as stylex from '@stylexjs/stylex';
import { useMutation } from '@tanstack/react-query';
import { Share2 } from 'lucide-react';
@@ -33,8 +33,9 @@ interface CredsListProps {
}
/**
- * The caller's personal credentials, on the personal settings page. Each row
- * can be shared into the caller's workspaces (see {@link openShareCredModal});
+ * The caller's personal credentials, on the personal settings page. A row
+ * opens its detail, which edits, removes or shares it into the caller's
+ * workspaces (see {@link openShareCredModal});
* the workspace page lists workspace credentials through `WorkspaceCredsList`.
*/
const CredsList: FC<CredsListProps> = ({ filter = {} }) => {
@@ -64,22 +65,26 @@ const CredsList: FC<CredsListProps> = ({ filter = {} }) => {
createEditCredModal({ cred, credsApi, onSuccess: () => refetch() });
};
- const handleView = (cred: UserCredSummary) => {
- createViewCredModal({ cred, credsApi });
- };
-
// Self-hosted deployments have no workspaces to share into.
- const shareItems = (cred: UserCredSummary) =>
- workspaces.length > 0
- ? [
- {
- icon: <Icon icon={Share2} />,
- key: 'share',
- label: t('creds.share.menu'),
- onClick: () => openShareCredModal(cred),
- },
- ]
- : [];
+ const handleOpen = (cred: UserCredSummary) =>
+ createViewCredModal({
+ actions:
+ workspaces.length > 0
+ ? [
+ {
+ icon: Share2,
+ key: 'share',
+ label: t('creds.share.menu'),
+ onClick: () => openShareCredModal(cred),
+ },
+ ]
+ : [],
+ canReadValues: canManageCredentials,
+ cred,
+ credsApi,
+ onDelete: canManageCredentials ? (id) => deleteMutation.mutateAsync(id) : undefined,
+ onEdit: canManageCredentials ? handleEdit : undefined,
+ });
return (
<MarketSignInGate>
@@ -108,18 +113,14 @@ const CredsList: FC<CredsListProps> = ({ filter = {} }) => {
)}
{visibleCredentials.map((cred) => (
<CredItem
- canManage={canManageCredentials}
cred={cred}
- extraMenuItems={shareItems(cred)}
key={cred.id}
tags={
!!cred.shares?.length && (
<Tag>{t('creds.share.badge', { count: cred.shares.length })}</Tag>
)
}
- onDelete={(id) => deleteMutation.mutate(id)}
- onEdit={canManageCredentials ? handleEdit : undefined}
- onView={handleView}
+ onClick={handleOpen}
/>
))}
</Flexbox>
diff --git a/src/features/Settings/creds/features/EditCredModal/EditKVForm.tsx b/src/features/Settings/creds/features/EditCredModal/EditKVForm.tsx
index d29a38df746..7e355b77c30 100644
--- a/src/features/Settings/creds/features/EditCredModal/EditKVForm.tsx
+++ b/src/features/Settings/creds/features/EditCredModal/EditKVForm.tsx
@@ -135,7 +135,9 @@ const EditKVForm: FC<EditKVFormProps> = ({ cred, credsApi, onCancel, onSuccess,
</Form.Field>
<CredFormFooter>
- <Button onClick={onCancel}>{t('creds.form.cancel')}</Button>
+ <Button type="fill" onClick={onCancel}>
+ {t('creds.form.cancel')}
+ </Button>
<Button
disabled={!canManageCredentials}
htmlType="submit"
diff --git a/src/features/Settings/creds/features/EditCredModal/EditMetaForm.tsx b/src/features/Settings/creds/features/EditCredModal/EditMetaForm.tsx
index 09a8aaab190..db84a93d76b 100644
--- a/src/features/Settings/creds/features/EditCredModal/EditMetaForm.tsx
+++ b/src/features/Settings/creds/features/EditCredModal/EditMetaForm.tsx
@@ -71,7 +71,9 @@ const EditMetaForm: FC<EditMetaFormProps> = ({ cred, credsApi, onCancel, onSucce
</Form.Field>
<CredFormFooter>
- <Button onClick={onCancel}>{t('creds.form.cancel')}</Button>
+ <Button type="fill" onClick={onCancel}>
+ {t('creds.form.cancel')}
+ </Button>
<Button
disabled={!canManageCredentials}
htmlType="submit"
diff --git a/src/features/Settings/creds/features/KVPairsField.tsx b/src/features/Settings/creds/features/KVPairsField.tsx
index 81ad4531bea..098ec8fbc06 100644
--- a/src/features/Settings/creds/features/KVPairsField.tsx
+++ b/src/features/Settings/creds/features/KVPairsField.tsx
@@ -77,7 +77,7 @@ const KVPairsField: FC<KVPairsFieldProps> = ({ disabled, hint, type }) => {
disabled={disabled}
icon={Plus}
size={'small'}
- type={'text'}
+ type={'fill'}
onClick={() => add({ key: '', value: '' })}
>
{type === 'kv-env' ? t('creds.form.addEnvVar') : t('creds.form.addHeader')}
diff --git a/src/features/Settings/creds/features/ShareCredModal.tsx b/src/features/Settings/creds/features/ShareCredModal.tsx
index c8673b228ba..9f26102c1a5 100644
--- a/src/features/Settings/creds/features/ShareCredModal.tsx
+++ b/src/features/Settings/creds/features/ShareCredModal.tsx
@@ -207,7 +207,11 @@ const ShareCredContent = memo<ShareCredContentProps>(({ credId }) => {
{scopeLabel(sharedVisibility.get(workspace.id)!)}
</Tag>
</Flexbox>
- <Button size={'small'} onClick={() => handleRevoke(workspace.id, workspace.name)}>
+ <Button
+ size={'small'}
+ type={'fill'}
+ onClick={() => handleRevoke(workspace.id, workspace.name)}
+ >
{tSetting('creds.share.revoke')}
</Button>
</Flexbox>
diff --git a/src/features/Settings/creds/features/VaultFilterBar.tsx b/src/features/Settings/creds/features/VaultFilterBar.tsx
index 3baf56241d0..da2d16abcf4 100644
--- a/src/features/Settings/creds/features/VaultFilterBar.tsx
+++ b/src/features/Settings/creds/features/VaultFilterBar.tsx
@@ -25,8 +25,8 @@ interface VaultFilterBarProps {
/**
* The vault's filter row, under the tabs and the create button: one tab per
- * credential type with its count on the left, the search box (and any extra
- * filters) on the right.
+ * credential type with its count on the left, the search box filling the rest
+ * of the row (and any extra filters) on the right.
*/
const VaultFilterBar: FC<VaultFilterBarProps> = ({ children, creds, onChange, value }) => {
const { t } = useTranslation('setting');
@@ -36,6 +36,7 @@ const VaultFilterBar: FC<VaultFilterBarProps> = ({ children, creds, onChange, va
<Flexbox horizontal align={'center'} gap={8} justify={'space-between'} wrap={'wrap'}>
<Segmented
value={value.type ?? 'all'}
+ variant={'outlined'}
options={(['all', ...CRED_TYPES] as CredTypeFilterValue[]).map((option) => ({
label: (
<span>
@@ -47,8 +48,8 @@ const VaultFilterBar: FC<VaultFilterBarProps> = ({ children, creds, onChange, va
}))}
onChange={(next) => onChange({ ...value, type: next as CredTypeFilterValue })}
/>
- {/* Takes the rest of the row and shrinks the search box before wrapping,
- so the tabs, search and visibility filter share one line at settings
+ {/* Takes the rest of the row, the search box stretching across it, so
+ the tabs, search and visibility filter share one line at settings
widths; a very narrow pane still wraps each control onto its own line. */}
<Flexbox
horizontal
@@ -61,7 +62,7 @@ const VaultFilterBar: FC<VaultFilterBarProps> = ({ children, creds, onChange, va
<SearchBar
allowClear
placeholder={t('creds.searchPlaceholder')}
- style={{ flex: '1 1 140px', maxWidth: 240, minWidth: 140 }}
+ style={{ flex: '1 1 140px', minWidth: 140 }}
value={value.keyword ?? ''}
variant={'filled'}
onChange={(e) => onChange({ ...value, keyword: e.target.value })}
diff --git a/src/features/Settings/creds/features/ViewCredModal/Content.tsx b/src/features/Settings/creds/features/ViewCredModal/Content.tsx
index 3aea656c933..9c4aabcf290 100644
--- a/src/features/Settings/creds/features/ViewCredModal/Content.tsx
+++ b/src/features/Settings/creds/features/ViewCredModal/Content.tsx
@@ -1,191 +1,280 @@
'use client';
import { type UserCredSummary } from '@lobechat/types';
-import { Alert, CopyButton, Descriptions, Flexbox, Text } from '@lobehub/ui';
+import {
+ ActionIcon,
+ Alert,
+ Button,
+ confirmModal,
+ CopyButton,
+ Flexbox,
+ Icon,
+ toast,
+ useModalContext,
+} from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import { useQuery } from '@tanstack/react-query';
-import { Eye, EyeOff } from 'lucide-react';
-import { type FC, useState } from 'react';
+import { Eye, EyeOff, type LucideIcon } from 'lucide-react';
+import { type FC, type ReactNode, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { ArticleSkeleton } from '@/components/Skeleton';
-import { densityTokens } from '@/styles/density.stylex';
+import SkeletonBar from '@/components/Skeleton/Bar';
import { type CredsApi } from '../useCredsApi';
+// The theme's card border (light: colorFill, dark: colorFillSecondary), the
+// line Surface draws; colorBorderSecondary vanishes on a dark modal.
+const FIELD_BORDER = 'var(--lobe-fill-border)';
+
const styles = stylex.create({
- kvKey: {
- minWidth: '140px',
- paddingBlock: '8px',
- paddingInline: densityTokens['--lobe-density-content-gap'],
- borderTopLeftRadius: cssVar.borderRadius,
- borderTopRightRadius: '0',
- borderBottomRightRadius: '0',
- borderBottomLeftRadius: cssVar.borderRadius,
- fontFamily: cssVar.fontFamilyCode,
- fontSize: '13px',
- color: cssVar.colorTextSecondary,
- backgroundColor: cssVar.colorFillQuaternary,
- backgroundImage: 'none',
- },
- kvRow: {
- display: 'flex',
- alignItems: 'stretch',
+ code: { fontFamily: cssVar.fontFamilyCode, fontSize: '13px' },
+ fields: {
+ overflow: 'hidden',
borderWidth: '1px',
borderStyle: 'solid',
- borderColor: cssVar.colorBorderSecondary,
- borderRadius: cssVar.borderRadius,
- marginBlockEnd: { 'default': null, ':not(:last-child)': '8px' },
+ borderColor: FIELD_BORDER,
+ borderRadius: cssVar.borderRadiusLG,
},
- kvValue: {
+ footer: {
display: 'flex',
- flex: '1',
+ flexWrap: 'wrap',
gap: '8px',
alignItems: 'center',
justifyContent: 'space-between',
- paddingBlock: '8px',
- paddingInline: densityTokens['--lobe-density-content-gap'],
- borderTopLeftRadius: '0',
- borderTopRightRadius: cssVar.borderRadius,
- borderBottomRightRadius: cssVar.borderRadius,
- borderBottomLeftRadius: '0',
- fontFamily: cssVar.fontFamilyCode,
+ marginBlockStart: '20px',
+ },
+ label: {
+ overflow: 'hidden',
+ flexShrink: 0,
+ width: '96px',
fontSize: '13px',
- backgroundColor: cssVar.colorBgContainer,
- backgroundImage: 'none',
+ color: cssVar.colorTextTertiary,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
},
- maskedValue: { color: cssVar.colorTextQuaternary, letterSpacing: '2px' },
- toggleBtn: {
- cursor: 'pointer',
+ // A stored value's name (`OPENAI_API_KEY`) keeps its full width up to half the row.
+ labelFit: { width: 'auto', minWidth: '96px', maxWidth: '50%' },
+ masked: { letterSpacing: '2px' },
+ row: {
display: 'flex',
+ gap: '12px',
alignItems: 'center',
- justifyContent: 'center',
- padding: '4px',
- borderRadius: cssVar.borderRadiusSM,
- color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorText },
- transition: 'all 0.2s',
- backgroundColor: { 'default': null, ':hover': cssVar.colorFillSecondary },
- backgroundImage: { 'default': null, ':hover': 'none' },
+ minHeight: '44px',
+ paddingBlock: '8px',
+ paddingInline: '14px',
+ borderBlockEndWidth: { 'default': '1px', ':last-child': '0' },
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: FIELD_BORDER,
+ },
+ value: {
+ overflow: 'hidden',
+ flex: '1',
+ minWidth: 0,
+ fontSize: '14px',
+ color: cssVar.colorText,
+ overflowWrap: 'anywhere',
},
- valuesSection: { marginBlockStart: '16px' },
- valuesTitle: { marginBlockEnd: '12px', fontWeight: 500 },
});
-const maskValue = (value: string): string => {
- if (value.length <= 4) return '••••••••';
- return '••••••••' + value.slice(-4);
-};
+const MASK = '••••••••••••';
-interface KVRowProps {
- keyName: string;
- value: string;
+interface FieldRowProps {
+ children: ReactNode;
+ extra?: ReactNode;
+ label: ReactNode;
+ mono?: boolean;
}
-const KVRow: FC<KVRowProps> = ({ keyName, value }) => {
+const FieldRow: FC<FieldRowProps> = ({ children, extra, label, mono }) => (
+ <div {...stylex.props(styles.row)}>
+ <div
+ {...stylex.props(styles.label, mono && styles.code, mono && styles.labelFit)}
+ title={mono && typeof label === 'string' ? label : undefined}
+ >
+ {label}
+ </div>
+ <div {...stylex.props(styles.value, mono && styles.code)}>{children}</div>
+ {extra}
+ </div>
+);
+
+/** One stored value: masked until revealed, copyable either way. */
+const SecretRow: FC<{ name: string; value: string }> = ({ name, value }) => {
+ const { t } = useTranslation('setting');
const [visible, setVisible] = useState(false);
return (
- <div {...stylex.props(styles.kvRow)}>
- <div {...stylex.props(styles.kvKey)}>{keyName}</div>
- <div {...stylex.props(styles.kvValue)}>
- <Text
- as={'span'}
- className={stylex.props(!visible && styles.maskedValue).className}
- style={{
- flex: 1,
- fontFamily: cssVar.fontFamilyCode,
- fontSize: 13,
- wordBreak: 'break-all',
- }}
- >
- {visible ? value : maskValue(value)}
- </Text>
- <Flexbox horizontal align={'center'} gap={4}>
- <div {...stylex.props(styles.toggleBtn)} onClick={() => setVisible(!visible)}>
- {visible ? <EyeOff size={16} /> : <Eye size={16} />}
- </div>
+ <FieldRow
+ mono
+ label={name}
+ extra={
+ <Flexbox horizontal align={'center'} gap={2}>
+ <ActionIcon
+ icon={visible ? EyeOff : Eye}
+ size={'small'}
+ title={t(visible ? 'creds.view.hide' : 'creds.view.show')}
+ onClick={() => setVisible(!visible)}
+ />
<CopyButton content={value} size={'small'} />
</Flexbox>
- </div>
- </div>
+ }
+ >
+ <span {...stylex.props(styles.code, !visible && styles.masked)}>
+ {visible ? value : MASK}
+ </span>
+ </FieldRow>
);
};
+/** A row-specific action (share, publish, unshare…) offered in the detail footer. */
+export interface CredDetailAction {
+ /** Danger actions sit on the left beside Remove; the rest before Edit. */
+ danger?: boolean;
+ icon?: LucideIcon;
+ key: string;
+ label: string;
+ onClick: () => void;
+}
+
export interface ViewCredModalContentProps {
+ /** Row-specific actions; each closes the detail before it runs. */
+ actions?: CredDetailAction[];
+ /** Whether a key-value item's stored values may be decrypted and shown. */
+ canReadValues?: boolean;
cred: UserCredSummary;
credsApi: CredsApi;
+ /** Removes the item after a confirmation; no Remove button when omitted. */
+ onDelete?: (id: number) => Promise<unknown>;
+ /** Opens the edit form; no Edit button when omitted. */
+ onEdit?: (cred: UserCredSummary) => void;
}
-const ViewCredModalContent: FC<ViewCredModalContentProps> = ({ cred, credsApi }) => {
+/**
+ * A vault item opened from its row: its fields as one bordered list (a
+ * key-value item's stored values included, masked), with Remove on the left of
+ * the footer and Edit / Done on the right.
+ */
+const ViewCredModalContent: FC<ViewCredModalContentProps> = ({
+ actions = [],
+ canReadValues = false,
+ cred,
+ credsApi,
+ onDelete,
+ onEdit,
+}) => {
const { t } = useTranslation('setting');
+ const { close } = useModalContext();
+ const isKV = cred.type === 'kv-env' || cred.type === 'kv-header';
+ const showValues = isKV && canReadValues;
const { data, isLoading, error } = useQuery({
- queryFn: () =>
- credsApi.client.get.query({
- decrypt: true,
- id: cred.id,
- }),
+ enabled: showValues,
+ queryFn: () => credsApi.client.get.query({ decrypt: true, id: cred.id }),
queryKey: ['cred-plaintext', cred.id],
});
- const values = (data as any)?.plaintext || {};
- const valueEntries = Object.entries(values);
+ const values = Object.entries<string>((data as any)?.plaintext ?? {});
+
+ const handleRemove = () => {
+ if (!onDelete) return;
+ confirmModal({
+ content: t('creds.actions.deleteConfirm.content'),
+ okButtonProps: { danger: true },
+ okText: t('creds.actions.deleteConfirm.ok'),
+ onOk: async () => {
+ try {
+ await onDelete(cred.id);
+ close();
+ } catch {
+ toast.error(t('creds.errors.deleteFailed'));
+ }
+ },
+ title: t('creds.actions.deleteConfirm.title'),
+ });
+ };
- if (isLoading) {
- return <ArticleSkeleton rows={3} />;
- }
+ const runAction = (action: CredDetailAction) => () => {
+ close();
+ action.onClick();
+ };
+
+ const renderAction = (action: CredDetailAction) => (
+ <Button
+ danger={action.danger}
+ icon={action.icon ? <Icon icon={action.icon} /> : undefined}
+ key={action.key}
+ type={action.danger ? 'text' : 'fill'}
+ onClick={runAction(action)}
+ >
+ {action.label}
+ </Button>
+ );
- if (error) {
- return (
- <Alert
- showIcon
- description={(error as Error).message}
- message={t('creds.view.error')}
- type={'error'}
- />
- );
- }
+ const handleEdit = () => {
+ close();
+ onEdit?.(cred);
+ };
return (
<>
- <Alert
- showIcon
- message={t('creds.view.warning')}
- style={{ marginBottom: 16 }}
- type={'warning'}
- />
- <Descriptions
- bordered
- items={[
- { children: cred.name, key: 'name', label: t('creds.table.name') },
- { children: <code>{cred.key}</code>, key: 'key', label: t('creds.table.key') },
- {
- children: cred.type ? t(`creds.types.${cred.type}` as any) : '-',
- key: 'type',
- label: t('creds.table.type'),
- },
- ]}
- />
-
- {valueEntries.length > 0 && (
- <div {...stylex.props(styles.valuesSection)}>
- <div {...stylex.props(styles.valuesTitle)}>{t('creds.view.values')}</div>
- {valueEntries.map(([key, value]) => (
- <KVRow key={key} keyName={key} value={String(value)} />
+ <div {...stylex.props(styles.fields)}>
+ <FieldRow label={t('creds.table.type')}>{t(`creds.types.${cred.type}`)}</FieldRow>
+ <FieldRow label={t('creds.table.key')}>
+ <span {...stylex.props(styles.code)}>{cred.key}</span>
+ </FieldRow>
+ {cred.type === 'oauth' && cred.oauthUsername && (
+ <FieldRow label={t('creds.detail.account')}>{cred.oauthUsername}</FieldRow>
+ )}
+ {cred.type === 'file' && cred.fileName && (
+ <FieldRow label={t('creds.form.file')}>{cred.fileName}</FieldRow>
+ )}
+ {cred.description && (
+ <FieldRow label={t('creds.form.description')}>{cred.description}</FieldRow>
+ )}
+ {showValues &&
+ (isLoading ? (
+ <FieldRow label={<SkeletonBar height={12} width={72} />}>
+ <SkeletonBar height={12} width={160} />
+ </FieldRow>
+ ) : (
+ values.map(([name, value]) => (
+ <SecretRow key={name} name={name} value={String(value)} />
+ ))
))}
- </div>
- )}
+ </div>
- {valueEntries.length === 0 && cred.type === 'oauth' && (
+ {error && (
<Alert
showIcon
- description={t('creds.view.oauthNote')}
- message={t('creds.view.noValues')}
- style={{ marginTop: 16 }}
- type={'info'}
+ description={(error as Error).message}
+ message={t('creds.view.error')}
+ style={{ marginTop: 12 }}
+ type={'error'}
/>
)}
+
+ <div {...stylex.props(styles.footer)}>
+ <Flexbox horizontal align={'center'} gap={4}>
+ {onDelete && (
+ <Button danger type={'text'} onClick={handleRemove}>
+ {t('creds.actions.remove')}
+ </Button>
+ )}
+ {actions.filter((action) => action.danger).map(renderAction)}
+ </Flexbox>
+ <Flexbox horizontal align={'center'} gap={8} style={{ marginInlineStart: 'auto' }}>
+ {actions.filter((action) => !action.danger).map(renderAction)}
+ {onEdit && (
+ <Button type={'fill'} onClick={handleEdit}>
+ {t('creds.actions.edit')}
+ </Button>
+ )}
+ <Button type={'primary'} onClick={close}>
+ {t('creds.actions.done')}
+ </Button>
+ </Flexbox>
+ </div>
</>
);
};
diff --git a/src/features/Settings/creds/features/ViewCredModal/index.tsx b/src/features/Settings/creds/features/ViewCredModal/index.tsx
index 9107f55042f..91ccdcdb79d 100644
--- a/src/features/Settings/creds/features/ViewCredModal/index.tsx
+++ b/src/features/Settings/creds/features/ViewCredModal/index.tsx
@@ -1,7 +1,6 @@
'use client';
import { createModal, type ModalInstance } from '@lobehub/ui';
-import { t } from 'i18next';
import CredModalTitle from '../CredModalTitle';
import ViewCredModalContent, { type ViewCredModalContentProps } from './Content';
@@ -14,11 +13,6 @@ export const createViewCredModal = (props: ViewCredModalContentProps): ModalInst
styles: {
content: { paddingBlock: 16, paddingInline: 24 },
},
- title: (
- <CredModalTitle
- title={t('creds.view.title', { name: props.cred.name, ns: 'setting' })}
- type={props.cred.type}
- />
- ),
- width: 'min(90vw, 600px)',
+ title: <CredModalTitle cred={props.cred} title={props.cred.name} type={props.cred.type} />,
+ width: 'min(90vw, 480px)',
});
diff --git a/src/features/Settings/creds/features/WorkspaceCredsList.test.tsx b/src/features/Settings/creds/features/WorkspaceCredsList.test.tsx
index fd30b3d07ea..200a941165b 100644
--- a/src/features/Settings/creds/features/WorkspaceCredsList.test.tsx
+++ b/src/features/Settings/creds/features/WorkspaceCredsList.test.tsx
@@ -1,5 +1,5 @@
import { type UserCredSummary } from '@lobechat/types';
-import { render, screen, within } from '@testing-library/react';
+import { fireEvent, render, screen, within } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import { type CredsApi } from './useCredsApi';
@@ -15,6 +15,9 @@ vi.mock('@/hooks/usePermission', () => ({
vi.mock('@/libs/trpc/client', () => ({ lambdaClient: { market: { creds: {} } } }));
+const { createViewCredModal } = vi.hoisted(() => ({ createViewCredModal: vi.fn() }));
+vi.mock('./ViewCredModal', () => ({ createViewCredModal }));
+
const cred = (overrides: Partial<UserCredSummary>): UserCredSummary =>
({
createdAt: '2026-11-19T00:00:00.000Z',
@@ -86,4 +89,25 @@ describe('WorkspaceCredsList', () => {
// personal credential shared in stays readable by its owner.
expect(screen.getAllByText('creds.writeOnly.tag')).toHaveLength(1);
});
+
+ it('opens the detail from the row, carrying its remove, edit and visibility actions', () => {
+ render(
+ <WorkspaceCredsList
+ credsApi={credsApiWith([
+ cred({ id: 2, key: 'MY_TOKEN', name: 'My token', visibility: 'private' }),
+ ])}
+ />,
+ );
+
+ // No "..." menu on the row any more: the row itself is the button.
+ expect(screen.queryByTitle('more')).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: /My token/ }));
+
+ expect(createViewCredModal).toHaveBeenCalledTimes(1);
+ const props = createViewCredModal.mock.calls[0][0];
+ expect(props.cred.id).toBe(2);
+ expect(props.onDelete).toBeTypeOf('function');
+ expect(props.onEdit).toBeTypeOf('function');
+ expect(props.actions.map((action: { key: string }) => action.key)).toContain('publish');
+ });
});
diff --git a/src/features/Settings/creds/features/WorkspaceCredsList.tsx b/src/features/Settings/creds/features/WorkspaceCredsList.tsx
index 32b00712563..59b95d0ae59 100644
--- a/src/features/Settings/creds/features/WorkspaceCredsList.tsx
+++ b/src/features/Settings/creds/features/WorkspaceCredsList.tsx
@@ -1,8 +1,8 @@
'use client';
import { type UserCredSummary } from '@lobechat/types';
-import { confirmModal, Empty, Flexbox, Icon, Tag, toast, Tooltip } from '@lobehub/ui';
-import { EyeOffIcon, GlobeIcon, Link2Off } from 'lucide-react';
+import { confirmModal, Empty, Flexbox, Tag, toast, Tooltip } from '@lobehub/ui';
+import { EyeOffIcon, GlobeIcon } from 'lucide-react';
import { type FC } from 'react';
import { useTranslation } from 'react-i18next';
@@ -22,6 +22,7 @@ import CredItem from './CredItem';
import { createEditCredModal } from './EditCredModal';
import { type CredsApi } from './useCredsApi';
import { createViewCredModal } from './ViewCredModal';
+import { type CredDetailAction } from './ViewCredModal/Content';
type Visibility = 'private' | 'public';
@@ -127,11 +128,11 @@ const WorkspaceCredsList: FC<WorkspaceCredsListProps> = ({
{visibleCredentials.map((cred) => {
const access = workspaceCredRowAccess(cred, { isAdmin, myAccountId });
const writeOnly = isWriteOnlyCredRow(cred);
- const extraMenuItems = [
+ const actions: CredDetailAction[] = [
...(access.publish
? [
{
- icon: <Icon icon={GlobeIcon} />,
+ icon: GlobeIcon,
key: 'publish',
label: t('creds.visibility.publish'),
onClick: () => handlePublish(cred),
@@ -141,7 +142,7 @@ const WorkspaceCredsList: FC<WorkspaceCredsListProps> = ({
...(access.makePrivate
? [
{
- icon: <Icon icon={EyeOffIcon} />,
+ icon: EyeOffIcon,
key: 'makePrivate',
label: t('makePrivate', { ns: 'common' }),
onClick: () => handleMakePrivate(cred),
@@ -152,7 +153,6 @@ const WorkspaceCredsList: FC<WorkspaceCredsListProps> = ({
? [
{
danger: true,
- icon: <Icon icon={Link2Off} />,
key: 'unshare',
label: t('creds.share.revoke'),
onClick: () => handleUnshare(cred),
@@ -163,9 +163,7 @@ const WorkspaceCredsList: FC<WorkspaceCredsListProps> = ({
return (
<CredItem
- canManage={access.manage}
cred={cred}
- extraMenuItems={extraMenuItems}
key={cred.id}
titleSuffix={cred.visibility === 'private' && <PrivateLockIcon />}
tags={
@@ -183,22 +181,23 @@ const WorkspaceCredsList: FC<WorkspaceCredsListProps> = ({
)
)
}
- onDelete={access.manage ? handleDelete : undefined}
- onEdit={
- access.manage
- ? (cred) =>
- createEditCredModal({
- cred,
- credsApi,
- onSuccess: () => refetch(),
- writeOnly,
- })
- : undefined
- }
- onView={
- access.manage && !writeOnly
- ? (cred) => createViewCredModal({ cred, credsApi })
- : undefined
+ onClick={() =>
+ createViewCredModal({
+ actions,
+ canReadValues: access.manage && !writeOnly,
+ cred,
+ credsApi,
+ onDelete: access.manage ? handleDelete : undefined,
+ onEdit: access.manage
+ ? () =>
+ createEditCredModal({
+ cred,
+ credsApi,
+ onSuccess: () => refetch(),
+ writeOnly,
+ })
+ : undefined,
+ })
}
/>
);
diff --git a/src/features/Settings/creds/features/style.ts b/src/features/Settings/creds/features/style.ts
index 0192e1e52fd..dbc79c2ade4 100644
--- a/src/features/Settings/creds/features/style.ts
+++ b/src/features/Settings/creds/features/style.ts
@@ -4,6 +4,16 @@ import * as stylex from '@stylexjs/stylex';
import { densityTokens } from '@/styles/density.stylex';
export const styles = stylex.create({
+ // The row opens the item: a hover wash that reaches 8px past the content,
+ // inside the list card's own padding.
+ clickable: {
+ cursor: 'pointer',
+ marginInline: '-8px',
+ paddingInline: '8px',
+ borderRadius: cssVar.borderRadiusLG,
+ transition: 'background-color 0.2s',
+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillQuaternary },
+ },
container: {
paddingBlock: densityTokens['--lobe-density-content-gap'],
paddingInline: 0,