TeamSettings.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { useParams } from 'common'
  2. import { Search } from 'lucide-react'
  3. import { useState } from 'react'
  4. import { Admonition } from 'ui-patterns'
  5. import { Input } from 'ui-patterns/DataInputs/Input'
  6. import { InviteMemberButton } from './InviteMemberButton'
  7. import MembersView from './MembersView'
  8. import {
  9. ScaffoldActionsContainer,
  10. ScaffoldActionsGroup,
  11. ScaffoldContainer,
  12. ScaffoldFilterAndContent,
  13. ScaffoldSection,
  14. ScaffoldSectionContent,
  15. ScaffoldTitle,
  16. } from '@/components/layouts/Scaffold'
  17. import { DocsButton } from '@/components/ui/DocsButton'
  18. import { useOrganizationRolesV2Query } from '@/data/organization-members/organization-roles-query'
  19. import { useOrgProjectsInfiniteQuery } from '@/data/projects/org-projects-infinite-query'
  20. import { DOCS_URL } from '@/lib/constants'
  21. export const TeamSettings = () => {
  22. const { slug } = useParams()
  23. const [searchString, setSearchString] = useState('')
  24. const { data: roles } = useOrganizationRolesV2Query({ slug })
  25. const hasProjectScopedRoles = (roles?.project_scoped_roles ?? []).length > 0
  26. const { data } = useOrgProjectsInfiniteQuery({ slug })
  27. const totalCount = data?.pages[0].pagination.count ?? 0
  28. const threshold = 1000
  29. return (
  30. <ScaffoldContainer>
  31. <ScaffoldSection isFullWidth className="py-8! gap-y-8">
  32. <ScaffoldTitle>Team</ScaffoldTitle>
  33. <ScaffoldFilterAndContent>
  34. <ScaffoldActionsContainer className="w-full flex-col md:flex-row gap-2 justify-between">
  35. <Input
  36. size="tiny"
  37. autoComplete="off"
  38. icon={<Search />}
  39. value={searchString}
  40. onChange={(e: any) => setSearchString(e.target.value)}
  41. name="email"
  42. id="email"
  43. placeholder="Filter members"
  44. />
  45. <ScaffoldActionsGroup className="w-full md:w-auto">
  46. <DocsButton href={`${DOCS_URL}/guides/platform/access-control`} />
  47. <InviteMemberButton />
  48. </ScaffoldActionsGroup>
  49. </ScaffoldActionsContainer>
  50. {hasProjectScopedRoles && totalCount > threshold && (
  51. <Admonition
  52. type="warning"
  53. title="This page may not render properly due to the number of projects your account has access to"
  54. description="We're actively looking into optimizing this page and will make things available as soon as we can!"
  55. />
  56. )}
  57. <ScaffoldSectionContent className="w-full">
  58. <MembersView searchString={searchString} />
  59. </ScaffoldSectionContent>
  60. </ScaffoldFilterAndContent>
  61. </ScaffoldSection>
  62. </ScaffoldContainer>
  63. )
  64. }