fix: standardize all @lib imports and add missing rbac utility

This commit is contained in:
Haitao Pan 2026-02-03 03:05:04 +08:00
parent d266e6e90c
commit 9c0372694e
8 changed files with 21 additions and 7 deletions

View File

@ -1,7 +1,7 @@
'use client'
import { InsightState } from '../../insight/store/urlState'
import { formatDuration } from '@lib/format'
import { formatDuration } from '../../../lib/format'
interface TimeRangePickerProps {
state: InsightState

View File

@ -2,7 +2,7 @@
import { useMemo, useState } from 'react'
import { InsightState } from '../../insight/store/urlState'
import { canAccessSnippet } from '@lib/rbac'
import { canAccessSnippet } from '../../../lib/rbac'
interface Snippet {
name: string

View File

@ -1,7 +1,7 @@
'use client'
import { LogEntry } from '../../insight/services/adapters/logs'
import { getLogLevelColor } from '@lib/format'
import { getLogLevelColor } from '../../../lib/format'
interface LogsTableProps {
logs: LogEntry[]

View File

@ -1,7 +1,7 @@
'use client'
import { LogEntry } from '../../insight/services/adapters/logs'
import { getLogLevelColor } from '@lib/format'
import { getLogLevelColor } from '../../../lib/format'
interface LogsViewerProps {
logs: LogEntry[]

View File

@ -1,7 +1,7 @@
'use client'
import { PrometheusResponse } from '../../insight/services/adapters/prometheus'
import { formatNumber } from '@lib/format'
import { formatNumber } from '../../../lib/format'
interface MetricsChartProps {
series: PrometheusResponse[]

View File

@ -1,7 +1,7 @@
'use client'
import { PrometheusResponse } from '../../insight/services/adapters/prometheus'
import { formatNumber } from '@lib/format'
import { formatNumber } from '../../../lib/format'
interface MetricsTableProps {
series: PrometheusResponse[]

View File

@ -1,7 +1,7 @@
'use client'
import { PrometheusResponse } from '../../insight/services/adapters/prometheus'
import { formatNumber } from '@lib/format'
import { formatNumber } from '../../../lib/format'
interface MetricsTopStatsProps {
series: PrometheusResponse[]

14
workbench/src/lib/rbac.ts Normal file
View File

@ -0,0 +1,14 @@
export interface SnippetRBAC {
roles?: string[]
environments?: string[]
}
export function canAccessSnippet(rbac: SnippetRBAC | undefined, context: {
role: string
env: string
}) {
if (!rbac) return true
if (rbac.roles && !rbac.roles.includes(context.role)) return false
if (rbac.environments && !rbac.environments.includes(context.env)) return false
return true
}