Skip to content

Commit

Permalink
Move things around
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Jun 20, 2024
1 parent 4227e5a commit 3738396
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 61 deletions.
34 changes: 33 additions & 1 deletion frontend/src/lib/integrations/SlackIntegrationHelpers.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { LemonBanner, LemonButton, LemonInputSelect, LemonInputSelectOption, Link } from '@posthog/lemon-ui'
import { useActions, useValues } from 'kea'
import { IconSlackExternal } from 'lib/lemon-ui/icons'
import { UserActivityIndicator } from 'lib/components/UserActivityIndicator/UserActivityIndicator'
import { IconSlack, IconSlackExternal } from 'lib/lemon-ui/icons'
import { useMemo } from 'react'

import { IntegrationType, SlackChannelType } from '~/types'
Expand Down Expand Up @@ -82,3 +83,34 @@ export function SlackChannelPicker({ onChange, value, integration, disabled }: S
</>
)
}

export function SlackIntegrationView({
integration,
suffix,
}: {
integration: IntegrationType
suffix?: JSX.Element
}): JSX.Element {
return (
<div className="rounded border flex justify-between items-center p-2 bg-bg-light">
<div className="flex items-center gap-4 ml-2">
<IconSlack className="text-2xl" />
<div>
<div>
Connected to <strong>{integration.config.team.name}</strong> workspace
</div>
{integration.created_by ? (
<UserActivityIndicator
at={integration.created_at}
by={integration.created_by}
prefix="Updated"
className="text-muted"
/>
) : null}
</div>
</div>

{suffix}
</div>
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LemonButton, LemonMenu, LemonSkeleton } from '@posthog/lemon-ui'
import { useValues } from 'kea'
import { UserActivityIndicator } from 'lib/components/UserActivityIndicator/UserActivityIndicator'
import { integrationsLogic } from 'lib/integrations/integrationsLogic'
import { SlackIntegrationView } from 'lib/integrations/SlackIntegrationHelpers'
import { IconSlack } from 'lib/lemon-ui/icons'

import { HogFunctionInputSchemaType } from '~/types'
Expand Down Expand Up @@ -60,32 +60,5 @@ export function HogFunctionIntegrationSlackConnection({
</LemonMenu>
)

return (
<>
{integration ? (
<div className="rounded border flex justify-between items-center p-2 bg-bg-light">
<div className="flex items-center gap-4 ml-2">
<IconSlack className="text-2xl" />
<div>
<div>
Connected to <strong>{integration.config.team.name}</strong> workspace
</div>
{integration.created_by ? (
<UserActivityIndicator
at={integration.created_at}
by={integration.created_by}
prefix="Updated"
className="text-muted"
/>
) : null}
</div>
</div>

{button}
</div>
) : (
button
)}
</>
)
return <>{integration ? <SlackIntegrationView integration={integration} suffix={button} /> : button}</>
}
45 changes: 14 additions & 31 deletions frontend/src/scenes/settings/project/SlackIntegration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { IconTrash } from '@posthog/icons'
import { LemonButton, Link } from '@posthog/lemon-ui'
import { useActions, useValues } from 'kea'
import { CodeSnippet, Language } from 'lib/components/CodeSnippet'
import { UserActivityIndicator } from 'lib/components/UserActivityIndicator/UserActivityIndicator'
import { getSlackAppManifest, integrationsLogic } from 'lib/integrations/integrationsLogic'
import { IconSlack } from 'lib/lemon-ui/icons'
import { SlackIntegrationView } from 'lib/integrations/SlackIntegrationHelpers'
import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
import { useState } from 'react'
import { urls } from 'scenes/urls'
Expand Down Expand Up @@ -50,36 +49,20 @@ export function SlackIntegration(): JSX.Element {

<div className="space-y-2">
{slackIntegrations?.map((integration) => (
<div
<SlackIntegrationView
key={integration.id}
className="rounded border flex justify-between items-center p-2 bg-bg-light"
>
<div className="flex items-center gap-4 ml-2">
<IconSlack className="text-2xl" />
<div>
<div>
Connected to <strong>{integration.config.team.name}</strong> workspace
</div>
{integration.created_by ? (
<UserActivityIndicator
at={integration.created_at}
by={integration.created_by}
prefix="Updated"
className="text-muted"
/>
) : null}
</div>
</div>

<LemonButton
type="secondary"
status="danger"
onClick={() => onDeleteClick(integration.id)}
icon={<IconTrash />}
>
Disconnect
</LemonButton>
</div>
integration={integration}
suffix={
<LemonButton
type="secondary"
status="danger"
onClick={() => onDeleteClick(integration.id)}
icon={<IconTrash />}
>
Disconnect
</LemonButton>
}
/>
))}

<div>
Expand Down

0 comments on commit 3738396

Please sign in to comment.