mirror of
https://github.com/langgenius/dify.git
synced 2026-05-09 04:36:31 +08:00
tweaks
This commit is contained in:
parent
cfb1e0217f
commit
ae7c534331
@ -79,7 +79,7 @@ function DeveloperApiAccessSection({
|
||||
)
|
||||
}
|
||||
|
||||
function handleRevokeApiKey(_environmentId: string, apiKeyId: string) {
|
||||
function handleRevokeApiKey(apiKeyId: string) {
|
||||
revokeApiKey.mutate({
|
||||
params: {
|
||||
appInstanceId: appId,
|
||||
@ -146,7 +146,6 @@ export function AccessTab({ instanceId: appId }: {
|
||||
const apiEnabled = accessConfig?.developerApi?.enabled ?? false
|
||||
const apiKeys = accessConfig?.developerApi?.apiKeys ?? []
|
||||
const handleSetEnvironmentAccessPolicy = async (
|
||||
appId: string,
|
||||
environmentId: string,
|
||||
accessMode: string,
|
||||
subjects: AccessSubject[],
|
||||
|
||||
@ -16,7 +16,7 @@ import { environmentName } from '../../utils'
|
||||
export function ApiKeyRow({ apiKey, onCopy, onRevoke }: {
|
||||
apiKey: DeveloperAPIKeySummary
|
||||
onCopy: (apiKeyId: string) => Promise<string>
|
||||
onRevoke: () => void
|
||||
onRevoke: (apiKeyId: string) => void
|
||||
}) {
|
||||
const { t } = useTranslation('deployments')
|
||||
const [copied, setCopied] = useState(false)
|
||||
@ -61,7 +61,7 @@ export function ApiKeyRow({ apiKey, onCopy, onRevoke }: {
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onRevoke}
|
||||
onClick={() => apiKey.id && onRevoke(apiKey.id)}
|
||||
aria-label={t('access.revoke')}
|
||||
className="flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-text-tertiary hover:bg-state-destructive-hover hover:text-text-destructive"
|
||||
>
|
||||
|
||||
@ -15,7 +15,7 @@ type DeveloperApiSectionProps = {
|
||||
onToggle: (enabled: boolean) => void
|
||||
onGenerate: (environmentId: string) => void
|
||||
onCopyApiKey: (apiKeyId: string) => Promise<string>
|
||||
onRevoke: (environmentId: string, apiKeyId: string) => void
|
||||
onRevoke: (apiKeyId: string) => void
|
||||
onClearCreatedToken: () => void
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ export function DeveloperApiSection({
|
||||
key={apiKey.id}
|
||||
apiKey={apiKey}
|
||||
onCopy={onCopyApiKey}
|
||||
onRevoke={() => onRevoke(environmentId, apiKey.id!)}
|
||||
onRevoke={onRevoke}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
|
||||
@ -10,7 +10,6 @@ type AccessPermissionsSectionProps = {
|
||||
environments: ConsoleEnvironmentSummary[]
|
||||
policies: AccessPermission[]
|
||||
onSetPolicy: (
|
||||
appId: string,
|
||||
environmentId: string,
|
||||
accessMode: string,
|
||||
subjects: AccessSubject[],
|
||||
|
||||
@ -290,7 +290,6 @@ type EnvironmentPermissionRowProps = {
|
||||
environment: ConsoleEnvironmentSummary
|
||||
summaryPolicy?: AccessPermission
|
||||
onSetPolicy: (
|
||||
appId: string,
|
||||
environmentId: string,
|
||||
accessMode: string,
|
||||
subjects: AccessSubject[],
|
||||
@ -344,7 +343,6 @@ export function EnvironmentPermissionRow({
|
||||
setIsSaving(true)
|
||||
try {
|
||||
await onSetPolicy(
|
||||
appId,
|
||||
environmentId,
|
||||
permissionKeyToAccessMode(nextKind),
|
||||
nextKind === 'specific' ? policySubjects(nextSubjects) : [],
|
||||
|
||||
@ -15,12 +15,6 @@ import {
|
||||
webappUrl,
|
||||
} from '../utils'
|
||||
|
||||
type SwitchableTab = 'deploy' | 'versions' | 'access' | 'settings'
|
||||
|
||||
function tabHref(appId: string, tab: SwitchableTab): string {
|
||||
return `/deployments/${appId}/${tab}`
|
||||
}
|
||||
|
||||
function Section({ title, action, children }: {
|
||||
title: string
|
||||
action?: ReactNode
|
||||
@ -144,7 +138,7 @@ export function OverviewTab({ instanceId }: {
|
||||
<Section
|
||||
title={t('overview.deploymentStatus')}
|
||||
action={(
|
||||
<Button nativeButton={false} size="small" variant="secondary" render={<Link href={tabHref(appId, 'deploy')} />}>
|
||||
<Button nativeButton={false} size="small" variant="secondary" render={<Link href={`/deployments/${appId}/deploy`} />}>
|
||||
{t('overview.viewDeployments')}
|
||||
<span className="i-ri-arrow-right-up-line h-3.5 w-3.5" />
|
||||
</Button>
|
||||
@ -162,7 +156,7 @@ export function OverviewTab({ instanceId }: {
|
||||
{releaseRows.length === 0
|
||||
? canCreateRelease
|
||||
? (
|
||||
<Button nativeButton={false} size="small" variant="primary" render={<Link href={tabHref(appId, 'versions')} />}>
|
||||
<Button nativeButton={false} size="small" variant="primary" render={<Link href={`/deployments/${appId}/versions`} />}>
|
||||
{t('overview.createRelease')}
|
||||
</Button>
|
||||
)
|
||||
@ -201,7 +195,7 @@ export function OverviewTab({ instanceId }: {
|
||||
<Section
|
||||
title={t('overview.accessStatus')}
|
||||
action={(
|
||||
<Button nativeButton={false} size="small" variant="secondary" render={<Link href={tabHref(appId, 'access')} />}>
|
||||
<Button nativeButton={false} size="small" variant="secondary" render={<Link href={`/deployments/${appId}/access`} />}>
|
||||
{t('overview.configureAccess')}
|
||||
<span className="i-ri-arrow-right-up-line h-3.5 w-3.5" />
|
||||
</Button>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import type { DeploymentEnvironmentOption } from '@dify/contracts/enterprise/types.gen'
|
||||
import type { ReactNode } from 'react'
|
||||
import { cn } from '@langgenius/dify-ui/cn'
|
||||
import {
|
||||
@ -23,23 +24,16 @@ type EnvironmentFilterOption = {
|
||||
disabledReason?: string
|
||||
}
|
||||
|
||||
type FilterEnvironment = {
|
||||
id: string
|
||||
name: string
|
||||
disabled?: boolean
|
||||
disabledReason?: string
|
||||
function hasEnvironmentId(env: DeploymentEnvironmentOption): env is DeploymentEnvironmentOption & { id: string } {
|
||||
return Boolean(env.id)
|
||||
}
|
||||
|
||||
function getEnvironmentId(env: FilterEnvironment) {
|
||||
return env.id
|
||||
}
|
||||
|
||||
function getEnvironmentFilterOption(env: FilterEnvironment): EnvironmentFilterOption {
|
||||
function getEnvironmentFilterOption(env: DeploymentEnvironmentOption & { id: string }): EnvironmentFilterOption {
|
||||
return {
|
||||
value: env.id,
|
||||
text: env.name,
|
||||
text: env.name || env.id,
|
||||
icon: <span className="i-ri-stack-line h-[14px] w-[14px]" />,
|
||||
disabled: env.disabled,
|
||||
disabled: env.deployable === false,
|
||||
disabledReason: env.disabledReason,
|
||||
}
|
||||
}
|
||||
@ -50,20 +44,8 @@ export function EnvironmentFilter() {
|
||||
const [envFilter, setEnvFilter] = useQueryState('env', envFilterQueryState)
|
||||
const { data: environmentOptionsReply } = useQuery(consoleQuery.enterprise.appDeploy.listDeploymentEnvironmentOptions.queryOptions())
|
||||
const environmentOptions = environmentOptionsReply?.environments ?? []
|
||||
|
||||
function getFilterEnvironment(env: (typeof environmentOptions)[number]): FilterEnvironment[] {
|
||||
if (!env.id)
|
||||
return []
|
||||
return [{
|
||||
id: env.id,
|
||||
name: env.name || env.id,
|
||||
disabled: env.deployable === false,
|
||||
disabledReason: env.disabledReason,
|
||||
}]
|
||||
}
|
||||
|
||||
const environments = environmentOptions.flatMap(getFilterEnvironment)
|
||||
const envIdSet = new Set(environments.map(getEnvironmentId))
|
||||
const environments = environmentOptions.filter(hasEnvironmentId)
|
||||
const envIdSet = new Set(environments.map(env => env.id))
|
||||
const activeFilter = envFilter === 'all' || envFilter === 'not-deployed' || envIdSet.has(envFilter)
|
||||
? envFilter
|
||||
: 'all'
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
'use client'
|
||||
|
||||
import type { ChangeEvent } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useDebounce } from 'ahooks'
|
||||
import { debounce, useQueryState } from 'nuqs'
|
||||
@ -26,14 +25,6 @@ function DeploymentsSearchInput() {
|
||||
})
|
||||
}
|
||||
|
||||
function handleKeywordsInputChange(e: ChangeEvent<HTMLInputElement>) {
|
||||
handleKeywordsChange(e.target.value)
|
||||
}
|
||||
|
||||
function handleKeywordsClear() {
|
||||
handleKeywordsChange('')
|
||||
}
|
||||
|
||||
return (
|
||||
<Input
|
||||
showLeftIcon
|
||||
@ -41,8 +32,8 @@ function DeploymentsSearchInput() {
|
||||
wrapperClassName="w-[200px]"
|
||||
placeholder={t('filter.searchPlaceholder')}
|
||||
value={keywords}
|
||||
onChange={handleKeywordsInputChange}
|
||||
onClear={handleKeywordsClear}
|
||||
onChange={e => handleKeywordsChange(e.target.value)}
|
||||
onClear={() => handleKeywordsChange('')}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@ -40,10 +40,6 @@ export function environmentHealth(environment?: ConsoleEnvironmentSummary | Envi
|
||||
return status.includes('ready') ? 'ready' : 'degraded'
|
||||
}
|
||||
|
||||
export function releaseId(release?: ConsoleReleaseSummary) {
|
||||
return release?.id ?? ''
|
||||
}
|
||||
|
||||
export function releaseLabel(release?: ConsoleReleaseSummary) {
|
||||
return release?.name || release?.displayId || release?.id || '—'
|
||||
}
|
||||
@ -52,14 +48,6 @@ export function releaseCommit(release?: ConsoleReleaseSummary) {
|
||||
return release?.shortCommitId || release?.commitId || '—'
|
||||
}
|
||||
|
||||
export function runtimeBindingLabel(binding?: RuntimeBindingDisplay) {
|
||||
return binding?.label || binding?.slot || binding?.kind || '—'
|
||||
}
|
||||
|
||||
export function runtimeBindingValue(binding?: RuntimeBindingDisplay) {
|
||||
return binding?.displayValue || binding?.maskedValue || binding?.displayName || '—'
|
||||
}
|
||||
|
||||
export function runtimeBindingSummary(binding?: RuntimeBindingDisplay) {
|
||||
return binding?.label || binding?.slot || binding?.displayName || binding?.displayValue || binding?.maskedValue || binding?.kind || '—'
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user