22
33import { useCallback , useEffect , useMemo , useRef , useState } from 'react'
44import type { ChipSelectOption } from '@sim/emcn'
5- import { Button , ChipConfirmModal , ChipSelect , Tooltip , toast } from '@sim/emcn'
5+ import { ChipConfirmModal , ChipSelect , Tooltip , toast } from '@sim/emcn'
66import { Database , FolderPlus , Pencil , Plus , Trash } from '@sim/emcn/icons'
77import { createLogger } from '@sim/logger'
88import { getErrorMessage } from '@sim/utils/errors'
@@ -23,7 +23,6 @@ import type {
2323} from '@/app/workspace/[workspaceId]/components'
2424import {
2525 EMPTY_CELL_PLACEHOLDER ,
26- FILTER_SECTION_LABEL_CLASS ,
2726 OwnerAvatar ,
2827 ownerCell ,
2928 Resource ,
@@ -72,6 +71,7 @@ import {
7271 KnowledgeBaseContextMenu ,
7372 KnowledgeListContextMenu ,
7473} from '@/app/workspace/[workspaceId]/knowledge/components'
74+ import { KnowledgeFilterHeading } from '@/app/workspace/[workspaceId]/knowledge/components/knowledge-filter-heading'
7575import KnowledgeLoading from '@/app/workspace/[workspaceId]/knowledge/loading'
7676import { canDeleteKnowledgeBase } from '@/app/workspace/[workspaceId]/knowledge/permissions'
7777import {
@@ -1334,18 +1334,11 @@ function KnowledgeContent() {
13341334 ( ) => (
13351335 < div className = 'flex w-[260px] flex-col gap-3 p-3' >
13361336 < div className = 'flex flex-col gap-2' >
1337- < div className = 'flex h-5 items-center justify-between' >
1338- < span className = { FILTER_SECTION_LABEL_CLASS } > Connectors</ span >
1339- { connectorFilter . length > 0 && (
1340- < Button
1341- variant = 'ghost'
1342- onClick = { ( ) => setConnectorFilter ( [ ] ) }
1343- className = '-mr-1 h-auto px-1 py-0.5 text-[var(--text-muted)] text-xs hover-hover:text-[var(--text-secondary)]'
1344- >
1345- Clear
1346- </ Button >
1347- ) }
1348- </ div >
1337+ < KnowledgeFilterHeading
1338+ title = 'Connectors'
1339+ active = { connectorFilter . length > 0 }
1340+ onClear = { ( ) => setConnectorFilter ( [ ] ) }
1341+ />
13491342 < ChipSelect
13501343 showSelectedCheck
13511344 dropdownWidth = 'trigger'
@@ -1358,18 +1351,11 @@ function KnowledgeContent() {
13581351 />
13591352 </ div >
13601353 < div className = 'flex flex-col gap-2' >
1361- < div className = 'flex h-5 items-center justify-between' >
1362- < span className = { FILTER_SECTION_LABEL_CLASS } > Content</ span >
1363- { contentFilter . length > 0 && (
1364- < Button
1365- variant = 'ghost'
1366- onClick = { ( ) => setContentFilter ( [ ] ) }
1367- className = '-mr-1 h-auto px-1 py-0.5 text-[var(--text-muted)] text-xs hover-hover:text-[var(--text-secondary)]'
1368- >
1369- Clear
1370- </ Button >
1371- ) }
1372- </ div >
1354+ < KnowledgeFilterHeading
1355+ title = 'Content'
1356+ active = { contentFilter . length > 0 }
1357+ onClear = { ( ) => setContentFilter ( [ ] ) }
1358+ />
13731359 < ChipSelect
13741360 showSelectedCheck
13751361 dropdownWidth = 'trigger'
@@ -1383,18 +1369,11 @@ function KnowledgeContent() {
13831369 </ div >
13841370 { memberOptions . length > 0 && (
13851371 < div className = 'flex flex-col gap-2' >
1386- < div className = 'flex h-5 items-center justify-between' >
1387- < span className = { FILTER_SECTION_LABEL_CLASS } > Owner</ span >
1388- { ownerFilter . length > 0 && (
1389- < Button
1390- variant = 'ghost'
1391- onClick = { ( ) => setOwnerFilter ( [ ] ) }
1392- className = '-mr-1 h-auto px-1 py-0.5 text-[var(--text-muted)] text-xs hover-hover:text-[var(--text-secondary)]'
1393- >
1394- Clear
1395- </ Button >
1396- ) }
1397- </ div >
1372+ < KnowledgeFilterHeading
1373+ title = 'Owner'
1374+ active = { ownerFilter . length > 0 }
1375+ onClear = { ( ) => setOwnerFilter ( [ ] ) }
1376+ />
13981377 < ChipSelect
13991378 placeholder = 'All'
14001379 showAllOption
0 commit comments