mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +03:00
## What kind of change does this PR introduce? Mechanical cleanup on top of the Button default-variant change (#50160). ## What is the current behavior? Many callsites still pass `variant="default"` even though that is now the component default. ## What is the new behavior? Removes redundant static `variant="default"` from legacy `Button` and `ButtonTooltip` callsites. Keeps explicit defaults where they document the API: - `button-default.tsx` and `button-sizes.tsx` demos - `DocsButton`, which pins neutral styling at the wrapper boundary ## To test Studio: - [Auth → Rate Limits](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/auth/rate-limits): dirty the form so Cancel appears; Cancel stays neutral, Save stays green - [Project Settings → API Keys](https://studio-staging-2s957kwc4-supabase.vercel.app/dashboard/project/_/settings/api-keys): `DocsButton` in the header actions stays neutral Design system: - [Design system → Button](https://design-system-git-dnywh-dc924ac1-supabase.vercel.app/design-system/docs/components/button): `button-default` / `button-sizes` still show explicit default styling; Primary (green) is restricted to the Primary section (and `asChild`) WWW: - [www → Brand assets](https://zone-www-dot-com-git-dnywh-dc924ac1-supabase.vercel.app/brand-assets): Download logo kit / Download button kit stay neutral
132 lines
3.8 KiB
TypeScript
132 lines
3.8 KiB
TypeScript
import { PermissionAction } from '@supabase/shared-types/out/constants'
|
|
import { Button, cn } from 'ui'
|
|
|
|
import { hasInstallError, hasUninstallError } from './stripe-sync-status'
|
|
import { useStripeSyncStatus } from '@/components/interfaces/Integrations/templates/StripeSyncEngine/useStripeSyncStatus'
|
|
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
|
|
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
|
|
|
|
export const IntegrationInstalledActions = ({
|
|
className,
|
|
disabled,
|
|
upgradeAvailable,
|
|
installing,
|
|
uninstalling,
|
|
setShowUninstallModal,
|
|
setShouldShowInstallSheet,
|
|
}: {
|
|
className?: string
|
|
disabled?: boolean
|
|
upgradeAvailable: boolean
|
|
installing: boolean
|
|
uninstalling: boolean
|
|
isUninstallRequested: boolean
|
|
setShowUninstallModal: (value: boolean) => void
|
|
setShouldShowInstallSheet: (value: boolean) => void
|
|
}) => {
|
|
const { can: canManageSecrets } = useAsyncCheckPermissions(
|
|
PermissionAction.FUNCTIONS_SECRET_WRITE,
|
|
'*'
|
|
)
|
|
|
|
const {
|
|
schemaComment: { status: installationStatus },
|
|
} = useStripeSyncStatus()
|
|
const uninstallError = hasUninstallError(installationStatus)
|
|
|
|
return (
|
|
<>
|
|
<div className={cn('flex gap-x-2 justify-end', className)}>
|
|
{upgradeAvailable && !uninstallError && !uninstalling && (
|
|
<ButtonTooltip
|
|
variant="primary"
|
|
onClick={() => setShouldShowInstallSheet(true)}
|
|
disabled={disabled}
|
|
loading={installing}
|
|
tooltip={{
|
|
content: {
|
|
text: !canManageSecrets
|
|
? 'You need additional permissions to upgrade the Stripe Sync Engine.'
|
|
: undefined,
|
|
},
|
|
}}
|
|
>
|
|
Upgrade integration
|
|
</ButtonTooltip>
|
|
)}
|
|
<ButtonTooltip
|
|
onClick={() => setShowUninstallModal(true)}
|
|
disabled={disabled}
|
|
loading={uninstalling}
|
|
tooltip={{
|
|
content: {
|
|
text: !canManageSecrets
|
|
? 'You need additional permissions to uninstall the Stripe Sync Engine.'
|
|
: undefined,
|
|
},
|
|
}}
|
|
>
|
|
{uninstallError ? 'Retry uninstallation' : 'Uninstall integration'}
|
|
</ButtonTooltip>
|
|
</div>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export const IntegrationNotInstalledActions = ({
|
|
className,
|
|
installing,
|
|
canInstall,
|
|
isUninstallRequested,
|
|
hideInstallCTA = false,
|
|
handleUninstall,
|
|
setShouldShowInstallSheet,
|
|
}: {
|
|
className?: string
|
|
installing: boolean
|
|
canInstall: boolean
|
|
isUninstallRequested: boolean
|
|
hideInstallCTA?: boolean
|
|
handleUninstall: () => void
|
|
setShouldShowInstallSheet: (value: boolean) => void
|
|
}) => {
|
|
const { can: canManageSecrets } = useAsyncCheckPermissions(
|
|
PermissionAction.FUNCTIONS_SECRET_WRITE,
|
|
'*'
|
|
)
|
|
|
|
const {
|
|
schemaComment: { status: installationStatus },
|
|
} = useStripeSyncStatus()
|
|
const installError = hasInstallError(installationStatus)
|
|
|
|
return (
|
|
<div className={cn('flex gap-x-2 justify-end', className)}>
|
|
{!hideInstallCTA && (
|
|
<ButtonTooltip
|
|
variant="primary"
|
|
onClick={() => setShouldShowInstallSheet(true)}
|
|
disabled={!canInstall || !canManageSecrets}
|
|
loading={installing}
|
|
tooltip={{
|
|
content: {
|
|
text: !canInstall
|
|
? 'Your database already uses a schema named "stripe"'
|
|
: !canManageSecrets
|
|
? 'You need additional permissions to install the Stripe Sync Engine.'
|
|
: undefined,
|
|
},
|
|
}}
|
|
>
|
|
{installError ? 'Retry installation' : 'Install integration'}
|
|
</ButtonTooltip>
|
|
)}
|
|
{installError && (
|
|
<Button loading={isUninstallRequested} onClick={handleUninstall}>
|
|
Uninstall
|
|
</Button>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|