π€― 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
'use client';
import { createStaticStyles, Icon } from '@lobehub/ui';
import {
AlertTriangleIcon,
CheckIcon,
EyeOffIcon,
FolderIcon,
InfoIcon,
KeyRoundIcon,
type LucideIcon,
UsersIcon,
} from 'lucide-react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { densityVars } from '@/styles/densityVars';
export type VisibilityConfirmVariant = 'makePrivate' | 'publish';
export interface VisibilityConfirmContentProps {
/**
* The resource carries state captured from a running session β an
* environment's home directory, its CLI logins, whatever a setup command
* left behind. Publishing it does not only make the row visible: members
* can run instances of it and reach that state. "Members will see this"
* does not say any of it, so the caller has to ask for the bullet that does.
*/
capturedState?: boolean;
/**
* The resource sits in a library. Going private does not pull it out of one
* β the row stays filed where the author put it and simply stops resolving
* for everyone else β so the dialog has to say that, or the author is left
* guessing whether their library just lost an entry.
*/
inLibrary?: boolean;
variant: VisibilityConfirmVariant;
}
type Tone = 'danger' | 'info' | 'ok';
interface Item {
emphasis?: boolean;
icon: LucideIcon;
key: string;
showIrreversible?: boolean;
tone: Tone;
}
interface VariantConfig {
items: readonly Item[];
}
/** Appended to `publish` when the caller says the resource carries captured session state. */
const CAPTURED_STATE_ITEM: Item = {
emphasis: true,
icon: KeyRoundIcon,
key: 'visibilityConfirm.publish.itemCapturedState',
tone: 'danger',
};
/** Appended to `makePrivate` when the caller says the resource is filed in a library. */
const LIBRARY_ITEM: Item = {
icon: FolderIcon,
key: 'visibilityConfirm.makePrivate.itemLibrary',
tone: 'info',
};
// 3 consequences per direction β the order matters (immediate β follow-on β
// irreversible tail), and mirrors the tone escalation across the pair. Keep
// the "loaded content can't be pulled back" bullet last in both variants so
// readers walk away with the strongest constraint fresh in mind.
//
// No hero icon pill up here on purpose β the modal's own title slot + the
// destructive vs primary button colour already carry the tone signal. An
// extra pill just left a lot of dead white space to the right of a small
// square. Each list row still carries its own tone icon.
const CONFIG: Record<VisibilityConfirmVariant, VariantConfig> = {
makePrivate: {
items: [
{
icon: EyeOffIcon,
key: 'visibilityConfirm.makePrivate.itemAccess',
tone: 'danger',
},
{
icon: AlertTriangleIcon,
key: 'visibilityConfirm.makePrivate.itemReferences',
tone: 'info',
},
{
emphasis: true,
icon: InfoIcon,
key: 'visibilityConfirm.makePrivate.itemLoaded',
showIrreversible: true,
tone: 'danger',
},
],
},
publish: {
items: [
{
icon: UsersIcon,
key: 'visibilityConfirm.publish.itemVisible',
tone: 'info',
},
{ icon: CheckIcon, key: 'visibilityConfirm.publish.itemReversible', tone: 'ok' },
{
emphasis: true,
icon: InfoIcon,
key: 'visibilityConfirm.publish.itemLoaded',
showIrreversible: true,
tone: 'danger',
},
],
},
};
const styles = createStaticStyles(({ css, cssVar }) => ({
list: css`
display: flex;
flex-direction: column;
gap: 8px;
margin: 0;
padding: ${densityVars.contentGap};
border-radius: 8px;
list-style: none;
background: ${cssVar.colorFillQuaternary};
`,
row: css`
display: flex;
gap: 10px;
align-items: flex-start;
font-size: 13px;
line-height: 1.55;
color: ${cssVar.colorText};
`,
rowIcon: css`
flex: none;
margin-block-start: 3px;
color: ${cssVar.colorTextTertiary};
`,
rowIconDanger: css`
color: ${cssVar.colorError};
`,
rowIconOk: css`
color: ${cssVar.colorSuccess};
`,
rowIconInfo: css`
color: ${cssVar.colorInfo};
`,
emphasis: css`
font-weight: 500;
`,
suffix: css`
color: ${cssVar.colorTextTertiary};
`,
}));
const rowIconClass = (tone: Tone) => {
if (tone === 'danger') return styles.rowIconDanger;
if (tone === 'ok') return styles.rowIconOk;
return styles.rowIconInfo;
};
/**
* `VisibilityConfirmContent`
*
* Shared body for the two mirrored confirm dialogs that guard workspace
* visibility transitions:
* - `makePrivate` β destructive, public β private
* - `publish` β constructive, private β public (bidirectional counterpart)
*
* Both directions render a compact 3-item bullet card. Consequences are
* enumerated (not paragraphs) because the user needs to *scan* three specific
* facts β an order-of-magnitude more scannable than the earlier one-sentence
* copy that all three variants used to reuse.
*
* Pass this as `content` to `confirmModal`; the modal keeps its own `title` /
* `okText` / `cancelText` slots so callers stay resource-specific. Tone is
* carried by the destructive vs primary button colour, so we don't need a
* separate hero icon here.
*/
const VisibilityConfirmContent = memo<VisibilityConfirmContentProps>(
({ capturedState, inLibrary, variant }) => {
const { t } = useTranslation('common');
const config = CONFIG[variant];
const irreversibleSuffix = t('visibilityConfirm.irreversible');
// Second-to-last, so the irreversible tail keeps the closing position it
// holds in both variants.
const extra =
variant === 'makePrivate' && inLibrary
? LIBRARY_ITEM
: variant === 'publish' && capturedState
? CAPTURED_STATE_ITEM
: undefined;
const items = extra
? [...config.items.slice(0, -1), extra, ...config.items.slice(-1)]
: config.items;
return (
<ul className={styles.list}>
{items.map((item) => {
const ItemIcon = item.icon;
return (
<li className={styles.row} key={item.key}>
<span className={`${styles.rowIcon} ${rowIconClass(item.tone)}`}>
<Icon icon={ItemIcon} size={14} />
</span>
<span className={item.emphasis ? styles.emphasis : undefined}>
{t(item.key as any)}
{item.showIrreversible && (
<span className={styles.suffix}>{irreversibleSuffix}</span>
)}
</span>
</li>
);
})}
</ul>
);
},
);
VisibilityConfirmContent.displayName = 'VisibilityConfirmContent';
export default VisibilityConfirmContent;