-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pipeline-ui): Destinations list view (#19171)
* feat(pipeline-ui): Destinations list view * Update UI snapshots for `chromium` (1) --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
7eb0c5f
commit af66a97
Showing
13 changed files
with
413 additions
and
48 deletions.
There are no files selected for viewing
Binary file added
BIN
+123 KB
frontend/__snapshots__/scenes-app-pipeline--pipeline-destinations-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+56.5 KB
(200%)
frontend/__snapshots__/scenes-app-pipeline--pipeline-landing-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,245 @@ | ||
import { | ||
LemonButton, | ||
LemonDivider, | ||
LemonTable, | ||
LemonTableColumn, | ||
LemonTag, | ||
LemonTagType, | ||
Link, | ||
Tooltip, | ||
} from '@posthog/lemon-ui' | ||
import { useActions, useValues } from 'kea' | ||
import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction' | ||
import { More } from 'lib/lemon-ui/LemonButton/More' | ||
import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown/LemonMarkdown' | ||
import { updatedAtColumn } from 'lib/lemon-ui/LemonTable/columnUtils' | ||
import { deleteWithUndo } from 'lib/utils/deleteWithUndo' | ||
import { urls } from 'scenes/urls' | ||
|
||
import { PipelineAppTabs, PipelineTabs, PluginConfigTypeNew, ProductKey } from '~/types' | ||
|
||
import { pipelineDestinationsLogic } from './destinationsLogic' | ||
import { NewButton } from './NewButton' | ||
import { RenderApp } from './utils' | ||
|
||
export function Destinations(): JSX.Element { | ||
const { enabledPluginConfigs, disabledPluginConfigs, shouldShowProductIntroduction } = | ||
useValues(pipelineDestinationsLogic) | ||
|
||
const shouldShowEmptyState = enabledPluginConfigs.length === 0 && disabledPluginConfigs.length === 0 | ||
|
||
return ( | ||
<> | ||
{(shouldShowEmptyState || shouldShowProductIntroduction) && ( | ||
<ProductIntroduction | ||
productName="Pipeline destinations" | ||
thingName="destination" | ||
productKey={ProductKey.PIPELINE_DESTINATIONS} | ||
description="Pipeline destinations allow you to export data outside of PostHog, such as webhooks to Slack." | ||
docsURL="https://posthog.com/docs/cdp" | ||
actionElementOverride={<NewButton tab={PipelineTabs.Destinations} />} | ||
isEmpty={true} | ||
/> | ||
)} | ||
<AppsTable /> | ||
<BatchExportsTable /> | ||
</> | ||
) | ||
} | ||
|
||
function BatchExportsTable(): JSX.Element { | ||
return ( | ||
<> | ||
<h2>Batch exports</h2> | ||
|
||
<h2>Backfills</h2> | ||
</> | ||
) | ||
} | ||
|
||
function AppsTable(): JSX.Element { | ||
const { loading, enabledPluginConfigs, disabledPluginConfigs, plugins, canConfigurePlugins } = | ||
useValues(pipelineDestinationsLogic) | ||
const { toggleEnabled, loadPluginConfigs } = useActions(pipelineDestinationsLogic) | ||
|
||
if (enabledPluginConfigs.length === 0 && disabledPluginConfigs.length === 0) { | ||
return <></> | ||
} | ||
|
||
return ( | ||
<> | ||
<h2>Webhooks</h2> | ||
<LemonTable | ||
dataSource={[...enabledPluginConfigs, ...disabledPluginConfigs]} | ||
size="xs" | ||
loading={loading} | ||
columns={[ | ||
{ | ||
title: 'Name', | ||
sticky: true, | ||
render: function RenderPluginName(_, pluginConfig) { | ||
return ( | ||
<> | ||
<Tooltip title={'Click to update configuration, view metrics, and more'}> | ||
<Link to={urls.pipelineApp(pluginConfig.id, PipelineAppTabs.Configuration)}> | ||
<span className="row-name">{pluginConfig.name}</span> | ||
</Link> | ||
</Tooltip> | ||
{pluginConfig.description && ( | ||
<LemonMarkdown className="row-description" lowKeyHeadings> | ||
{pluginConfig.description} | ||
</LemonMarkdown> | ||
)} | ||
</> | ||
) | ||
}, | ||
}, | ||
{ | ||
title: 'App', | ||
render: function RenderAppInfo(_, pluginConfig) { | ||
return <RenderApp plugin={plugins[pluginConfig.plugin]} /> | ||
}, | ||
}, | ||
{ | ||
title: '24h', | ||
render: function Render24hDeliveryRate(_, pluginConfig) { | ||
let tooltip = 'No events exported in the past 24 hours' | ||
let value = '-' | ||
let tagType: LemonTagType = 'muted' | ||
if ( | ||
pluginConfig.delivery_rate_24h !== null && | ||
pluginConfig.delivery_rate_24h !== undefined | ||
) { | ||
const deliveryRate = pluginConfig.delivery_rate_24h | ||
value = `${Math.floor(deliveryRate * 100)}%` | ||
tooltip = 'Success rate for past 24 hours' | ||
if (deliveryRate >= 0.99) { | ||
tagType = 'success' | ||
} else if (deliveryRate >= 0.75) { | ||
tagType = 'warning' | ||
} else { | ||
tagType = 'danger' | ||
} | ||
} | ||
return ( | ||
<Tooltip title={tooltip}> | ||
<Link to={urls.pipelineApp(pluginConfig.id, PipelineAppTabs.Metrics)}> | ||
<LemonTag type={tagType}>{value}</LemonTag> | ||
</Link> | ||
</Tooltip> | ||
) | ||
}, | ||
}, | ||
updatedAtColumn() as LemonTableColumn<PluginConfigTypeNew, any>, | ||
{ | ||
title: 'Status', | ||
render: function RenderStatus(_, pluginConfig) { | ||
return ( | ||
<> | ||
{pluginConfig.enabled ? ( | ||
<LemonTag type="success" className="uppercase"> | ||
Enabled | ||
</LemonTag> | ||
) : ( | ||
<LemonTag type="default" className="uppercase"> | ||
Disabled | ||
</LemonTag> | ||
)} | ||
</> | ||
) | ||
}, | ||
}, | ||
{ | ||
width: 0, | ||
render: function Render(_, pluginConfig) { | ||
return ( | ||
<More | ||
overlay={ | ||
<> | ||
<LemonButton | ||
status="stealth" | ||
onClick={() => { | ||
toggleEnabled({ | ||
enabled: !pluginConfig.enabled, | ||
id: pluginConfig.id, | ||
}) | ||
}} | ||
id={`app-${pluginConfig.id}-enable-switch`} | ||
disabledReason={ | ||
canConfigurePlugins | ||
? undefined | ||
: 'You do not have permission to enable/disable apps.' | ||
} | ||
fullWidth | ||
> | ||
{pluginConfig.enabled ? 'Disable' : 'Enable'} app | ||
</LemonButton> | ||
<LemonButton | ||
status="stealth" | ||
to={urls.pipelineApp(pluginConfig.id, PipelineAppTabs.Configuration)} | ||
id={`app-${pluginConfig.id}-configuration`} | ||
fullWidth | ||
> | ||
{canConfigurePlugins ? 'Edit' : 'View'} app configuration | ||
</LemonButton> | ||
<LemonButton | ||
status="stealth" | ||
to={urls.pipelineApp(pluginConfig.id, PipelineAppTabs.Metrics)} | ||
id={`app-${pluginConfig.id}-metrics`} | ||
fullWidth | ||
> | ||
View app metrics | ||
</LemonButton> | ||
<LemonButton | ||
status="stealth" | ||
to={urls.pipelineApp(pluginConfig.id, PipelineAppTabs.Logs)} | ||
id={`app-${pluginConfig.id}-logs`} | ||
fullWidth | ||
> | ||
View app logs | ||
</LemonButton> | ||
{plugins[pluginConfig.plugin].url && ( | ||
<LemonButton | ||
status="stealth" | ||
to={plugins[pluginConfig.plugin].url} | ||
targetBlank={true} | ||
id={`app-${pluginConfig.id}-source-code`} | ||
fullWidth | ||
> | ||
View app source code | ||
</LemonButton> | ||
)} | ||
<LemonDivider /> | ||
<LemonButton | ||
status="danger" | ||
onClick={() => { | ||
void deleteWithUndo({ | ||
endpoint: `plugin_config`, | ||
object: { | ||
id: pluginConfig.id, | ||
name: pluginConfig.name, | ||
}, | ||
callback: loadPluginConfigs, | ||
}) | ||
}} | ||
id={`app-reorder`} | ||
disabledReason={ | ||
canConfigurePlugins | ||
? undefined | ||
: 'You do not have permission to delete apps.' | ||
} | ||
fullWidth | ||
> | ||
Delete app | ||
</LemonButton> | ||
</> | ||
} | ||
/> | ||
) | ||
}, | ||
}, | ||
]} | ||
/> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.