|
|
@@ -16,15 +16,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
For commercial licensing, please contact support@quantumnous.com
|
|
|
*/
|
|
|
-import { getRouteApi, useNavigate } from '@tanstack/react-router'
|
|
|
-import { useCallback, useMemo } from 'react'
|
|
|
+import { getRouteApi } from '@tanstack/react-router'
|
|
|
+import { useCallback } from 'react'
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
|
import { SectionPageLayout } from '@/components/layout'
|
|
|
-import type { NavGroup } from '@/components/layout/types'
|
|
|
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
|
|
import { CacheStatsDialog } from '@/features/system-settings/general/channel-affinity/cache-stats-dialog'
|
|
|
-import { useSidebarConfig } from '@/hooks/use-sidebar-config'
|
|
|
|
|
|
import { UserInfoDialog } from './components/dialogs/user-info-dialog'
|
|
|
import {
|
|
|
@@ -41,7 +39,6 @@ import {
|
|
|
} from './section-registry'
|
|
|
|
|
|
const route = getRouteApi('/_authenticated/usage-logs/$section')
|
|
|
-const TASK_LOG_SECTIONS = ['drawing', 'task'] as const
|
|
|
|
|
|
const SECTION_META: Record<UsageLogsSectionId, { titleKey: string }> = {
|
|
|
common: {
|
|
|
@@ -50,9 +47,6 @@ const SECTION_META: Record<UsageLogsSectionId, { titleKey: string }> = {
|
|
|
audit: {
|
|
|
titleKey: 'Audit Logs',
|
|
|
},
|
|
|
- drawing: {
|
|
|
- titleKey: 'Drawing Logs',
|
|
|
- },
|
|
|
task: {
|
|
|
titleKey: 'Task Logs',
|
|
|
},
|
|
|
@@ -60,7 +54,6 @@ const SECTION_META: Record<UsageLogsSectionId, { titleKey: string }> = {
|
|
|
|
|
|
function UsageLogsContent() {
|
|
|
const { t } = useTranslation()
|
|
|
- const navigate = useNavigate()
|
|
|
const params = route.useParams()
|
|
|
const activeCategory: UsageLogsSectionId =
|
|
|
params.section && isUsageLogsSectionId(params.section)
|
|
|
@@ -76,41 +69,6 @@ function UsageLogsContent() {
|
|
|
} = useUsageLogsContext()
|
|
|
const { canViewSelf, canViewAll, viewScope, setViewScope } =
|
|
|
useLogsViewScope(activeCategory)
|
|
|
- const tabNavGroups = useMemo<NavGroup[]>(
|
|
|
- () => [
|
|
|
- {
|
|
|
- title: 'Task Logs',
|
|
|
- items: TASK_LOG_SECTIONS.map((section) => ({
|
|
|
- title: SECTION_META[section].titleKey,
|
|
|
- url: `/usage-logs/${section}`,
|
|
|
- })),
|
|
|
- },
|
|
|
- ],
|
|
|
- []
|
|
|
- )
|
|
|
- const filteredTabGroups = useSidebarConfig(tabNavGroups)
|
|
|
- const visibleSections = useMemo(
|
|
|
- () =>
|
|
|
- (filteredTabGroups[0]?.items ?? [])
|
|
|
- .map((item) => {
|
|
|
- if (!('url' in item) || typeof item.url !== 'string') return null
|
|
|
- return item.url.split('/').pop() ?? null
|
|
|
- })
|
|
|
- .filter((section): section is UsageLogsSectionId =>
|
|
|
- Boolean(section && isUsageLogsSectionId(section))
|
|
|
- ),
|
|
|
- [filteredTabGroups]
|
|
|
- )
|
|
|
-
|
|
|
- const handleSectionChange = useCallback(
|
|
|
- (section: string) => {
|
|
|
- void navigate({
|
|
|
- to: '/usage-logs/$section',
|
|
|
- params: { section: section as UsageLogsSectionId },
|
|
|
- })
|
|
|
- },
|
|
|
- [navigate]
|
|
|
- )
|
|
|
|
|
|
const handleViewScopeChange = useCallback(
|
|
|
(scope: string) => {
|
|
|
@@ -122,10 +80,6 @@ function UsageLogsContent() {
|
|
|
)
|
|
|
|
|
|
const pageMeta = SECTION_META[activeCategory]
|
|
|
- const showTaskSwitcher =
|
|
|
- activeCategory !== 'common' &&
|
|
|
- activeCategory !== 'audit' &&
|
|
|
- visibleSections.length > 1
|
|
|
|
|
|
return (
|
|
|
<>
|
|
|
@@ -133,7 +87,9 @@ function UsageLogsContent() {
|
|
|
<SectionPageLayout.Title>
|
|
|
{t(pageMeta.titleKey)}
|
|
|
</SectionPageLayout.Title>
|
|
|
- {(activeCategory === 'common' || activeCategory === 'audit') &&
|
|
|
+ {(activeCategory === 'common' ||
|
|
|
+ activeCategory === 'audit' ||
|
|
|
+ activeCategory === 'task') &&
|
|
|
canViewSelf && (
|
|
|
<SectionPageLayout.Actions>
|
|
|
<Tabs value={viewScope} onValueChange={handleViewScopeChange}>
|
|
|
@@ -148,17 +104,6 @@ function UsageLogsContent() {
|
|
|
)}
|
|
|
<SectionPageLayout.Content>
|
|
|
<div className='flex h-full min-h-0 flex-col gap-4'>
|
|
|
- {showTaskSwitcher && (
|
|
|
- <Tabs value={activeCategory} onValueChange={handleSectionChange}>
|
|
|
- <TabsList className='max-w-full flex-wrap justify-start group-data-horizontal/tabs:h-auto'>
|
|
|
- {visibleSections.map((section) => (
|
|
|
- <TabsTrigger key={section} value={section}>
|
|
|
- {t(SECTION_META[section].titleKey)}
|
|
|
- </TabsTrigger>
|
|
|
- ))}
|
|
|
- </TabsList>
|
|
|
- </Tabs>
|
|
|
- )}
|
|
|
<div className='min-h-0 flex-1'>
|
|
|
<UsageLogsTable logCategory={activeCategory} />
|
|
|
</div>
|