Skip to content

Commit

Permalink
chore: remove antd from plugins (#19481)
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin authored Dec 21, 2023
1 parent ce48493 commit b1e3699
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Link } from '@posthog/lemon-ui'
import { Button, Progress } from 'antd'
import { Progress } from 'antd'
import { useActions, useValues } from 'kea'
import { PageHeader } from 'lib/components/PageHeader'
import { IconPlayCircle, IconRefresh, IconReplay } from 'lib/lemon-ui/icons'
Expand Down Expand Up @@ -151,13 +151,13 @@ export function AsyncMigrations(): JSX.Element {
<div>
{status === AsyncMigrationStatus.NotStarted || status === AsyncMigrationStatus.FailedAtStartup ? (
<Tooltip title="Start">
<Button
type="link"
<LemonButton
size="small"
icon={<IconPlayCircle />}
onClick={() => triggerMigration(asyncMigration)}
>
Run
</Button>
</LemonButton>
</Tooltip>
) : status === AsyncMigrationStatus.Starting || status === AsyncMigrationStatus.Running ? (
<More
Expand Down
25 changes: 14 additions & 11 deletions frontend/src/scenes/plugins/edit/PluginField.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LemonButton, LemonInput, LemonSelect } from '@posthog/lemon-ui'
import { PluginConfigSchema } from '@posthog/plugin-scaffold/src/types'
import { Button, Input, Select } from 'antd'
import { CodeEditor } from 'lib/components/CodeEditors'
import { IconEdit } from 'lib/lemon-ui/icons'
import { useState } from 'react'
Expand Down Expand Up @@ -50,32 +50,35 @@ export function PluginField({
(value === SECRET_FIELD_VALUE || value.name === SECRET_FIELD_VALUE)
) {
return (
<Button
<LemonButton
type="secondary"
icon={<IconEdit />}
onClick={() => {
onChange(fieldConfig.default || '')
setEditingSecret(true)
}}
>
Reset secret {fieldConfig.type === 'attachment' ? 'attachment' : 'field'}
</Button>
</LemonButton>
)
}

return fieldConfig.type === 'attachment' ? (
<UploadField value={value} onChange={onChange} />
) : fieldConfig.type === 'string' ? (
<Input value={value} onChange={onChange} autoFocus={editingSecret} className="ph-no-capture" />
<LemonInput value={value} onChange={onChange} autoFocus={editingSecret} className="ph-no-capture" />
) : fieldConfig.type === 'json' ? (
<JsonConfigField value={value} onChange={onChange} autoFocus={editingSecret} className="ph-no-capture" />
) : fieldConfig.type === 'choice' ? (
<Select dropdownMatchSelectWidth={false} value={value} className="ph-no-capture" onChange={onChange} showSearch>
{fieldConfig.choices.map((choice) => (
<Select.Option value={choice} key={choice}>
{choice}
</Select.Option>
))}
</Select>
<LemonSelect
fullWidth
value={value}
className="ph-no-capture"
onChange={onChange}
options={fieldConfig.choices.map((choice) => {
return { label: choice, value: choice }
})}
/>
) : (
<strong className="text-danger">
Unknown field type "<code>{fieldConfig.type}</code>".
Expand Down
12 changes: 5 additions & 7 deletions frontend/src/scenes/plugins/source/PluginSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './PluginSource.scss'

import { useMonaco } from '@monaco-editor/react'
import { Link } from '@posthog/lemon-ui'
import { Button, Skeleton } from 'antd'
import { Skeleton } from 'antd'
import { useActions, useValues } from 'kea'
import { Form } from 'kea-forms'
import { CodeEditor } from 'lib/components/CodeEditors'
Expand Down Expand Up @@ -81,13 +81,11 @@ export function PluginSource({
title={pluginSourceLoading ? 'Loading...' : `Edit App: ${name}`}
placement={placement ?? 'left'}
footer={
<div className="text-right">
<Button onClick={closePluginSource} style={{ marginRight: 16 }}>
Close
</Button>
<Button type="primary" loading={isPluginSourceSubmitting} onClick={submitPluginSource}>
<div className="text-right space-x-2">
<LemonButton onClick={closePluginSource}>Close</LemonButton>
<LemonButton type="primary" loading={isPluginSourceSubmitting} onClick={submitPluginSource}>
Save
</Button>
</LemonButton>
</div>
}
>
Expand Down
22 changes: 13 additions & 9 deletions frontend/src/scenes/surveys/SurveyAppearance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ interface ButtonProps {
children: React.ReactNode
}

const Button = ({
const SurveyButton = ({
link,
type,
onSubmit,
Expand Down Expand Up @@ -351,15 +351,15 @@ export function BaseAppearance({

<div className="bottom-section">
<div className="buttons">
<Button
<SurveyButton
{...(preview ? { tabIndex: -1 } : null)}
appearance={appearance}
link={question.type === SurveyQuestionType.Link ? question.link : null}
onSubmit={onSubmit}
type={question.type}
>
{question.buttonText || appearance.submitButtonText}
</Button>
</SurveyButton>
</div>

{!preview && !appearance.whiteLabel && (
Expand Down Expand Up @@ -572,13 +572,13 @@ export function SurveyRatingAppearance({

<div className="bottom-section">
<div className="buttons">
<Button
<SurveyButton
{...(preview ? { tabIndex: -1 } : null)}
appearance={appearance}
onSubmit={onSubmit}
>
{ratingSurveyQuestion.buttonText || appearance.submitButtonText}
</Button>
</SurveyButton>
</div>

{!preview && !appearance.whiteLabel && (
Expand Down Expand Up @@ -739,9 +739,13 @@ export function SurveyMultipleChoiceAppearance({
</div>
<div className="bottom-section">
<div className="buttons">
<Button {...(preview ? { tabIndex: -1 } : null)} appearance={appearance} onSubmit={onSubmit}>
<SurveyButton
{...(preview ? { tabIndex: -1 } : null)}
appearance={appearance}
onSubmit={onSubmit}
>
{multipleChoiceQuestion.buttonText || appearance.submitButtonText}
</Button>
</SurveyButton>
</div>

{!preview && !appearance.whiteLabel && (
Expand Down Expand Up @@ -797,9 +801,9 @@ export function SurveyThankYou({ appearance }: { appearance: SurveyAppearanceTyp
className="thank-you-message-body"
dangerouslySetInnerHTML={{ __html: sanitizeHTML(appearance?.thankYouMessageDescription || '') }}
/>
<Button appearance={appearance} onSubmit={() => undefined}>
<SurveyButton appearance={appearance} onSubmit={() => undefined}>
Close
</Button>
</SurveyButton>
{!appearance.whiteLabel && (
<Link to="https://posthog.com" target="_blank" className="footer-branding">
Survey by {posthogLogoSVG}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/stories/How to build a form.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ export function FeatureFlag({ id }: { id?: string } = {}): JSX.Element {
</Group>
)}

<Button
<LemonButton
loading={isFeatureFlagSubmitting}
icon={<SaveOutlined />}
htmlType="submit"
type="primary"
data-attr="feature-flag-submit-bottom"
>
Save changes
</Button>
</LemonButton>
</Form>
)
}
Expand Down

0 comments on commit b1e3699

Please sign in to comment.