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 Remove, Unshare and confirmation Cancel use the fill variant (#23701)

Lobehub Coder58983a12422e
diff --git a/src/features/Settings/creds/features/ShareCredModal.tsx b/src/features/Settings/creds/features/ShareCredModal.tsx
index 9f26102c1a5..f0909ffd4ee 100644
--- a/src/features/Settings/creds/features/ShareCredModal.tsx
+++ b/src/features/Settings/creds/features/ShareCredModal.tsx
@@ -1,17 +1,7 @@
'use client';
import { type UserCredSummary } from '@lobechat/types';
-import {
- Button,
- confirmModal,
- createModal,
- Flexbox,
- Icon,
- Select,
- Tag,
- Text,
- toast,
-} from '@lobehub/ui';
+import { Button, createModal, Flexbox, Icon, Select, Tag, Text, toast } from '@lobehub/ui';
import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import { t } from 'i18next';
@@ -24,6 +14,7 @@ import { useWorkspaces } from '@/business/client/hooks/useWorkspaces';
import { createWorkspaceLambdaClient, lambdaQuery } from '@/libs/trpc/client';
import { densityTokens } from '@/styles/density.stylex';
+import { confirmCredModal } from './confirmCredModal';
import { credErrorKey } from './credError';
type Visibility = 'private' | 'public';
@@ -164,9 +155,9 @@ const ShareCredContent = memo<ShareCredContentProps>(({ credId }) => {
};
const handleRevoke = (workspaceId: string, name: string) =>
- confirmModal({
+ confirmCredModal({
content: tSetting('creds.share.revokeConfirmDesc'),
- okButtonProps: { danger: true },
+ danger: true,
okText: tSetting('creds.share.revoke'),
onOk: async () => {
try {
diff --git a/src/features/Settings/creds/features/ViewCredModal/Content.tsx b/src/features/Settings/creds/features/ViewCredModal/Content.tsx
index 9c4aabcf290..c0827e16925 100644
--- a/src/features/Settings/creds/features/ViewCredModal/Content.tsx
+++ b/src/features/Settings/creds/features/ViewCredModal/Content.tsx
@@ -5,7 +5,6 @@ import {
ActionIcon,
Alert,
Button,
- confirmModal,
CopyButton,
Flexbox,
Icon,
@@ -21,6 +20,7 @@ import { useTranslation } from 'react-i18next';
import SkeletonBar from '@/components/Skeleton/Bar';
+import { confirmCredModal } from '../confirmCredModal';
import { type CredsApi } from '../useCredsApi';
// The theme's card border (light: colorFill, dark: colorFillSecondary), the
@@ -129,7 +129,7 @@ const SecretRow: FC<{ name: string; value: string }> = ({ name, value }) => {
/** 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 actions sit on the left beside Remove (red fill); the rest before Edit. */
danger?: boolean;
icon?: LucideIcon;
key: string;
@@ -153,7 +153,7 @@ export interface ViewCredModalContentProps {
/**
* 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.
+ * the footer and Edit / Done on the right. Every button but Done is the fill variant.
*/
const ViewCredModalContent: FC<ViewCredModalContentProps> = ({
actions = [],
@@ -178,9 +178,9 @@ const ViewCredModalContent: FC<ViewCredModalContentProps> = ({
const handleRemove = () => {
if (!onDelete) return;
- confirmModal({
+ confirmCredModal({
content: t('creds.actions.deleteConfirm.content'),
- okButtonProps: { danger: true },
+ danger: true,
okText: t('creds.actions.deleteConfirm.ok'),
onOk: async () => {
try {
@@ -204,7 +204,7 @@ const ViewCredModalContent: FC<ViewCredModalContentProps> = ({
danger={action.danger}
icon={action.icon ? <Icon icon={action.icon} /> : undefined}
key={action.key}
- type={action.danger ? 'text' : 'fill'}
+ type={'fill'}
onClick={runAction(action)}
>
{action.label}
@@ -255,9 +255,9 @@ const ViewCredModalContent: FC<ViewCredModalContentProps> = ({
)}
<div {...stylex.props(styles.footer)}>
- <Flexbox horizontal align={'center'} gap={4}>
+ <Flexbox horizontal align={'center'} gap={8}>
{onDelete && (
- <Button danger type={'text'} onClick={handleRemove}>
+ <Button danger type={'fill'} onClick={handleRemove}>
{t('creds.actions.remove')}
</Button>
)}
diff --git a/src/features/Settings/creds/features/WorkspaceCredsList.tsx b/src/features/Settings/creds/features/WorkspaceCredsList.tsx
index 59b95d0ae59..a8f403596d0 100644
--- a/src/features/Settings/creds/features/WorkspaceCredsList.tsx
+++ b/src/features/Settings/creds/features/WorkspaceCredsList.tsx
@@ -1,7 +1,7 @@
'use client';
import { type UserCredSummary } from '@lobechat/types';
-import { confirmModal, Empty, Flexbox, Tag, toast, Tooltip } from '@lobehub/ui';
+import { Empty, Flexbox, Tag, toast, Tooltip } from '@lobehub/ui';
import { EyeOffIcon, GlobeIcon } from 'lucide-react';
import { type FC } from 'react';
import { useTranslation } from 'react-i18next';
@@ -15,6 +15,7 @@ import { usePermission } from '@/hooks/usePermission';
import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';
import { lambdaClient } from '@/libs/trpc/client';
+import { confirmCredModal } from './confirmCredModal';
import { isOwnCredRow, isWriteOnlyCredRow, workspaceCredRowAccess } from './credAccess';
import { credErrorKey } from './credError';
import { type CredFilter, filterCreds } from './credFilter';
@@ -80,7 +81,7 @@ const WorkspaceCredsList: FC<WorkspaceCredsListProps> = ({
: credsApi.setVisibility!(cred.id, next);
const handlePublish = (cred: UserCredSummary) =>
- confirmModal({
+ confirmCredModal({
content: <VisibilityConfirmContent variant={'publish'} />,
okText: t('creds.visibility.publish'),
onOk: () => run(() => changeVisibility(cred, 'public')),
@@ -88,18 +89,18 @@ const WorkspaceCredsList: FC<WorkspaceCredsListProps> = ({
});
const handleMakePrivate = (cred: UserCredSummary) =>
- confirmModal({
+ confirmCredModal({
content: <VisibilityConfirmContent variant={'makePrivate'} />,
- okButtonProps: { danger: true },
+ danger: true,
okText: t('makePrivate.confirm.ok', { ns: 'common' }),
onOk: () => run(() => changeVisibility(cred, 'private')),
title: t('makePrivate.confirm.title', { ns: 'common' }),
});
const handleUnshare = (cred: UserCredSummary) =>
- confirmModal({
+ confirmCredModal({
content: t('creds.share.unshareConfirmDesc'),
- okButtonProps: { danger: true },
+ danger: true,
okText: t('creds.share.revoke'),
onOk: () => run(() => lambdaClient.market.creds.unshare.mutate({ id: cred.id })),
title: t('creds.share.unshareConfirmTitle'),
diff --git a/src/features/Settings/creds/features/confirmCredModal.tsx b/src/features/Settings/creds/features/confirmCredModal.tsx
new file mode 100644
index 00000000000..6032c18b7e9
--- /dev/null
+++ b/src/features/Settings/creds/features/confirmCredModal.tsx
@@ -0,0 +1,61 @@
+'use client';
+
+import { Button, createModal, ModalFooter, useModalContext } from '@lobehub/ui';
+import { type ReactNode, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+export interface ConfirmCredModalConfig {
+ content?: ReactNode;
+ /** Red confirm button, for removing or revoking. */
+ danger?: boolean;
+ okText: ReactNode;
+ /** Runs on confirm; the dialog stays open, loading, until it settles, and closes unless it throws. */
+ onOk: () => unknown | Promise<unknown>;
+ title: ReactNode;
+}
+
+const ConfirmBody = ({ content, danger, okText, onOk }: ConfirmCredModalConfig) => {
+ const { t } = useTranslation('common');
+ const { close } = useModalContext();
+ const [loading, setLoading] = useState(false);
+
+ const handleOk = async () => {
+ setLoading(true);
+ try {
+ await onOk();
+ close();
+ } catch {
+ // The caller reports its own failure; keep the dialog open to retry.
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ return (
+ <>
+ {content && <div style={{ padding: '12px 16px' }}>{content}</div>}
+ <ModalFooter>
+ <Button type={'fill'} onClick={close}>
+ {t('cancel')}
+ </Button>
+ <Button danger={danger} loading={loading} type={'primary'} onClick={handleOk}>
+ {okText}
+ </Button>
+ </ModalFooter>
+ </>
+ );
+};
+
+/**
+ * The vault's confirmation dialog: `confirmModal`'s layout, with Cancel in the
+ * fill variant like every other secondary button in the vault (`confirmModal`
+ * offers no way to style its Cancel).
+ */
+export const confirmCredModal = (config: ConfirmCredModalConfig) =>
+ createModal({
+ content: <ConfirmBody {...config} />,
+ footer: null,
+ styles: { content: { padding: 0 } },
+ title: config.title,
+ width: 420,
+ });