Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
Integration card rename and deprecate existing one (#74)
Browse files Browse the repository at this point in the history
* Deprecate existing integration card

* Rename new card to Integration card and update references

---------

Co-authored-by: Rodrigo Arze Leon <[email protected]>
  • Loading branch information
Rodri77 and Rodrigo Arze Leon authored Oct 30, 2024
1 parent 91ef554 commit f1b09cf
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 164 deletions.
6 changes: 3 additions & 3 deletions packages/engine-frontend/DeprecatedOpenIntConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {SchemaFormElement, UIProps, UIPropsNoChildren} from '@openint/ui'
import {
Button,
ConnectorConfigCard,
DeprecatedIntegrationCard,
Dialog,
DialogContent,
DialogDescription,
Expand All @@ -36,7 +37,6 @@ import {
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
IntegrationCard,
ResourceCard,
SchemaForm,
useToast,
Expand Down Expand Up @@ -364,7 +364,7 @@ export function _OpenIntConnect({
))}
{!debugConnectorConfigs &&
configuredIntegrations.map((int) => (
<IntegrationCard
<DeprecatedIntegrationCard
{...uiProps}
key={int.id}
integration={{
Expand All @@ -382,7 +382,7 @@ export function _OpenIntConnect({
onEvent?.({type: e.type, ccfgId: int.connector_config_id})
}}
/>
</IntegrationCard>
</DeprecatedIntegrationCard>
))}
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions packages/engine-frontend/components/IntegrationSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Loader, Search} from 'lucide-react'
import {useState} from 'react'
import {Input, parseCategory} from '@openint/ui'
import {CheckboxFilter} from '@openint/ui/components/CheckboxFilter'
import {ConnectionCard} from '@openint/ui/domain-components/ConnectionCard'
import {IntegrationCard} from '@openint/ui/domain-components/IntegrationCard'
import type {ConnectorConfig} from '../hocs/WithConnectConfig'
import type {ConnectEventType} from '../hocs/WithConnectorConnect'
import {WithConnectorConnect} from '../hocs/WithConnectorConnect'
Expand Down Expand Up @@ -111,7 +111,7 @@ export function IntegrationSearch({
})
}}>
{({openConnect}) => (
<ConnectionCard
<IntegrationCard
onClick={openConnect}
logo={int.ccfg.connector.logoUrl ?? ''}
name={int.name}
Expand Down
48 changes: 0 additions & 48 deletions packages/ui/domain-components/ConnectionCard.tsx

This file was deleted.

111 changes: 111 additions & 0 deletions packages/ui/domain-components/DeprecatedIntegrationCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import {Landmark} from 'lucide-react'
import React from 'react'
import type {Id} from '@openint/cdk'
import type {RouterOutput} from '@openint/engine-backend'
import {Badge, Card} from '../shadcn'
import {cn} from '../utils'

/** Can be img or next/image component */
type ImageComponent = React.FC<
Omit<
React.DetailedHTMLProps<
React.ImgHTMLAttributes<HTMLImageElement>,
HTMLImageElement
>,
'loading' | 'ref'
>
>

interface UIPropsNoChildren {
className?: string
Image?: ImageComponent
}

interface UIProps extends UIPropsNoChildren {
children?: React.ReactNode
}

type Integration = RouterOutput['listConfiguredIntegrations']['items'][number]

export const DeprecatedIntegrationCard = ({
integration: int,
className,
children,
onClick,
...uiProps
}: UIProps & {
integration: Integration & {
connectorName: string
connectorConfigId?: Id['ccfg']
envName?: string | null
}
className?: string
onClick?: () => void
}) => (
// <ConnectorCard
// {...props}
// showName={false}
// labels={int.envName ? [int.envName] : []}
// />
<Card
className={cn(
'm-3 flex h-36 w-48 flex-col p-4 sm:h-48 sm:w-64',
'cursor-pointer rounded-lg shadow-md hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-indigo-600',
className,
)}
onClick={onClick}>
<div className="flex h-6 self-stretch">
{int.envName && (
<Badge key={int.envName} variant="secondary">
{int.envName}
</Badge>
)}
{/* {showStageBadge && (
<Badge
variant="secondary"
className={cn(
'ml-auto',
connector.stage === 'ga' && 'bg-green-200',
connector.stage === 'beta' && 'bg-blue-200',
connector.stage === 'alpha' && 'bg-pink-50',
)}>
{connector.stage}
</Badge>
)} */}
</div>
<IntegrationLogoTemp
{...uiProps}
integration={int}
// min-h-0 is a hack where some images do not shrink in height @see https://share.cleanshot.com/jMX1bzLP
className="h-12 min-h-0 w-12"
/>
<span className="mt-2 text-sm text-muted-foreground">{int.name}</span>
{/* {children} */}
</Card>
)

/** Dedupe me with ResourceCard.IntegrationLogo */
const IntegrationLogoTemp = ({
integration: int,
className,
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
Image = (props) => <img {...props} />,
}: UIPropsNoChildren & {
integration: Integration
}) =>
int.logo_url ? (
<Image
// width={100}
// height={100}
src={int.logo_url}
alt={`"${int.name}" logo`}
className={cn('object-contain', className)}
/>
) : (
<div className={cn('flex flex-col items-center justify-center', className)}>
{/* <span>{int.name}</span> */}
<div className="flex h-16 w-16 items-center justify-center rounded-full bg-primary">
<Landmark className="h-8 w-8 text-primary-foreground" />
</div>
</div>
)
151 changes: 44 additions & 107 deletions packages/ui/domain-components/IntegrationCard.tsx
Original file line number Diff line number Diff line change
@@ -1,111 +1,48 @@
import {Landmark} from 'lucide-react'
import React from 'react'
import type {Id} from '@openint/cdk'
import type {RouterOutput} from '@openint/engine-backend'
import {Badge, Card} from '../shadcn'
import {cn} from '../utils'
import {Plus} from 'lucide-react'
import {useState} from 'react'
import {Card, CardContent} from '../shadcn'

/** Can be img or next/image component */
type ImageComponent = React.FC<
Omit<
React.DetailedHTMLProps<
React.ImgHTMLAttributes<HTMLImageElement>,
HTMLImageElement
>,
'loading' | 'ref'
>
>

interface UIPropsNoChildren {
className?: string
Image?: ImageComponent
}

interface UIProps extends UIPropsNoChildren {
children?: React.ReactNode
}

type Integration = RouterOutput['listConfiguredIntegrations']['items'][number]

export const IntegrationCard = ({
integration: int,
className,
children,
export function IntegrationCard({
logo,
name,
onClick,
...uiProps
}: UIProps & {
integration: Integration & {
connectorName: string
connectorConfigId?: Id['ccfg']
envName?: string | null
}
className?: string
onClick?: () => void
}) => (
// <ConnectorCard
// {...props}
// showName={false}
// labels={int.envName ? [int.envName] : []}
// />
<Card
className={cn(
'm-3 flex h-36 w-48 flex-col p-4 sm:h-48 sm:w-64',
'cursor-pointer rounded-lg shadow-md hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-indigo-600',
className,
)}
onClick={onClick}>
<div className="flex h-6 self-stretch">
{int.envName && (
<Badge key={int.envName} variant="secondary">
{int.envName}
</Badge>
)}
{/* {showStageBadge && (
<Badge
variant="secondary"
className={cn(
'ml-auto',
connector.stage === 'ga' && 'bg-green-200',
connector.stage === 'beta' && 'bg-blue-200',
connector.stage === 'alpha' && 'bg-pink-50',
)}>
{connector.stage}
</Badge>
)} */}
</div>
<IntegrationLogoTemp
{...uiProps}
integration={int}
// min-h-0 is a hack where some images do not shrink in height @see https://share.cleanshot.com/jMX1bzLP
className="h-12 min-h-0 w-12"
/>
<span className="mt-2 text-sm text-muted-foreground">{int.name}</span>
{/* {children} */}
</Card>
)
}: {
logo: string
name: string
onClick: () => void
}) {
const [isHovered, setIsHovered] = useState(false)

/** Dedupe me with ResourceCard.IntegrationLogo */
const IntegrationLogoTemp = ({
integration: int,
className,
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
Image = (props) => <img {...props} />,
}: UIPropsNoChildren & {
integration: Integration
}) =>
int.logo_url ? (
<Image
// width={100}
// height={100}
src={int.logo_url}
alt={`"${int.name}" logo`}
className={cn('object-contain', className)}
/>
) : (
<div className={cn('flex flex-col items-center justify-center', className)}>
{/* <span>{int.name}</span> */}
<div className="flex h-16 w-16 items-center justify-center rounded-full bg-primary">
<Landmark className="h-8 w-8 text-primary-foreground" />
</div>
</div>
return (
<Card
className="relative h-[120px] w-[120px] cursor-pointer rounded-lg border border-gray-300 bg-white p-0 transition-colors duration-300 ease-in-out hover:border-[#8A7DFF] hover:bg-[#F8F7FF]"
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}>
<CardContent
className="flex h-full flex-col items-center justify-center pt-6"
onClick={onClick}>
{isHovered ? (
<div className="flex h-full flex-col items-center justify-center">
<Plus color="#8A7DFF" size={24} />
<span className="mt-2 font-sans text-[14px] font-semibold text-[#8A7DFF]">
Add
</span>{' '}
{/* Set to 14px and semibold */}
</div>
) : (
<div className="flex h-full flex-col items-center justify-center">
<img
src={logo}
alt={`${name} logo`}
className="h-8 w-8"
style={{marginBottom: '10px'}}
/>{' '}
<p className="m-0 mb-2 text-center font-sans text-sm font-semibold">
{name}
</p>{' '}
</div>
)}
</CardContent>
</Card>
)
}
2 changes: 1 addition & 1 deletion packages/ui/domain-components/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// codegen:start {preset: barrel, include: "./{*.{ts,tsx},*/index.{ts,tsx}}", exclude: "./**/*.{d,spec,test,fixture,gen,node}.{ts,tsx}"}
export * from './ConnectorCard'
export * from './IntegrationCard'
export * from './DeprecatedIntegrationCard'
export * from './ResourceCard'
// codegen:end
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {fn} from '@storybook/test'
import logoGreenhouse from '../../../apps/web/public/_assets/logo-greenhouse.svg'
import {ConnectionCard} from '../domain-components/ConnectionCard'
import {IntegrationCard} from '../domain-components/IntegrationCard'

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
export default {
title: 'Example/ConnectionCard',
component: ConnectionCard,
title: 'Example/IntegrationCard',
component: IntegrationCard,
parameters: {
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
layout: 'centered',
Expand Down

0 comments on commit f1b09cf

Please sign in to comment.