mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-18 02:11:59 -05:00
removed redundant util
This commit is contained in:
@@ -34,7 +34,6 @@ import {
|
||||
} from '@/lib/oauth'
|
||||
import { EditConnectorModal } from '@/app/workspace/[workspaceId]/knowledge/[id]/components/edit-connector-modal/edit-connector-modal'
|
||||
import { OAuthRequiredModal } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/components/oauth-required-modal'
|
||||
import { CONNECTOR_META } from '@/connectors/icons'
|
||||
import { CONNECTOR_REGISTRY } from '@/connectors/registry'
|
||||
import type { ConnectorData, SyncLogData } from '@/hooks/queries/kb/connectors'
|
||||
import {
|
||||
@@ -265,15 +264,14 @@ function ConnectorCard({
|
||||
const [expanded, setExpanded] = useState(false)
|
||||
const [showOAuthModal, setShowOAuthModal] = useState(false)
|
||||
|
||||
const meta = CONNECTOR_META[connector.connectorType]
|
||||
const Icon = meta?.icon
|
||||
const connectorDef = CONNECTOR_REGISTRY[connector.connectorType]
|
||||
const Icon = connectorDef?.icon
|
||||
const statusConfig =
|
||||
STATUS_CONFIG[connector.status as keyof typeof STATUS_CONFIG] || STATUS_CONFIG.active
|
||||
|
||||
const connectorConfig = CONNECTOR_REGISTRY[connector.connectorType]
|
||||
const serviceId = connectorConfig?.oauth.provider
|
||||
const serviceId = connectorDef?.oauth.provider
|
||||
const providerId = serviceId ? getProviderIdFromServiceId(serviceId) : undefined
|
||||
const requiredScopes = connectorConfig?.oauth.requiredScopes ?? []
|
||||
const requiredScopes = connectorDef?.oauth.requiredScopes ?? []
|
||||
|
||||
const { data: credentials } = useOAuthCredentials(providerId)
|
||||
|
||||
@@ -297,7 +295,7 @@ function ConnectorCard({
|
||||
<div className='flex flex-col gap-[2px]'>
|
||||
<div className='flex items-center gap-[8px]'>
|
||||
<span className='font-medium text-[13px] text-[var(--text-primary)]'>
|
||||
{meta?.name || connector.connectorType}
|
||||
{connectorDef?.name || connector.connectorType}
|
||||
</span>
|
||||
<Badge variant={statusConfig.variant} className='text-[10px]'>
|
||||
{connector.status === 'syncing' && (
|
||||
@@ -444,7 +442,7 @@ function ConnectorCard({
|
||||
isOpen={showOAuthModal}
|
||||
onClose={() => setShowOAuthModal(false)}
|
||||
provider={providerId as OAuthProvider}
|
||||
toolName={connectorConfig?.name ?? connector.connectorType}
|
||||
toolName={connectorDef?.name ?? connector.connectorType}
|
||||
requiredScopes={getCanonicalScopesForProvider(providerId)}
|
||||
newScopes={missingScopes}
|
||||
serviceId={serviceId}
|
||||
|
||||
@@ -282,7 +282,8 @@ export const githubConnector: ConnectorConfig = {
|
||||
const path = externalId
|
||||
|
||||
try {
|
||||
const url = `${GITHUB_API_URL}/repos/${owner}/${repo}/contents/${encodeURIComponent(path)}?ref=${encodeURIComponent(branch)}`
|
||||
const encodedPath = path.split('/').map(encodeURIComponent).join('/')
|
||||
const url = `${GITHUB_API_URL}/repos/${owner}/${repo}/contents/${encodedPath}?ref=${encodeURIComponent(branch)}`
|
||||
const response = await fetchWithRetry(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { ConfluenceIcon, GithubIcon, LinearIcon, NotionIcon } from '@/components/icons'
|
||||
|
||||
interface ConnectorMeta {
|
||||
icon: React.ComponentType<{ className?: string }>
|
||||
name: string
|
||||
}
|
||||
|
||||
/** Connector type → client-safe metadata (icon + display name) */
|
||||
export const CONNECTOR_META: Record<string, ConnectorMeta> = {
|
||||
confluence: { icon: ConfluenceIcon, name: 'Confluence' },
|
||||
github: { icon: GithubIcon, name: 'GitHub' },
|
||||
linear: { icon: LinearIcon, name: 'Linear' },
|
||||
notion: { icon: NotionIcon, name: 'Notion' },
|
||||
}
|
||||
|
||||
/** Connector type → icon component mapping for client-side use */
|
||||
export const CONNECTOR_ICONS: Record<
|
||||
string,
|
||||
React.ComponentType<{ className?: string }>
|
||||
> = Object.fromEntries(Object.entries(CONNECTOR_META).map(([k, v]) => [k, v.icon]))
|
||||
@@ -804,9 +804,28 @@ export interface TagFilterCondition {
|
||||
/**
|
||||
* Builds a Drizzle SQL condition from a tag filter.
|
||||
*/
|
||||
const ALLOWED_TAG_SLOTS = new Set([
|
||||
'tag1',
|
||||
'tag2',
|
||||
'tag3',
|
||||
'tag4',
|
||||
'tag5',
|
||||
'tag6',
|
||||
'tag7',
|
||||
'number1',
|
||||
'number2',
|
||||
'number3',
|
||||
'number4',
|
||||
'number5',
|
||||
'date1',
|
||||
'date2',
|
||||
'boolean1',
|
||||
'boolean2',
|
||||
'boolean3',
|
||||
])
|
||||
|
||||
function buildTagFilterCondition(filter: TagFilterCondition): SQL | undefined {
|
||||
const column = document[filter.tagSlot as keyof typeof document.$inferSelect]
|
||||
if (!column) return undefined
|
||||
if (!ALLOWED_TAG_SLOTS.has(filter.tagSlot)) return undefined
|
||||
|
||||
const col = document[filter.tagSlot as keyof typeof document]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user