EmptyStates.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { Github } from 'lucide-react'
  2. import Link from 'next/link'
  3. import { Button } from 'ui'
  4. import { BranchSelector } from './BranchSelector'
  5. import { DocsButton } from '@/components/ui/DocsButton'
  6. import type { Branch } from '@/data/branches/branches-query'
  7. import { DOCS_URL } from '@/lib/constants'
  8. const EMPTY_STATE_CONTAINER = 'flex items-center flex-col gap-0.5 justify-center w-full py-10 px-4'
  9. export const PullRequestsEmptyState = ({
  10. url,
  11. projectRef,
  12. branches,
  13. onBranchSelected,
  14. isUpdating,
  15. hasGithubConnection,
  16. }: {
  17. url: string
  18. projectRef: string
  19. branches: Branch[]
  20. onBranchSelected: (branch: Branch) => void
  21. isUpdating: boolean
  22. hasGithubConnection?: boolean
  23. }) => {
  24. return (
  25. <div className={EMPTY_STATE_CONTAINER}>
  26. <p>No merge requests</p>
  27. <p className="text-foreground-lighter text-center text-balance">
  28. Create your first merge request to merge changes back to the main branch
  29. </p>
  30. <div className="flex items-center space-x-2 mt-4">
  31. {hasGithubConnection ? (
  32. <Button type="outline" asChild icon={<Github />}>
  33. <a href={url} target="_blank" rel="noopener noreferrer">
  34. Create pull request
  35. </a>
  36. </Button>
  37. ) : (
  38. <Button asChild type="outline">
  39. <Link href={`/project/${projectRef}/settings/integrations`}>Connect to GitHub</Link>
  40. </Button>
  41. )}
  42. <BranchSelector
  43. type="outline"
  44. align="center"
  45. branches={branches}
  46. onBranchSelected={onBranchSelected}
  47. isUpdating={isUpdating}
  48. />
  49. </div>
  50. </div>
  51. )
  52. }
  53. export const PreviewBranchesEmptyState = ({
  54. onSelectCreateBranch,
  55. }: {
  56. onSelectCreateBranch: () => void
  57. }) => {
  58. return (
  59. <div className={EMPTY_STATE_CONTAINER}>
  60. <p>Create your first preview branch</p>
  61. <p className="text-foreground-lighter text-center text-balance mb-4">
  62. Preview branches are short-lived environments that let you safely experiment with changes to
  63. your database schema without affecting your main database.
  64. </p>
  65. <div className="flex items-center space-x-2">
  66. <DocsButton href={`${DOCS_URL}/guides/platform/branching`} />
  67. <Button type="primary" onClick={() => onSelectCreateBranch()}>
  68. Create branch
  69. </Button>
  70. </div>
  71. </div>
  72. )
  73. }