organizationSelectHeader.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import styled from '@emotion/styled';
  2. import SelectControl from 'sentry/components/forms/controls/selectControl';
  3. import OrganizationBadge from 'sentry/components/idBadge/organizationBadge';
  4. import {t} from 'sentry/locale';
  5. import {space} from 'sentry/styles/space';
  6. import type {Organization} from 'sentry/types';
  7. type OrganizationSelectHeaderProps = {
  8. handleOrgChange: (orgId: string) => void;
  9. organizationId: string | undefined;
  10. organizations: Organization[];
  11. };
  12. export function OrganizationSelectHeader({
  13. handleOrgChange,
  14. organizationId,
  15. organizations,
  16. }: OrganizationSelectHeaderProps) {
  17. return (
  18. <OrgControlWrapper>
  19. {t('Settings for Organization')}
  20. <StyledSelectControl
  21. options={organizations.map(org => {
  22. return {
  23. label: org.name,
  24. value: org.id,
  25. leadingItems: (
  26. <OrganizationBadge
  27. organization={org}
  28. avatarSize={20}
  29. avatarProps={{consistentWidth: true}}
  30. hideName
  31. />
  32. ),
  33. };
  34. })}
  35. onChange={option => handleOrgChange(option.value)}
  36. value={organizationId}
  37. styles={{
  38. container: (provided: Record<string, string>) => ({
  39. ...provided,
  40. minWidth: `200px`,
  41. }),
  42. }}
  43. />
  44. </OrgControlWrapper>
  45. );
  46. }
  47. // Resetting styles because its in a panel header
  48. const StyledSelectControl = styled(SelectControl)`
  49. text-transform: initial;
  50. font-weight: normal;
  51. `;
  52. const OrgControlWrapper = styled('div')`
  53. display: flex;
  54. align-items: center;
  55. gap: ${space(1)};
  56. flex-grow: 1;
  57. `;