dify/web/app/components/access-rules-editor/open-scope-option.tsx
Wu Tianwei 33edf97f81
feat: RBAC (#37107)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: fatelei <fatelei@gmail.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: 盐粒 Yanli <yanli@dify.ai>
Co-authored-by: Charles Yao <chongbinyao33@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: yunlu.wen <yunlu.wen@dify.ai>
Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
Co-authored-by: Jingyi <jingyi.qi@dify.ai>
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
Co-authored-by: Joel <iamjoel007@gmail.com>
Co-authored-by: hjlarry <hjlarry@163.com>
Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
Co-authored-by: gigglewang <gigglewang@dify.ai>
Co-authored-by: chariri <w@chariri.moe>
Co-authored-by: Evan <2869018789@qq.com>
Co-authored-by: zyssyz123 <916125788@qq.com>
2026-06-18 16:35:29 +00:00

46 lines
1.3 KiB
TypeScript

'use client'
import type { ResourceOpenScope } from '@/models/access-control'
import { cn } from '@langgenius/dify-ui/cn'
import { memo } from 'react'
type OpenScopeOptionProps = {
value: ResourceOpenScope
selected: boolean
disabled: boolean
title: string
description: string
onChange?: (openScope: ResourceOpenScope) => void
}
function OpenScopeOption({
value,
selected,
disabled,
title,
description,
onChange,
}: OpenScopeOptionProps) {
return (
<button
type="button"
aria-pressed={selected}
disabled={disabled || !onChange}
className={cn(
'flex min-h-19 flex-col items-start rounded-xl border bg-components-panel-bg px-7 py-3 text-left shadow-xs outline-hidden transition-colors',
'focus-visible:ring-2 focus-visible:ring-state-accent-solid',
selected
? 'border-[1.5px] border-state-accent-solid'
: 'border-components-panel-border hover:border-divider-deep',
(disabled || !onChange) && 'cursor-not-allowed opacity-70',
)}
onClick={() => onChange?.(value)}
>
<div className="system-sm-semibold text-text-secondary">{title}</div>
<p className="mt-0.5 system-xs-regular text-text-tertiary">{description}</p>
</button>
)
}
export default memo(OpenScopeOption)